From e499b084c8d5c73cfa0a0e28d31b310a8f295bc9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 17 Aug 2022 08:58:44 +0200 Subject: [PATCH] replace deprecated 'affine_coordinates_gfp' call Signed-off-by: Wolfgang Bumiller --- src/key.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/key.rs b/src/key.rs index 487f65ec..5dbc5460 100644 --- a/src/key.rs +++ b/src/key.rs @@ -106,9 +106,8 @@ impl TryFrom<&openssl::ec::EcKey

> for EcPublicKey { let mut ctx = openssl::bn::BigNumContext::new()?; let mut x = openssl::bn::BigNum::new()?; let mut y = openssl::bn::BigNum::new()?; - let _: () = key - .public_key() - .affine_coordinates_gfp(group, &mut x, &mut y, &mut ctx)?; + key.public_key() + .affine_coordinates(group, &mut x, &mut y, &mut ctx)?; Ok(EcPublicKey { crv: "P-256", @@ -117,3 +116,14 @@ impl TryFrom<&openssl::ec::EcKey

> for EcPublicKey { }) } } + +#[test] +fn test_key_conversion() -> Result<(), Error> { + let key = openssl::ec::EcKey::generate( + openssl::ec::EcGroup::from_curve_name(openssl::nid::Nid::X9_62_PRIME256V1)?.as_ref(), + )?; + + let _ = EcPublicKey::try_from(&key).expect("failed to jsonify ec key"); + + Ok(()) +}