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
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4065,12 +4065,15 @@ The [`util.types.isNativeError`][] API is deprecated. Please use [`Error.isError

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/59008
description: Runtime deprecation.
- version: v24.4.0
pr-url: https://github.com/nodejs/node/pull/58942
description: Documentation-only deprecation with support for `--pending-deprecation`.
-->

Type: Documentation-only (supports [`--pending-deprecation`][])
Type: Runtime

Creating SHAKE-128 and SHAKE-256 digests without an explicit `options.outputLength` is deprecated.

Expand Down
2 changes: 0 additions & 2 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const {
lazyDOMException,
normalizeEncoding,
encodingsMap,
isPendingDeprecation,
getDeprecationWarningEmitter,
} = require('internal/util');

Expand Down Expand Up @@ -80,7 +79,6 @@ const maybeEmitDeprecationWarning = getDeprecationWarningEmitter(
undefined,
false,
(algorithm) => {
if (!isPendingDeprecation()) return false;
const normalized = normalizeAlgorithm(algorithm);
return normalized === 'shake128' || normalized === 'shake256';
},
Expand Down
4 changes: 4 additions & 0 deletions src/crypto/crypto_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
} else if (output_length == 0) {
// This is to handle OpenSSL 3.4's breaking change in SHAKE128/256
// default lengths
// TODO(@panva): remove this behaviour when DEP0198 is End-Of-Life
const char* name = OBJ_nid2sn(EVP_MD_type(md));
if (name != nullptr) {
if (strcmp(name, "SHAKE128") == 0) {
Expand Down Expand Up @@ -379,6 +380,9 @@ bool Hash::HashInit(const EVP_MD* md, Maybe<unsigned int> xof_md_len) {
}

md_len_ = mdctx_.getDigestSize();

// This is to handle OpenSSL 3.4's breaking change in SHAKE128/256
// default lengths
// TODO(@panva): remove this behaviour when DEP0198 is End-Of-Life
if (mdctx_.hasXofFlag() && !xof_md_len.IsJust() && md_len_ == 0) {
const char* name = OBJ_nid2sn(EVP_MD_type(md));
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-crypto-default-shake-lengths-oneshot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --pending-deprecation
'use strict';

const common = require('../common');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-crypto-default-shake-lengths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --pending-deprecation
'use strict';

const common = require('../common');
Expand Down
15 changes: 9 additions & 6 deletions test/parallel/test-crypto-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
}

common.expectWarning({
DeprecationWarning: [
['crypto.Hash constructor is deprecated.',
'DEP0179'],
['Creating SHAKE128/256 digests without an explicit options.outputLength is deprecated.',
'DEP0198'],
]
});

const assert = require('assert');
const crypto = require('crypto');
const fs = require('fs');
Expand Down Expand Up @@ -280,10 +289,4 @@ assert.throws(

{
crypto.Hash('sha256');
common.expectWarning({
DeprecationWarning: [
['crypto.Hash constructor is deprecated.',
'DEP0179'],
]
});
}
Loading