aboutsummaryrefslogtreecommitdiffstats
path: root/serve/seal.h
diff options
context:
space:
mode:
Diffstat (limited to 'serve/seal.h')
-rw-r--r--serve/seal.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/serve/seal.h b/serve/seal.h
index e802b46..18e3e5f 100644
--- a/serve/seal.h
+++ b/serve/seal.h
@@ -58,7 +58,10 @@ void pure_opener_free(PureOpener *);
* private key and the other's public key: the same on both sides, and
* never all zeros), keys from it (HKDF-SHA256 with the info given), and
* AES-128-GCM under such a key with the nonce the caller gives (sealing may
- * be in place: out may be plain). A context is used by one thread at a time. */
+ * be in place: out may be plain). A context is used by one thread at a time;
+ * sealing or opening with a key given uses that key from then on, so one
+ * context serves many links (a key costs about as much as a small packet),
+ * and NULL keeps the key it has. */
typedef struct PureAead PureAead;
enum { PURE_AEAD_KEY = 16, PURE_AEAD_NONCE = 12, PURE_AEAD_TAG = 16 };
bool pure_link_secret(const PureSealKey *own, const unsigned char peer[PURE_SEAL_KEY], unsigned char out[32]);
@@ -66,10 +69,12 @@ bool pure_link_derive(const unsigned char secret[32], const unsigned char *info,
size_t out_size);
PureAead *pure_aead(const unsigned char key[PURE_AEAD_KEY]);
/* size + PURE_AEAD_TAG bytes into out. */
-bool pure_aead_seal(PureAead *, const unsigned char nonce[PURE_AEAD_NONCE], const unsigned char *aad, size_t aad_size,
- const unsigned char *plain, size_t size, unsigned char *out);
+bool pure_aead_seal(PureAead *, const unsigned char *key, const unsigned char nonce[PURE_AEAD_NONCE],
+ const unsigned char *aad, size_t aad_size, const unsigned char *plain, size_t size,
+ unsigned char *out);
/* size - PURE_AEAD_TAG bytes into plain; false when it does not open. */
-bool pure_aead_open(PureAead *, const unsigned char nonce[PURE_AEAD_NONCE], const unsigned char *aad,
- size_t aad_size, const unsigned char *sealed, size_t size, unsigned char *plain);
+bool pure_aead_open(PureAead *, const unsigned char *key, const unsigned char nonce[PURE_AEAD_NONCE],
+ const unsigned char *aad, size_t aad_size, const unsigned char *sealed, size_t size,
+ unsigned char *plain);
void pure_aead_free(PureAead *);
#endif