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-apps.git

commit db735d025554ef11eb1b1ddda784fec29c554b7d
Author: makejian <[email protected]>
AuthorDate: Wed Apr 23 15:21:49 2025 +0800

    testing/drivers/crypto: set olen and the cipher op
    
    A hardware cryptodev driver such as virtio-crypto needs the output
    length and, at session creation, the direction of the cipher. The 3DES
    and AES-CBC tests, including the AES-CBC stream test, left both unset,
    which only the software driver tolerates. Set them.
    
    Signed-off-by: makejian <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 testing/drivers/crypto/3descbc.c | 2 ++
 testing/drivers/crypto/aescbc.c  | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/testing/drivers/crypto/3descbc.c b/testing/drivers/crypto/3descbc.c
index 7966e34bb..5095786c2 100644
--- a/testing/drivers/crypto/3descbc.c
+++ b/testing/drivers/crypto/3descbc.c
@@ -66,6 +66,7 @@ static int syscrypt(FAR const unsigned char *key, size_t klen,
   session.cipher = CRYPTO_3DES_CBC;
   session.key = (caddr_t) key;
   session.keylen = klen;
+  session.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   if (ioctl(cryptodev_fd, CIOCGSESSION, &session) == -1)
     {
       warn("CIOCGSESSION");
@@ -77,6 +78,7 @@ static int syscrypt(FAR const unsigned char *key, size_t klen,
   cryp.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   cryp.flags = 0;
   cryp.len = len;
+  cryp.olen = len;
   cryp.src = (caddr_t) in;
   cryp.dst = (caddr_t) out;
   cryp.iv = (caddr_t) iv;
diff --git a/testing/drivers/crypto/aescbc.c b/testing/drivers/crypto/aescbc.c
index 5ba646175..6e9a33abb 100644
--- a/testing/drivers/crypto/aescbc.c
+++ b/testing/drivers/crypto/aescbc.c
@@ -167,6 +167,7 @@ static int syscrypt(FAR const char *key, size_t klen,
   memset(&session, 0, sizeof(session));
   session.cipher = aescbc_cipher_id(klen);
   session.key = (caddr_t) key;
+  session.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   session.keylen = klen;
   if (ioctl(cryptodev_fd, CIOCGSESSION, &session) == -1)
     {
@@ -180,6 +181,7 @@ static int syscrypt(FAR const char *key, size_t klen,
   cryp.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   cryp.flags = 0;
   cryp.len = len;
+  cryp.olen = len;
   cryp.src = (caddr_t) in;
   cryp.dst = (caddr_t) out;
   cryp.iv = (caddr_t) tmp_iv;
@@ -244,6 +246,7 @@ static int syscrypt_stream(FAR const char *key, size_t klen,
   memset(&session, 0, sizeof(session));
   session.cipher = aescbc_cipher_id(klen);
   session.key = (caddr_t) key;
+  session.op = encrypt ? COP_ENCRYPT : COP_DECRYPT;
   session.keylen = klen;
   if (ioctl(cryptodev_fd, CIOCGSESSION, &session) == -1)
     {
@@ -261,6 +264,7 @@ static int syscrypt_stream(FAR const char *key, size_t klen,
   while (len >= 16)
     {
       cryp.len = 16;
+      cryp.olen = 16;
       cryp.src = (caddr_t) in + offset;
       cryp.dst = (caddr_t) out + offset;
       if (ioctl(cryptodev_fd, CIOCCRYPT, &cryp) == -1)

Reply via email to