From e0fa78f8f33fc3a157869900f6e0e929f309c4f5 Mon Sep 17 00:00:00 2001 From: makejian Date: Fri, 5 May 2023 20:25:34 +0800 Subject: [PATCH] crypto: fix aesxts and hmac crash bug (1)aesxts uses correct size to memcpy (2)prevent hmac null pointer of struct crde Signed-off-by: makejian --- crypto/cryptodev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/cryptodev.c b/crypto/cryptodev.c index f5f0d783f3..bda06e44d9 100644 --- a/crypto/cryptodev.c +++ b/crypto/cryptodev.c @@ -495,8 +495,8 @@ int cryptodev_op(FAR struct csession *cse, if (!(crde->crd_flags & CRD_F_IV_EXPLICIT)) { - memcpy(cse->tmp_iv, cop->iv, cse->txform->blocksize); - bcopy(cse->tmp_iv, crde->crd_iv, cse->txform->blocksize); + memcpy(cse->tmp_iv, cop->iv, cse->txform->ivsize); + bcopy(cse->tmp_iv, crde->crd_iv, cse->txform->ivsize); crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; crde->crd_skip = 0; } @@ -564,7 +564,7 @@ dispatch: crypto_invoke(crp); processed: - if ((cop->flags & COP_FLAG_UPDATE) == 0) + if (crde && (cop->flags & COP_FLAG_UPDATE) == 0) { crde->crd_flags &= ~CRD_F_IV_EXPLICIT; }