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

test: openssl 3.4 compatibility #56294

wants to merge 2 commits into from

Conversation

adrien-n
Copy link

This PR fixes two issues in the testsuite caused by changes in openssl 3.4:

  • using SHAKE128 and SHAKE256 requires explicitely setting an output length,
  • the error code for one of the failure mode in TLS 1.3 was off-spec.

In addition to #56160 , this should fix
the build of nodejs with openssl 3.4 for Ubuntu 25.04 (Plucky).

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.

Fixes: nodejs#56159
Refs: openssl/openssl@b911fef
Refs: openssl/openssl@ad3f28c
…ilure

According to RFC 8446 (TLS 1.3), a PSK binder validation failure should
result in decrypt_error rather than illegal_parameter which openssl had
been using. Update the tests to match openssl's fix.

Refs: openssl/openssl@02b8b7b
Refs: https://www.rfc-editor.org/rfc/rfc8446
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Dec 17, 2024
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.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.54%. Comparing base (ca96c8d) to head (cc18241).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #56294   +/-   ##
=======================================
  Coverage   88.53%   88.54%           
=======================================
  Files         657      657           
  Lines      190285   190285           
  Branches    36535    36536    +1     
=======================================
+ Hits       168470   168485   +15     
+ Misses      14991    14976   -15     
  Partials     6824     6824           

see 35 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants