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
3 changes: 3 additions & 0 deletions apps/wolfssh/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ static int ParseRFC6187(const byte* in, word32 inSz, byte** leafOut,

/* Skip the name */
ato32(in, &l);
if (l > inSz - sizeof(word32))
Comment thread
ejohnstown marked this conversation as resolved.
return WS_BUFFER_E;

m += l + sizeof(word32);

/* Get the cert count */
Expand Down
9 changes: 7 additions & 2 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,7 @@ int GenerateKey(byte hashId, byte keyId,
ret = wc_HashFinal(&hash, enmhashId, lastBlock);
if (ret == WS_SUCCESS)
WMEMCPY(key, lastBlock, remainder);
ForceZero(lastBlock, sizeof(lastBlock));
}
}
else {
Expand Down Expand Up @@ -2629,6 +2630,7 @@ int GenerateKey(byte hashId, byte keyId,
ret = wc_HashFinal(&hash, enmhashId, lastBlock);
if (ret == WS_SUCCESS)
WMEMCPY(key + runningKeySz, lastBlock, remainder);
ForceZero(lastBlock, sizeof(lastBlock));
}
}
}
Expand Down Expand Up @@ -13474,7 +13476,7 @@ int SendKexDhGexGroup(WOLFSSH* ssh)
int ret = WS_SUCCESS;

WLOG(WS_LOG_DEBUG, "Entering SendKexDhGexGroup()");
if (ssh == NULL)
if (ssh == NULL || ssh->handshake == NULL)
ret = WS_BAD_ARGUMENT;

if (ret == WS_SUCCESS) {
Expand Down Expand Up @@ -13521,8 +13523,11 @@ int SendKexDhGexGroup(WOLFSSH* ssh)
ret = BundlePacket(ssh);
}

if (ret == WS_SUCCESS)
if (ret == WS_SUCCESS) {
WLOG_EXPECT_MSGID(MSGID_KEXDH_GEX_INIT);
ssh->handshake->expectMsgId = MSGID_KEXDH_GEX_INIT;
ret = wolfSSH_SendPacket(ssh);
Comment thread
ejohnstown marked this conversation as resolved.
}

WLOG(WS_LOG_DEBUG, "Leaving SendKexDhGexGroup(), ret = %d", ret);
return ret;
Expand Down
7 changes: 6 additions & 1 deletion src/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ static int DoPemKey(const byte* in, word32 inSz, byte** out,
WOLFSSH_UNUSED(heap);

if (*out == NULL) {
newKey = (byte*)WMALLOC(inSz, heap, DYNTYPE_PRIVKEY);
newKey = (byte*)WMALLOC(newKeySz, heap, DYNTYPE_PRIVKEY);
Comment thread
ejohnstown marked this conversation as resolved.
if (newKey == NULL) {
return WS_MEMORY_E;
}
Expand All @@ -1879,6 +1879,7 @@ static int DoPemKey(const byte* in, word32 inSz, byte** out,
return WS_BUFFER_E;
}
newKey = *out;
newKeySz = *outSz;
Comment thread
padelsbach marked this conversation as resolved.
}

/* If it is PEM, convert to ASN1 then process. */
Expand Down Expand Up @@ -1914,6 +1915,7 @@ static int DoPemKey(const byte* in, word32 inSz, byte** out,
}
else {
WLOG(WS_LOG_DEBUG, "Unable to identify PEM key");
ForceZero(newKey, newKeySz);
if (*out == NULL) {
WFREE(newKey, heap, DYNTYPE_PRIVKEY);
}
Expand Down Expand Up @@ -1943,6 +1945,7 @@ static int DoOpenSshKey(const byte* in, word32 inSz, byte** out,
return WS_BUFFER_E;
}
newKey = *out;
newKeySz = *outSz;
}

in += WSTRLEN(PrivBeginOpenSSH);
Expand Down Expand Up @@ -1970,6 +1973,7 @@ static int DoOpenSshKey(const byte* in, word32 inSz, byte** out,
}
else {
WLOG(WS_LOG_DEBUG, "Unable to identify key");
ForceZero(newKey, newKeySz);
if (*out == NULL) {
WFREE(newKey, heap, DYNTYPE_PRIVKEY);
}
Expand Down Expand Up @@ -2122,6 +2126,7 @@ int wolfSSH_ReadKey_file(const char* name,
}

WFCLOSE(NULL, file);
ForceZero(in, inSz);
WFREE(in, heap, DYNTYPE_FILE);

return ret;
Expand Down
Loading