summaryrefslogtreecommitdiffhomepage
path: root/src/messages.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-09-29 04:36:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-09-29 19:25:30 +0200
commit7dbb44fcbea3bbed2c73919394e22865552b7c0d (patch)
tree09d03a9b211f9f068d25b84f67c8c60d9eb30199 /src/messages.h
parent0b9dfadd25b60bf2fed43d5b553098ed70028374 (diff)
Rework headers and includes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/messages.h')
-rw-r--r--src/messages.h41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/messages.h b/src/messages.h
index 38bead5..fc539ec 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -7,8 +7,45 @@
#ifndef MESSAGES_H
#define MESSAGES_H
-#include "noise.h"
-#include "cookie.h"
+#include "crypto/curve25519.h"
+#include "crypto/chacha20poly1305.h"
+#include "crypto/blake2s.h"
+
+#include <linux/kernel.h>
+#include <linux/param.h>
+
+enum noise_lengths {
+ NOISE_PUBLIC_KEY_LEN = CURVE25519_POINT_SIZE,
+ NOISE_SYMMETRIC_KEY_LEN = CHACHA20POLY1305_KEYLEN,
+ NOISE_TIMESTAMP_LEN = sizeof(u64) + sizeof(u32),
+ NOISE_AUTHTAG_LEN = CHACHA20POLY1305_AUTHTAGLEN,
+ NOISE_HASH_LEN = BLAKE2S_OUTBYTES
+};
+
+#define noise_encrypted_len(plain_len) (plain_len + NOISE_AUTHTAG_LEN)
+
+enum cookie_values {
+ COOKIE_SECRET_MAX_AGE = 2 * 60 * HZ,
+ COOKIE_SECRET_LATENCY = 5 * HZ,
+ COOKIE_SALT_LEN = 32,
+ COOKIE_LEN = 16
+};
+
+enum counter_values {
+ COUNTER_BITS_TOTAL = 2048,
+ COUNTER_REDUNDANT_BITS = BITS_PER_LONG,
+ COUNTER_WINDOW_SIZE = COUNTER_BITS_TOTAL - COUNTER_REDUNDANT_BITS
+};
+
+enum limits {
+ REKEY_AFTER_MESSAGES = U64_MAX - 0xffff,
+ REJECT_AFTER_MESSAGES = U64_MAX - COUNTER_WINDOW_SIZE - 1,
+ REKEY_TIMEOUT = 5 * HZ,
+ REKEY_AFTER_TIME = 120 * HZ,
+ REJECT_AFTER_TIME = 180 * HZ,
+ INITIATIONS_PER_SECOND = HZ / 50,
+ MAX_PEERS_PER_DEVICE = U16_MAX
+};
enum message_type {
MESSAGE_INVALID = 0,