Skip to content

Commit e51c9a3

Browse files
committed
Add zeroization in wolfSSH_ProcessBuffer
1 parent a608f19 commit e51c9a3

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
@@ -2415,6 +2415,11 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
24152415
else
24162416
ret = wc_CertPemToDer(in, inSz, der, inSz, wcType);
24172417
if (ret < 0) {
2418+
if (type == BUFTYPE_PRIVKEY) {
2419+
/* wc_KeyPemToDer may have written partial key material;
2420+
* zeroize before free on the private-key path. */
2421+
ForceZero(der, inSz);
2422+
}
24182423
WFREE(der, heap, dynamicType);
24192424
return WS_BAD_FILE_E;
24202425
}
@@ -2430,8 +2435,10 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
24302435
if (type == BUFTYPE_PRIVKEY) {
24312436
ret = IdentifyAsn1Key(der, derSz, 1, ctx->heap, NULL);
24322437
if (ret < 0) {
2433-
if (der != NULL)
2438+
if (der != NULL) {
2439+
ForceZero(der, derSz);
24342440
WFREE(der, heap, dynamicType);
2441+
}
24352442
return ret;
24362443
}
24372444
keyId = (byte)ret;

0 commit comments

Comments
 (0)