EVP_PKEY_get_raw_public_key fails with OpenSSL 3.0

James Muir muir.james.a at gmail.com
Fri Nov 11 00:49:00 UTC 2022


On 2022-11-10 18:35, fus at plutonium24.de wrote:
> I have been using EVP_PKEY_get_raw_public_key with OpenSSL 1.1.1 without 
> any problems to extract a raw public key (secp521r1, NIST curve P-521). 
> With OpenSSL 3.0 this fails. I'm using this call to get the raw public 
> key and to compare it with a reference value I have and I also check 
> that the group name is "secp521r1".

That doesn't work in 3.0.

Quoting from 
https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_new.html  :

<quote>
EVP_PKEY_get_raw_public_key() fills the buffer provided by pub with raw 
public key data. The size of the pub buffer should be in *len on entry 
to the function, and on exit *len is updated with the number of bytes 
actually written. If the buffer pub is NULL then *len is populated with 
the number of bytes required to hold the key. The calling application is 
responsible for ensuring that the buffer is large enough to receive the 
public key data. This function only works for algorithms that support 
raw public keys. Currently this is: EVP_PKEY_X25519, EVP_PKEY_ED25519, 
EVP_PKEY_X448 or EVP_PKEY_ED448.
</quote>

You were reading the P521 public-key previously (with 1.1.1), but in 
what format was it sent you?  Do you want just the bytes of the public 
EC point?

-James M


More information about the openssl-users mailing list