diff options
Diffstat (limited to 'openpgp/src/keyid.rs')
-rw-r--r-- | openpgp/src/keyid.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 275599f9..5cda407b 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -45,6 +45,30 @@ impl From<u64> for KeyID { } } +impl From<&Fingerprint> for KeyID { + fn from(fp: &Fingerprint) -> Self { + match fp { + Fingerprint::V4(fp) => + KeyID::from_bytes(&fp[fp.len() - 8..]), + Fingerprint::Invalid(fp) => { + KeyID::Invalid(fp.clone()) + } + } + } +} + +impl From<Fingerprint> for KeyID { + fn from(fp: Fingerprint) -> Self { + match fp { + Fingerprint::V4(fp) => + KeyID::from_bytes(&fp[fp.len() - 8..]), + Fingerprint::Invalid(fp) => { + KeyID::Invalid(fp) + } + } + } +} + impl KeyID { /// Converts a u64 to a KeyID. pub fn new(data: u64) -> KeyID { @@ -100,7 +124,7 @@ impl KeyID { } else { // Maybe a fingerprint was given. Try to parse it and // convert it to a KeyID. - Ok(Fingerprint::from_hex(hex)?.to_keyid()) + Ok(Fingerprint::from_hex(hex)?.into()) } } |