check that the generator and primeGroup are set before trying to flatten them into output

pull/312/head
John Safranek 2021-01-26 16:59:42 -08:00
parent e097c234fc
commit 3653afac34
No known key found for this signature in database
GPG Key ID: 8CE817DE0D3CCB4A
1 changed files with 7 additions and 0 deletions

View File

@ -2843,6 +2843,13 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
if (ret == WS_SUCCESS && ssh->handshake->kexId == ID_DH_GEX_SHA256) {
byte primeGroupPad = 0, generatorPad = 0;
if (ssh->handshake->primeGroup == NULL ||
ssh->handshake->generator == NULL) {
WLOG(WS_LOG_DEBUG,
"DKDR: trying GEX without generator or prime group");
ret = WS_BAD_ARGUMENT;
}
/* Hash in the client's requested minimum key size. */
if (ret == 0) {
c32toa(ssh->handshake->dhGexMinSz, scratchLen);