Skip to content

Commit f601946

Browse files
committed
add unit test for NULL SHAKE parameters
1 parent e085d46 commit f601946

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/api/test_evp_digest.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,22 @@ int test_wolfSSL_EVP_DigestFinalXOF(void)
368368
ExpectIntEQ(sz, 16);
369369
ExpectIntEQ(EVP_MD_CTX_cleanup(&mdCtx), WOLFSSL_SUCCESS);
370370
#endif
371+
372+
/* NULL size pointer on the non-XOF Final must not crash;
373+
* defaults to 32 / 16 bytes for SHAKE256 / SHAKE128. */
374+
wolfSSL_EVP_MD_CTX_init(&mdCtx);
375+
ExpectIntEQ(EVP_DigestInit(&mdCtx, EVP_shake256()), WOLFSSL_SUCCESS);
376+
ExpectIntEQ(EVP_DigestUpdate(&mdCtx, data, 1), WOLFSSL_SUCCESS);
377+
ExpectIntEQ(EVP_DigestFinal(&mdCtx, shake, NULL), WOLFSSL_SUCCESS);
378+
ExpectIntEQ(EVP_MD_CTX_cleanup(&mdCtx), WOLFSSL_SUCCESS);
379+
380+
#if defined(WOLFSSL_SHAKE128)
381+
wolfSSL_EVP_MD_CTX_init(&mdCtx);
382+
ExpectIntEQ(EVP_DigestInit(&mdCtx, EVP_shake128()), WOLFSSL_SUCCESS);
383+
ExpectIntEQ(EVP_DigestUpdate(&mdCtx, data, 1), WOLFSSL_SUCCESS);
384+
ExpectIntEQ(EVP_DigestFinal(&mdCtx, shake, NULL), WOLFSSL_SUCCESS);
385+
ExpectIntEQ(EVP_MD_CTX_cleanup(&mdCtx), WOLFSSL_SUCCESS);
386+
#endif
371387
#endif
372388
return EXPECT_RESULT();
373389
}

0 commit comments

Comments
 (0)