FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
wireguard_messages.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Doc.ai and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __included_wg_messages_h__
17 #define __included_wg_messages_h__
18 
19 #include <stdint.h>
22 
23 #define WG_TICK 0.01 /**< WG tick period (s) */
24 #define WHZ (u32) (1/WG_TICK) /**< WG tick frequency */
25 
26 #define NOISE_KEY_LEN_BASE64 ((((NOISE_PUBLIC_KEY_LEN) + 2) / 3) * 4 + 1)
27 #define noise_encrypted_len(plain_len) ((plain_len) + NOISE_AUTHTAG_LEN)
28 
29 enum limits
30 {
35  MAX_PEERS = 1U << 20
36 };
37 
38 #define foreach_wg_message_type \
39  _(INVALID, "Invalid") \
40  _(HANDSHAKE_INITIATION, "Handshake initiation") \
41  _(HANDSHAKE_RESPONSE, "Handshake response") \
42  _(HANDSHAKE_COOKIE, "Handshake cookie") \
43  _(DATA, "Data") \
44 
45 typedef enum message_type
46 {
47 #define _(v,s) MESSAGE_##v,
49 #undef _
51 
52 typedef struct message_header
53 {
56 
58 {
66 
68 {
76 
78 {
84 
85 typedef struct message_data
86 {
92 
93 #define message_data_len(plain_len) \
94  (noise_encrypted_len(plain_len) + sizeof(message_data_t))
95 
96 #endif /* __included_wg_messages_h__ */
97 
98 /*
99  * fd.io coding-style-patch-verification: ON
100  *
101  * Local Variables:
102  * eval: (c-set-style "gnu")
103  * End:
104  */
REKEY_TIMEOUT_JITTER
@ REKEY_TIMEOUT_JITTER
Definition: wireguard_messages.h:32
REKEY_TIMEOUT
@ REKEY_TIMEOUT
Definition: wireguard_messages.h:31
message_handshake_response
Definition: wireguard_messages.h:67
message_handshake_cookie_t
struct message_handshake_cookie message_handshake_cookie_t
message_data::counter
u64 counter
Definition: wireguard_messages.h:89
message_header
Definition: wireguard_messages.h:52
message_data::header
message_header_t header
Definition: wireguard_messages.h:87
MAX_PEERS
@ MAX_PEERS
Definition: wireguard_messages.h:35
message_data::receiver_index
u32 receiver_index
Definition: wireguard_messages.h:88
message_data::encrypted_data
u8 encrypted_data[]
Definition: wireguard_messages.h:90
message_type_t
enum message_type message_type_t
message_handshake_initiation
Definition: wireguard_messages.h:57
KEEPALIVE_TIMEOUT
@ KEEPALIVE_TIMEOUT
Definition: wireguard_messages.h:33
limits
limits
Definition: wireguard_messages.h:29
message_handshake_response::encrypted_nothing
u8 encrypted_nothing[noise_encrypted_len(0)]
Definition: wireguard_messages.h:73
message_data_t
struct message_data message_data_t
wireguard_noise.h
message_handshake_initiation::unencrypted_ephemeral
u8 unencrypted_ephemeral[NOISE_PUBLIC_KEY_LEN]
Definition: wireguard_messages.h:61
cookie_macs
Definition: wireguard_cookie.h:56
WHZ
#define WHZ
WG tick frequency.
Definition: wireguard_messages.h:24
message_handshake_response::sender_index
u32 sender_index
Definition: wireguard_messages.h:70
message_handshake_initiation::sender_index
u32 sender_index
Definition: wireguard_messages.h:60
message_handshake_initiation::encrypted_static
u8 encrypted_static[noise_encrypted_len(NOISE_PUBLIC_KEY_LEN)]
Definition: wireguard_messages.h:62
message_handshake_response::unencrypted_ephemeral
u8 unencrypted_ephemeral[NOISE_PUBLIC_KEY_LEN]
Definition: wireguard_messages.h:72
u64
unsigned long u64
Definition: types.h:89
NOISE_PUBLIC_KEY_LEN
#define NOISE_PUBLIC_KEY_LEN
Definition: wireguard_noise.h:26
message_handshake_initiation::header
message_header_t header
Definition: wireguard_messages.h:59
u32
unsigned int u32
Definition: types.h:88
message_handshake_initiation_t
struct message_handshake_initiation message_handshake_initiation_t
message_handshake_response::header
message_header_t header
Definition: wireguard_messages.h:69
MAX_TIMER_HANDSHAKES
@ MAX_TIMER_HANDSHAKES
Definition: wireguard_messages.h:34
noise_encrypted_len
#define noise_encrypted_len(plain_len)
Definition: wireguard_messages.h:27
message_handshake_response::macs
message_macs_t macs
Definition: wireguard_messages.h:74
u8
unsigned char u8
Definition: types.h:56
message_data
Definition: wireguard_messages.h:85
message_handshake_initiation::encrypted_timestamp
u8 encrypted_timestamp[noise_encrypted_len(NOISE_TIMESTAMP_LEN)]
Definition: wireguard_messages.h:63
message_type
message_type
Definition: wireguard_messages.h:45
NOISE_TIMESTAMP_LEN
#define NOISE_TIMESTAMP_LEN
Definition: wireguard_noise.h:28
foreach_wg_message_type
#define foreach_wg_message_type
Definition: wireguard_messages.h:38
message_header_t
struct message_header message_header_t
message_header::type
message_type_t type
Definition: wireguard_messages.h:54
message_handshake_response_t
struct message_handshake_response message_handshake_response_t
message_handshake_response::receiver_index
u32 receiver_index
Definition: wireguard_messages.h:71
message_handshake_initiation::macs
message_macs_t macs
Definition: wireguard_messages.h:64