Skip to content

Commit a472745

Browse files
authored
crypto: runtime-deprecate default shake128/256 output lengths
PR-URL: #59008 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 0d128e3 commit a472745

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4065,12 +4065,15 @@ The [`util.types.isNativeError`][] API is deprecated. Please use [`Error.isError
40654065

40664066
<!-- YAML
40674067
changes:
4068+
- version: REPLACEME
4069+
pr-url: https://github.com/nodejs/node/pull/59008
4070+
description: Runtime deprecation.
40684071
- version: v24.4.0
40694072
pr-url: https://github.com/nodejs/node/pull/58942
40704073
description: Documentation-only deprecation with support for `--pending-deprecation`.
40714074
-->
40724075

4073-
Type: Documentation-only (supports [`--pending-deprecation`][])
4076+
Type: Runtime
40744077

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

lib/internal/crypto/hash.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const {
3434
lazyDOMException,
3535
normalizeEncoding,
3636
encodingsMap,
37-
isPendingDeprecation,
3837
getDeprecationWarningEmitter,
3938
} = require('internal/util');
4039

@@ -80,7 +79,6 @@ const maybeEmitDeprecationWarning = getDeprecationWarningEmitter(
8079
undefined,
8180
false,
8281
(algorithm) => {
83-
if (!isPendingDeprecation()) return false;
8482
const normalized = normalizeAlgorithm(algorithm);
8583
return normalized === 'shake128' || normalized === 'shake256';
8684
},

src/crypto/crypto_hash.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
251251
} else if (output_length == 0) {
252252
// This is to handle OpenSSL 3.4's breaking change in SHAKE128/256
253253
// default lengths
254+
// TODO(@panva): remove this behaviour when DEP0198 is End-Of-Life
254255
const char* name = OBJ_nid2sn(EVP_MD_type(md));
255256
if (name != nullptr) {
256257
if (strcmp(name, "SHAKE128") == 0) {
@@ -379,6 +380,9 @@ bool Hash::HashInit(const EVP_MD* md, Maybe<unsigned int> xof_md_len) {
379380
}
380381

381382
md_len_ = mdctx_.getDigestSize();
383+
384+
// This is to handle OpenSSL 3.4's breaking change in SHAKE128/256
385+
// default lengths
382386
// TODO(@panva): remove this behaviour when DEP0198 is End-Of-Life
383387
if (mdctx_.hasXofFlag() && !xof_md_len.IsJust() && md_len_ == 0) {
384388
const char* name = OBJ_nid2sn(EVP_MD_type(md));

test/parallel/test-crypto-default-shake-lengths-oneshot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Flags: --pending-deprecation
21
'use strict';
32

43
const common = require('../common');

test/parallel/test-crypto-default-shake-lengths.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Flags: --pending-deprecation
21
'use strict';
32

43
const common = require('../common');

test/parallel/test-crypto-hash.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ if (!common.hasCrypto) {
44
common.skip('missing crypto');
55
}
66

7+
common.expectWarning({
8+
DeprecationWarning: [
9+
['crypto.Hash constructor is deprecated.',
10+
'DEP0179'],
11+
['Creating SHAKE128/256 digests without an explicit options.outputLength is deprecated.',
12+
'DEP0198'],
13+
]
14+
});
15+
716
const assert = require('assert');
817
const crypto = require('crypto');
918
const fs = require('fs');
@@ -280,10 +289,4 @@ assert.throws(
280289

281290
{
282291
crypto.Hash('sha256');
283-
common.expectWarning({
284-
DeprecationWarning: [
285-
['crypto.Hash constructor is deprecated.',
286-
'DEP0179'],
287-
]
288-
});
289292
}

0 commit comments

Comments
 (0)