EVP_PKEY_get_int_param is not getting degree from EC key
Tomas Mraz
tomas at openssl.org
Mon Jan 3 09:11:19 UTC 2022
On Mon, 2022-01-03 at 01:51 +0100, Wolf wrote:
> Greetings,
>
> I'm trying to port my program to openssl 3.0 and in the process I
> need
> to replace EC_GROUP_get_degree(EC_KEY_get0_group(ec)) with something
> that is not deprecated. I'm trying to use EVP_PKEY_get_int_param with
> OSSL_PKEY_PARAM_EC_CHAR2_M, however it does not work. I'm assuming
> I'm
> just doing something wrong, but have no idea what. Would there be any
> kind soul willing to point me in the right direction?
You're using the secp384r1 curve which is a prime field curve. The
OSSL_PKEY_PARAM_EC_CHAR2_M parameter can be obtained only for binary
field curves.
If you have a group NID for the curve of the EC key, you could use:
EC_GROUP *group = EC_GROUP_new_by_curve_name_ex(NULL, NULL, nid);
to create the group to call EC_GROUP_get_degree() on.
Of course if you can have an EC key with arbitrary explicit group
parameters, that would not work.
But you can then use number of bits of the OSSL_PKEY_PARAM_EC_P
parameter as the degree for prime field curves.
--
Tomáš Mráz, OpenSSL
More information about the openssl-users
mailing list