Skip to content

openssl ed25519 fix#134

Open
henrikalves wants to merge 3 commits into
lbuchs:masterfrom
henrikalves:openssl-ed25519
Open

openssl ed25519 fix#134
henrikalves wants to merge 3 commits into
lbuchs:masterfrom
henrikalves:openssl-ed25519

Conversation

@henrikalves
Copy link
Copy Markdown

PHP 8.4 added ed25519 support in OpenSSL:
https://www.php.net/manual/en/migration84.new-features.php#migration84.new-features.openssl

openssl_get_curve_names() does not return ed25519, so the previous curve-based check did not work.

I changed the detection to check if OPENSSL_KEYTYPE_ED25519 is defined instead.

There was also an issue in the verify logic: for Ed25519, openssl_verify() must use algorithm 0, not OPENSSL_ALGO_SHA256.

At the moment, I am using openssl_pkey_get_details() to determine the key type. I am not sure whether there is a better way to detect this without calling openssl_pkey_get_details(), but this works for now.

ScottHelme pushed a commit to report-uri/passkeys-php that referenced this pull request May 13, 2026
PHP 8.4 added native Ed25519 support to the OpenSSL extension, but
openssl_get_curve_names() never returns 'ed25519' — so the previous
detection only ever found the Sodium path. The correct signal is the
presence of the OPENSSL_KEYTYPE_ED25519 constant (PHP >= 8.4).

Also fixes the actual verify call for Ed25519 keys: openssl_verify()
requires algorithm 0 (no extra hash) for EdDSA, not OPENSSL_ALGO_SHA256.
The key type is determined via openssl_pkey_get_details().

README updated to mention the OpenSSL Ed25519 path.

Includes a 'lenght' → 'length' comment typo fix.

Adopted from upstream PR lbuchs/WebAuthn#134 by @henrikalves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant