@@ -1490,12 +1490,18 @@ int test_aes256_cbc_bad_pad(void *data)
14901490
14911491/******************************************************************************/
14921492
1493+ #endif /* WP_HAVE_AESCBC */
1494+
1495+ #if defined(WP_HAVE_AESCBC ) || defined(WP_HAVE_AESCTR ) || \
1496+ defined(WP_HAVE_AESCFB ) || defined(WP_HAVE_DES3CBC )
14931497/**
1494- * Test AES-CBC encrypt/decrypt roundtrip with a large buffer processed in
1495- * multiple update calls. Validates the chunked loop path in
1496- * wp_aes_block_doit (F-1641).
1498+ * Test cipher encrypt/decrypt roundtrip with a large buffer processed in
1499+ * multiple update calls. Validates the chunked loop path used by
1500+ * wp_aes_block_doit, wp_aes_stream_doit, and wp_des3_block_doit
1501+ * (F-1641, F-1642, F-1643).
14971502 */
1498- static int test_aes_cbc_large_update_helper (OSSL_LIB_CTX * libCtx )
1503+ static int test_cipher_large_update_helper (OSSL_LIB_CTX * libCtx ,
1504+ const char * cipherName , int keyLen , int ivLen )
14991505{
15001506 int err ;
15011507 EVP_CIPHER_CTX * ctx = NULL ;
@@ -1511,11 +1517,13 @@ static int test_aes_cbc_large_update_helper(OSSL_LIB_CTX *libCtx)
15111517 int totalDec = 0 ;
15121518 size_t i ;
15131519
1514- RAND_bytes (key , sizeof (key ));
1515- RAND_bytes (iv , sizeof (iv ));
1520+ RAND_bytes (key , keyLen );
1521+ if (ivLen > 0 ) {
1522+ RAND_bytes (iv , ivLen );
1523+ }
15161524 RAND_bytes (plain , sizeof (plain ));
15171525
1518- err = (cipher = EVP_CIPHER_fetch (libCtx , "AES-256-CBC" , "" )) == NULL ;
1526+ err = (cipher = EVP_CIPHER_fetch (libCtx , cipherName , "" )) == NULL ;
15191527
15201528 /* Encrypt in 1024-byte chunks */
15211529 if (err == 0 ) {
@@ -1575,20 +1583,72 @@ static int test_aes_cbc_large_update_helper(OSSL_LIB_CTX *libCtx)
15751583 EVP_CIPHER_free (cipher );
15761584 return err ;
15771585}
1586+ #endif /* any large-update-testable cipher */
15781587
1588+ #ifdef WP_HAVE_AESCBC
15791589int test_aes_cbc_large_update (void * data )
15801590{
15811591 int err ;
15821592
15831593 (void )data ;
15841594
15851595 PRINT_MSG ("AES-CBC large update with OpenSSL" );
1586- err = test_aes_cbc_large_update_helper (osslLibCtx );
1596+ err = test_cipher_large_update_helper (osslLibCtx , "AES-256-CBC" , 32 , 16 );
15871597 if (err == 0 ) {
15881598 PRINT_MSG ("AES-CBC large update with wolfProvider" );
1589- err = test_aes_cbc_large_update_helper (wpLibCtx );
1599+ err = test_cipher_large_update_helper (wpLibCtx , "AES-256-CBC" , 32 , 16 );
15901600 }
15911601 return err ;
15921602}
1593-
15941603#endif /* WP_HAVE_AESCBC */
1604+
1605+ #ifdef WP_HAVE_AESCTR
1606+ int test_aes_ctr_large_update (void * data )
1607+ {
1608+ int err ;
1609+
1610+ (void )data ;
1611+
1612+ PRINT_MSG ("AES-CTR large update with OpenSSL" );
1613+ err = test_cipher_large_update_helper (osslLibCtx , "AES-256-CTR" , 32 , 16 );
1614+ if (err == 0 ) {
1615+ PRINT_MSG ("AES-CTR large update with wolfProvider" );
1616+ err = test_cipher_large_update_helper (wpLibCtx , "AES-256-CTR" , 32 , 16 );
1617+ }
1618+ return err ;
1619+ }
1620+ #endif /* WP_HAVE_AESCTR */
1621+
1622+ #ifdef WP_HAVE_AESCFB
1623+ int test_aes_cfb_large_update (void * data )
1624+ {
1625+ int err ;
1626+
1627+ (void )data ;
1628+
1629+ PRINT_MSG ("AES-CFB large update with OpenSSL" );
1630+ err = test_cipher_large_update_helper (osslLibCtx , "AES-256-CFB" , 32 , 16 );
1631+ if (err == 0 ) {
1632+ PRINT_MSG ("AES-CFB large update with wolfProvider" );
1633+ err = test_cipher_large_update_helper (wpLibCtx , "AES-256-CFB" , 32 , 16 );
1634+ }
1635+ return err ;
1636+ }
1637+ #endif /* WP_HAVE_AESCFB */
1638+
1639+ #ifdef WP_HAVE_DES3CBC
1640+ int test_des3_cbc_large_update (void * data )
1641+ {
1642+ int err ;
1643+
1644+ (void )data ;
1645+
1646+ PRINT_MSG ("DES3-CBC large update with OpenSSL" );
1647+ err = test_cipher_large_update_helper (osslLibCtx , "DES-EDE3-CBC" , 24 , 8 );
1648+ if (err == 0 ) {
1649+ PRINT_MSG ("DES3-CBC large update with wolfProvider" );
1650+ err = test_cipher_large_update_helper (wpLibCtx , "DES-EDE3-CBC" , 24 , 8 );
1651+ }
1652+ return err ;
1653+ }
1654+ #endif /* WP_HAVE_DES3CBC */
0 commit comments