1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::Result;
use super::{prelude::*, Key, Proto};
pub fn format_fingerprint<S: AsRef<str>>(fingerprint: S) -> String {
fingerprint.as_ref().trim().to_uppercase()
}
pub fn fingerprints_equal<S: AsRef<str>, T: AsRef<str>>(a: S, b: T) -> bool {
!a.as_ref().trim().is_empty()
&& a.as_ref().trim().to_uppercase() == b.as_ref().trim().to_uppercase()
}
pub fn keys_contain_fingerprint<S: AsRef<str>>(keys: &[Key], fingerprint: S) -> bool {
keys.iter()
.any(|key| fingerprints_equal(key.fingerprint(false), fingerprint.as_ref()))
}
pub fn has_private_key(proto: Proto) -> Result<bool> {
Ok(!super::context(proto)?.keys_private()?.is_empty())
}