Skip to contentSkip to conversation

crypto/openssl: fix of dstlen passed in HMAC

PATCH In review Kai Ji 3 participants 5 messages Jul 11, 2022 – Sep 22, 2022 Crypto API

lore
Share & tools
lore

Kai Ji

author
#0 lore raw

PATCH 1/1 crypto/openssl: fix of dstlen passed in HMAC

This fix of dstlen passed in OpenSSL 3.0 lib EVP MAC final routine.

Fixes 75adf1eae44f ("crypto/openssl: update HMAC routine with 3.0 EVP API")
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
index e01dacc98d..5658b9db66 100644
@@ -1395,7 +1395,7 @@ process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset,
 	}
 
 process_auth_final:
-	if (EVP_MAC_final(ctx, dst, &dstlen, sizeof(dst)) != 1)
+	if (EVP_MAC_final(ctx, dst, &dstlen, DIGEST_LENGTH_MAX) != 1)
 		goto process_auth_err;
 
 	EVP_MAC_CTX_free(ctx);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 31 lines

-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Monday, July 11, 2022 6:08 PM
To: [email protected]
Cc: [email protected]; Ji, Kai <[email protected]>
Subject: [dpdk-dev v1] crypto/openssl: fix of dstlen passed in HMAC

This fix of dstlen passed in OpenSSL 3.0 lib EVP MAC final routine.

Fixes 75adf1eae44f ("crypto/openssl: update HMAC routine with 3.0 EVP

API")

---
 drivers/crypto/openssl/rte_openssl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
index e01dacc98d..5658b9db66 100644
@@ -1395,7 +1395,7 @@ process_openssl_auth_hmac(struct rte_mbuf
 *mbuf_src, uint8_t *dst, int offset,
 	}
 
 process_auth_final:
-	if (EVP_MAC_final(ctx, dst, &dstlen, sizeof(dst)) != 1)
+	if (EVP_MAC_final(ctx, dst, &dstlen, DIGEST_LENGTH_MAX) != 1)
 		goto process_auth_err;
 
Quoted 3 lines

EVP_MAC_CTX_free(ctx);
--
2.17.1

#2 lore raw
In reply to Kai Ji
Quoted 2 lines

Subject: [EXT] [dpdk-dev v1] crypto/openssl: fix of dstlen passed in HMAC

Title can be reworded
Crypto/openssl: fix HMAC output length

Quoted 1 line

This fix of dstlen passed in OpenSSL 3.0 lib EVP MAC final routine.

Please reword the description to explain what is not correct and what is done to fix it.

Quoted 25 lines
Fixes 75adf1eae44f ("crypto/openssl: update HMAC routine with 3.0 EVP API")
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
index e01dacc98d..5658b9db66 100644
@@ -1395,7 +1395,7 @@ process_openssl_auth_hmac(struct rte_mbuf
 *mbuf_src, uint8_t *dst, int offset,
 	}
 
 process_auth_final:
-	if (EVP_MAC_final(ctx, dst, &dstlen, sizeof(dst)) != 1)
+	if (EVP_MAC_final(ctx, dst, &dstlen, DIGEST_LENGTH_MAX) != 1)
 		goto process_auth_err;
 

EVP_MAC_CTX_free(ctx);
--
2.17.1

author
#3 lore raw

PATCH v2 1/1 crypto/openssl: fix HMAC output length

In reply to Kai Ji

This patch sets the max length of dst in OpenSSL 3.0 lib EVP MAC final routine to ensure enough space for the result.

Fixes 75adf1eae44f ("crypto/openssl: update HMAC routine with 3.0 EVP API")
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
index 392b546a63..a078038651 100644
@@ -1447,7 +1447,7 @@ process_openssl_auth_mac(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset,
 	}
 
 process_auth_final:
-	if (EVP_MAC_final(ctx, dst, &dstlen, sizeof(dst)) != 1)
+	if (EVP_MAC_final(ctx, dst, &dstlen, DIGEST_LENGTH_MAX) != 1)
 		goto process_auth_err;
 
 	EVP_MAC_CTX_free(ctx);
Signature · 1 line
2.17.1