mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
convert name to oidsum to curve type for setting supported curves
This commit is contained in:
@@ -23272,15 +23272,9 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
|
||||
|
||||
#if defined(HAVE_ECC)
|
||||
|
||||
static byte SetCurveId(ecc_key* key)
|
||||
{
|
||||
if (key == NULL || key->dp == NULL) {
|
||||
WOLFSSL_MSG("SetCurveId: Invalid key!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch(key->dp->oidSum) {
|
||||
/* returns the WOLFSSL_* version of the curve from the OID sum */
|
||||
unsigned char GetCurveByOID(int oidSum) {
|
||||
switch(oidSum) {
|
||||
#if defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES)
|
||||
#ifndef NO_ECC_SECP
|
||||
case ECC_SECP160R1_OID:
|
||||
@@ -23356,6 +23350,16 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
}
|
||||
}
|
||||
|
||||
static byte SetCurveId(ecc_key* key)
|
||||
{
|
||||
if (key == NULL || key->dp == NULL) {
|
||||
WOLFSSL_MSG("SetCurveId: Invalid key!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (byte)GetCurveByOID(key->dp->oidSum);
|
||||
}
|
||||
|
||||
#endif /* HAVE_ECC || HAVE_CURVE25519 */
|
||||
|
||||
typedef struct SskeArgs {
|
||||
|
15
src/ssl.c
15
src/ssl.c
@@ -44409,11 +44409,22 @@ int wolfSSL_CTX_set1_curves_list(WOLFSSL_CTX* ctx, const char* names)
|
||||
curve = WOLFSSL_ECC_X25519;
|
||||
}
|
||||
else {
|
||||
int ret = wc_ecc_get_curve_id_from_name(name);
|
||||
int ret;
|
||||
const ecc_set_type *eccSet;
|
||||
|
||||
ret = wc_ecc_get_curve_idx_from_name(name);
|
||||
if (ret < 0) {
|
||||
WOLFSSL_MSG("Could not find name in set");
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
curve = (word16)ret;
|
||||
|
||||
eccSet = wc_ecc_get_curve_params(ret);
|
||||
if (eccSet == NULL) {
|
||||
WOLFSSL_MSG("NULL set returned");
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
|
||||
curve = GetCurveByOID(eccSet->oidSum);
|
||||
}
|
||||
|
||||
if (curve > (sizeof(word32) * WOLFSSL_BIT_SIZE)) {
|
||||
|
@@ -4465,6 +4465,7 @@ WOLFSSL_LOCAL int SetKeysSide(WOLFSSL*, enum encrypt_side);
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
WOLFSSL_LOCAL int EccMakeKey(WOLFSSL* ssl, ecc_key* key, ecc_key* peer);
|
||||
WOLFSSL_LOCAL unsigned char GetCurveByOID(int oidSum);
|
||||
#endif
|
||||
|
||||
WOLFSSL_LOCAL int InitHandshakeHashes(WOLFSSL* ssl);
|
||||
|
Reference in New Issue
Block a user