简体   繁体   中英

Is it possible to generate an ED25519 keypair with the built-in openssl_pkey_new function in PHP?

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;

...
?>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM