Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4751,7 +4751,7 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
* in the message isn't of the DH e value. Treat the Q as e. */
/* DYNTYPE_DH */

byte* e;
const byte* e;
word32 eSz;
word32 begin;
int ret = WS_SUCCESS;
Expand All @@ -4770,28 +4770,20 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
*idx += len;
return WS_SUCCESS;
}
}

if (ret == WS_SUCCESS) {
begin = *idx;
ret = GetUint32(&eSz, buf, len, &begin);
ret = GetStringRef(&eSz, &e, buf, len, &begin);
}

if (ret == WS_SUCCESS) {
/* Validate eSz */
if ((len < begin) || (eSz > len - begin)) {
ret = WS_RECV_OVERFLOW_E;
}
if (eSz > (word32)sizeof(ssh->handshake->e) || eSz == 0)
ret = WS_PUBKEY_REJECTED_E;
}

if (ret == WS_SUCCESS) {
e = buf + begin;
begin += eSz;

if (eSz <= (word32)sizeof(ssh->handshake->e)) {
WMEMCPY(ssh->handshake->e, e, eSz);
ssh->handshake->eSz = eSz;
}
WMEMCPY(ssh->handshake->e, e, eSz);
ssh->handshake->eSz = eSz;

ssh->clientState = CLIENT_KEXDH_INIT_DONE;
*idx = begin;
Expand Down
12 changes: 11 additions & 1 deletion src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ STATIC INLINE word32 min(word32 a, word32 b)
/* convert opaque to 32 bit integer */
STATIC INLINE void ato32(const byte* c, word32* u32)
{
*u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3];
word32 v = 0;

v |= (word32)(c[0] & 0xFF);
v <<= 8;
v |= (word32)(c[1] & 0xFF);
v <<= 8;
v |= (word32)(c[2] & 0xFF);
v <<= 8;
v |= (word32)(c[3] & 0xFF);

*u32 = v;
}


Expand Down