diff options
author | Tobias Brunner <tobias@strongswan.org> | 2010-03-09 17:15:16 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2010-03-09 17:15:16 +0100 |
commit | 908d571796173929f89790da9b4ba854a2651762 (patch) | |
tree | a3828bc6fd615f710790aae1a8f240e5e7aa222b /src/libstrongswan/crypto/diffie_hellman.h | |
parent | 38031382dc1abb3b0f5f5e856e1894f05ad68cd3 (diff) | |
download | strongswan-908d571796173929f89790da9b4ba854a2651762.tar.bz2 strongswan-908d571796173929f89790da9b4ba854a2651762.tar.xz |
Provide the Diffie Hellman parameters from a central location, so that we do not have to replicate them in every plugin that implements the DH interface.
The main reason for this change is that Android's libcrypto does not
include the get_rfcX_prime_Y functions by default. Therefore we would
have had to replicate the primes a third time.
Diffstat (limited to 'src/libstrongswan/crypto/diffie_hellman.h')
-rw-r--r-- | src/libstrongswan/crypto/diffie_hellman.h | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/libstrongswan/crypto/diffie_hellman.h b/src/libstrongswan/crypto/diffie_hellman.h index 842938c3b..9d3b604cc 100644 --- a/src/libstrongswan/crypto/diffie_hellman.h +++ b/src/libstrongswan/crypto/diffie_hellman.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2010 Tobias Brunner * Copyright (C) 2005-2007 Martin Willi * Copyright (C) 2005 Jan Hutter * Hochschule fuer Technik Rapperswil @@ -24,6 +25,7 @@ typedef enum diffie_hellman_group_t diffie_hellman_group_t; typedef struct diffie_hellman_t diffie_hellman_t; +typedef struct diffie_hellman_params_t diffie_hellman_params_t; #include <library.h> @@ -70,8 +72,8 @@ struct diffie_hellman_t { * Space for returned secret is allocated and must be * freed by the caller. * - * @param secret shared secret will be written into this chunk - * @return SUCCESS, FAILED if not both DH values are set + * @param secret shared secret will be written into this chunk + * @return SUCCESS, FAILED if not both DH values are set */ status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret); @@ -80,7 +82,7 @@ struct diffie_hellman_t { * * Chunk gets cloned and can be destroyed afterwards. * - * @param value public value of partner + * @param value public value of partner */ void (*set_other_public_value) (diffie_hellman_t *this, chunk_t value); @@ -106,4 +108,48 @@ struct diffie_hellman_t { void (*destroy) (diffie_hellman_t *this); }; +/** + * Parameters for a specific diffie hellman group. + */ +struct diffie_hellman_params_t { + /** + * DH group. + */ + diffie_hellman_group_t group; + + /** + * The prime as byte array. + */ + const u_int8_t *prime; + + /** + * Length of the prime (in bytes). + */ + size_t prime_len; + + /** + * Optimal length of the exponent (in bytes), as specified in RFC 3526. + */ + size_t opt_exp_len; + + /** + * Length of the exponent (in bytes) that should be used, depending on + * the dh_exponent_ansi_x9_42 setting in strongswan.conf. + */ + size_t exp_len; + + /** + * Generator. + */ + u_int16_t generator; +}; + +/** + * Get the parameters associated with the specified diffie hellman group. + * + * @param group DH group + * @return The parameters or NULL, if the group is not supported + */ +diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group); + #endif /** DIFFIE_HELLMAN_H_ @}*/ |