Skip to content

ext/openssl: Add validation for XOF digests requiring explicit output length - #24079

Open
adapik wants to merge 1 commit into
php:masterfrom
adapik:openssl-digest-xof-no-length
Open

adapik wants to merge 1 commit into
php:masterfrom
adapik:openssl-digest-xof-no-length

Conversation

@adapik

@adapik adapik commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Emit a warning when openssl_digest() / openssl_x509_fingerprint() get XOF algorithm without a length.

OpenSSL 3.4 removed the default output length of SHAKE128/256, so EVP_DigestFinal() now fails without an error:
openssl_digest('abc', 'shake128') returns false silently, while on OpenSSL 3.0 it returns 16 bytes. SHAKE128/256 are listed by openssl_get_md_methods(), so users can reasonably pass them to these functions.

Suggested fix: "Unsupported digest algorithm: output length must be specified" when an XOF digest fails. Fixed-length digests and older OpenSSL are unaffected.

Possible follow-up: allow passing $length parameter, if it's ok let me know.

@adapik
adapik requested a review from bukka as a code owner October 2, 2026 15:33
@adapik
adapik force-pushed the openssl-digest-xof-no-length branch from 1b01fad to 76af998 Compare October 2, 2026 15:50
@adapik
adapik force-pushed the openssl-digest-xof-no-length branch from 76af998 to a5973f3 Compare October 2, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant