FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
wireguard_noise.h File Reference
+ Include dependency graph for wireguard_noise.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  noise_handshake
 
struct  noise_counter
 
struct  noise_keypair
 
struct  noise_remote
 
struct  noise_local
 
struct  noise_local::noise_upcall
 

Macros

#define NOISE_PUBLIC_KEY_LEN   CURVE25519_KEY_SIZE
 
#define NOISE_SYMMETRIC_KEY_LEN   32
 
#define NOISE_TIMESTAMP_LEN   (sizeof(uint64_t) + sizeof(uint32_t))
 
#define NOISE_AUTHTAG_LEN   16
 
#define NOISE_HASH_LEN   BLAKE2S_HASH_SIZE
 
#define NOISE_HANDSHAKE_NAME   "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"
 
#define NOISE_IDENTIFIER_NAME   "WireGuard v1 zx2c4 Jason@zx2c4.com"
 
#define COUNTER_BITS_TOTAL   8192
 
#define COUNTER_BITS   (sizeof(unsigned long) * 8)
 
#define COUNTER_NUM   (COUNTER_BITS_TOTAL / COUNTER_BITS)
 
#define COUNTER_WINDOW_SIZE   (COUNTER_BITS_TOTAL - COUNTER_BITS)
 
#define REKEY_AFTER_MESSAGES   (1ull << 60)
 
#define REJECT_AFTER_MESSAGES   (UINT64_MAX - COUNTER_WINDOW_SIZE - 1)
 
#define REKEY_AFTER_TIME   120
 
#define REKEY_AFTER_TIME_RECV   165
 
#define REJECT_AFTER_TIME   180
 
#define REJECT_INTERVAL   (0.02) /* fifty times per sec */
 
#define REJECT_INTERVAL_MASK   (~((1ull<<24)-1))
 

Typedefs

typedef struct noise_handshake noise_handshake_t
 
typedef struct noise_counter noise_counter_t
 
typedef struct noise_keypair noise_keypair_t
 
typedef struct noise_local noise_local_t
 
typedef struct noise_remote noise_remote_t
 

Enumerations

enum  noise_state_crypt { SC_OK = 0, SC_CONN_RESET, SC_KEEP_KEY_FRESH, SC_FAILED }
 
enum  noise_state_hs {
  HS_ZEROED = 0, CREATED_INITIATION, CONSUMED_INITIATION, CREATED_RESPONSE,
  CONSUMED_RESPONSE
}
 

Functions

static_always_inline noise_local_tnoise_local_get (uint32_t locali)
 
void noise_local_init (noise_local_t *, struct noise_upcall *)
 
bool noise_local_set_private (noise_local_t *, const uint8_t[NOISE_PUBLIC_KEY_LEN])
 
void noise_remote_init (noise_remote_t *, uint32_t, const uint8_t[NOISE_PUBLIC_KEY_LEN], uint32_t)
 
void noise_remote_precompute (noise_remote_t *)
 
bool noise_create_initiation (vlib_main_t *vm, noise_remote_t *, uint32_t *s_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t es[NOISE_PUBLIC_KEY_LEN+NOISE_AUTHTAG_LEN], uint8_t ets[NOISE_TIMESTAMP_LEN+NOISE_AUTHTAG_LEN])
 
bool noise_consume_initiation (vlib_main_t *vm, noise_local_t *, noise_remote_t **, uint32_t s_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t es[NOISE_PUBLIC_KEY_LEN+NOISE_AUTHTAG_LEN], uint8_t ets[NOISE_TIMESTAMP_LEN+NOISE_AUTHTAG_LEN])
 
bool noise_create_response (vlib_main_t *vm, noise_remote_t *, uint32_t *s_idx, uint32_t *r_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t en[0+NOISE_AUTHTAG_LEN])
 
bool noise_consume_response (vlib_main_t *vm, noise_remote_t *, uint32_t s_idx, uint32_t r_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t en[0+NOISE_AUTHTAG_LEN])
 
bool noise_remote_begin_session (vlib_main_t *vm, noise_remote_t *r)
 
void noise_remote_clear (vlib_main_t *vm, noise_remote_t *r)
 
void noise_remote_expire_current (noise_remote_t *r)
 
bool noise_remote_ready (noise_remote_t *)
 
enum noise_state_crypt noise_remote_encrypt (vlib_main_t *vm, noise_remote_t *, uint32_t *r_idx, uint64_t *nonce, uint8_t *src, size_t srclen, uint8_t *dst)
 
enum noise_state_crypt noise_remote_decrypt (vlib_main_t *vm, noise_remote_t *, uint32_t r_idx, uint64_t nonce, uint8_t *src, size_t srclen, uint8_t *dst)
 

Variables

noise_local_tnoise_local_pool
 

Macro Definition Documentation

◆ COUNTER_BITS

#define COUNTER_BITS   (sizeof(unsigned long) * 8)

Definition at line 38 of file wireguard_noise.h.

◆ COUNTER_BITS_TOTAL

#define COUNTER_BITS_TOTAL   8192

Definition at line 37 of file wireguard_noise.h.

◆ COUNTER_NUM

#define COUNTER_NUM   (COUNTER_BITS_TOTAL / COUNTER_BITS)

Definition at line 39 of file wireguard_noise.h.

◆ COUNTER_WINDOW_SIZE

#define COUNTER_WINDOW_SIZE   (COUNTER_BITS_TOTAL - COUNTER_BITS)

Definition at line 40 of file wireguard_noise.h.

◆ NOISE_AUTHTAG_LEN

#define NOISE_AUTHTAG_LEN   16

Definition at line 29 of file wireguard_noise.h.

◆ NOISE_HANDSHAKE_NAME

#define NOISE_HANDSHAKE_NAME   "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"

Definition at line 33 of file wireguard_noise.h.

◆ NOISE_HASH_LEN

#define NOISE_HASH_LEN   BLAKE2S_HASH_SIZE

Definition at line 30 of file wireguard_noise.h.

◆ NOISE_IDENTIFIER_NAME

#define NOISE_IDENTIFIER_NAME   "WireGuard v1 zx2c4 Jason@zx2c4.com"

Definition at line 34 of file wireguard_noise.h.

◆ NOISE_PUBLIC_KEY_LEN

#define NOISE_PUBLIC_KEY_LEN   CURVE25519_KEY_SIZE

Definition at line 26 of file wireguard_noise.h.

◆ NOISE_SYMMETRIC_KEY_LEN

#define NOISE_SYMMETRIC_KEY_LEN   32

Definition at line 27 of file wireguard_noise.h.

◆ NOISE_TIMESTAMP_LEN

#define NOISE_TIMESTAMP_LEN   (sizeof(uint64_t) + sizeof(uint32_t))

Definition at line 28 of file wireguard_noise.h.

◆ REJECT_AFTER_MESSAGES

#define REJECT_AFTER_MESSAGES   (UINT64_MAX - COUNTER_WINDOW_SIZE - 1)

Definition at line 44 of file wireguard_noise.h.

◆ REJECT_AFTER_TIME

#define REJECT_AFTER_TIME   180

Definition at line 47 of file wireguard_noise.h.

◆ REJECT_INTERVAL

#define REJECT_INTERVAL   (0.02) /* fifty times per sec */

Definition at line 48 of file wireguard_noise.h.

◆ REJECT_INTERVAL_MASK

#define REJECT_INTERVAL_MASK   (~((1ull<<24)-1))

Definition at line 50 of file wireguard_noise.h.

◆ REKEY_AFTER_MESSAGES

#define REKEY_AFTER_MESSAGES   (1ull << 60)

Definition at line 43 of file wireguard_noise.h.

◆ REKEY_AFTER_TIME

#define REKEY_AFTER_TIME   120

Definition at line 45 of file wireguard_noise.h.

◆ REKEY_AFTER_TIME_RECV

#define REKEY_AFTER_TIME_RECV   165

Definition at line 46 of file wireguard_noise.h.

Typedef Documentation

◆ noise_counter_t

◆ noise_handshake_t

◆ noise_keypair_t

◆ noise_local_t

typedef struct noise_local noise_local_t

Definition at line 98 of file wireguard_noise.h.

◆ noise_remote_t

typedef struct noise_remote noise_remote_t

Enumeration Type Documentation

◆ noise_state_crypt

Enumerator
SC_OK 
SC_CONN_RESET 
SC_KEEP_KEY_FRESH 
SC_FAILED 

Definition at line 52 of file wireguard_noise.h.

◆ noise_state_hs

Enumerator
HS_ZEROED 
CREATED_INITIATION 
CONSUMED_INITIATION 
CREATED_RESPONSE 
CONSUMED_RESPONSE 

Definition at line 60 of file wireguard_noise.h.

Function Documentation

◆ noise_consume_initiation()

bool noise_consume_initiation ( vlib_main_t vm,
noise_local_t ,
noise_remote_t **  ,
uint32_t  s_idx,
uint8_t  ue[NOISE_PUBLIC_KEY_LEN],
uint8_t  es[NOISE_PUBLIC_KEY_LEN+NOISE_AUTHTAG_LEN],
uint8_t  ets[NOISE_TIMESTAMP_LEN+NOISE_AUTHTAG_LEN] 
)

Definition at line 170 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_consume_response()

bool noise_consume_response ( vlib_main_t vm,
noise_remote_t ,
uint32_t  s_idx,
uint32_t  r_idx,
uint8_t  ue[NOISE_PUBLIC_KEY_LEN],
uint8_t  en[0+NOISE_AUTHTAG_LEN] 
)

Definition at line 307 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_create_initiation()

bool noise_create_initiation ( vlib_main_t vm,
noise_remote_t ,
uint32_t *  s_idx,
uint8_t  ue[NOISE_PUBLIC_KEY_LEN],
uint8_t  es[NOISE_PUBLIC_KEY_LEN+NOISE_AUTHTAG_LEN],
uint8_t  ets[NOISE_TIMESTAMP_LEN+NOISE_AUTHTAG_LEN] 
)

Definition at line 118 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_create_response()

bool noise_create_response ( vlib_main_t vm,
noise_remote_t ,
uint32_t *  s_idx,
uint32_t *  r_idx,
uint8_t  ue[NOISE_PUBLIC_KEY_LEN],
uint8_t  en[0+NOISE_AUTHTAG_LEN] 
)

Definition at line 254 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_local_get()

static_always_inline noise_local_t* noise_local_get ( uint32_t  locali)

Definition at line 134 of file wireguard_noise.h.

+ Here is the caller graph for this function:

◆ noise_local_init()

void noise_local_init ( noise_local_t ,
struct noise_upcall *   
)

Definition at line 74 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_local_set_private()

bool noise_local_set_private ( noise_local_t ,
const uint8_t  [NOISE_PUBLIC_KEY_LEN] 
)

Definition at line 81 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_begin_session()

bool noise_remote_begin_session ( vlib_main_t vm,
noise_remote_t r 
)

Definition at line 368 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_clear()

void noise_remote_clear ( vlib_main_t vm,
noise_remote_t r 
)

Definition at line 450 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_decrypt()

enum noise_state_crypt noise_remote_decrypt ( vlib_main_t vm,
noise_remote_t ,
uint32_t  r_idx,
uint64_t  nonce,
uint8_t *  src,
size_t  srclen,
uint8_t *  dst 
)

Definition at line 597 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_encrypt()

enum noise_state_crypt noise_remote_encrypt ( vlib_main_t vm,
noise_remote_t ,
uint32_t *  r_idx,
uint64_t *  nonce,
uint8_t *  src,
size_t  srclen,
uint8_t *  dst 
)

Definition at line 545 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_expire_current()

void noise_remote_expire_current ( noise_remote_t r)

Definition at line 466 of file wireguard_noise.c.

+ Here is the call graph for this function:

◆ noise_remote_init()

void noise_remote_init ( noise_remote_t ,
uint32_t  ,
const uint8_t  [NOISE_PUBLIC_KEY_LEN],
uint32_t   
)

◆ noise_remote_precompute()

void noise_remote_precompute ( noise_remote_t )

Definition at line 105 of file wireguard_noise.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise_remote_ready()

bool noise_remote_ready ( noise_remote_t )

Definition at line 477 of file wireguard_noise.c.

+ Here is the call graph for this function:

Variable Documentation

◆ noise_local_pool

noise_local_t* noise_local_pool

Definition at line 29 of file wireguard_noise.c.