aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-07-10 09:06:15 +0200
committerMartin Willi <martin@revosec.ch>2012-07-16 14:55:07 +0200
commit3aca89c8e6c5d8a697c3158f54fbc69c54715e5a (patch)
tree49aaed5e574a8c4bf799a47a33b7b40040080f01 /src/libstrongswan/plugins
parent9138f49e6aa29c678f87544fd44adf7f3734d156 (diff)
downloadstrongswan-3aca89c8e6c5d8a697c3158f54fbc69c54715e5a.tar.bz2
strongswan-3aca89c8e6c5d8a697c3158f54fbc69c54715e5a.tar.xz
Resetting OpenSSL HMAC with NULL key reuses existing key
Diffstat (limited to 'src/libstrongswan/plugins')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_hmac.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_hmac.c b/src/libstrongswan/plugins/openssl/openssl_hmac.c
index b027e0fc3..8c8767d89 100644
--- a/src/libstrongswan/plugins/openssl/openssl_hmac.c
+++ b/src/libstrongswan/plugins/openssl/openssl_hmac.c
@@ -65,11 +65,6 @@ struct private_mac_t {
* Current HMAC context
*/
HMAC_CTX hmac;
-
- /**
- * Key
- */
- chunk_t key;
};
/**
@@ -77,8 +72,7 @@ struct private_mac_t {
*/
static bool reset(private_mac_t *this)
{
- return HMAC_Init_ex(&this->hmac, this->key.ptr, this->key.len,
- this->hasher, NULL);
+ return HMAC_Init_ex(&this->hmac, NULL, 0, this->hasher, NULL);
}
METHOD(mac_t, get_mac, bool,
@@ -102,16 +96,13 @@ METHOD(mac_t, get_mac_size, size_t,
METHOD(mac_t, set_key, bool,
private_mac_t *this, chunk_t key)
{
- chunk_clear(&this->key);
- this->key = chunk_clone(key);
- return reset(this);
+ return HMAC_Init_ex(&this->hmac, key.ptr, key.len, this->hasher, NULL);
}
METHOD(mac_t, destroy, void,
private_mac_t *this)
{
HMAC_CTX_cleanup(&this->hmac);
- chunk_clear(&this->key);
free(this);
}