Skip to content

Test test/parallel/test-crypto-oneshot-hash.js fails in OpenSSL 3.4.0 due to breaking changes in OpenSSL #56159

Description

@jelly

Version

23.3.0 and main

Platform

Linux X 6.12.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 22 Nov 2024 16:04:27 +0000 x86_64 GNU/Linux

Subsystem

crypto

What steps will reproduce the bug?

const crypto = require('crypto');
crypto.hash('shake128', "wefwwfe", "utf-8")

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

Hashing does not throw an Error

What do you see instead?

> crypto.hash('shake128', "wefwwfe", "utf-8")
Uncaught Error: error:00000000:lib(0)::reason(0)
    at Object.hash (node:internal/crypto/hash:216:10)
>

Additional information

This is due to a breaking change in OpenSSL 3.4.0 which makes providing an output length mandatory.

See also, how this is completely broken.

[jelle@natrium][~/projects/node]%openssl shake128 /etc/os-release
[jelle@natrium][~/projects/node]%

Further writeup available here.

Activity

  1. changed the title [-]Running tests against OpenSSL 3.4 breaks `crypto.hash('shake128', "wefwwfe", "utf-8")` [/-] [+]Test test/parallel/test-crypto-oneshot-hash.js fails in OpenSSL 3.4.0 due to breaking changes in OpenSSL[/+] on Dec 6, 2024
  2. adrien-n commented on Dec 10, 2024

    @adrien-n

    I started looking at the issue too and AFAIU, crypto.hash() needs an API change to pass options and outputLength in particular in order to match the change in openssl (and I don't think the change in openssl is bad). It seems sensible to me to have options in hash just like there are options in createHash.

    Also, code as what follows does not make the libraries give an error but the result is erroneous nonetheless:

    crypto.createHash('shake128').update('foo').digest('base64')
    

    Thus, the question is whether not passing options should be accepted. Not preventing progress after such code seems like a footgun to me but I'm not sure which part should throw an error (digest probably?).

    BTW, if you want to read more about the change, the relevant documentation change in openssl is openssl/openssl@ad3f28c

  3. 14 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions