crypto: ccree - use crypto_memneq() to compare AEAD tag
Subsystems (2)
PATCH 1/1 crypto: ccree - use crypto_memneq() to compare AEAD tag
cc_aead_complete() compares the computed MAC against the received ICV with memcmp(), which short-circuits on the first differing byte and leaks tag-match length via timing. Use crypto_memneq() instead.
Assisted-by gregkh_clanker_t1000
Signed-off-by David C.C.M. Gall <[email protected]>
--- drivers/crypto/ccree/cc_aead.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ccree/cc_aead.c +2 -2
@@ -226,8 +226,8 @@ static void cc_aead_complete(struct device *dev, void *cc_req, int err) goto done;if (areq_ctx->gen_ctx.op_type ==DRV_CRYPTO_DIRECTION_DECRYPT ) { -if (memcmp (areq_ctx->mac_buf, areq_ctx->icv_virt_addr, - ctx->authsize) !=0 ) { +if (crypto_memneq (areq_ctx->mac_buf, areq_ctx->icv_virt_addr, + ctx->authsize)) {dev_dbg (dev,"Payload authentication failure, (auth-size=%d, cipher=%d)\n" , ctx->authsize, ctx->cipher_mode);/* In case of payload authentication failure, MUST NOT
Signature · 1 line
2.43.0
Herbert Xu
maintainerQuoted 9 lines · David C.C.M. Gall
cc_aead_complete()compares the computed MAC against the received ICV withmemcmp(), which short-circuits on the first differing byte and leaks tag-match length via timing. Usecrypto_memneq()instead.Assisted-by gregkh_clanker_t1000Signed-off-by David C.C.M. Gall <[email protected]>--- drivers/crypto/ccree/cc_aead.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt