Reputation: 347
I'm trying to generate an ED25519 private/public keypair with the built-in openssl_pkey_new in PHP, but i don't get it working.
Not sure, but isn't it possible?
Using PHP-7.3.13 and OpenSSL-1.1.1d.
<?php
...
// OpenSSL config
$openssl_config = array(
'curve_name' => 'ed25519', // <- not working
'private_key_type' => OPENSSL_KEYTYPE_EC
);
// Create OpenSSL keypair
$openssl_keypair = openssl_pkey_new($openssl_config);
openssl_pkey_export($openssl_keypair, $privatekey);
$openssl_details = openssl_pkey_get_details($openssl_keypair);
$publickey = $openssl_details['key'];
echo $privatekey;
echo $publickey;
...
?>
Upvotes: 1
Views: 2192
Reputation: 1414
Looks like impossible, read doc on https://www.php.net/manual/en/function.openssl-get-curve-names.php, there is no ED25519 curve name.
ED25519 is used for signing, so to generate an ED25519 key pair in php. use 'sodium_crypto_sign_keypair' function.
Upvotes: 2