summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/include/sequoia/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-09-06 13:47:50 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-09-06 16:42:12 +0200
commit38a4d2b4ff4fc4512b31a4ff4e4ddd8a6b3c7503 (patch)
tree469d667b6bab8333df02c7a2402b9edabbe08419 /openpgp-ffi/include/sequoia/openpgp
parent4d642187f1df0c9a4c60dc2355c797ebac6fcd4f (diff)
openpgp: Rework streaming encryptor.
- Instead of giving a set of TPKs to the encryptor, hand in a set of recipients, which are (keyid, key)-tuples, conveniently created from key queries over TPKs. This simplifies the encryptor, and makes the key selection explicit. - Drop the EncryptionMode type. - As a nice side effect, we can now generate encrypted messages with wildcard recipient addresses.
Diffstat (limited to 'openpgp-ffi/include/sequoia/openpgp')
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/serialize.h40
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/types.h24
2 files changed, 42 insertions, 22 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp/serialize.h b/openpgp-ffi/include/sequoia/openpgp/serialize.h
new file mode 100644
index 00000000..7d41d9b0
--- /dev/null
+++ b/openpgp-ffi/include/sequoia/openpgp/serialize.h
@@ -0,0 +1,40 @@
+#ifndef SEQUOIA_OPENPGP_SERIALIZE_H
+#define SEQUOIA_OPENPGP_SERIALIZE_H
+
+/*/
+/// Creates a new recipient with an explicit recipient keyid.
+///
+/// Consumes `keyid`, references `key`.
+/*/
+pgp_recipient_t pgp_recipient_new (pgp_keyid_t keyid, pgp_key_t key);
+
+/*/
+/// Frees this object.
+/*/
+void pgp_recipient_free (pgp_recipient_t);
+
+/*/
+/// Returns a human readable description of this object suitable for
+/// debugging.
+/*/
+char *pgp_recipient_debug (const pgp_recipient_t);
+
+/*/
+/// Gets the KeyID.
+/*/
+pgp_keyid_t pgp_recipient_keyid (const pgp_recipient_t);
+
+/*/
+/// Sets the KeyID.
+/*/
+void pgp_recipient_set_keyid (pgp_recipient_t, pgp_keyid_t);
+
+/*/
+/// Collects recipients from a `pgp_tpk_key_iter_t`.
+///
+/// Consumes the iterator. The returned buffer must be freed using
+/// libc's allocator.
+/*/
+pgp_recipient_t *pgp_recipients_from_key_iter (pgp_tpk_key_iter_t, size_t *);
+
+#endif
diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h
index b6003b1d..d1612a73 100644
--- a/openpgp-ffi/include/sequoia/openpgp/types.h
+++ b/openpgp-ffi/include/sequoia/openpgp/types.h
@@ -445,29 +445,9 @@ typedef struct pgp_tpk_builder *pgp_tpk_builder_t;
typedef struct pgp_writer_stack *pgp_writer_stack_t;
/*/
-/// Specifies whether to encrypt for archival purposes or for
-/// transport.
+/// A recipient of an encrypted message.
/*/
-typedef enum pgp_encryption_mode {
- /*/
- /// Encrypt data for long-term storage.
- ///
- /// This should be used for things that should be decryptable for
- /// a long period of time, e.g. backups, archives, etc.
- /*/
- PGP_ENCRYPTION_MODE_AT_REST = 0,
-
- /*/
- /// Encrypt data for transport.
- ///
- /// This should be used to protect a message in transit. The
- /// recipient is expected to take additional steps if she wants to
- /// be able to decrypt it later on, e.g. store the decrypted
- /// session key, or re-encrypt the session key with a different
- /// key.
- /*/
- PGP_ENCRYPTION_MODE_FOR_TRANSPORT = 1,
-} pgp_encryption_mode_t;
+typedef struct pgp_recipient *pgp_recipient_t;
/// Communicates the message structure to the VerificationHelper.
typedef struct pgp_message_structure *pgp_message_structure_t;