From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Tejasree Kondoj <ktejasree@marvell.com>,
Ankur Dwivedi <adwivedi@marvell.com>,
Anoob Joseph <anoobj@marvell.com>,
Akhil Goyal <gakhil@marvell.com>,
Archana Muniganti <marchana@marvell.com>
Subject: [PATCH v2 5/6] crypto/cnxk: use timing-safe digest comparison
Date: Mon, 29 Jun 2026 11:59:28 -0700 [thread overview]
Message-ID: <20260629190027.2071745-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20260629190027.2071745-1-stephen@networkplumber.org>
compl_auth_verify() compared the generated and received MAC with
memcmp(), which returns early on the first differing byte and leaks
the number of matching leading bytes through timing.
Use rte_memeq_timingsafe() for the verify comparison.
Bugzilla ID: 1773
Fixes: 786963fdcf3e ("crypto/cnxk: add digest support")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tejasree Kondoj <ktejasree@marvell.com>
---
drivers/crypto/cnxk/cnxk_ae.h | 4 +++-
drivers/crypto/cnxk/cnxk_se.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 691f9bfce5..f2aa5d5a2e 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -8,6 +8,7 @@
#include <rte_common.h>
#include <rte_crypto_asym.h>
#include <rte_malloc.h>
+#include <rte_memory.h>
#include "roc_ae.h"
#include "roc_re.h"
@@ -1921,7 +1922,8 @@ cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,
* Offset output data pointer by length field
* (2 bytes) and compare signed data.
*/
- if (memcmp(rptr + 2, rsa->message.data, rsa->message.length))
+ if (!rte_memeq_timingsafe(rptr + 2,
+ rsa->message.data, rsa->message.length))
cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
}
break;
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 09d9d1e0e3..3ed32f7ddd 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -3362,7 +3362,7 @@ compl_auth_verify(struct rte_crypto_op *op, uint8_t *gen_mac, uint64_t mac_len)
return;
}
- if (memcmp(mac, gen_mac, mac_len))
+ if (!rte_memeq_timingsafe(mac, gen_mac, mac_len))
op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
else
op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
--
2.53.0
next prev parent reply other threads:[~2026-06-29 19:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 15:56 [PATCH 0/5] crypto: use timing-safe digest comparison Stephen Hemminger
2026-06-25 15:56 ` [PATCH 1/5] eal: take experimental flag off of rte_memeq_timingsafe Stephen Hemminger
2026-06-25 15:56 ` [PATCH 2/5] crypto/uadk: use timing-safe digest comparison Stephen Hemminger
2026-06-25 15:56 ` [PATCH 3/5] crypto/ccp: " Stephen Hemminger
2026-06-25 15:56 ` [PATCH 4/5] crypto/armv8: " Stephen Hemminger
2026-06-26 17:11 ` Jack Bond-Preston
2026-06-25 15:56 ` [PATCH 5/5] crypto/cnxk: " Stephen Hemminger
2026-06-29 6:42 ` [EXTERNAL] " Tejasree Kondoj
2026-06-29 7:38 ` [EXTERNAL] [PATCH 0/5] crypto: " Akhil Goyal
2026-06-29 18:59 ` [PATCH v2 0/6] " Stephen Hemminger
2026-06-29 18:59 ` [PATCH v2 1/6] eal: take experimental flag off of rte_memeq_timingsafe Stephen Hemminger
2026-06-29 18:59 ` [PATCH v2 2/6] crypto/uadk: use timing-safe digest comparison Stephen Hemminger
2026-06-29 18:59 ` [PATCH v2 3/6] crypto/ccp: " Stephen Hemminger
2026-06-29 18:59 ` [PATCH v2 4/6] crypto/armv8: " Stephen Hemminger
2026-06-29 18:59 ` Stephen Hemminger [this message]
2026-06-29 18:59 ` [PATCH v2 6/6] crypto/octeontx: use timing-safe RSA signature verification Stephen Hemminger
2026-06-30 9:50 ` [EXTERNAL] " Tejasree Kondoj
2026-06-30 17:22 ` [PATCH v2 0/6] crypto: use timing-safe digest comparison Morten Brørup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629190027.2071745-6-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=adwivedi@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=ktejasree@marvell.com \
--cc=marchana@marvell.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox