OpenSSL: Add support for HMAC functions with 0.9.8 and older
Commit d9cc4646eb
added
crypto_hash_{init,update,finish}() wrappers for OpenSSL, but it
assumed the current HMAC API in OpenSSL. This was changed in 0.9.9
to return error codes from the functions while older versions used
void functions. Add support for the older versions, too.
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
990933fb1d
commit
895cb1683d
1 changed files with 9 additions and 0 deletions
|
@ -572,10 +572,14 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
|
|||
if (ctx == NULL)
|
||||
return NULL;
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x00909000
|
||||
HMAC_Init_ex(&ctx->ctx, key, key_len, md, NULL);
|
||||
#else /* openssl < 0.9.9 */
|
||||
if (HMAC_Init_ex(&ctx->ctx, key, key_len, md, NULL) != 1) {
|
||||
os_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
#endif /* openssl < 0.9.9 */
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
@ -603,7 +607,12 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
|
|||
}
|
||||
|
||||
mdlen = *len;
|
||||
#if OPENSSL_VERSION_NUMBER < 0x00909000
|
||||
HMAC_Final(&ctx->ctx, mac, &mdlen);
|
||||
res = 1;
|
||||
#else /* openssl < 0.9.9 */
|
||||
res = HMAC_Final(&ctx->ctx, mac, &mdlen);
|
||||
#endif /* openssl < 0.9.9 */
|
||||
HMAC_CTX_cleanup(&ctx->ctx);
|
||||
os_free(ctx);
|
||||
|
||||
|
|
Loading…
Reference in a new issue