Merge pull request #3406 from ejohnstown/dh-fix-2

DH Fix 2
This commit is contained in:
Sean Parkinson
2020-10-21 08:05:42 +10:00
committed by GitHub

View File

@ -21260,6 +21260,9 @@ static int GetDhPublicKey(WOLFSSL* ssl, const byte* input, word32 size,
if (length > ssl->options.maxDhKeySz) { if (length > ssl->options.maxDhKeySz) {
WOLFSSL_MSG("Server using a DH key generator that is too big"); WOLFSSL_MSG("Server using a DH key generator that is too big");
SendAlert(ssl, alert_fatal, handshake_failure); SendAlert(ssl, alert_fatal, handshake_failure);
XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap,
DYNAMIC_TYPE_PUBLIC_KEY);
ssl->buffers.serverDH_P.buffer = NULL;
ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk); ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk);
} }
@ -21306,11 +21309,23 @@ static int GetDhPublicKey(WOLFSSL* ssl, const byte* input, word32 size,
if (length < ssl->options.minDhKeySz) { if (length < ssl->options.minDhKeySz) {
WOLFSSL_MSG("Server using a public DH key that is too small"); WOLFSSL_MSG("Server using a public DH key that is too small");
SendAlert(ssl, alert_fatal, handshake_failure); SendAlert(ssl, alert_fatal, handshake_failure);
XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap,
DYNAMIC_TYPE_PUBLIC_KEY);
ssl->buffers.serverDH_P.buffer = NULL;
XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap,
DYNAMIC_TYPE_PUBLIC_KEY);
ssl->buffers.serverDH_G.buffer = NULL;
ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk); ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk);
} }
if (length > ssl->options.maxDhKeySz) { if (length > ssl->options.maxDhKeySz) {
WOLFSSL_MSG("Server using a public DH key that is too big"); WOLFSSL_MSG("Server using a public DH key that is too big");
SendAlert(ssl, alert_fatal, handshake_failure); SendAlert(ssl, alert_fatal, handshake_failure);
XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap,
DYNAMIC_TYPE_PUBLIC_KEY);
ssl->buffers.serverDH_P.buffer = NULL;
XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap,
DYNAMIC_TYPE_PUBLIC_KEY);
ssl->buffers.serverDH_G.buffer = NULL;
ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk); ERROR_OUT(DH_KEY_SIZE_E, exit_gdpk);
} }