tls: return immediately if kyber_id2type() fails

This prevents a crash as ecc_key is not initialized but the
free function is still called.
This commit is contained in:
res0nance
2023-11-18 15:41:47 +08:00
parent 06dcc114c1
commit 98789dc000

View File

@ -8396,7 +8396,7 @@ static int TLSX_KeyShare_ProcessPqc(WOLFSSL* ssl, KeyShareEntry* keyShareEntry)
ret = kyber_id2type(oqs_group, &type);
if (ret != 0) {
WOLFSSL_MSG("Invalid OQS algorithm specified.");
ret = BAD_FUNC_ARG;
return BAD_FUNC_ARG;
}
if (ret == 0) {
ret = wc_KyberKey_Init(type, kem, ssl->heap, INVALID_DEVID);
@ -8887,7 +8887,7 @@ static int server_generate_pqc_ciphertext(WOLFSSL* ssl,
ret = kyber_id2type(oqs_group, &type);
if (ret != 0) {
WOLFSSL_MSG("Invalid Kyber algorithm specified.");
ret = BAD_FUNC_ARG;
return BAD_FUNC_ARG;
}
if (ret == 0) {