summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2018-11-21 15:11:37 +0100
committerNeal H. Walfield <neal@pep.foundation>2018-11-22 08:55:32 +0100
commit2eaccfca0bd4e34c1ee9a42d582296b2225985ec (patch)
tree5944da233beb350421d0ddc3f6bd13773efa7396 /ffi
parent0fad2b0ab90fc63306cd64be7e9de8524e47a30b (diff)
ffi: Wrap Pool::lookup_by_keyid and Pool::lookup_by_subkeyid.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/include/sequoia/store.h10
-rw-r--r--ffi/src/store.rs31
2 files changed, 39 insertions, 2 deletions
diff --git a/ffi/include/sequoia/store.h b/ffi/include/sequoia/store.h
index 2b368943..4cb6c22a 100644
--- a/ffi/include/sequoia/store.h
+++ b/ffi/include/sequoia/store.h
@@ -273,6 +273,16 @@ sq_binding_t sq_store_lookup (sq_context_t ctx, sq_store_t store,
const char *label);
/*/
+/// Looks up a key in the common key pool by KeyID.
+/*/
+sq_key_t sq_store_lookup_by_keyid (sq_context_t ctx, sq_keyid_t keyid);
+
+/*/
+/// Looks up a key in the common key pool by (Sub)KeyID.
+/*/
+sq_key_t sq_store_lookup_by_subkeyid (sq_context_t ctx, sq_keyid_t keyid);
+
+/*/
/// Deletes this store.
///
/// Consumes `store`. Returns != 0 on error.
diff --git a/ffi/src/store.rs b/ffi/src/store.rs
index c77981fd..f54eab59 100644
--- a/ffi/src/store.rs
+++ b/ffi/src/store.rs
@@ -30,9 +30,12 @@ use std::ptr;
extern crate openpgp;
use self::openpgp::TPK;
-use self::openpgp::Fingerprint;
+use self::openpgp::{
+ Fingerprint,
+ KeyID
+};
use sequoia_store::{
- self, Store, StoreIter, Binding, BindingIter, Key, KeyIter, LogIter,
+ self, Store, StoreIter, Binding, BindingIter, Key, KeyIter, LogIter, Pool,
};
use super::error::Status;
@@ -279,6 +282,30 @@ pub extern "system" fn sq_store_lookup(ctx: Option<&mut Context>,
fry_box!(ctx, store.lookup(&label))
}
+/// Looks up a key in the common key pool by KeyID.
+#[no_mangle]
+pub extern "system" fn sq_store_lookup_by_keyid(ctx: Option<&mut Context>,
+ keyid: Option<&KeyID>)
+ -> *mut Key
+{
+ let ctx = ctx.expect("Context is NULL");
+ let keyid = keyid.expect("KeyID is NULL");
+
+ fry_box!(ctx, Pool::lookup_by_keyid(&ctx.c, keyid))
+}
+
+/// Looks up a key in the common key pool by (Sub)KeyID.
+#[no_mangle]
+pub extern "system" fn sq_store_lookup_by_subkeyid(ctx: Option<&mut Context>,
+ keyid: Option<&KeyID>)
+ -> *mut Key
+{
+ let ctx = ctx.expect("Context is NULL");
+ let keyid = keyid.expect("KeyID is NULL");
+
+ fry_box!(ctx, Pool::lookup_by_subkeyid(&ctx.c, keyid))
+}
+
/// Deletes this store.
///
/// Consumes `store`. Returns != 0 on error.