summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/include/sequoia/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-04-29 14:36:24 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-04-29 14:55:52 +0200
commitb3b18a2a9e370b226cdc3015616e072d22937ddf (patch)
treeaddde6ca6e51fb788dd0c7bbdb5d6beeddd3d66d /openpgp-ffi/include/sequoia/openpgp
parent36ed0f847c4f033c67fca9f2a332598b5effc107 (diff)
openpgp-ffi: Introduce a new Packet type.
- See #156.
Diffstat (limited to 'openpgp-ffi/include/sequoia/openpgp')
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/packet.h33
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/types.h15
2 files changed, 30 insertions, 18 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp/packet.h b/openpgp-ffi/include/sequoia/openpgp/packet.h
index 7d9f3f07..778deabe 100644
--- a/openpgp-ffi/include/sequoia/openpgp/packet.h
+++ b/openpgp-ffi/include/sequoia/openpgp/packet.h
@@ -2,14 +2,14 @@
#define SEQUOIA_OPENPGP_PACKET_H
/*/
-/// Returns a human-readable tag name.
+/// Frees the Packet.
/*/
-const char *pgp_tag_to_string (pgp_tag_t tag);
+void pgp_packet_free (pgp_packet_t p);
/*/
-/// Frees the Packet.
+/// Clones this object.
/*/
-void pgp_packet_free (pgp_packet_t p);
+pgp_packet_t pgp_packet_clone (pgp_packet_t keyid);
/*/
/// Returns a human readable description of this object suitable for
@@ -18,6 +18,16 @@ void pgp_packet_free (pgp_packet_t p);
char *pgp_packet_debug (const pgp_packet_t fp);
/*/
+/// Compares objects of this kind.
+/*/
+int pgp_packet_equal (const pgp_packet_t a, const pgp_packet_t b);
+
+/*/
+/// Hashes this object.
+/*/
+uint64_t pgp_packet_hash (pgp_packet_t keyid);
+
+/*/
/// Returns the `Packet's` corresponding OpenPGP tag.
///
/// Tags are explained in [Section 4.3 of RFC 4880].
@@ -37,4 +47,19 @@ pgp_tag_t pgp_packet_tag (pgp_packet_t p);
/*/
pgp_tag_t pgp_packet_kind (pgp_packet_t p);
+/*/
+/// Returns a human-readable tag name.
+/*/
+const char *pgp_tag_to_string (pgp_tag_t tag);
+
+/*/
+/// Given a packet references the contained signature, if any.
+///
+/// If the Packet is not of the `Packet::Signature` variant, this
+/// function returns `NULL`. Objects returned from this function must
+/// be deallocated using `pgp_signature_free` even though they only
+/// reference the given packet.
+/*/
+pgp_signature_t pgp_packet_ref_signature (pgp_packet_t p);
+
#endif
diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h
index 140554f5..742c782ce 100644
--- a/openpgp-ffi/include/sequoia/openpgp/types.h
+++ b/openpgp-ffi/include/sequoia/openpgp/types.h
@@ -321,20 +321,7 @@ typedef struct pgp_mdc *pgp_mdc_t;
///
/// [Section 5 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5
/*/
-typedef union pgp_packet {
- pgp_unknown_t unknown;
- pgp_signature_t signature;
- pgp_one_pass_sig_t one_pass_sig;
- pgp_key_t key;
- pgp_user_id_t user_id;
- pgp_user_attribute_t user_attribute;
- pgp_literal_t literal;
- pgp_compressed_data_t compressed_data;
- pgp_pkesk_t pkesk;
- pgp_skesk_t skesk;
- pgp_seip_t seip;
- pgp_mdc_t mdc;
-} pgp_packet_t;
+typedef struct pgp_packet *pgp_packet_t;
/*/
/// A low-level OpenPGP message parser.