This commit is contained in:
Heiko Schaefer 2021-08-13 21:27:59 +02:00
parent 3361c8b79d
commit 83d9a703db

View file

@ -86,10 +86,9 @@ pub fn public_key_material_to_key(
) -> Result<Key<PublicParts, UnspecifiedRole>> { ) -> Result<Key<PublicParts, UnspecifiedRole>> {
match pkm { match pkm {
PublicKeyMaterial::R(rsa) => { PublicKeyMaterial::R(rsa) => {
let k4: Key4<key::PublicParts, key::UnspecifiedRole> = let k4 = Key4::import_public_rsa(&rsa.v, &rsa.n, Some(time))?;
Key4::import_public_rsa(&rsa.v, &rsa.n, Some(time))?;
Ok(Key::from(k4)) Ok(k4.into())
} }
PublicKeyMaterial::E(ecc) => { PublicKeyMaterial::E(ecc) => {
let algo = ecc.algo.clone(); // FIXME? let algo = ecc.algo.clone(); // FIXME?
@ -107,10 +106,8 @@ pub fn public_key_material_to_key(
KeyType::Authentication | KeyType::Signing => { KeyType::Authentication | KeyType::Signing => {
if algo_ecc.curve == Curve::Ed25519 { if algo_ecc.curve == Curve::Ed25519 {
// EdDSA // EdDSA
let k4: Key4< let k4 =
key::PublicParts, Key4::import_public_ed25519(&ecc.data, time)?;
key::UnspecifiedRole,
> = Key4::import_public_ed25519(&ecc.data, time)?;
Ok(Key::from(k4)) Ok(Key::from(k4))
} else { } else {
@ -124,20 +121,17 @@ pub fn public_key_material_to_key(
}, },
)?; )?;
Ok(Key::from(k4)) Ok(k4.into())
} }
} }
KeyType::Decryption => { KeyType::Decryption => {
if algo_ecc.curve == Curve::Cv25519 { if algo_ecc.curve == Curve::Cv25519 {
// EdDSA // EdDSA
let k4: Key4< let k4 = Key4::import_public_cv25519(
key::PublicParts,
key::UnspecifiedRole,
> = Key4::import_public_cv25519(
&ecc.data, None, None, time, &ecc.data, None, None, time,
)?; )?;
Ok(Key::from(k4)) Ok(k4.into())
} else { } else {
// FIXME: just defining `hash` and `sym` is not // FIXME: just defining `hash` and `sym` is not
// ok when a cert already exists // ok when a cert already exists
@ -154,7 +148,7 @@ pub fn public_key_material_to_key(
}, },
)?; )?;
Ok(Key::from(k4)) Ok(k4.into())
} }
} }
_ => unimplemented!("Unsupported KeyType"), _ => unimplemented!("Unsupported KeyType"),