Add HMAC_CTX_get_md. CPython uses this function. Change-Id: I03ead7f54ad19e2a0b2ea3b142298cc1e55c3c90 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/53967 Auto-Submit: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com> Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/fipsmodule/hmac/hmac.c b/crypto/fipsmodule/hmac/hmac.c index 56e21b0..ca774bc 100644 --- a/crypto/fipsmodule/hmac/hmac.c +++ b/crypto/fipsmodule/hmac/hmac.c
@@ -224,9 +224,9 @@ return ret; } -size_t HMAC_size(const HMAC_CTX *ctx) { - return EVP_MD_size(ctx->md); -} +size_t HMAC_size(const HMAC_CTX *ctx) { return EVP_MD_size(ctx->md); } + +const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx) { return ctx->md; } int HMAC_CTX_copy_ex(HMAC_CTX *dest, const HMAC_CTX *src) { if (!EVP_MD_CTX_copy_ex(&dest->i_ctx, &src->i_ctx) ||
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h index 56b0802..7a4737f 100644 --- a/include/openssl/hmac.h +++ b/include/openssl/hmac.h
@@ -137,6 +137,9 @@ // |ctx|. On entry, |ctx| must have been setup with |HMAC_Init_ex|. OPENSSL_EXPORT size_t HMAC_size(const HMAC_CTX *ctx); +// HMAC_CTX_get_md returns |ctx|'s hash function. +OPENSSL_EXPORT const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); + // HMAC_CTX_copy_ex sets |dest| equal to |src|. On entry, |dest| must have been // initialised by calling |HMAC_CTX_init|. It returns one on success and zero // on error.