diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-15 09:35:04 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-15 11:34:49 +0100 |
commit | 59a59ac5bf9cc9be2698eb35376c3b58fd483252 (patch) | |
tree | 5eb5c8256c67b8397669c48fae905840c3302866 /ffi/include | |
parent | de5c18230ddcad3928ae5c4bd2c1badbe9ec2e92 (diff) |
net: Decouple from core.
- Move core::NetworkPolicy to net::Policy, update all code
accordingly.
Diffstat (limited to 'ffi/include')
-rw-r--r-- | ffi/include/sequoia/core.h | 36 | ||||
-rw-r--r-- | ffi/include/sequoia/net.h | 32 | ||||
-rw-r--r-- | ffi/include/sequoia/store.h | 4 |
3 files changed, 34 insertions, 38 deletions
diff --git a/ffi/include/sequoia/core.h b/ffi/include/sequoia/core.h index c7f73f45..c73d54c1 100644 --- a/ffi/include/sequoia/core.h +++ b/ffi/include/sequoia/core.h @@ -33,32 +33,6 @@ pgp_error_t sq_context_last_error (sq_context_t ctx); typedef struct sq_config *sq_config_t; /*/ -/// Network policy for Sequoia. -/// -/// With this policy you can control how Sequoia accesses remote -/// systems. -/*/ -typedef enum sq_network_policy { - /* Do not contact remote systems. */ - SQ_NETWORK_POLICY_OFFLINE = 0, - - /* Only contact remote systems using anonymization techniques like - * TOR. */ - SQ_NETWORK_POLICY_ANONYMIZED = 1, - - /* Only contact remote systems using transports offering - * encryption and authentication like TLS. */ - SQ_NETWORK_POLICY_ENCRYPTED = 2, - - /* Contact remote systems even with insecure transports. */ - SQ_NETWORK_POLICY_INSECURE = 3, - - /* Dummy value to make sure the enumeration has a defined size. Do - not use this value. */ - SQ_NETWORK_POLICY_FORCE_WIDTH = INT_MAX, -} sq_network_policy_t; - -/*/ /// IPC policy for Sequoia. /// /// With this policy you can control how Sequoia starts background @@ -155,11 +129,6 @@ const char *sq_context_home(const sq_context_t ctx); const char *sq_context_lib(const sq_context_t ctx); /*/ -/// Returns the network policy. -/*/ -sq_network_policy_t sq_context_network_policy(const sq_context_t ctx); - -/*/ /// Returns the IPC policy. /*/ sq_ipc_policy_t sq_context_ipc_policy(const sq_context_t ctx); @@ -191,11 +160,6 @@ void sq_config_home(sq_config_t cfg, const char *home); void sq_config_lib(sq_config_t cfg, const char *lib); /*/ -/// Sets the network policy. -/*/ -void sq_config_network_policy(sq_config_t cfg, sq_network_policy_t policy); - -/*/ /// Sets the IPC policy. /*/ void sq_config_ipc_policy(sq_config_t cfg, sq_ipc_policy_t policy); diff --git a/ffi/include/sequoia/net.h b/ffi/include/sequoia/net.h index 63311d85..f1d850d3 100644 --- a/ffi/include/sequoia/net.h +++ b/ffi/include/sequoia/net.h @@ -9,6 +9,33 @@ typedef struct sq_keyserver *sq_keyserver_t; /*/ +/// Network policy for Sequoia. +/// +/// With this policy you can control how Sequoia accesses remote +/// systems. +/*/ +typedef enum sq_network_policy { + /* Do not contact remote systems. */ + SQ_NETWORK_POLICY_OFFLINE = 0, + + /* Only contact remote systems using anonymization techniques like + * TOR. */ + SQ_NETWORK_POLICY_ANONYMIZED = 1, + + /* Only contact remote systems using transports offering + * encryption and authentication like TLS. */ + SQ_NETWORK_POLICY_ENCRYPTED = 2, + + /* Contact remote systems even with insecure transports. */ + SQ_NETWORK_POLICY_INSECURE = 3, + + /* Dummy value to make sure the enumeration has a defined size. Do + not use this value. */ + SQ_NETWORK_POLICY_FORCE_WIDTH = INT_MAX, +} sq_network_policy_t; + + +/*/ /// Returns a handle for the given URI. /// /// `uri` is a UTF-8 encoded value of a keyserver URI, @@ -17,6 +44,7 @@ typedef struct sq_keyserver *sq_keyserver_t; /// Returns `NULL` on errors. /*/ sq_keyserver_t sq_keyserver_new (sq_context_t ctx, + sq_network_policy_t policy, const char *uri); /*/ @@ -29,6 +57,7 @@ sq_keyserver_t sq_keyserver_new (sq_context_t ctx, /// Returns `NULL` on errors. /*/ sq_keyserver_t sq_keyserver_with_cert (sq_context_t ctx, + sq_network_policy_t policy, const char *uri, const uint8_t *cert, size_t len); @@ -41,7 +70,8 @@ sq_keyserver_t sq_keyserver_with_cert (sq_context_t ctx, /// /// Returns `NULL` on errors. /*/ -sq_keyserver_t sq_keyserver_keys_openpgp_org (sq_context_t ctx); +sq_keyserver_t sq_keyserver_keys_openpgp_org (sq_context_t ctx, + sq_network_policy_t policy); /*/ /// Frees a keyserver object. diff --git a/ffi/include/sequoia/store.h b/ffi/include/sequoia/store.h index 694aa32c..5fc84d19 100644 --- a/ffi/include/sequoia/store.h +++ b/ffi/include/sequoia/store.h @@ -2,6 +2,7 @@ #define SEQUOIA_STORE_H #include <sequoia/core.h> +#include <sequoia/net.h> /*/ /// Keys used for communications. @@ -262,7 +263,8 @@ sq_key_iter_t sq_store_list_keys (sq_context_t ctx); /// Opening the mapping with a different network policy is /// forbidden. /*/ -sq_mapping_t sq_mapping_open (sq_context_t ctx, const char *realm, const char *name); +sq_mapping_t sq_mapping_open (sq_context_t ctx, sq_network_policy_t policy, + const char *realm, const char *name); /*/ /// Adds a key identified by fingerprint to the mapping. |