mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Fix for TLS with non-standard curves. The generted ECC ephemeral key did not use the same curve type as peer. Only the server was populating ssl->ecdhCurveOID
. Now the curveOID is populated for both and as a fail-safe the peer key curve is used as default (when available).
This commit is contained in:
@ -4278,11 +4278,12 @@ int EccMakeKey(WOLFSSL* ssl, ecc_key* key, ecc_key* peer)
|
||||
#endif
|
||||
|
||||
/* get key size */
|
||||
if (peer == NULL) {
|
||||
if (peer == NULL || peer->dp == NULL) {
|
||||
keySz = ssl->eccTempKeySz;
|
||||
}
|
||||
else {
|
||||
keySz = peer->dp->size;
|
||||
ecc_curve = peer->dp->id;
|
||||
}
|
||||
|
||||
/* get curve type */
|
||||
@ -11513,6 +11514,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
ret = ECC_KEY_SIZE_E;
|
||||
WOLFSSL_MSG("Peer ECC key is too small");
|
||||
}
|
||||
|
||||
/* populate curve oid */
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END)
|
||||
ssl->ecdhCurveOID = args->dCert->pkCurveOID;
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_ECC */
|
||||
@ -11563,6 +11568,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
ret = ECC_KEY_SIZE_E;
|
||||
WOLFSSL_MSG("Peer ECC key is too small");
|
||||
}
|
||||
|
||||
/* populate curve oid */
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END)
|
||||
ssl->ecdhCurveOID = ECC_X25519_OID;
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_ED25519 */
|
||||
@ -11612,6 +11621,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
ret = ECC_KEY_SIZE_E;
|
||||
WOLFSSL_MSG("Peer ECC key is too small");
|
||||
}
|
||||
|
||||
/* populate curve oid */
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END)
|
||||
ssl->ecdhCurveOID = ECC_X448_OID;
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_ED448 */
|
||||
|
Reference in New Issue
Block a user