summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ffi/src/lib.rs26
-rw-r--r--ffi/src/sequoia.h10
-rw-r--r--net/src/lib.rs4
3 files changed, 21 insertions, 19 deletions
diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs
index eade52fe..b471cace 100644
--- a/ffi/src/lib.rs
+++ b/ffi/src/lib.rs
@@ -38,8 +38,8 @@ use std::ptr;
use std::slice;
use openpgp::tpk::TPK;
-use openpgp::types::KeyId;
-use self::libc::{uint8_t, uint64_t, c_char, size_t};
+use openpgp::KeyID;
+use self::libc::{uint8_t, c_char, size_t};
use self::native_tls::Certificate;
use sequoia_core::{Config, Context};
use sequoia_net::KeyServer;
@@ -190,27 +190,29 @@ pub extern "system" fn sq_config_ephemeral(cfg: Option<&mut Config>) {
}
-/* openpgp::types. */
+/* openpgp::KeyID. */
-/// Returns a KeyID with the given `id`.
+/// Reads a binary key ID.
#[no_mangle]
-pub extern "system" fn sq_keyid_new(id: uint64_t) -> *mut KeyId {
- Box::into_raw(Box::new(KeyId::new(id)))
+pub extern "system" fn sq_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID {
+ if id.is_null() { return ptr::null_mut() }
+ let id = unsafe { slice::from_raw_parts(id, 8) };
+ Box::into_raw(Box::new(KeyID::from_bytes(id)))
}
-/// Returns a KeyID with the given `id` encoded as hexadecimal string.
+/// Reads a hex-encoded Key ID.
#[no_mangle]
-pub extern "system" fn sq_keyid_from_hex(id: *const c_char) -> *mut KeyId {
+pub extern "system" fn sq_keyid_from_hex(id: *const c_char) -> *mut KeyID {
if id.is_null() { return ptr::null_mut() }
let id = unsafe { CStr::from_ptr(id).to_string_lossy() };
- KeyId::from_hex(&id)
+ KeyID::from_hex(&id)
.map(|id| Box::into_raw(Box::new(id)))
.unwrap_or(ptr::null_mut())
}
-/// Frees an `KeyId` object.
+/// Frees an `KeyID` object.
#[no_mangle]
-pub extern "system" fn sq_keyid_free(keyid: *mut KeyId) {
+pub extern "system" fn sq_keyid_free(keyid: *mut KeyID) {
if keyid.is_null() { return }
unsafe {
drop(Box::from_raw(keyid));
@@ -361,7 +363,7 @@ pub extern "system" fn sq_keyserver_free(ks: *mut KeyServer) {
/// Returns `NULL` on errors.
#[no_mangle]
pub extern "system" fn sq_keyserver_get(ks: Option<&mut KeyServer>,
- id: Option<&KeyId>) -> *mut TPK {
+ id: Option<&KeyID>) -> *mut TPK {
if ks.is_none() || id.is_none() {
return ptr::null_mut();
}
diff --git a/ffi/src/sequoia.h b/ffi/src/sequoia.h
index a39c63f4..5a765d58 100644
--- a/ffi/src/sequoia.h
+++ b/ffi/src/sequoia.h
@@ -130,20 +130,20 @@ void sq_config_network_policy(struct sq_config *cfg, uint8_t policy);
void sq_config_ephemeral(struct sq_config *cfg);
-/* sequoia::openpgp::types. */
+/* sequoia::openpgp::KeyID. */
/*/
-/// Uniquely identifies OpenPGP keys.
+/// Holds a KeyID.
/*/
struct sq_keyid;
/*/
-/// Returns a KeyID with the given `id`.
+/// Reads a binary key ID.
/*/
-struct sq_keyid *sq_keyid_new (uint64_t id);
+struct sq_keyid *sq_keyid_from_bytes (const uint8_t *id);
/*/
-/// Returns a KeyID with the given `id` encoded as hexadecimal string.
+/// Reads a hex-encoded Key ID.
/*/
struct sq_keyid *sq_keyid_from_hex (const char *id);
diff --git a/net/src/lib.rs b/net/src/lib.rs
index 63ac9c2b..0e5497b5 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -17,14 +17,14 @@
//! # extern crate openpgp;
//! # extern crate sequoia_core;
//! # extern crate sequoia_net;
-//! # use openpgp::types::KeyId;
+//! # use openpgp::KeyID;
//! # use sequoia_core::Context;
//! # use sequoia_net::{KeyServer, Result};
//! # fn main() { f().unwrap(); }
//! # fn f() -> Result<()> {
//! let ctx = Context::new("org.sequoia-pgp.example")?;
//! let mut ks = KeyServer::sks_pool(&ctx)?;
-//! let keyid = KeyId::from_hex("31855247603831FD").unwrap();
+//! let keyid = KeyID::from_hex("31855247603831FD").unwrap();
//! println!("{:?}", ks.get(&keyid));
//! Ok(())
//! # }