Implement 'Display' for PublicKeyMaterial
This commit is contained in:
parent
874c28b7ff
commit
e695e8171a
2 changed files with 21 additions and 0 deletions
|
@ -14,6 +14,7 @@ documentation = "https://docs.rs/crate/openpgp-card"
|
|||
[dependencies]
|
||||
nom = "6"
|
||||
hex-literal = "0.3"
|
||||
hex-slice = "0.1"
|
||||
anyhow = "1"
|
||||
thiserror = "1"
|
||||
env_logger = "0.8"
|
||||
|
|
|
@ -120,6 +120,26 @@ pub enum PublicKeyMaterial {
|
|||
E(EccPub),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PublicKeyMaterial {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use hex_slice::AsHex;
|
||||
|
||||
match self {
|
||||
Self::R(rsa) => {
|
||||
write!(
|
||||
f,
|
||||
"RSA, n: {:02X}, e: {:02X}",
|
||||
rsa.n.plain_hex(false),
|
||||
rsa.v.plain_hex(false)
|
||||
)
|
||||
}
|
||||
Self::E(ecc) => {
|
||||
write!(f, "ECC, data: {:02X}", ecc.data.plain_hex(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// RSA-specific container for public key material from an OpenPGP card.
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
|
|
Loading…
Reference in a new issue