From: Jouni Malinen Date: Sat, 7 Jul 2012 07:58:32 +0000 (+0300) Subject: OpenSSL: Add support for HMAC functions with 0.9.8 and older X-Git-Tag: hostap_2_0~541 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=895cb1683d56d6def966ca5bd0b77c43cad823b1;p=thirdparty%2Fhostap.git OpenSSL: Add support for HMAC functions with 0.9.8 and older Commit d9cc4646eb0255be31f11d8a8edad857431fdf49 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 --- diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 457da5666..8506fff49 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -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);