summaryrefslogtreecommitdiffstats
path: root/ffi/src/sequoia.h
diff options
context:
space:
mode:
authorJustus Winter <justus@pep-project.org>2017-12-12 17:16:00 +0100
committerJustus Winter <justus@pep-project.org>2017-12-13 13:55:20 +0100
commitc86ad83ae31d44aeab3317e5e05d6d63e428f0e0 (patch)
tree12d1aac77f256e733104e98faf9143152eacd573 /ffi/src/sequoia.h
parentc0cab61441df7a0334f817c2cc4817a0910e1193 (diff)
Split up Sequoia.
- Split up into six crates: buffered-reader, openpgp, sequoia-core, sequoia-ffi, sequoia-net, and sequoia-store. - Adjust imports accordingly.
Diffstat (limited to 'ffi/src/sequoia.h')
-rw-r--r--ffi/src/sequoia.h201
1 files changed, 201 insertions, 0 deletions
diff --git a/ffi/src/sequoia.h b/ffi/src/sequoia.h
new file mode 100644
index 00000000..6201ade7
--- /dev/null
+++ b/ffi/src/sequoia.h
@@ -0,0 +1,201 @@
+#ifndef SEQUOIA_H
+#define SEQUOIA_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+
+/* sequoia::Context. */
+
+/*/
+/// A `struct sq_context *` is required for many operations.
+///
+/// # Example
+///
+/// ```c
+/// struct sq_context *ctx sq_context_new("org.sequoia-pgp.example");
+/// if (ctx == NULL) { ... }
+/// ```
+/*/
+struct sq_context;
+
+/*/
+/// Represents a `Context` configuration.
+/*/
+struct sq_config;
+
+/*/
+/// Creates a Context with reasonable defaults.
+///
+/// `domain` should uniquely identify your application, it is strongly
+/// suggested to use a reversed fully qualified domain name that is
+/// associated with your application. `domain` must not be `NULL`.
+///
+/// Returns `NULL` on errors.
+/*/
+struct sq_context *sq_context_new(const char *domain);
+
+/*/
+/// Frees a context.
+/*/
+void sq_context_free(struct sq_context *context);
+
+/*/
+/// Creates a Context that can be configured.
+///
+/// `domain` should uniquely identify your application, it is strongly
+/// suggested to use a reversed fully qualified domain name that is
+/// associated with your application. `domain` must not be `NULL`.
+///
+/// The configuration is seeded like in `sq_context_new`, but can be
+/// modified. A configuration has to be finalized using
+/// `sq_config_build()` in order to turn it into a Context.
+/*/
+struct sq_config *sq_context_configure(const char *domain);
+
+/*/
+/// Returns the domain of the context.
+/*/
+const char *sq_context_domain(const struct sq_context *ctx);
+
+/*/
+/// Returns the directory containing shared state.
+/*/
+const char *sq_context_home(const struct sq_context *ctx);
+
+/*/
+/// Returns the directory containing backend servers.
+/*/
+const char *sq_context_lib(const struct sq_context *ctx);
+
+
+/* sequoia::Config. */
+
+/*/
+/// Finalizes the configuration and return a `Context`.
+///
+/// Consumes `cfg`. Returns `NULL` on errors.
+/*/
+struct sq_context *sq_config_build(struct sq_config *cfg);
+
+/*/
+/// Sets the directory containing shared state.
+/*/
+void sq_config_home(struct sq_config *cfg, const char *home);
+
+/*/
+/// Set the directory containing backend servers.
+/*/
+void sq_config_lib(struct sq_config *cfg, const char *lib);
+
+/* sequoia::openpgp::types. */
+
+/*/
+/// Uniquely identifies OpenPGP keys.
+/*/
+struct sq_keyid;
+
+/*/
+/// Returns a KeyID with the given `id`.
+/*/
+struct sq_keyid *sq_keyid_new (uint64_t id);
+
+/*/
+/// Returns a KeyID with the given `id` encoded as hexadecimal string.
+/*/
+struct sq_keyid *sq_keyid_from_hex (const char *id);
+
+/*/
+/// Frees a keyid object.
+/*/
+void sq_keyid_free (struct sq_keyid *keyid);
+
+
+/* sequoia::keys. */
+
+/*/
+/// A transferable public key (TPK).
+///
+/// A TPK (see [RFC 4880, section 11.1]) can be used to verify
+/// signatures and encrypt data. It can be stored in a keystore and
+/// uploaded to keyservers.
+///
+/// [RFC 4880, section 11.1]: https://tools.ietf.org/html/rfc4880#section-11.1
+/*/
+struct sq_tpk;
+
+/*/
+/// Returns the first TPK found in `buf`.
+///
+/// `buf` must be an OpenPGP encoded message.
+/*/
+struct sq_tpk *sq_tpk_from_bytes (const char *b, size_t len);
+
+/*/
+/// Frees the TPK.
+/*/
+void sq_tpk_free (struct sq_tpk *tpk);
+
+/*/
+/// Dumps the TPK.
+/*/
+void sq_tpk_dump (const struct sq_tpk *tpk);
+
+
+/* sequoia::net. */
+
+/*/
+/// For accessing keyservers using HKP.
+/*/
+struct sq_keyserver;
+
+/*/
+/// Returns a handle for the given URI.
+///
+/// `uri` is a UTF-8 encoded value of a keyserver URI,
+/// e.g. `hkps://examle.org`.
+///
+/// Returns `NULL` on errors.
+/*/
+struct sq_keyserver *sq_keyserver_new (const struct sq_context *ctx,
+ const char *uri);
+
+/*/
+/// Returns a handle for the given URI.
+///
+/// `uri` is a UTF-8 encoded value of a keyserver URI,
+/// e.g. `hkps://examle.org`. `cert` is a DER encoded certificate of
+/// size `len` used to authenticate the server.
+///
+/// Returns `NULL` on errors.
+/*/
+struct sq_keyserver *sq_keyserver_with_cert (const struct sq_context *ctx,
+ const char *uri,
+ const uint8_t *cert,
+ size_t len);
+
+/*/
+/// Returns a handle for the SKS keyserver pool.
+///
+/// The pool `hkps://hkps.pool.sks-keyservers.net` provides HKP
+/// services over https. It is authenticated using a certificate
+/// included in this library. It is a good default choice.
+///
+/// Returns `NULL` on errors.
+/*/
+struct sq_keyserver *sq_keyserver_sks_pool (const struct sq_context *ctx);
+
+/*/
+/// Frees a keyserver object.
+/*/
+void sq_keyserver_free (struct sq_keyserver *ks);
+
+/*/
+/// Retrieves the key with the given `keyid`.
+///
+/// Returns `NULL` on errors.
+/*/
+struct sq_tpk *sq_keyserver_get (struct sq_keyserver *ks,
+ const struct sq_keyid *id);
+
+#endif