aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@noconroy.net>2021-04-19 05:45:47 +1000
committerMatt Dunwoodie <ncon@noconroy.net>2021-04-19 11:16:40 +1000
commitf685f466dbc371783b6bc8920f542cae2bd54fd8 (patch)
treef63e231fe790c60641540e23f40fe1a601fafcc0 /src/crypto.h
parentif_wg: actually use DEFAULT_MTU value (diff)
downloadwireguard-freebsd-f685f466dbc371783b6bc8920f542cae2bd54fd8.tar.xz
wireguard-freebsd-f685f466dbc371783b6bc8920f542cae2bd54fd8.zip
crypto: encrypt mbuf in place
This introduces a couple of routines to encrypt the mbufs in place. It is likely that these will be replaced by something in opencrypto, however for the time being this fixes a heap overflow and sets up wg_noise for the "correct" API. When the time comes, this should make it easier to drop in new crypto. It should be noted, this was written at 0500. Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
Diffstat (limited to 'src/crypto.h')
-rw-r--r--src/crypto.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/crypto.h b/src/crypto.h
index 0ac23f9..b1a5f0e 100644
--- a/src/crypto.h
+++ b/src/crypto.h
@@ -7,6 +7,7 @@
#define _WG_CRYPTO
#include <sys/types.h>
+#include <sys/mbuf.h>
enum chacha20poly1305_lengths {
XCHACHA20POLY1305_NONCE_SIZE = 24,
@@ -26,6 +27,14 @@ chacha20poly1305_decrypt(uint8_t *dst, const uint8_t *src, const size_t src_len,
const uint64_t nonce,
const uint8_t key[CHACHA20POLY1305_KEY_SIZE]);
+bool
+chacha20poly1305_encrypt_mbuf(struct mbuf *, const uint64_t nonce,
+ const uint8_t key[CHACHA20POLY1305_KEY_SIZE]);
+
+bool
+chacha20poly1305_decrypt_mbuf(struct mbuf *, const uint64_t nonce,
+ const uint8_t key[CHACHA20POLY1305_KEY_SIZE]);
+
void
xchacha20poly1305_encrypt(uint8_t *dst, const uint8_t *src,
const size_t src_len, const uint8_t *ad,