Skip to content

Commit

Permalink
src: avoid heap allocation in crypto.pbkdf2()
Browse files Browse the repository at this point in the history
PR-URL: #14122
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
bnoordhuis authored and addaleax committed Jul 18, 2017
1 parent 1c3e090 commit b5802c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5355,8 +5355,9 @@ void PBKDF2Request::Work(uv_work_t* work_req) {
void PBKDF2Request::After(Local<Value> (*argv)[2]) {
if (error()) {
(*argv)[0] = Undefined(env()->isolate());
(*argv)[1] = Encode(env()->isolate(), key(), keylen(), BUFFER);
OPENSSL_cleanse(key(), keylen());
(*argv)[1] = Buffer::New(env(), key(), keylen()).ToLocalChecked();
key_ = nullptr;
keylen_ = 0;
} else {
(*argv)[0] = Exception::Error(env()->pbkdf2_error_string());
(*argv)[1] = Undefined(env()->isolate());
Expand Down

0 comments on commit b5802c7

Please sign in to comment.