Skip to content

Commit bd7fc7a

Browse files
committed
test: skip sha128/256 createHash()/hash() on openssl 3.4.
OpenSSL 3.4 has intentionally broken EVP_DigestFinal for SHAKE128 and SHAKE256 when OSSL_DIGEST_PARAM_XOFLEN is not set because a) the default length used weakened them from their maximum strength and b) a static length does not fully make sense for XOFs (which SHAKE* are). Unfortunately, while crypto.createHash accepts an option argument that can be something like `{ outputLength: 128 }`, crypto.hash doesn't offer a similar API. Therefore there is little choice but to skip the test completely for shake128 and shake256 on openssl >= 3.4. PR-URL: nodejs#56294 Fixes: nodejs#56159 Refs: openssl/openssl@b911fef Refs: openssl/openssl@ad3f28c
1 parent 529b56e commit bd7fc7a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/parallel/test-crypto-oneshot-hash.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ const fs = require('fs');
2626
assert.throws(() => { crypto.hash('sha1', 'test', 'not an encoding'); }, { code: 'ERR_INVALID_ARG_VALUE' });
2727

2828
// Test that the output of crypto.hash() is the same as crypto.createHash().
29-
const methods = crypto.getHashes();
29+
const methods =
30+
crypto.getHashes()
31+
// OpenSSL 3.4 has stopped supporting shake128 and shake256 if the output
32+
// length is not set explicitly as the a fixed output length doesn't make a
33+
// lot of sense for them, and the default one in OpenSSL was too short and
34+
// unexpectedly limiting the security strength
35+
.filter(
36+
common.hasOpenSSL(3, 4) ?
37+
method => method !== 'shake128' && method !== 'shake256' :
38+
() => true,
39+
)
40+
;
3041

3142
const input = fs.readFileSync(fixtures.path('utf8_test_text.txt'));
3243

0 commit comments

Comments
 (0)