Skip to content

Commit 937d247

Browse files
committed
Don't create a key if we don't support the curve.
Found with the following configuration: ./configure --enable-tls13 --disable-oldtls --enable-static --enable-singlethreaded --enable-dtls --enable-dtls13 --enable-dtls-mtu --enable-sp=yes,4096 --disable-shared --disable-sha3 --disable-dh --enable-curve25519 --enable-secure-renegotiation --enable-debug --enable-opensslextra 'CFLAGS=-DWOLFSSL_DTLS_ALLOW_FUTURE -DWOLFSSL_MIN_RSA_BITS=2048 -DWOLFSSL_MIN_ECC_BITS=256 -DFP_MAX_BITS=8192 -fomit-frame-pointer'
1 parent eb69ccb commit 937d247

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/pk.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9168,12 +9168,19 @@ WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new_by_curve_name(int nid)
91689168

91699169
if (eccEnum != -1) {
91709170
/* search and set the corresponding internal curve idx */
9171-
for (x = 0; ecc_sets[x].size != 0; x++)
9171+
for (x = 0; ecc_sets[x].size != 0; x++) {
91729172
if (ecc_sets[x].id == eccEnum) {
91739173
key->group->curve_idx = x;
91749174
key->group->curve_oid = ecc_sets[x].oidSum;
91759175
break;
91769176
}
9177+
}
9178+
9179+
/* if not found, we don't support this curve. */
9180+
if (ecc_sets[x].size == 0) {
9181+
wolfSSL_EC_KEY_free(key);
9182+
key = NULL;
9183+
}
91779184
}
91789185

91799186
return key;

tests/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46165,7 +46165,7 @@ static int test_wolfSSL_EC_KEY_print_fp(void)
4616546165
{
4616646166
int res = TEST_SKIPPED;
4616746167
#if defined(HAVE_ECC) && ((defined(HAVE_ECC224) && defined(HAVE_ECC256)) || \
46168-
defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256 && \
46168+
defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 224 && \
4616946169
defined(OPENSSL_EXTRA) && defined(XFPRINTF) && !defined(NO_FILESYSTEM) && \
4617046170
!defined(NO_STDIO_FILESYSTEM)
4617146171
EC_KEY* key = NULL;

0 commit comments

Comments
 (0)