diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index cfff46b7f..b495f1502 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -1126,6 +1126,9 @@ int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, word32 inSz) int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, word32 gSz) { + if (key == NULL || p == NULL || g == NULL || pSz == 0 || gSz == 0) + return BAD_FUNC_ARG; + /* may have leading 0 */ if (p[0] == 0) { pSz--; p++; @@ -5470,6 +5473,9 @@ int EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, byte priv[ECC_MAXSIZE]; byte pub[ECC_MAXSIZE * 2 + 1]; /* public key has two parts plus header */ + if (input == NULL || inOutIdx == NULL || key == NULL || inSz == 0) + return BAD_FUNC_ARG; + if (GetSequence(input, inOutIdx, &length, inSz) < 0) return ASN_PARSE_E; diff --git a/src/internal.c b/src/internal.c index 182697ac4..b99d56319 100644 --- a/src/internal.c +++ b/src/internal.c @@ -10733,6 +10733,12 @@ static void PickHashSigAlgo(CYASSL* ssl, (void)input; (void)size; + if (ssl->options.side != CYASSL_SERVER_END) { + CYASSL_MSG("Client received client keyexchange, attack?"); + CYASSL_ERROR(ssl->error = SIDE_ERROR); + return SSL_FATAL_ERROR; + } + if (ssl->options.clientState < CLIENT_HELLO_COMPLETE) { CYASSL_MSG("Client sending keyexchange at wrong time"); SendAlert(ssl, alert_fatal, unexpected_message);