From 1559e92dcad40f8685f24918e0e919ab1bdc84c2 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 15 Nov 2021 16:22:10 -0800 Subject: [PATCH] Add crypto callback AES CCM test case. --- wolfcrypt/test/test.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index e953e8ef5..a6a8673da 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -38022,6 +38022,48 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx) } } #endif /* HAVE_AES_CBC */ + #if defined(HAVE_AESCCM) && defined(WOLFSSL_AES_128) + if (info->cipher.type == WC_CIPHER_AES_CCM) { + if (info->cipher.enc) { + /* set devId to invalid, so software is used */ + info->cipher.aesccm_enc.aes->devId = INVALID_DEVID; + + ret = wc_AesCcmEncrypt( + info->cipher.aesccm_enc.aes, + info->cipher.aesccm_enc.out, + info->cipher.aesccm_enc.in, + info->cipher.aesccm_enc.sz, + info->cipher.aesccm_enc.nonce, + info->cipher.aesccm_enc.nonceSz, + info->cipher.aesccm_enc.authTag, + info->cipher.aesccm_enc.authTagSz, + info->cipher.aesccm_enc.authIn, + info->cipher.aesccm_enc.authInSz); + + /* reset devId */ + info->cipher.aesccm_enc.aes->devId = devIdArg; + } + else { + /* set devId to invalid, so software is used */ + info->cipher.aesccm_dec.aes->devId = INVALID_DEVID; + + ret = wc_AesCcmDecrypt( + info->cipher.aesccm_dec.aes, + info->cipher.aesccm_dec.out, + info->cipher.aesccm_dec.in, + info->cipher.aesccm_dec.sz, + info->cipher.aesccm_dec.nonce, + info->cipher.aesccm_dec.nonceSz, + info->cipher.aesccm_dec.authTag, + info->cipher.aesccm_dec.authTagSz, + info->cipher.aesccm_dec.authIn, + info->cipher.aesccm_dec.authInSz); + + /* reset devId */ + info->cipher.aesccm_dec.aes->devId = devIdArg; + } + } + #endif #ifndef NO_DES3 if (info->cipher.type == WC_CIPHER_DES3) { if (info->cipher.enc) { @@ -38245,6 +38287,10 @@ WOLFSSL_TEST_SUBROUTINE int cryptocb_test(void) if (ret == 0) ret = aes_test(); #endif + #if defined(HAVE_AESCCM) && defined(WOLFSSL_AES_128) + if (ret == 0) + ret = aesccm_test(); + #endif #endif /* !NO_AES */ #ifndef NO_DES3 if (ret == 0)