Do not add DH padding on failure.

This commit is contained in:
David Garske
2021-08-16 14:00:44 -07:00
parent 9898b5d82b
commit 5c00951f09

View File

@ -2345,13 +2345,13 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session,
wc_FreeDhKey(&dhKey);
#ifdef WOLFSSL_SNIFFER_STATS
if (ret != 0)
INC_STAT(SnifferStats.sslKeyFails);
#endif
/* left-padded with zeros up to the size of the prime */
if (params->p_len > session->sslServer->arrays->preMasterSz) {
if (ret == 0 && params->p_len > session->sslServer->arrays->preMasterSz) {
word32 diff = params->p_len - session->sslServer->arrays->preMasterSz;
XMEMMOVE(session->sslServer->arrays->preMasterSecret + diff,
session->sslServer->arrays->preMasterSecret,