Tests all NULL argument cases

This commit is contained in:
Ruby Martin
2024-05-23 13:36:48 -06:00
parent f2492da6a4
commit b8838dca44

View File

@ -27521,15 +27521,6 @@ static wc_test_ret_t hpke_test_single(Hpke* hpke)
ret = WC_TEST_RET_ENC_EC(ret);
}
/* NULL argument results in failure */
if (ret == 0) {
ret = wc_HpkeGenerateKeyPair(NULL, &receiverKey, rng);
if (ret != BAD_FUNC_ARG)
ret = WC_TEST_RET_ENC_EC(ret);
else
ret = 0;
}
/* seal */
if (ret == 0) {
ret = wc_HpkeSealBase(hpke, ephemeralKey, receiverKey,
@ -27565,6 +27556,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);