@@ -1309,10 +1309,6 @@ static void wb_gcmccm_pending(void)
13091309 return ;
13101310 }
13111311
1312- /* Zero the device table (a zeroed slot has devId==0, not INVALID_DEVID,
1313- * so registration finds no free slot until this runs). */
1314- wc_CryptoCb_Init ();
1315-
13161312 /* GCM: baseline (ret==0) then PENDING. */
13171313 mcdc_cb_uninstall ();
13181314 if (wc_AesInit (& aes , NULL , MCDC_CB_DEVID ) == 0 &&
@@ -1739,7 +1735,8 @@ static void wb_slow_vaes(void)
17391735 * GcmCountInvocation() on every call, which is enough to drive all three
17401736 * operand rows.
17411737 * ------------------------------------------------------------------------- */
1742- #if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 )
1738+ #if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 ) && \
1739+ !defined(WC_NO_RNG )
17431740static void wb_gcm_count_invocation (void )
17441741{
17451742 Aes aes ;
@@ -1755,14 +1752,23 @@ static void wb_gcm_count_invocation(void)
17551752 XMEMSET (key , 0x61 , sizeof (key ));
17561753 XMEMSET (in , 0x62 , sizeof (in ));
17571754
1758- if (wc_AesInit (& aes , NULL , INVALID_DEVID ) != 0 ||
1759- wc_InitRng (& rng ) != 0 ||
1760- wc_AesGcmSetKey (& aes , key , sizeof (key )) != 0 ||
1755+ if (wc_AesInit (& aes , NULL , INVALID_DEVID ) != 0 ) {
1756+ WB_NOTE ("wc_AesInit failed (GcmCountInvocation skipped)" );
1757+ wb_fail = 1 ;
1758+ return ;
1759+ }
1760+ if (wc_InitRng (& rng ) != 0 ) {
1761+ WB_NOTE ("wc_InitRng failed (GcmCountInvocation skipped)" );
1762+ wb_fail = 1 ;
1763+ wc_AesFree (& aes );
1764+ return ;
1765+ }
1766+ if (wc_AesGcmSetKey (& aes , key , sizeof (key )) != 0 ||
17611767 wc_AesGcmSetIV (& aes , sizeof (iv ), NULL , 0 , & rng ) != 0 ) {
17621768 WB_NOTE ("GCM setup failed (GcmCountInvocation skipped)" );
17631769 wb_fail = 1 ;
1764- if ( rng . status == 0 )
1765- wc_FreeRng ( & rng );
1770+ wc_FreeRng ( & rng );
1771+ wc_AesFree ( & aes );
17661772 return ;
17671773 }
17681774
@@ -1797,7 +1803,7 @@ static void wb_gcm_count_invocation(void)
17971803}
17981804#else
17991805static void wb_gcm_count_invocation (void )
1800- { WB_NOTE ("AESGCM off; GcmCountInvocation guard skipped " ); }
1806+ { WB_NOTE ("GcmCountInvocation prerequisites unavailable " ); }
18011807#endif
18021808
18031809/* ------------------------------------------------------------------------- *
@@ -1864,7 +1870,7 @@ static void wb_getkeysize_claimed(void)
18641870 * first byte stops it at i == 0 (idx0 T, idx1 F).
18651871 * ------------------------------------------------------------------------- */
18661872#if !defined(NO_AES ) && defined(HAVE_AESGCM ) && defined(WOLFSSL_AES_128 ) && \
1867- defined(WOLF_CRYPTO_CB )
1873+ defined(WOLF_CRYPTO_CB ) && !defined( WC_NO_RNG )
18681874static byte wb_rng_fill ;
18691875
18701876static int wb_rng_fill_cb (int devId , wc_CryptoInfo * info , void * ctx )
@@ -1921,7 +1927,7 @@ static void wb_gcm_setiv_carry(void)
19211927}
19221928#else
19231929static void wb_gcm_setiv_carry (void )
1924- { WB_NOTE ("AESGCM/WOLF_CRYPTO_CB off; GcmSetIV carry scan skipped " ); }
1930+ { WB_NOTE ("GcmSetIV carry scan prerequisites unavailable " ); }
19251931#endif
19261932
19271933/* ------------------------------------------------------------------------- *
@@ -2036,6 +2042,9 @@ int main(void)
20362042 printf (" NO_AES defined; nothing to exercise\n" );
20372043 return 0 ;
20382044#else
2045+ #ifdef WOLF_CRYPTO_CB
2046+ wc_CryptoCb_Init ();
2047+ #endif
20392048 wb_ghash_classic ();
20402049 wb_ghash_update ();
20412050 wb_aesnew_common ();
0 commit comments