Commit bacbcdcf0ad for nodejs
commit bacbcdcf0ad600dcc7204ed2809af93354106a6d
Author: Filip Skokan <panva.ip@gmail.com>
Date: Wed Sep 30 13:50:19 2026 +0200
crypto: skip secret key mutex allocation
Secret key bytes are immutable after KeyObjectData construction. AES,
ChaCha20-Poly1305, MAC, and KDF jobs read those bytes without acquiring
KeyObjectData::mutex(), and secret-key export and equality do the same.
Do not allocate a shared mutex that none of these operations uses.
Asymmetric key mutex initialization remains eager so copies continue to
share the same lock while asymmetric acquisitions remain.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc
index 580f9ac009d..da56f4a4e26 100644
--- a/src/crypto/crypto_keys.cc
+++ b/src/crypto/crypto_keys.cc
@@ -1053,7 +1053,6 @@ KeyObjectData::KeyObjectData(std::nullptr_t)
KeyObjectData::KeyObjectData(ByteSource symmetric_key)
: key_type_(KeyType::kKeyTypeSecret),
- mutex_(std::make_shared<Mutex>()),
data_(std::make_shared<Data>(std::move(symmetric_key))) {}
KeyObjectData::KeyObjectData(KeyType type, EVPKeyPointer&& pkey)