From: Tobias Brunner Date: Thu, 28 Jun 2018 13:33:35 +0000 (+0200) Subject: keymat_v2: Proper cleanup if derive_ike_keys() is called multiple times X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4e26ef7f4fbd2ac3eae2a9e71d48e95ac2b8495;p=thirdparty%2Fstrongswan.git keymat_v2: Proper cleanup if derive_ike_keys() is called multiple times --- diff --git a/src/libcharon/sa/ikev2/keymat_v2.c b/src/libcharon/sa/ikev2/keymat_v2.c index 5b26537c04..6fb2065d27 100644 --- a/src/libcharon/sa/ikev2/keymat_v2.c +++ b/src/libcharon/sa/ikev2/keymat_v2.c @@ -280,6 +280,8 @@ METHOD(keymat_v2_t, derive_ike_keys, bool, ENCRYPTION_ALGORITHM); return FALSE; } + DESTROY_IF(this->aead_in); + DESTROY_IF(this->aead_out); if (!encryption_algorithm_is_aead(enc_alg)) { if (!proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM, &int_alg, @@ -412,6 +414,7 @@ METHOD(keymat_v2_t, derive_ike_keys, bool, { goto failure; } + chunk_clear(&this->skd); chunk_split(keymat, "ammmmaa", key_size, &this->skd, sk_ai.len, &sk_ai, sk_ar.len, &sk_ar, sk_ei.len, &sk_ei, sk_er.len, &sk_er, key_size, &sk_pi, key_size, &sk_pr); @@ -433,6 +436,8 @@ METHOD(keymat_v2_t, derive_ike_keys, bool, /* SK_pi/SK_pr used for authentication => stored for later */ DBG4(DBG_IKE, "Sk_pi secret %B", &sk_pi); DBG4(DBG_IKE, "Sk_pr secret %B", &sk_pr); + chunk_clear(&this->skp_build); + chunk_clear(&this->skp_verify); if (this->initiator) { this->skp_build = sk_pi;