Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: openssl 3.4 compatibility #56294

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 9 additions & 7 deletions test/parallel/test-crypto-oneshot-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ const input = fs.readFileSync(fixtures.path('utf8_test_text.txt'));

for (const method of methods) {
for (const outputEncoding of ['buffer', 'hex', 'base64', undefined]) {
const oldDigest = crypto.createHash(method).update(input).digest(outputEncoding || 'hex');
const digestFromBuffer = crypto.hash(method, input, outputEncoding);
assert.deepStrictEqual(digestFromBuffer, oldDigest,
`different result from ${method} with encoding ${outputEncoding}`);
const digestFromString = crypto.hash(method, input.toString(), outputEncoding);
assert.deepStrictEqual(digestFromString, oldDigest,
`different result from ${method} with encoding ${outputEncoding}`);
if (method !== 'shake128' && method !== 'shake256' || !common.hasOpenSSL(3, 4)) {
Copy link
Contributor

@aduh95 aduh95 Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it would be more readable to filter them above, with a comment explaining why.

// As of OpenSSL 3.4.0, shake128 and shake256 methods are not supported because…
const methods = crypto.getHashes().filter(
  common.hasOpenSSL(3, 4) ?
    method => method !== 'shake128' && method !== 'shake256' :
    () => true,
);

In any case, we should move the check to outside the inner loop.

const oldDigest = crypto.createHash(method).update(input).digest(outputEncoding || 'hex');
const digestFromBuffer = crypto.hash(method, input, outputEncoding);
assert.deepStrictEqual(digestFromBuffer, oldDigest,
`different result from ${method} with encoding ${outputEncoding}`);
const digestFromString = crypto.hash(method, input.toString(), outputEncoding);
assert.deepStrictEqual(digestFromString, oldDigest,
`different result from ${method} with encoding ${outputEncoding}`);
}
}
}
8 changes: 6 additions & 2 deletions test/parallel/test-tls-psk-circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@
'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE';
test({ psk: USERS.UserB, identity: 'UserC' }, {}, expectedHandshakeErr);
// Recognized user but incorrect secret should fail handshake
const expectedIllegalParameterErr = common.hasOpenSSL(3, 2) ?
'ERR_SSL_SSL/TLS_ALERT_ILLEGAL_PARAMETER' : 'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER';
const expectedIllegalParameterErr =
common.hasOpenSSL(3, 4)
? 'ERR_SSL_TLSV1_ALERT_DECRYPT_ERROR'

Check failure on line 71 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 4 spaces but found 2

Check failure on line 71 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'?' should be placed at the end of the line
: (common.hasOpenSSL(3, 2)

Check failure on line 72 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 4 spaces but found 2

Check failure on line 72 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

':' should be placed at the end of the line
? 'ERR_SSL_SSL/TLS_ALERT_ILLEGAL_PARAMETER'

Check failure on line 73 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 6 spaces but found 4

Check failure on line 73 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'?' should be placed at the end of the line
: 'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER');

Check failure on line 74 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 6 spaces but found 4

Check failure on line 74 in test/parallel/test-tls-psk-circuit.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

':' should be placed at the end of the line
test({ psk: USERS.UserA, identity: 'UserB' }, {}, expectedIllegalParameterErr);
test({ psk: USERS.UserB, identity: 'UserB' });
Loading