You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can X25519/Ed25519 functions be possibly exposed for direct use? #5453
Trying to get equivalent functionality over the binary data using only available OpenSSL API seems pretty hard or even impossible. I'm not very familiar with OpenSSL so I failed to figure it out. On the other hand, these functions are simple and obvious.
We understand, but our policy is that the EVP interface is the only one we are going to expose. Of course, you have the source and can do what you want.
The difficulty with the X25519/Ed25519 EVP interface at the moment is that it is built for TLS use and not much else. This is mainly a problem when getting/setting private/public keys. You either have to generate a new key, or read it from a file in a recognised format (PKCS#8, or embedded in X509), or (in the case of public keys) know how to use some undocumented and TLS specific functions (EVP_PKEY_set1_tls_encodedpoint() and EVP_PKEY_get1_tls_encodedpoint()). You can't just say "here's my key, use that".
My PR #5419 adds some functions which should make this easier. That PR is actually about adding X448/Ed448 support but co-incidentally adds some functions which should ease X25519/Ed25519. The basic process then will be:
Create a new EVP_PKEY for the private/public key (using EVP_PKEY_new_priv_key() or EVP_PKEY_new_pub_key())
2a) For signing use EVP_DigestSignInit() and EVP_DigestSign()
2b) For verifying use EVP_DigestVerifyInit() and EVP_DigestVerify()
2c) For key derivation use EVP_PKEY_derive_init(). Set the peer key using EVP_PKEY_derive_set_peer() and then EVP_PKEY_derive().
doesn't look like there's an EVP equivalent to ED25519_public_from_private yet?
If you create a new EVP_PKEY via EVP_PKEY_fromdata with just setting the private key, the resulting key will have the public key calculated during the import. So you can then get the public key value via EVP_PKEY_get_BN_param().
If you create a new EVP_PKEY via EVP_PKEY_fromdata with just setting the private key, the resulting key will have the public key calculated during the import. So you can then get the public key value via EVP_PKEY_get_BN_param().
Easier is to create the EVP_PKEY using EVP_PKEY_new_raw_private_key_ex(). The public key is actually an octet string so you actually have to use EVP_PKEY_get_octet_string_param(). E.g. something like this:
Activity
richsalz commentedon Feb 23, 2018
We understand, but our policy is that the EVP interface is the only one we are going to expose. Of course, you have the source and can do what you want.
mattcaswell commentedon Feb 23, 2018
I'm going to reopen this, because I think there may be some issues with the EVP interface to this, but I need time to investigate.
mattcaswell commentedon Feb 26, 2018
The difficulty with the X25519/Ed25519 EVP interface at the moment is that it is built for TLS use and not much else. This is mainly a problem when getting/setting private/public keys. You either have to generate a new key, or read it from a file in a recognised format (PKCS#8, or embedded in X509), or (in the case of public keys) know how to use some undocumented and TLS specific functions (EVP_PKEY_set1_tls_encodedpoint() and EVP_PKEY_get1_tls_encodedpoint()). You can't just say "here's my key, use that".
My PR #5419 adds some functions which should make this easier. That PR is actually about adding X448/Ed448 support but co-incidentally adds some functions which should ease X25519/Ed25519. The basic process then will be:
2a) For signing use EVP_DigestSignInit() and EVP_DigestSign()
2b) For verifying use EVP_DigestVerifyInit() and EVP_DigestVerify()
2c) For key derivation use EVP_PKEY_derive_init(). Set the peer key using EVP_PKEY_derive_set_peer() and then EVP_PKEY_derive().
You might also find the overview documentation relevant:
https://www.openssl.org/docs/manmaster/man7/Ed25519.html
https://www.openssl.org/docs/manmaster/man7/X25519.html
mattcaswell commentedon Mar 20, 2018
#5520 eventually got merged which makes using X25519/Ed25519 via EVP considerably easier. Closing this.
aep commentedon Feb 7, 2022
doesn't look like there's an EVP equivalent to ED25519_public_from_private yet?
t8m commentedon Feb 7, 2022
If you create a new EVP_PKEY via EVP_PKEY_fromdata with just setting the private key, the resulting key will have the public key calculated during the import. So you can then get the public key value via EVP_PKEY_get_BN_param().
mattcaswell commentedon Feb 8, 2022
Easier is to create the EVP_PKEY using
EVP_PKEY_new_raw_private_key_ex(). The public key is actually an octet string so you actually have to useEVP_PKEY_get_octet_string_param(). E.g. something like this:mattcaswell commentedon Feb 8, 2022
Oh...sorry...you said Ed25519 and my example was X25519. Same concept applies though.