@@ -582,6 +582,27 @@ static WC_MAYBE_UNUSED int test_AesCbcInit(Aes* aes, void* heap,
582582
583583#endif /* !NO_AES && HAVE_AES_CBC */
584584
585+ /* --- AES ECB id[] and init helper --- */
586+ #if !defined(NO_AES) && \
587+ (defined(HAVE_AES_ECB) || defined(WOLFSSL_AES_DIRECT))
588+ #if defined(WOLF_PRIVATE_KEY_ID) && defined(WC_TEST_AES_ECB_ID)
589+ static unsigned char testAesEcbId[] = WC_TEST_AES_ECB_ID;
590+ static int testAesEcbIdLen = (int)sizeof(testAesEcbId);
591+ #endif
592+
593+ static WC_MAYBE_UNUSED int test_AesEcbInit(Aes* aes, void* heap,
594+ int declaredDevId)
595+ {
596+ #if defined(WOLF_PRIVATE_KEY_ID) && defined(WC_TEST_AES_ECB_ID)
597+ return wc_AesInit_Id(aes, testAesEcbId, testAesEcbIdLen, heap,
598+ declaredDevId);
599+ #else
600+ return wc_AesInit(aes, heap, declaredDevId);
601+ #endif
602+ }
603+
604+ #endif /* !NO_AES && (HAVE_AES_ECB || WOLFSSL_AES_DIRECT) */
605+
585606/* --- AES GCM id[] and init helper --- */
586607#if !defined(NO_AES) && defined(HAVE_AESGCM)
587608#if defined(WOLF_PRIVATE_KEY_ID) && defined(WC_TEST_AES_GCM_ID)
@@ -1366,6 +1387,20 @@ static WC_MAYBE_UNUSED Aes* test_AesCbcNew(void* heap, int declaredDevId,
13661387}
13671388#endif /* !NO_AES && HAVE_AES_CBC */
13681389
1390+ #if !defined(NO_AES) && \
1391+ (defined(HAVE_AES_ECB) || defined(WOLFSSL_AES_DIRECT))
1392+ static WC_MAYBE_UNUSED Aes* test_AesEcbNew(void* heap, int declaredDevId,
1393+ int* ret)
1394+ {
1395+ #if defined(WOLF_PRIVATE_KEY_ID) && defined(WC_TEST_AES_ECB_ID)
1396+ return wc_AesNew_Id(testAesEcbId, testAesEcbIdLen, heap, declaredDevId,
1397+ ret);
1398+ #else
1399+ return wc_AesNew(heap, declaredDevId, ret);
1400+ #endif
1401+ }
1402+ #endif /* !NO_AES && (HAVE_AES_ECB || WOLFSSL_AES_DIRECT) */
1403+
13691404#if !defined(NO_AES) && defined(HAVE_AESGCM)
13701405static WC_MAYBE_UNUSED Aes* test_AesGcmNew(void* heap, int declaredDevId,
13711406 int* ret)
@@ -16806,20 +16841,20 @@ static wc_test_ret_t aes_ecb_direct_test(void)
1680616841#endif
1680716842
1680816843#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
16809- enc = wc_AesNew (HEAP_HINT, devId, &ret);
16844+ enc = test_AesEcbNew (HEAP_HINT, devId, &ret);
1681016845 if (enc == NULL)
1681116846 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
1681216847#ifdef HAVE_AES_DECRYPT
16813- dec = wc_AesNew (HEAP_HINT, devId, &ret);
16848+ dec = test_AesEcbNew (HEAP_HINT, devId, &ret);
1681416849 if (dec == NULL)
1681516850 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
1681616851#endif
1681716852#else
16818- ret = wc_AesInit (enc, HEAP_HINT, devId);
16853+ ret = test_AesEcbInit (enc, HEAP_HINT, devId);
1681916854 if (ret != 0)
1682016855 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
1682116856#ifdef HAVE_AES_DECRYPT
16822- ret = wc_AesInit (dec, HEAP_HINT, devId);
16857+ ret = test_AesEcbInit (dec, HEAP_HINT, devId);
1682316858 if (ret != 0)
1682416859 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
1682516860#endif
0 commit comments