fix check on ephemeral key type before free'ing

This commit is contained in:
Jacob Barthelmeh
2017-08-18 10:55:38 -06:00
parent c9efcc4561
commit c6e722170e
2 changed files with 6 additions and 4 deletions

View File

@ -4811,7 +4811,8 @@ void SSL_ResourceFree(WOLFSSL* ssl)
FreeKey(ssl, DYNAMIC_TYPE_ECC, (void**)&ssl->peerEccDsaKey);
ssl->peerEccDsaKeyPresent = 0;
#ifdef HAVE_CURVE25519
if (!ssl->peerX25519KeyPresent)
if (!ssl->peerX25519KeyPresent &&
ssl->eccTempKeyPresent != DYNAMIC_TYPE_CURVE25519)
#endif /* HAVE_CURVE25519 */
{
FreeKey(ssl, DYNAMIC_TYPE_ECC, (void**)&ssl->eccTempKey);
@ -20725,7 +20726,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
ret = X25519MakeKey(ssl,
(curve25519_key*)ssl->eccTempKey, NULL);
if (ret == 0 || ret == WC_PENDING_E) {
ssl->eccTempKeyPresent = 1;
ssl->eccTempKeyPresent =
DYNAMIC_TYPE_CURVE25519;
}
}
break;
@ -20747,7 +20749,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
then we know curve dp */
ret = EccMakeKey(ssl, ssl->eccTempKey, NULL);
if (ret == 0 || ret == WC_PENDING_E) {
ssl->eccTempKeyPresent = 1;
ssl->eccTempKeyPresent = DYNAMIC_TYPE_ECC;
}
}
#endif

View File

@ -3312,7 +3312,7 @@ struct WOLFSSL {
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519)
word32 ecdhCurveOID; /* curve Ecc_Sum */
ecc_key* eccTempKey; /* private ECDHE key */
byte eccTempKeyPresent;
byte eccTempKeyPresent; /* also holds type */
byte peerEccKeyPresent;
#endif
#ifdef HAVE_ECC