crypto: move DEP0182 to End-of-Life by tniessen · Pull Request #61084 · 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
22 changes: 6 additions & 16 deletions doc/api/crypto.md
17 changes: 10 additions & 7 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3992,6 +3992,9 @@ Please use the [`crypto.createHmac()`][] method to create Hmac instances.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/61084
description: End-of-Life.
- version: v23.0.0
pr-url: https://github.com/nodejs/node/pull/52552
description: Runtime deprecation.
Expand All @@ -4000,16 +4003,16 @@ changes:
description: Documentation-only deprecation.
-->

Type: Runtime
Type: End-of-Life

Applications that intend to use authentication tags that are shorter than the
default authentication tag length must set the `authTagLength` option of the
For ciphers in GCM mode, the [`decipher.setAuthTag()`][] function used to accept
authentication tags of any valid length (see also [DEP0090](#DEP0090)). This
exception has been removed to better align with recommendations per
[NIST SP 800-38D][], and applications that intend to use authentication tags
that are shorter than the default authentication tag length (i.e., shorter than
16 bytes for AES-GCM) must explicitly set the `authTagLength` option of the
[`crypto.createDecipheriv()`][] function to the appropriate length.

For ciphers in GCM mode, the [`decipher.setAuthTag()`][] function accepts
authentication tags of any valid length (see [DEP0090](#DEP0090)). This behavior
is deprecated to better align with recommendations per [NIST SP 800-38D][].

### DEP0183: OpenSSL engine-based APIs

<!-- YAML
Expand Down
17 changes: 4 additions & 13 deletions src/crypto/crypto_cipher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -554,23 +554,14 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
is_valid = cipher->auth_tag_len_ == tag_len;
}

if (!is_valid) {
// TODO(tniessen): refactor this check.
if (!is_valid ||
(cipher->ctx_.isGcmMode() && cipher->auth_tag_len_ == kNoAuthTagLength &&
tag_len != EVP_GCM_TLS_TAG_LEN)) {
return THROW_ERR_CRYPTO_INVALID_AUTH_TAG(
env, "Invalid authentication tag length: %u", tag_len);
}

if (cipher->ctx_.isGcmMode() && cipher->auth_tag_len_ == kNoAuthTagLength &&
tag_len != EVP_GCM_TLS_TAG_LEN && env->EmitProcessEnvWarning()) {
if (ProcessEmitDeprecationWarning(
env,
"Using AES-GCM authentication tags of less than 128 bits without "
"specifying the authTagLength option when initializing decryption "
"is deprecated.",
"DEP0182")
.IsNothing())
return;
}

cipher->auth_tag_len_ = tag_len;
CHECK_LE(cipher->auth_tag_len_, ncrypto::Cipher::MAX_AUTH_TAG_LENGTH);

Expand Down
20 changes: 9 additions & 11 deletions test/parallel/test-crypto-gcm-implicit-short-tag.js
Loading