[PATCH v1 1/3] common/cpt: use timing-safe digest comparison
Rupesh Chiluka <[email protected]> Mon, 3 Aug 2026 11:54:13 +0530
| Newsgroups | org.dpdk.dev |
|---|---|
| Message-ID | <89e98b3ccc1ad93ed67fb5750c88df94f0c1ecf7.1785737875.git.rchiluka@marvell.com> |
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 Signed-off-by: Rupesh Chiluka <[email protected]> --- drivers/common/cpt/cpt_ucode.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 636f93604e..a6ecbaf429 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -3354,10 +3354,10 @@ compl_auth_verify(struct rte_crypto_op *op, return; } - if (memcmp(mac, gen_mac, mac_len)) - op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; - else + if (rte_memeq_timingsafe(mac, gen_mac, mac_len)) op->status = RTE_CRYPTO_OP_STATUS_SUCCESS; + else + op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; } static __rte_always_inline void -- 2.48.1