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 <makejian@xiaomi.com>
This commit is contained in:
makejian 2023-09-04 16:42:53 +08:00 committed by Xiang Xiao
parent ee0bc579c1
commit 16a1655bba

View File

@ -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)
{