Skip to content

Commit e955f9a

Browse files
ChALkeRrvagg
authored andcommitted
crypto: Use OPENSSL_cleanse to shred the data.
memset() is not useful here, it's efficiently a noop. PR-URL: #2575 Reviewed-By: Fedor Indutny <[email protected]>
1 parent 5e65181 commit e955f9a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/node_crypto.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -4721,8 +4721,8 @@ void EIO_PBKDF2(PBKDF2Request* req) {
47214721
req->digest(),
47224722
req->keylen(),
47234723
reinterpret_cast<unsigned char*>(req->key())));
4724-
memset(req->pass(), 0, req->passlen());
4725-
memset(req->salt(), 0, req->saltlen());
4724+
OPENSSL_cleanse(req->pass(), req->passlen());
4725+
OPENSSL_cleanse(req->salt(), req->saltlen());
47264726
}
47274727

47284728

@@ -4736,7 +4736,7 @@ void EIO_PBKDF2After(PBKDF2Request* req, Local<Value> argv[2]) {
47364736
if (req->error()) {
47374737
argv[0] = Undefined(req->env()->isolate());
47384738
argv[1] = Encode(req->env()->isolate(), req->key(), req->keylen(), BUFFER);
4739-
memset(req->key(), 0, req->keylen());
4739+
OPENSSL_cleanse(req->key(), req->keylen());
47404740
} else {
47414741
argv[0] = Exception::Error(req->env()->pbkdf2_error_string());
47424742
argv[1] = Undefined(req->env()->isolate());

0 commit comments

Comments
 (0)