openpgp-card: add Curve::Unknown variant
This commit is contained in:
parent
da776bc4cf
commit
423c9d23ee
2 changed files with 8 additions and 6 deletions
|
@ -247,7 +247,7 @@ pub fn public_key_material_to_key(
|
||||||
|
|
||||||
match key_type {
|
match key_type {
|
||||||
KeyType::Authentication | KeyType::Signing => {
|
KeyType::Authentication | KeyType::Signing => {
|
||||||
if algo_ecc.curve() == Curve::Ed25519 {
|
if algo_ecc.curve() == &Curve::Ed25519 {
|
||||||
// EdDSA
|
// EdDSA
|
||||||
let k4 =
|
let k4 =
|
||||||
Key4::import_public_ed25519(ecc.data(), time).map_err(|e| {
|
Key4::import_public_ed25519(ecc.data(), time).map_err(|e| {
|
||||||
|
@ -277,7 +277,7 @@ pub fn public_key_material_to_key(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyType::Decryption => {
|
KeyType::Decryption => {
|
||||||
if algo_ecc.curve() == Curve::Cv25519 {
|
if algo_ecc.curve() == &Curve::Cv25519 {
|
||||||
// EdDSA
|
// EdDSA
|
||||||
let k4 = Key4::import_public_cv25519(ecc.data(), hash, sym, time)
|
let k4 = Key4::import_public_cv25519(ecc.data(), hash, sym, time)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
|
|
@ -298,8 +298,8 @@ impl EccAttrs {
|
||||||
self.ecc_type
|
self.ecc_type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn curve(&self) -> Curve {
|
pub fn curve(&self) -> &Curve {
|
||||||
self.curve
|
&self.curve
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn oid(&self) -> &[u8] {
|
pub fn oid(&self) -> &[u8] {
|
||||||
|
@ -312,7 +312,7 @@ impl EccAttrs {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enum for naming ECC curves, and mapping them to/from their OIDs.
|
/// Enum for naming ECC curves, and mapping them to/from their OIDs.
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Curve {
|
pub enum Curve {
|
||||||
NistP256r1,
|
NistP256r1,
|
||||||
|
@ -326,6 +326,7 @@ pub enum Curve {
|
||||||
Cv25519,
|
Cv25519,
|
||||||
Ed448,
|
Ed448,
|
||||||
X448,
|
X448,
|
||||||
|
Unknown(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Curve {
|
impl Curve {
|
||||||
|
@ -343,6 +344,7 @@ impl Curve {
|
||||||
Cv25519 => oid::CV25519,
|
Cv25519 => oid::CV25519,
|
||||||
Ed448 => oid::ED448,
|
Ed448 => oid::ED448,
|
||||||
X448 => oid::X448,
|
X448 => oid::X448,
|
||||||
|
Unknown(v) => v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,7 +372,7 @@ impl TryFrom<&[u8]> for Curve {
|
||||||
oid::ED448 => Ed448,
|
oid::ED448 => Ed448,
|
||||||
oid::X448 => X448,
|
oid::X448 => X448,
|
||||||
|
|
||||||
_ => return Err(Error::ParseError(format!("Unknown curve OID {oid:?}"))),
|
o => Unknown(o.to_vec()),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(curve)
|
Ok(curve)
|
||||||
|
|
Loading…
Reference in a new issue