From: Tobias Brunner Date: Mon, 16 Aug 2021 08:50:01 +0000 (+0200) Subject: openssl: Use a longer key to test/initialize HMAC instances X-Git-Tag: 5.9.4dr1~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=64b281723c82c2345404fc7ac3fddf9bd2b155b6;p=thirdparty%2Fstrongswan.git openssl: Use a longer key to test/initialize HMAC instances OpenSSL enforces a minimum of 14 bytes (112 bits) on the key size when used in FIPS-mode (as required by SP 800-131A). So by using an empty string, instantiation always failed. 32 bytes (256 bits) should be safe for now. Closes strongswan/strongswan#557 --- diff --git a/src/libstrongswan/plugins/openssl/openssl_hmac.c b/src/libstrongswan/plugins/openssl/openssl_hmac.c index c4462fd3fd..f1a81919ce 100644 --- a/src/libstrongswan/plugins/openssl/openssl_hmac.c +++ b/src/libstrongswan/plugins/openssl/openssl_hmac.c @@ -100,8 +100,9 @@ METHOD(mac_t, set_key, bool, private_mac_t *this, chunk_t key) { if (!key.ptr) - { /* HMAC_Init_ex() won't reset the key if a NULL pointer is passed */ - key = chunk_from_str(""); + { /* HMAC_Init_ex() won't reset the key if a NULL pointer is passed, + * use a lenghty string in case there is a limit in FIPS-mode */ + key = chunk_from_str("00000000000000000000000000000000"); } return reset(this, key); } @@ -188,7 +189,7 @@ static mac_t *hmac_create(hash_algorithm_t algo) #endif /* make sure the underlying hash algorithm is supported */ - if (!set_key(this, chunk_from_str(""))) + if (!set_key(this, chunk_empty)) { destroy(this); return NULL;