Skip to content

Commit 87e5c62

Browse files
committed
Zeroize EC DER buffer in i2d_ECPrivateKey error path
F-2147 The error path in wolfSSL_i2d_ECPrivateKey could free an EC private key DER staging buffer that may contain a partial private scalar. Zeroize before XFREE.
1 parent 9925f90 commit 87e5c62

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/pk_ec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,6 +3524,9 @@ int wolfSSL_i2d_ECPrivateKey(const WOLFSSL_EC_KEY *key, unsigned char **out)
35243524

35253525
/* Dispose of any allocated buffer on error. */
35263526
if (err && (*out == buf)) {
3527+
if (buf != NULL) {
3528+
ForceZero(buf, len);
3529+
}
35273530
XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
35283531
*out = NULL;
35293532
}

0 commit comments

Comments
 (0)