summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2018-11-22 10:04:55 +0100
committerNeal H. Walfield <neal@pep.foundation>2018-11-22 10:06:14 +0100
commitbbcd118f255cf5cb7d49a89e332d20592792605e (patch)
treef4309aad7e8dba527505a9b76d7ca481b85ac93b /ffi
parentb11b12bdcf61a3d74da3fadbbb8b6b8ae9040e08 (diff)
ffi: Wrap some of Signature's methods.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/include/sequoia/openpgp.h18
-rw-r--r--ffi/src/openpgp.rs28
2 files changed, 46 insertions, 0 deletions
diff --git a/ffi/include/sequoia/openpgp.h b/ffi/include/sequoia/openpgp.h
index 0331a2ad..f18bbeb8 100644
--- a/ffi/include/sequoia/openpgp.h
+++ b/ffi/include/sequoia/openpgp.h
@@ -496,6 +496,24 @@ sq_status_t sq_packet_pile_serialize (sq_context_t ctx,
const sq_packet_pile_t message,
sq_writer_t writer);
+/*/
+/// Returns the value of the `Signature` packet's Issuer subpacket.
+///
+/// If there is no Issuer subpacket, this returns NULL. Note: if
+/// there is no Issuer subpacket, but there is an IssuerFingerprint
+/// subpacket, this still returns NULL.
+/*/
+sq_keyid_t sq_signature_issuer(sq_signature_t sig);
+
+/*/
+/// Returns the value of the `Signature` packet's IssuerFingerprint subpacket.
+///
+/// If there is no IssuerFingerprint subpacket, this returns NULL.
+/// Note: if there is no IssuerFingerprint subpacket, but there is an
+/// Issuer subpacket, this still returns NULL.
+/*/
+sq_fingerprint_t sq_signature_issuer_fingerprint(sq_signature_t sig);
+
/* openpgp::tpk. */
diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs
index 25f42509..f7cc1b16 100644
--- a/ffi/src/openpgp.rs
+++ b/ffi/src/openpgp.rs
@@ -26,6 +26,7 @@ use self::openpgp::{
crypto::Password,
};
use self::openpgp::tpk::{CipherSuite, TPKBuilder};
+use self::openpgp::packet;
use self::openpgp::parse::{PacketParserResult, PacketParser, PacketParserEOF};
use self::openpgp::serialize::Serialize;
use self::openpgp::constants::{
@@ -1102,6 +1103,33 @@ pub extern "system" fn sq_packet_kind(p: Option<&Packet>)
}
}
+/// Returns the value of the `Signature` packet's Issuer subpacket.
+///
+/// If there is no Issuer subpacket, this returns NULL. Note: if
+/// there is no Issuer subpacket, but there is an IssuerFingerprint
+/// subpacket, this still returns NULL.
+#[no_mangle]
+pub extern "system" fn sq_signature_issuer(sig: Option<&packet::Signature>)
+ -> *mut KeyID {
+ let sig = sig.expect("Signature is NULL");
+ maybe_box_raw!(sig.issuer())
+}
+
+/// Returns the value of the `Signature` packet's IssuerFingerprint subpacket.
+///
+/// If there is no IssuerFingerprint subpacket, this returns NULL.
+/// Note: if there is no IssuerFingerprint subpacket, but there is an
+/// Issuer subpacket, this still returns NULL.
+#[no_mangle]
+pub extern "system" fn sq_signature_issuer_fingerprint(
+ sig: Option<&packet::Signature>)
+ -> *mut Fingerprint
+{
+ let sig = sig.expect("Signature is NULL");
+ maybe_box_raw!(sig.issuer_fingerprint())
+}
+
+
/// Computes and returns the key's fingerprint as per Section 12.2
/// of RFC 4880.
#[no_mangle]