mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 04:34:41 +02:00
Added ForceZero on the password buffer after done using it.
This commit is contained in:
13
src/ssl.c
13
src/ssl.c
@@ -4603,12 +4603,17 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
|
||||
ret = NO_PASSWORD;
|
||||
}
|
||||
else {
|
||||
passwordSz = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||
ret = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||
info->passwd_userdata);
|
||||
if (ret >= 0) {
|
||||
passwordSz = ret;
|
||||
|
||||
/* decrypt the key */
|
||||
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
||||
(byte*)password, passwordSz, WC_MD5);
|
||||
/* decrypt the key */
|
||||
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
||||
(byte*)password, passwordSz, WC_MD5);
|
||||
|
||||
ForceZero(password, passwordSz);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
|
@@ -7990,30 +7990,31 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
||||
#endif
|
||||
|
||||
/* get password */
|
||||
passwordSz = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||
ret = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||
info->passwd_userdata);
|
||||
if (ret >= 0) {
|
||||
passwordSz = ret;
|
||||
|
||||
/* convert and adjust length */
|
||||
if (header == BEGIN_ENC_PRIV_KEY) {
|
||||
ret = ToTraditionalEnc(der->buffer, der->length,
|
||||
password, passwordSz);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(password, NULL, DYNAMIC_TYPE_STRING);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
/* convert and adjust length */
|
||||
if (header == BEGIN_ENC_PRIV_KEY) {
|
||||
ret = ToTraditionalEnc(der->buffer, der->length,
|
||||
password, passwordSz);
|
||||
|
||||
if (ret >= 0) {
|
||||
der->length = ret;
|
||||
}
|
||||
}
|
||||
/* decrypt the key */
|
||||
else {
|
||||
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
||||
(byte*)password, passwordSz, WC_MD5);
|
||||
}
|
||||
ForceZero(password, passwordSz);
|
||||
}
|
||||
|
||||
der->length = ret;
|
||||
}
|
||||
/* decrypt the key */
|
||||
else {
|
||||
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
||||
(byte*)password, passwordSz, WC_MD5);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(password, heap, DYNAMIC_TYPE_STRING);
|
||||
XFREE(password, heap, DYNAMIC_TYPE_STRING);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* WOLFSSL_ENCRYPTED_KEYS */
|
||||
|
||||
|
Reference in New Issue
Block a user