Skip to content

Commit

Permalink
Merge pull request wolfSSL#7571 from rlm2002/internship
Browse files Browse the repository at this point in the history
Test case for wc_HpkeGenerateKeyPair() NULL argument
  • Loading branch information
cconlon authored Jun 5, 2024
2 parents 1852615 + 078fb66 commit 70d317e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27902,6 +27902,31 @@ static wc_test_ret_t hpke_test_single(Hpke* hpke)
ret = WC_TEST_RET_ENC_NC;
}

/* Negative test case with NULL argument */
if (ret == 0) {
ret = wc_HpkeGenerateKeyPair(NULL, &receiverKey, rng);
if (ret != BAD_FUNC_ARG)
ret = WC_TEST_RET_ENC_EC(ret);
else
ret = 0;
}

if (ret == 0) {
ret = wc_HpkeGenerateKeyPair(hpke, NULL, rng);
if (ret != BAD_FUNC_ARG)
ret = WC_TEST_RET_ENC_EC(ret);
else
ret = 0;
}

if (ret == 0) {
ret = wc_HpkeGenerateKeyPair(hpke, &receiverKey, NULL);
if (ret != BAD_FUNC_ARG)
ret = WC_TEST_RET_ENC_EC(ret);
else
ret = 0;
}

if (ephemeralKey != NULL)
wc_HpkeFreeKey(hpke, hpke->kem, ephemeralKey, hpke->heap);

Expand Down

0 comments on commit 70d317e

Please sign in to comment.