From a18ceb81ca78a7f37adc436f35e6eeb8683bb984 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 29 Sep 2016 04:36:14 +0200 Subject: Rework headers and includes --- src/noise.h | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'src/noise.h') diff --git a/src/noise.h b/src/noise.h index 9ae3c85..ca865f8 100644 --- a/src/noise.h +++ b/src/noise.h @@ -7,51 +7,16 @@ #ifndef NOISE_H #define NOISE_H -#include "crypto/curve25519.h" -#include "crypto/chacha20poly1305.h" -#include "crypto/blake2s.h" +#include "messages.h" +#include "hashtables.h" + #include #include #include #include #include #include - -enum index_hashtable_type { - INDEX_HASHTABLE_HANDSHAKE = (1 << 0), - INDEX_HASHTABLE_KEYPAIR = (1 << 1) -}; - -struct index_hashtable_entry { - struct wireguard_peer *peer; - struct hlist_node index_hash; - enum index_hashtable_type type; - __le32 index; -}; - -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 -}; - -enum counter_values { - COUNTER_BITS_TOTAL = 2048, - COUNTER_REDUNDANT_BITS = BITS_PER_LONG, - COUNTER_WINDOW_SIZE = COUNTER_BITS_TOTAL - COUNTER_REDUNDANT_BITS -}; - -enum wireguard_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 -}; +#include union noise_counter { struct { @@ -128,8 +93,6 @@ struct noise_handshake { struct rw_semaphore lock; }; -#define noise_encrypted_len(plain_len) (plain_len + NOISE_AUTHTAG_LEN) - struct wireguard_peer; struct wireguard_device; struct message_header; -- cgit v1.2.3-59-g8ed1b