openssl: Ensure underlying hash algorithm is available during HMAC init
[strongswan.git] / src / libstrongswan / plugins / openssl / openssl_hmac.c
index e3f44de..e0b9f21 100644 (file)
@@ -185,6 +185,12 @@ static mac_t *hmac_create(hash_algorithm_t algo)
        this->hmac = &this->hmac_ctx;
 #endif
 
+       /* make sure the underlying hash algorithm is supported */
+       if (!set_key(this, chunk_from_str("")))
+       {
+               destroy(this);
+               return NULL;
+       }
        return &this->public;
 }