diff options
author | Reto Buerki <reet@codelabs.ch> | 2012-08-29 09:41:02 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-03-19 15:23:46 +0100 |
commit | 4c38878db529442d4a3b86f716687a365157d7f7 (patch) | |
tree | 17c07c1735148bdb37e823513049cfae15f45c18 /src | |
parent | fc828aaac64a9681ad5351e4db959c44047b3ab0 (diff) | |
download | strongswan-4c38878db529442d4a3b86f716687a365157d7f7.tar.bz2 strongswan-4c38878db529442d4a3b86f716687a365157d7f7.tar.xz |
keymat: Extract enc,inc algorithms from proposal
Extract encryption and integrity algorithms from proposal and check them
before deriving IKE keys.
Diffstat (limited to 'src')
-rw-r--r-- | src/charon-tkm/src/tkm/tkm_keymat.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/charon-tkm/src/tkm/tkm_keymat.c b/src/charon-tkm/src/tkm/tkm_keymat.c index 6c39782c4..43c180b8a 100644 --- a/src/charon-tkm/src/tkm/tkm_keymat.c +++ b/src/charon-tkm/src/tkm/tkm_keymat.c @@ -71,6 +71,31 @@ METHOD(tkm_keymat_t, derive_ike_keys, bool, chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id, pseudo_random_function_t rekey_function, chunk_t rekey_skd) { + /* Check encryption and integrity algorithms */ + u_int16_t enc_alg, int_alg, key_size; + if (!proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM, &enc_alg, &key_size)) + { + DBG1(DBG_IKE, "no %N selected", transform_type_names, + ENCRYPTION_ALGORITHM); + return FALSE; + } + if (encryption_algorithm_is_aead(enc_alg)) + { + DBG1(DBG_IKE, "AEAD algorithm %N not supported", + encryption_algorithm_names, enc_alg); + return FALSE; + } + if (!proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM, &int_alg, NULL)) + { + DBG1(DBG_IKE, "no %N selected", transform_type_names, + INTEGRITY_ALGORITHM); + return FALSE; + } + DBG2(DBG_IKE, "using %N for encryption, %N for integrity", + encryption_algorithm_names, enc_alg, + integrity_algorithm_names, int_alg); + + /* Acquire nonce context id */ chunk_t * const nonce = this->initiator ? &nonce_i : &nonce_r; const uint64_t nc_id = tkm->chunk_map->get_id(tkm->chunk_map, nonce); if (!nc_id) @@ -79,6 +104,7 @@ METHOD(tkm_keymat_t, derive_ike_keys, bool, return FALSE; } + /* Get DH context id */ tkm_diffie_hellman_t * const tkm_dh = (tkm_diffie_hellman_t *)dh; const dh_id_type dh_id = tkm_dh->get_id(tkm_dh); |