@@ -1311,10 +1311,6 @@ static void wb_gcmccm_pending(void)
13111311 return ;
13121312 }
13131313
1314- /* Zero the device table (a zeroed slot has devId==0, not INVALID_DEVID,
1315- * so registration finds no free slot until this runs). */
1316- wc_CryptoCb_Init ();
1317-
13181314 /* GCM: baseline (ret==0) then PENDING. */
13191315 mcdc_cb_uninstall ();
13201316 if (wc_AesInit (& aes , NULL , MCDC_CB_DEVID ) == 0 &&
@@ -1741,7 +1737,8 @@ static void wb_slow_vaes(void)
17411737 * GcmCountInvocation() on every call, which is enough to drive all three
17421738 * operand rows.
17431739 * ------------------------------------------------------------------------- */
1744- #if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 )
1740+ #if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 ) && \
1741+ !defined(WC_NO_RNG )
17451742static void wb_gcm_count_invocation (void )
17461743{
17471744 Aes aes ;
@@ -1757,14 +1754,23 @@ static void wb_gcm_count_invocation(void)
17571754 XMEMSET (key , 0x61 , sizeof (key ));
17581755 XMEMSET (in , 0x62 , sizeof (in ));
17591756
1760- if (wc_AesInit (& aes , NULL , INVALID_DEVID ) != 0 ||
1761- wc_InitRng (& rng ) != 0 ||
1762- wc_AesGcmSetKey (& aes , key , sizeof (key )) != 0 ||
1757+ if (wc_AesInit (& aes , NULL , INVALID_DEVID ) != 0 ) {
1758+ WB_NOTE ("wc_AesInit failed (GcmCountInvocation skipped)" );
1759+ wb_fail = 1 ;
1760+ return ;
1761+ }
1762+ if (wc_InitRng (& rng ) != 0 ) {
1763+ WB_NOTE ("wc_InitRng failed (GcmCountInvocation skipped)" );
1764+ wb_fail = 1 ;
1765+ wc_AesFree (& aes );
1766+ return ;
1767+ }
1768+ if (wc_AesGcmSetKey (& aes , key , sizeof (key )) != 0 ||
17631769 wc_AesGcmSetIV (& aes , sizeof (iv ), NULL , 0 , & rng ) != 0 ) {
17641770 WB_NOTE ("GCM setup failed (GcmCountInvocation skipped)" );
17651771 wb_fail = 1 ;
1766- if ( rng . status == 0 )
1767- wc_FreeRng ( & rng );
1772+ wc_FreeRng ( & rng );
1773+ wc_AesFree ( & aes );
17681774 return ;
17691775 }
17701776
@@ -1799,7 +1805,7 @@ static void wb_gcm_count_invocation(void)
17991805}
18001806#else
18011807static void wb_gcm_count_invocation (void )
1802- { WB_NOTE ("AESGCM off; GcmCountInvocation guard skipped " ); }
1808+ { WB_NOTE ("GcmCountInvocation prerequisites unavailable " ); }
18031809#endif
18041810
18051811/* ------------------------------------------------------------------------- *
@@ -1866,7 +1872,7 @@ static void wb_getkeysize_claimed(void)
18661872 * first byte stops it at i == 0 (idx0 T, idx1 F).
18671873 * ------------------------------------------------------------------------- */
18681874#if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 ) && \
1869- defined(WOLF_CRYPTO_CB )
1875+ defined(WOLF_CRYPTO_CB ) && !defined( WC_NO_RNG )
18701876static byte wb_rng_fill ;
18711877
18721878static int wb_rng_fill_cb (int devId , wc_CryptoInfo * info , void * ctx )
@@ -1923,7 +1929,7 @@ static void wb_gcm_setiv_carry(void)
19231929}
19241930#else
19251931static void wb_gcm_setiv_carry (void )
1926- { WB_NOTE ("AESGCM/WOLF_CRYPTO_CB off; GcmSetIV carry scan skipped " ); }
1932+ { WB_NOTE ("GcmSetIV carry scan prerequisites unavailable " ); }
19271933#endif
19281934
19291935/* ------------------------------------------------------------------------- *
@@ -2038,6 +2044,9 @@ int main(void)
20382044 printf (" NO_AES defined; nothing to exercise\n" );
20392045 return 0 ;
20402046#else
2047+ #ifdef WOLF_CRYPTO_CB
2048+ wc_CryptoCb_Init ();
2049+ #endif
20412050 wb_ghash_classic ();
20422051 wb_ghash_update ();
20432052 wb_aesnew_common ();
0 commit comments