summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2020-03-20 15:14:05 +0100
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2020-03-20 15:36:58 +0100
commit857845f523ab090638693d5498c8753e1e41cf36 (patch)
tree589fe471f65f98f3438633d83894fb160aa04f6f /store
parent8905aabfa245754426bd67ba5319024e61fc39db (diff)
openpgp: Remove `to_hex` in KeyHandle, KeyID and Fingerprint.
- Replace all usages of `to_hex` with formatting string with :X specifier. - Fixes #456.
Diffstat (limited to 'store')
-rw-r--r--store/src/backend/mod.rs12
-rw-r--r--store/src/lib.rs6
2 files changed, 9 insertions, 9 deletions
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index 342a14c4..91803a42 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -568,7 +568,7 @@ impl node::binding::Server for BindingServer {
// If we found one, convert it to Cert.
let current = if let Some(current) = key {
let current = sry!(Cert::from_bytes(&current));
- if current.fingerprint().to_hex() != fingerprint {
+ if format!("{:X}", current.fingerprint()) != fingerprint {
// Inconsistent database.
fail!(node::Error::SystemError);
}
@@ -578,7 +578,7 @@ impl node::binding::Server for BindingServer {
};
// Check for conflicts.
- if new.fingerprint().to_hex() != fingerprint {
+ if format!("{:X}", new.fingerprint()) != fingerprint {
if force {
// Update binding, and retry.
let key_id =
@@ -716,7 +716,7 @@ impl KeyServer {
///
/// On success, the id of the key is returned.
fn lookup(c: &Connection, fp: &Fingerprint) -> Result<ID> {
- let fp = fp.to_hex();
+ let fp = format!("{:X}", fp);
Ok(c.query_row(
"SELECT id FROM keys WHERE fingerprint = ?1",
&[&fp], |row| row.get(0))?)
@@ -726,7 +726,7 @@ impl KeyServer {
///
/// On success, the id of the key is returned.
fn lookup_by_id(c: &Connection, keyid: &KeyID) -> Result<ID> {
- let keyid = format!("%{}", keyid.to_hex());
+ let keyid = format!("%{:X}", keyid);
Ok(c.query_row(
"SELECT id FROM keys WHERE fingerprint LIKE ?1",
&[&keyid], |row| row.get(0))?)
@@ -736,7 +736,7 @@ impl KeyServer {
///
/// On success, the id of the key is returned.
fn lookup_or_create(c: &Connection, fp: &Fingerprint) -> Result<ID> {
- let fp = fp.to_hex();
+ let fp = format!("{:X}", fp);
if let Ok(x) = c.query_row(
"SELECT id FROM keys WHERE fingerprint = ?1",
&[&fp], |row| row.get(0)) {
@@ -780,7 +780,7 @@ impl KeyServer {
if let Some(current) = key {
let current = Cert::from_bytes(&current)?;
- if current.fingerprint().to_hex() != fingerprint {
+ if format!("{:X}", current.fingerprint()) != fingerprint {
// Inconsistent database.
return Err(node::Error::SystemError.into());
}
diff --git a/store/src/lib.rs b/store/src/lib.rs
index 28ef59c4..1156a5ad 100644
--- a/store/src/lib.rs
+++ b/store/src/lib.rs
@@ -200,7 +200,7 @@ impl Store {
pub fn lookup(c: &Context, fp: &Fingerprint) -> Result<Key> {
let (mut core, client) = Self::connect(c)?;
let mut request = client.lookup_by_fingerprint_request();
- let fp = fp.to_hex();
+ let fp = format!("{:X}", fp);
request.get().set_fingerprint(&fp);
let key = make_request!(&mut core, request)?;
Ok(Key::new(Rc::new(RefCell::new(core)), key))
@@ -385,7 +385,7 @@ impl Mapping {
pub fn add(&self, label: &str, fingerprint: &Fingerprint) -> Result<Binding> {
let mut request = self.mapping.add_request();
request.get().set_label(label);
- request.get().set_fingerprint(fingerprint.to_hex().as_ref());
+ request.get().set_fingerprint(format!("{:X}", fingerprint).as_ref());
let binding = make_request!(self.core.borrow_mut(), request)?;
Ok(Binding::new(self.core.clone(), Some(label), binding))
}
@@ -419,7 +419,7 @@ impl Mapping {
let fingerprint = cert.fingerprint();
let mut request = self.mapping.add_request();
request.get().set_label(label);
- request.get().set_fingerprint(fingerprint.to_hex().as_ref());
+ request.get().set_fingerprint(format!("{:X}", fingerprint).as_ref());
let binding = make_request!(self.core.borrow_mut(), request)?;
let binding = Binding::new(self.core.clone(), Some(label), binding);
binding.import(cert)