Skip to content

Commit 70d317e

Browse files
authored
Merge pull request #7571 from rlm2002/internship
Test case for wc_HpkeGenerateKeyPair() NULL argument
2 parents 1852615 + 078fb66 commit 70d317e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27902,6 +27902,31 @@ static wc_test_ret_t hpke_test_single(Hpke* hpke)
2790227902
ret = WC_TEST_RET_ENC_NC;
2790327903
}
2790427904

27905+
/* Negative test case with NULL argument */
27906+
if (ret == 0) {
27907+
ret = wc_HpkeGenerateKeyPair(NULL, &receiverKey, rng);
27908+
if (ret != BAD_FUNC_ARG)
27909+
ret = WC_TEST_RET_ENC_EC(ret);
27910+
else
27911+
ret = 0;
27912+
}
27913+
27914+
if (ret == 0) {
27915+
ret = wc_HpkeGenerateKeyPair(hpke, NULL, rng);
27916+
if (ret != BAD_FUNC_ARG)
27917+
ret = WC_TEST_RET_ENC_EC(ret);
27918+
else
27919+
ret = 0;
27920+
}
27921+
27922+
if (ret == 0) {
27923+
ret = wc_HpkeGenerateKeyPair(hpke, &receiverKey, NULL);
27924+
if (ret != BAD_FUNC_ARG)
27925+
ret = WC_TEST_RET_ENC_EC(ret);
27926+
else
27927+
ret = 0;
27928+
}
27929+
2790527930
if (ephemeralKey != NULL)
2790627931
wc_HpkeFreeKey(hpke, hpke->kem, ephemeralKey, hpke->heap);
2790727932

0 commit comments

Comments
 (0)