Skip to content

crypto:hash/2 not fixed when crypto:hash_init/1 was fixed for shake128/256 on OpenSSL >= 3.4 #9901

Open
@martinsvalin-kivra

Description

@martinsvalin-kivra

Describe the bug
As reported in #8997:

Since OpenSSL 3.4 the SHAKE-128 and SHAKE-256 implementations have no default digest length link

This was fixed in #9002 for nif_hash_init, but not for nif_hash (used when byte_size(Data) < ?MAX_BYTES_TO_NIF in crypto:hash/2).

To Reproduce

1> crypto:hash(shake256, ~"foobar").
** exception error: {error,{"hash.c",126},"Low-level call failed"}
     in function  crypto:hash/2
        called as crypto:hash(shake256,<<"foobar">>)

Expected behavior

2> crypto:hash(shake256, ~"foobar") == crypto:hash_final(crypto:hash_update(crypto:hash_init(shake256), ~"foobar")).
true

Affected versions
I've tested this on OTP 27.3.4, but the relevant code in hash.c on master appears untouched.
This becomes an issue when openssl is updated to version >= 3.4. My openssl version is OpenSSL 3.4.1

Metadata

Metadata

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions