forked from wolfSSL/wolfssl
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;
|
ret = NO_PASSWORD;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
passwordSz = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
ret = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||||
info->passwd_userdata);
|
info->passwd_userdata);
|
||||||
|
if (ret >= 0) {
|
||||||
|
passwordSz = ret;
|
||||||
|
|
||||||
/* decrypt the key */
|
/* decrypt the key */
|
||||||
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,
|
||||||
(byte*)password, passwordSz, WC_MD5);
|
(byte*)password, passwordSz, WC_MD5);
|
||||||
|
|
||||||
|
ForceZero(password, passwordSz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
@@ -7990,30 +7990,31 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get password */
|
/* get password */
|
||||||
passwordSz = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
ret = info->passwd_cb(password, passwordSz, PEM_PASS_READ,
|
||||||
info->passwd_userdata);
|
info->passwd_userdata);
|
||||||
|
if (ret >= 0) {
|
||||||
|
passwordSz = ret;
|
||||||
|
|
||||||
/* convert and adjust length */
|
/* convert and adjust length */
|
||||||
if (header == BEGIN_ENC_PRIV_KEY) {
|
if (header == BEGIN_ENC_PRIV_KEY) {
|
||||||
ret = ToTraditionalEnc(der->buffer, der->length,
|
ret = ToTraditionalEnc(der->buffer, der->length,
|
||||||
password, passwordSz);
|
password, passwordSz);
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(password, NULL, DYNAMIC_TYPE_STRING);
|
if (ret >= 0) {
|
||||||
#endif
|
der->length = ret;
|
||||||
if (ret < 0) {
|
}
|
||||||
return 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
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(password, heap, DYNAMIC_TYPE_STRING);
|
XFREE(password, heap, DYNAMIC_TYPE_STRING);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ENCRYPTED_KEYS */
|
#endif /* WOLFSSL_ENCRYPTED_KEYS */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user