diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-21 13:51:47 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-22 17:43:59 +0100 |
commit | 0cb819a1c3cc127c05c03a7220b5aa11a3ef1d44 (patch) | |
tree | 1728827a18dc3ce6ed17ff5668dfb6208ce67144 | |
parent | 0209427578d656eab7796c2505dc8755c415785b (diff) |
openpgp-ffi: Qualify KeyID.
-rw-r--r-- | openpgp-ffi/src/common.rs | 9 | ||||
-rw-r--r-- | openpgp-ffi/src/keyid.rs | 27 |
2 files changed, 17 insertions, 19 deletions
diff --git a/openpgp-ffi/src/common.rs b/openpgp-ffi/src/common.rs index 4c4c1b1a..f764c4b0 100644 --- a/openpgp-ffi/src/common.rs +++ b/openpgp-ffi/src/common.rs @@ -258,7 +258,6 @@ extern crate sequoia_openpgp as openpgp; extern crate time; use self::openpgp::{ - KeyID, RevocationStatus, TPK, packet::{ @@ -427,7 +426,7 @@ type FreeCallback = fn(*mut c_void); /// If the free callback is not NULL, then it is called to free the /// returned array of TPKs. type GetPublicKeysCallback = fn(*mut HelperCookie, - *const &KeyID, usize, + *const &openpgp::KeyID, usize, &mut *mut &mut TPK, *mut usize, *mut FreeCallback) -> Status; @@ -467,12 +466,12 @@ impl VHelper { } impl VerificationHelper for VHelper { - fn get_public_keys(&mut self, ids: &[KeyID]) + fn get_public_keys(&mut self, ids: &[openpgp::KeyID]) -> Result<Vec<TPK>, failure::Error> { // The size of KeyID is not known in C. Convert from an array // of KeyIDs to an array of KeyID refs. - let ids : Vec<&KeyID> = ids.iter().collect(); + let ids : Vec<&openpgp::KeyID> = ids.iter().collect(); let mut tpk_refs_raw : *mut &mut TPK = ptr::null_mut(); let mut tpk_refs_raw_len = 0usize; @@ -622,7 +621,7 @@ impl DHelper { } impl VerificationHelper for DHelper { - fn get_public_keys(&mut self, ids: &[KeyID]) + fn get_public_keys(&mut self, ids: &[openpgp::KeyID]) -> Result<Vec<TPK>, failure::Error> { self.vhelper.get_public_keys(ids) diff --git a/openpgp-ffi/src/keyid.rs b/openpgp-ffi/src/keyid.rs index 8ce4da47..2e428ea9 100644 --- a/openpgp-ffi/src/keyid.rs +++ b/openpgp-ffi/src/keyid.rs @@ -15,8 +15,7 @@ use std::ptr; use std::slice; use libc::{uint8_t, uint64_t, c_char}; -extern crate sequoia_openpgp; -use self::sequoia_openpgp::KeyID; +extern crate sequoia_openpgp as openpgp; use build_hasher; @@ -39,38 +38,38 @@ use build_hasher; /// free (mr_b_as_string); /// ``` #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID { +pub extern "system" fn pgp_keyid_from_bytes(id: *const uint8_t) -> *mut openpgp::KeyID { assert!(!id.is_null()); let id = unsafe { slice::from_raw_parts(id, 8) }; - Box::into_raw(Box::new(KeyID::from_bytes(id))) + Box::into_raw(Box::new(openpgp::KeyID::from_bytes(id))) } /// Reads a hex-encoded Key ID. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_from_hex(id: *const c_char) -> *mut KeyID { +pub extern "system" fn pgp_keyid_from_hex(id: *const c_char) -> *mut openpgp::KeyID { let id = ffi_param_cstr!(id).to_string_lossy(); - KeyID::from_hex(&id) + openpgp::KeyID::from_hex(&id) .map(|id| Box::into_raw(Box::new(id))) .unwrap_or(ptr::null_mut()) } /// Frees an `KeyID` object. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_free(keyid: Option<&mut KeyID>) { +pub extern "system" fn pgp_keyid_free(keyid: Option<&mut openpgp::KeyID>) { ffi_free!(keyid) } /// Clones the KeyID. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_clone(id: *const KeyID) - -> *mut KeyID { +pub extern "system" fn pgp_keyid_clone(id: *const openpgp::KeyID) + -> *mut openpgp::KeyID { let id = ffi_param_ref!(id); box_raw!(id.clone()) } /// Hashes the KeyID. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_hash(id: *const KeyID) +pub extern "system" fn pgp_keyid_hash(id: *const openpgp::KeyID) -> uint64_t { let id = ffi_param_ref!(id); let mut hasher = build_hasher(); @@ -80,7 +79,7 @@ pub extern "system" fn pgp_keyid_hash(id: *const KeyID) /// Converts the KeyID to its standard representation. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_to_string(id: *const KeyID) +pub extern "system" fn pgp_keyid_to_string(id: *const openpgp::KeyID) -> *mut c_char { let id = ffi_param_ref!(id); ffi_return_string!(id.to_string()) @@ -88,7 +87,7 @@ pub extern "system" fn pgp_keyid_to_string(id: *const KeyID) /// Converts the KeyID to a hexadecimal number. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_to_hex(id: *const KeyID) +pub extern "system" fn pgp_keyid_to_hex(id: *const openpgp::KeyID) -> *mut c_char { let id = ffi_param_ref!(id); ffi_return_string!(id.to_hex()) @@ -96,8 +95,8 @@ pub extern "system" fn pgp_keyid_to_hex(id: *const KeyID) /// Compares KeyIDs. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_keyid_equal(a: *const KeyID, - b: *const KeyID) +pub extern "system" fn pgp_keyid_equal(a: *const openpgp::KeyID, + b: *const openpgp::KeyID) -> bool { let a = ffi_param_ref!(a); let b = ffi_param_ref!(b); |