Skip to content

Commit 90c0ee6

Browse files
padelsbachejohnstown
authored andcommitted
Add zeroization in wolfSSH_ProcessBuffer
1 parent 3f03a85 commit 90c0ee6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/internal.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,11 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
24182418
else
24192419
ret = wc_CertPemToDer(in, inSz, der, inSz, wcType);
24202420
if (ret < 0) {
2421+
if (type == BUFTYPE_PRIVKEY) {
2422+
/* wc_KeyPemToDer may have written partial key material;
2423+
* zeroize before free on the private-key path. */
2424+
ForceZero(der, inSz);
2425+
}
24212426
WFREE(der, heap, dynamicType);
24222427
return WS_BAD_FILE_E;
24232428
}
@@ -2433,8 +2438,10 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
24332438
if (type == BUFTYPE_PRIVKEY) {
24342439
ret = IdentifyAsn1Key(der, derSz, 1, ctx->heap, NULL);
24352440
if (ret < 0) {
2436-
if (der != NULL)
2441+
if (der != NULL) {
2442+
ForceZero(der, derSz);
24372443
WFREE(der, heap, dynamicType);
2444+
}
24382445
return ret;
24392446
}
24402447
keyId = (byte)ret;

0 commit comments

Comments
 (0)