From 1724b133557761ed29e1480bb77f2241c0994451 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 6 Dec 2024 18:24:41 +0100 Subject: [PATCH 1/2] test: make test-crypto-hash compatible with OpenSSL > 3.4.0 OpenSSL 3.4 has a breaking change where the outputLength is now mandatory for shake* hash algorithms. https://github.com/openssl/openssl/commit/b911fef216d1386210ec24e201d54d709528abb4 --- test/parallel/test-crypto-hash.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index 83218c105a4596..ca8f630b4bb7e7 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -7,6 +7,7 @@ const assert = require('assert'); const crypto = require('crypto'); const fs = require('fs'); +const { hasOpenSSL } = common; const fixtures = require('../common/fixtures'); let cryptoType; @@ -182,19 +183,21 @@ assert.throws( // Test XOF hash functions and the outputLength option. { - // Default outputLengths. - assert.strictEqual(crypto.createHash('shake128').digest('hex'), - '7f9c2ba4e88f827d616045507605853e'); - assert.strictEqual(crypto.createHash('shake128', null).digest('hex'), - '7f9c2ba4e88f827d616045507605853e'); - assert.strictEqual(crypto.createHash('shake256').digest('hex'), - '46b9dd2b0ba88d13233b3feb743eeb24' + - '3fcd52ea62b81b82b50c27646ed5762f'); - assert.strictEqual(crypto.createHash('shake256', { outputLength: 0 }) - .copy() // Default outputLength. - .digest('hex'), - '46b9dd2b0ba88d13233b3feb743eeb24' + - '3fcd52ea62b81b82b50c27646ed5762f'); + // Default outputLengths. Since OpenSSL 3.4 an outputLength is mandatory + if (!hasOpenSSL(3, 4)) { + assert.strictEqual(crypto.createHash('shake128').digest('hex'), + '7f9c2ba4e88f827d616045507605853e'); + assert.strictEqual(crypto.createHash('shake128', null).digest('hex'), + '7f9c2ba4e88f827d616045507605853e'); + assert.strictEqual(crypto.createHash('shake256').digest('hex'), + '46b9dd2b0ba88d13233b3feb743eeb24' + + '3fcd52ea62b81b82b50c27646ed5762f'); + assert.strictEqual(crypto.createHash('shake256', { outputLength: 0 }) + .copy() // Default outputLength. + .digest('hex'), + '46b9dd2b0ba88d13233b3feb743eeb24' + + '3fcd52ea62b81b82b50c27646ed5762f'); + } // Short outputLengths. assert.strictEqual(crypto.createHash('shake128', { outputLength: 0 }) From 95b7ba63d537432affa6c8a394cc64092d4e9f26 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 6 Dec 2024 19:14:16 +0100 Subject: [PATCH 2/2] test: disable openssl 3.4.0 incompatible tests The shake128/shake256 hashing algorithms broke due to an OpenSSL 3.4 incompatible change and now throws an Error. --- test/parallel/test-crypto-oneshot-hash.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-crypto-oneshot-hash.js b/test/parallel/test-crypto-oneshot-hash.js index 56b4c04a65a1c1..4c960148317e41 100644 --- a/test/parallel/test-crypto-oneshot-hash.js +++ b/test/parallel/test-crypto-oneshot-hash.js @@ -32,6 +32,9 @@ const input = fs.readFileSync(fixtures.path('utf8_test_text.txt')); for (const method of methods) { for (const outputEncoding of ['buffer', 'hex', 'base64', undefined]) { + // Skip failing tests on OpenSSL 3.4.0 + if (method.startsWith("shake")) + continue; const oldDigest = crypto.createHash(method).update(input).digest(outputEncoding || 'hex'); const digestFromBuffer = crypto.hash(method, input, outputEncoding); assert.deepStrictEqual(digestFromBuffer, oldDigest,