crypto: prevent Hmac.digest() from returning uninitialized memory after stream use by mcollina · Pull Request #65112 · nodejs/node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/internal/crypto/hash.js
3 changes: 3 additions & 0 deletions src/crypto/crypto_hmac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
return ThrowCryptoError(env, ERR_get_error(), "Failed to finalize HMAC");
}
hmac->ctx_.reset();
} else {
// The context has already been finalized; never emit unwritten bytes.
buf.len = 0;
}

Local<Value> ret;
Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-crypto-hmac.js
Loading