You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/09/07 05:15:40 UTC

[nuttx-apps] branch master updated: testing/crypto: fix aescbc crash when update iv

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 16a1655bb testing/crypto: fix aescbc crash when update iv
16a1655bb is described below

commit 16a1655bbad1ec9c1980b823776a3a850de2ec05
Author: makejian <ma...@xiaomi.com>
AuthorDate: Mon Sep 4 16:42:53 2023 +0800

    testing/crypto: fix aescbc crash when update iv
    
    iv content always should be updated when performing encryption operation, so need update testing case
    Signed-off-by: makejian <ma...@xiaomi.com>
---
 testing/crypto/aescbc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testing/crypto/aescbc.c b/testing/crypto/aescbc.c
index 638f4f411..2bbe408d6 100644
--- a/testing/crypto/aescbc.c
+++ b/testing/crypto/aescbc.c
@@ -95,6 +95,7 @@ static int syscrypt(FAR const char *key, size_t klen,
   struct crypt_op cryp;
   int cryptodev_fd = -1;
   int fd = -1;
+  char tmp_iv[16];
 
   if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0)
     {
@@ -119,13 +120,14 @@ static int syscrypt(FAR const char *key, size_t klen,
     }
 
   memset(&cryp, 0, sizeof(cryp));
+  memcpy(tmp_iv, iv, 16);
   cryp.ses = session.ses;
   cryp.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   cryp.flags = 0;
   cryp.len = len;
   cryp.src = (caddr_t) in;
   cryp.dst = (caddr_t) out;
-  cryp.iv = (caddr_t) iv;
+  cryp.iv = (caddr_t) tmp_iv;
   cryp.mac = 0;
   if (ioctl(cryptodev_fd, CIOCCRYPT, &cryp) == -1)
     {