Correctly handle HMAC_Init_ex() for older versions of OpenSSL

This commit is contained in:
David FORT 2015-04-01 14:12:08 +02:00
parent edb915943f
commit 9bb4d64608

View File

@ -148,12 +148,21 @@ CryptoHmac crypto_hmac_new(void)
BOOL crypto_hmac_sha1_init(CryptoHmac hmac, const BYTE* data, UINT32 length)
{
#if (OPENSSL_VERSION_NUMBER >= 0x00909000)
return HMAC_Init_ex(&hmac->hmac_ctx, data, length, EVP_sha1(), NULL) == 1;
#else
HMAC_Init_ex(&hmac->hmac_ctx, data, length, EVP_sha1(), NULL);
return TRUE;
#endif
}
BOOL crypto_hmac_md5_init(CryptoHmac hmac, const BYTE* data, UINT32 length)
{
#if (OPENSSL_VERSION_NUMBER >= 0x00909000)
return HMAC_Init_ex(&hmac->hmac_ctx, data, length, EVP_md5(), NULL) == 1;
#else
HMAC_Init_ex(&hmac->hmac_ctx, data, length, EVP_md5(), NULL);
#endif
}
void crypto_hmac_update(CryptoHmac hmac, const BYTE* data, UINT32 length)