This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new ed4cc5bbe8f crypto/cryptosoft: do not skip an IV byte in the CMAC 
authenc path
ed4cc5bbe8f is described below

commit ed4cc5bbe8f56789f65f7404e5d6f951731cf81d
Author: makejian <[email protected]>
AuthorDate: Mon Nov 16 21:18:54 2026 +0800

    crypto/cryptosoft: do not skip an IV byte in the CMAC authenc path
    
    swcr_authenc() assumed that a composite request without an explicit
    IV carries the IV at the start of the source buffer, so it advanced
    crd_skip by the block size and shortened crd_len by the same amount.
    The CMAC cipher xform has no IV (ivsize 0) and a block size of 1,
    so for a plain AES-CMAC request the message was truncated by one
    byte and the MAC was computed over len-1 bytes: the NIST 16-byte
    vector returned f212d4c2154c8766de60c18c98fa0c93 instead of the
    RFC 4493 value 070a16b46b4d4144f79bdd9dd04a287c.  The empty-message
    case only passed by luck, because the negative length kept the loop
    from running at all.
    
    Only apply the prepended-IV adjustment when the xform actually has an
    IV (ivsize > 0); leave the skip and length untouched otherwise.
    
    Signed-off-by: makejian <[email protected]>
---
 crypto/cryptosoft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/cryptosoft.c b/crypto/cryptosoft.c
index 37b9a318279..15f0e76cf43 100644
--- a/crypto/cryptosoft.c
+++ b/crypto/cryptosoft.c
@@ -1298,7 +1298,7 @@ int swcr_authenc(FAR struct cryptop *crp)
           crde->crd_skip = 0;
         }
     }
-  else
+  else if (exf->ivsize > 0)
     {
       crde->crd_flags |= CRD_F_IV_PRESENT;
       crde->crd_skip = exf->blocksize;

Reply via email to