summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/hmac/hmac.c5
-rw-r--r--include/openssl/hmac.h1
-rw-r--r--test/hmactest.c15
-rw-r--r--util/libcrypto.num1
4 files changed, 22 insertions, 0 deletions
diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c
index da7f58688f..3374105cbb 100644
--- a/crypto/hmac/hmac.c
+++ b/crypto/hmac/hmac.c
@@ -233,3 +233,8 @@ void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
EVP_MD_CTX_set_flags(ctx->o_ctx, flags);
EVP_MD_CTX_set_flags(ctx->md_ctx, flags);
}
+
+const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx)
+{
+ return ctx->md;
+}
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h
index 809ca34227..9f06896059 100644
--- a/include/openssl/hmac.h
+++ b/include/openssl/hmac.h
@@ -40,6 +40,7 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
+const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);
#ifdef __cplusplus
}
diff --git a/test/hmactest.c b/test/hmactest.c
index 145c467e50..0f4348b73c 100644
--- a/test/hmactest.c
+++ b/test/hmactest.c
@@ -123,6 +123,11 @@ int main(int argc, char *argv[])
err++;
goto end;
}
+ if (HMAC_CTX_get_md(ctx) != NULL) {
+ printf("Message digest not NULL for HMAC (test 4)\n");
+ err++;
+ goto test5;
+ }
if (HMAC_Init_ex(ctx, NULL, 0, NULL, NULL)) {
printf("Should fail to initialise HMAC with empty MD and key (test 4)\n");
err++;
@@ -155,6 +160,11 @@ test5:
}
HMAC_CTX_reset(ctx);
+ if (HMAC_CTX_get_md(ctx) != NULL) {
+ printf("Message digest not NULL for HMAC (test 5)\n");
+ err++;
+ goto test6;
+ }
if (HMAC_Init_ex(ctx, test[4].key, test[4].key_len, NULL, NULL)) {
printf("Should fail to initialise HMAC with empty MD (test 5)\n");
err++;
@@ -202,6 +212,11 @@ test5:
err++;
goto test6;
}
+ if (HMAC_CTX_get_md(ctx) != EVP_sha256()) {
+ printf("Unexpected message digest for HMAC (test 5)\n");
+ err++;
+ goto test6;
+ }
if (!HMAC_Update(ctx, test[5].data, test[5].data_len)) {
printf("Error updating HMAC with data (sha256) (test 5)\n");
err++;
diff --git a/util/libcrypto.num b/util/libcrypto.num
index fa07ecfef9..fc118b19bb 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -4149,3 +4149,4 @@ X509_get_pathlen 4092 1_1_0 EXIST::FUNCTION:
ECDSA_SIG_set0 4093 1_1_0 EXIST::FUNCTION:EC
DSA_SIG_set0 4094 1_1_0 EXIST::FUNCTION:DSA
EVP_PKEY_get0_hmac 4095 1_1_0 EXIST::FUNCTION:
+HMAC_CTX_get_md 4096 1_1_0 EXIST::FUNCTION: