replace deprecated 'affine_coordinates_gfp' call

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-08-17 08:58:44 +02:00
parent 65f05daf7e
commit e499b084c8

View File

@ -106,9 +106,8 @@ impl<P: HasPublic> TryFrom<&openssl::ec::EcKey<P>> 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<P: HasPublic> TryFrom<&openssl::ec::EcKey<P>> 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(())
}