FD.io VPP  v16.06
Vector Packet Processing
ikev2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco 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 #ifndef __included_ikev2_h__
16 #define __included_ikev2_h__
17 
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 
21 #include <vppinfra/error.h>
22 
23 #define IKEV2_NONCE_SIZE 32
24 
25 #define IKEV2_KEY_PAD "Key Pad for IKEv2"
26 
27 typedef u8 v8;
28 
29 typedef CLIB_PACKED (struct {
30  u64 ispi;
31  u64 rspi;
32  u8 nextpayload;
33  u8 version;
34  u8 exchange;
35  u8 flags;
36  u32 msgid;
37  u32 length;
38  u8 payload[0];
39 }) ike_header_t;
40 
41 typedef CLIB_PACKED (struct {
42  u8 nextpayload;
43  u8 flags;
44  u16 length;
45  u16 dh_group;
46  u8 reserved[2];
47  u8 payload[0];
48 }) ike_ke_payload_header_t;
49 
50 typedef CLIB_PACKED (struct {
51  u8 nextpayload;
52  u8 flags;
53  u16 length;
54  u8 payload[0];
55 }) ike_payload_header_t;
56 
57 typedef CLIB_PACKED (struct {
58  u8 nextpayload;
59  u8 flags;
60  u16 length;
61  u8 auth_method;
62  u8 reserved[3];
63  u8 payload[0];
64 }) ike_auth_payload_header_t;
65 
66 typedef CLIB_PACKED (struct {
67  u8 nextpayload;
68  u8 flags;
69  u16 length;
70  u8 id_type;
71  u8 reserved[3];
72  u8 payload[0];
73 }) ike_id_payload_header_t;
74 
75 #define IKE_VERSION_2 0x20
76 
77 #define IKEV2_EXCHANGE_SA_INIT 34
78 #define IKEV2_EXCHANGE_IKE_AUTH 35
79 #define IKEV2_EXCHANGE_CREATE_CHILD_SA 36
80 #define IKEV2_EXCHANGE_INFORMATIONAL 37
81 
82 #define IKEV2_HDR_FLAG_INITIATOR (1<<3)
83 #define IKEV2_HDR_FLAG_VERSION (1<<4)
84 #define IKEV2_HDR_FLAG_RESPONSE (1<<5)
85 
86 #define IKEV2_PAYLOAD_FLAG_CRITICAL (1<<7)
87 
88 #define IKEV2_PAYLOAD_NONE 0
89 #define IKEV2_PAYLOAD_SA 33
90 #define IKEV2_PAYLOAD_KE 34
91 #define IKEV2_PAYLOAD_IDI 35
92 #define IKEV2_PAYLOAD_IDR 36
93 #define IKEV2_PAYLOAD_AUTH 39
94 #define IKEV2_PAYLOAD_NONCE 40
95 #define IKEV2_PAYLOAD_NOTIFY 41
96 #define IKEV2_PAYLOAD_DELETE 42
97 #define IKEV2_PAYLOAD_VENDOR 43
98 #define IKEV2_PAYLOAD_TSI 44
99 #define IKEV2_PAYLOAD_TSR 45
100 #define IKEV2_PAYLOAD_SK 46
101 
102 typedef enum {
107 
108 #define foreach_ikev2_notify_msg_type \
109  _( 0, NONE) \
110  _( 1, UNSUPPORTED_CRITICAL_PAYLOAD) \
111  _( 4, INVALID_IKE_SPI) \
112  _( 5, INVALID_MAJOR_VERSION) \
113  _( 7, INVALID_SYNTAX) \
114  _( 8, INVALID_MESSAGE_ID) \
115  _( 11, INVALID_SPI) \
116  _( 14, NO_PROPOSAL_CHOSEN) \
117  _( 17, INVALID_KE_PAYLOAD) \
118  _( 24, AUTHENTICATION_FAILED) \
119  _( 34, SINGLE_PAIR_REQUIRED) \
120  _( 35, NO_ADDITIONAL_SAS) \
121  _( 36, INTERNAL_ADDRESS_FAILURE) \
122  _( 37, FAILED_CP_REQUIRED) \
123  _( 38, TS_UNACCEPTABLE) \
124  _( 39, INVALID_SELECTORS) \
125  _( 40, UNACCEPTABLE_ADDRESSES) \
126  _( 41, UNEXPECTED_NAT_DETECTED) \
127  _( 42, USE_ASSIGNED_HoA) \
128  _( 43, TEMPORARY_FAILURE) \
129  _( 44, CHILD_SA_NOT_FOUND) \
130  _( 45, INVALID_GROUP_ID) \
131  _( 46, AUTHORIZATION_FAILED) \
132  _(16384, INITIAL_CONTACT) \
133  _(16385, SET_WINDOW_SIZE) \
134  _(16386, ADDITIONAL_TS_POSSIBLE) \
135  _(16387, IPCOMP_SUPPORTED) \
136  _(16388, NAT_DETECTION_SOURCE_IP) \
137  _(16389, NAT_DETECTION_DESTINATION_IP) \
138  _(16390, COOKIE) \
139  _(16391, USE_TRANSPORT_MODE) \
140  _(16392, HTTP_CERT_LOOKUP_SUPPORTED) \
141  _(16393, REKEY_SA) \
142  _(16394, ESP_TFC_PADDING_NOT_SUPPORTED) \
143  _(16395, NON_FIRST_FRAGMENTS_ALSO) \
144  _(16396, MOBIKE_SUPPORTED) \
145  _(16397, ADDITIONAL_IP4_ADDRESS) \
146  _(16398, ADDITIONAL_IP6_ADDRESS) \
147  _(16399, NO_ADDITIONAL_ADDRESSES) \
148  _(16400, UPDATE_SA_ADDRESSES) \
149  _(16401, COOKIE2) \
150  _(16402, NO_NATS_ALLOWED) \
151  _(16403, AUTH_LIFETIME) \
152  _(16404, MULTIPLE_AUTH_SUPPORTED) \
153  _(16405, ANOTHER_AUTH_FOLLOWS) \
154  _(16406, REDIRECT_SUPPORTED) \
155  _(16407, REDIRECT) \
156  _(16408, REDIRECTED_FROM) \
157  _(16409, TICKET_LT_OPAQUE) \
158  _(16410, TICKET_REQUEST) \
159  _(16411, TICKET_ACK) \
160  _(16412, TICKET_NACK) \
161  _(16413, TICKET_OPAQUE) \
162  _(16414, LINK_ID) \
163  _(16415, USE_WESP_MODE) \
164  _(16416, ROHC_SUPPORTED) \
165  _(16417, EAP_ONLY_AUTHENTICATION) \
166  _(16418, CHILDLESS_IKEV2_SUPPORTED) \
167  _(16419, QUICK_CRASH_DETECTION) \
168  _(16420, IKEV2_MESSAGE_ID_SYNC_SUPPORTED) \
169  _(16421, IPSEC_REPLAY_COUNTER_SYNC_SUPPORTED) \
170  _(16422, IKEV2_MESSAGE_ID_SYNC) \
171  _(16423, IPSEC_REPLAY_COUNTER_SYNC) \
172  _(16424, SECURE_PASSWORD_METHODS) \
173  _(16425, PSK_PERSIST) \
174  _(16426, PSK_CONFIRM) \
175  _(16427, ERX_SUPPORTED) \
176  _(16428, IFOM_CAPABILITY) \
177  _(16429, SENDER_REQUEST_ID) \
178  _(16430, IKEV2_FRAGMENTATION_SUPPORTED) \
179  _(16431, SIGNATURE_HASH_ALGORITHMS)
180 
181 
182 typedef enum {
183 #define _(v,f) IKEV2_NOTIFY_MSG_##f = v,
185 #undef _
187 
188 #define foreach_ikev2_transform_type \
189  _(0, UNDEFINED, "undefinded") \
190  _(1, ENCR, "encr") \
191  _(2, PRF, "prf") \
192  _(3, INTEG, "integ") \
193  _(4, DH, "dh-group") \
194  _(5, ESN, "esn")
195 
196 typedef enum {
197 #define _(v,f,s) IKEV2_TRANSFORM_TYPE_##f = v,
199 #undef _
202 
203 
204 #define foreach_ikev2_transform_encr_type \
205  _(1 , DES_IV64, "des-iv64") \
206  _(2 , DES, "des") \
207  _(3 , 3DES, "3des") \
208  _(4 , RC5, "rc5") \
209  _(5 , IDEA, "idea") \
210  _(6 , CAST, "cast") \
211  _(7 , BLOWFISH, "blowfish") \
212  _(8 , 3IDEA, "3idea") \
213  _(9 , DES_IV32, "des-iv32") \
214  _(11, NULL, "null") \
215  _(12, AES_CBC, "aes-cbc") \
216  _(13, AES_CTR, "aes-ctr")
217 
218 typedef enum {
219 #define _(v,f,str) IKEV2_TRANSFORM_ENCR_TYPE_##f = v,
221 #undef _
223 
224 #define foreach_ikev2_transform_prf_type \
225  _(1, PRF_HMAC_MD5, "hmac-md5") \
226  _(2, PRF_HMAC_SHA1, "hmac-sha1") \
227  _(3, PRF_MAC_TIGER, "mac-tiger") \
228  _(4, PRF_AES128_XCBC, "aes128-xcbc") \
229  _(5, PRF_HMAC_SHA2_256, "hmac-sha2-256") \
230  _(6, PRF_HMAC_SHA2_384, "hmac-sha2-384") \
231  _(7, PRF_HMAC_SHA2_512, "hmac-sha2-512") \
232  _(8, PRF_AES128_CMAC, "aes128-cmac")
233 
234 typedef enum {
235 #define _(v,f,str) IKEV2_TRANSFORM_PRF_TYPE_##f = v,
237 #undef _
239 
240 #define foreach_ikev2_transform_integ_type \
241  _(0, NONE, "none") \
242  _(1, AUTH_HMAC_MD5_96, "md5-96") \
243  _(2, AUTH_HMAC_SHA1_96, "sha1-96") \
244  _(3, AUTH_DES_MAC, "des-mac") \
245  _(4, AUTH_KPDK_MD5, "kpdk-md5") \
246  _(5, AUTH_AES_XCBC_96, "aes-xcbc-96") \
247  _(6, AUTH_HMAC_MD5_128, "md5-128") \
248  _(7, AUTH_HMAC_SHA1_160, "sha1-160") \
249  _(8, AUTH_AES_CMAC_96, "cmac-96") \
250  _(9, AUTH_AES_128_GMAC, "aes-128-gmac") \
251  _(10, AUTH_AES_192_GMAC, "aes-192-gmac") \
252  _(11, AUTH_AES_256_GMAC, "aes-256-gmac") \
253  _(12, AUTH_HMAC_SHA2_256_128, "hmac-sha2-256-128") \
254  _(13, AUTH_HMAC_SHA2_384_192, "hmac-sha2-384-192") \
255  _(14, AUTH_HMAC_SHA2_512_256, "hmac-sha2-512-256")
256 
257 typedef enum {
258 #define _(v,f, str) IKEV2_TRANSFORM_INTEG_TYPE_##f = v,
260 #undef _
262 
263 #if defined(OPENSSL_NO_CISCO_FECDH)
264 #define foreach_ikev2_transform_dh_type \
265  _(0, NONE, "none") \
266  _(1, MODP_768, "modp-768") \
267  _(2, MODP_1024, "modp-1024") \
268  _(5, MODP_1536, "modp-1536") \
269  _(14, MODP_2048, "modp-2048") \
270  _(15, MODP_3072, "modp-3072") \
271  _(16, MODP_4096, "modp-4096") \
272  _(17, MODP_6144, "modp-6144") \
273  _(18, MODP_8192, "modp-8192") \
274  _(19, ECP_256, "ecp-256") \
275  _(20, ECP_384, "ecp-384") \
276  _(21, ECP_521, "ecp-521") \
277  _(22, MODP_1024_160, "modp-1024-160") \
278  _(23, MODP_2048_224, "modp-2048-224") \
279  _(24, MODP_2048_256, "modp-2048-256") \
280  _(25, ECP_192, "ecp-192") \
281  _(26, ECP_224, "ecp-224") \
282  _(27, BRAINPOOL_224, "brainpool-224") \
283  _(28, BRAINPOOL_256, "brainpool-256") \
284  _(29, BRAINPOOL_384, "brainpool-384") \
285  _(30, BRAINPOOL_512, "brainpool-512")
286 #else
287 #define foreach_ikev2_transform_dh_type \
288  _(0, NONE, "none") \
289  _(1, MODP_768, "modp-768") \
290  _(2, MODP_1024, "modp-1024") \
291  _(5, MODP_1536, "modp-1536") \
292  _(14, MODP_2048, "modp-2048") \
293  _(15, MODP_3072, "modp-3072") \
294  _(16, MODP_4096, "modp-4096") \
295  _(17, MODP_6144, "modp-6144") \
296  _(18, MODP_8192, "modp-8192") \
297  _(19, ECP_256, "ecp-256") \
298  _(20, ECP_384, "ecp-384") \
299  _(21, ECP_521, "ecp-521") \
300  _(22, MODP_1024_160, "modp-1024-160") \
301  _(23, MODP_2048_224, "modp-2048-224") \
302  _(24, MODP_2048_256, "modp-2048-256") \
303  _(25, ECP_192, "ecp-192")
304 #endif
305 
306 typedef enum {
307 #define _(v,f, str) IKEV2_TRANSFORM_DH_TYPE_##f = v,
309 #undef _
311 
312 #define foreach_ikev2_transform_esn_type \
313  _(0, NO_ESN, "no") \
314  _(1, ESN, "yes")
315 
316 typedef enum {
317 #define _(v,f,str) IKEV2_TRANSFORM_ESN_TYPE_##f = v,
319 #undef _
321 
322 #define foreach_ikev2_auth_method \
323  _( 1, RSA_SIG, "rsa-sig") \
324  _( 2, SHARED_KEY_MIC, "shared-key-mic")
325 
326 typedef enum {
327 #define _(v,f,s) IKEV2_AUTH_METHOD_##f = v,
329 #undef _
331 
332 #define foreach_ikev2_id_type \
333  _( 1, ID_IPV4_ADDR, "ip4-addr") \
334  _( 2, ID_FQDN, "fqdn") \
335  _( 3, ID_RFC822_ADDR, "rfc822") \
336  _( 5, ID_IPV6_ADDR, "ip6-addr") \
337  _( 9, ID_DER_ASN1_DN, "der-asn1-dn") \
338  _(10, ID_DER_ASN1_GN, "der-asn1-gn") \
339  _(11, ID_KEY_ID, "key-id")
340 
341 typedef enum {
342 #define _(v,f,s) IKEV2_ID_TYPE_##f = v,
344 #undef _
346 
349 clib_error_t * ikev2_add_del_profile(vlib_main_t * vm, u8 * name, int is_add);
351  u8 auth_method, u8 * data,
352  u8 data_hex_format);
354  u8 id_type, u8 * data, int is_local);
355 clib_error_t * ikev2_set_profile_ts(vlib_main_t * vm, u8 * name, u8 protocol_id,
356  u16 start_port, u16 end_port,
357  ip4_address_t start_addr,
358  ip4_address_t end_addr, int is_local);
359 /* ikev2_format.c */
360 u8 * format_ikev2_auth_method (u8 * s, va_list * args);
361 u8 * format_ikev2_id_type (u8 * s, va_list * args);
362 u8 * format_ikev2_transform_type (u8 * s, va_list * args);
363 u8 * format_ikev2_notify_msg_type (u8 * s, va_list * args);
364 u8 * format_ikev2_transform_encr_type(u8 * s, va_list * args);
365 u8 * format_ikev2_transform_prf_type(u8 * s, va_list * args);
366 u8 * format_ikev2_transform_integ_type(u8 * s, va_list * args);
367 u8 * format_ikev2_transform_dh_type(u8 * s, va_list * args);
368 u8 * format_ikev2_transform_esn_type(u8 * s, va_list * args);
369 u8 * format_ikev2_sa_transform(u8 * s, va_list * args);
370 
371 uword unformat_ikev2_auth_method (unformat_input_t * input, va_list * args);
372 uword unformat_ikev2_id_type (unformat_input_t * input, va_list * args);
373 uword unformat_ikev2_transform_type (unformat_input_t * input, va_list * args);
379 
380 #endif /* __included_ikev2_h__ */
381 
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
Definition: ikev2.c:2016
ikev2_transform_integ_type_t
Definition: ikev2.h:257
#define foreach_ikev2_transform_esn_type
Definition: ikev2.h:312
uword unformat_ikev2_transform_encr_type(unformat_input_t *input, va_list *args)
ikev2_auth_method_t
Definition: ikev2.h:326
u8 * format_ikev2_auth_method(u8 *s, va_list *args)
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip4_address_t start_addr, ip4_address_t end_addr, int is_local)
Definition: ikev2.c:2053
u8 v8
Definition: ikev2.h:27
u8 * format_ikev2_sa_transform(u8 *s, va_list *args)
Definition: ikev2_format.c:24
uword unformat_ikev2_id_type(unformat_input_t *input, va_list *args)
uword unformat_ikev2_transform_prf_type(unformat_input_t *input, va_list *args)
#define foreach_ikev2_transform_integ_type
Definition: ikev2.h:240
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
Definition: ikev2.c:1956
ikev2_transform_dh_type_t
Definition: ikev2.h:306
uword unformat_ikev2_transform_dh_type(unformat_input_t *input, va_list *args)
unsigned long u64
Definition: types.h:89
ikev2_notify_msg_type_t
Definition: ikev2.h:182
#define foreach_ikev2_transform_type
Definition: ikev2.h:188
u8 * format_ikev2_transform_prf_type(u8 *s, va_list *args)
ikev2_protocol_id_t
Definition: ikev2.h:102
u8 * format_ikev2_notify_msg_type(u8 *s, va_list *args)
typedef CLIB_PACKED(struct{u64 ispi;u64 rspi;u8 nextpayload;u8 version;u8 exchange;u8 flags;u32 msgid;u32 length;u8 payload[0];}) ike_header_t
ikev2_transform_encr_type_t
Definition: ikev2.h:218
#define foreach_ikev2_transform_prf_type
Definition: ikev2.h:224
u8 * format_ikev2_transform_encr_type(u8 *s, va_list *args)
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
Definition: ikev2.c:1944
unsigned int u32
Definition: types.h:88
u8 * format_ikev2_transform_type(u8 *s, va_list *args)
ikev2_id_type_t
Definition: ikev2.h:341
ikev2_transform_esn_type_t
Definition: ikev2.h:316
uword unformat_ikev2_transform_integ_type(unformat_input_t *input, va_list *args)
clib_error_t * ikev2_init(vlib_main_t *vm)
Definition: ikev2.c:2091
u8 * format_ikev2_transform_dh_type(u8 *s, va_list *args)
u64 uword
Definition: types.h:112
u8 * format_ikev2_transform_integ_type(u8 *s, va_list *args)
#define foreach_ikev2_id_type
Definition: ikev2.h:332
unsigned short u16
Definition: types.h:57
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *data, u8 data_hex_format)
Definition: ikev2.c:1986
#define foreach_ikev2_transform_encr_type
Definition: ikev2.h:204
unsigned char u8
Definition: types.h:56
u8 * format_ikev2_transform_esn_type(u8 *s, va_list *args)
uword unformat_ikev2_auth_method(unformat_input_t *input, va_list *args)
ikev2_transform_prf_type_t
Definition: ikev2.h:234
uword unformat_ikev2_transform_type(unformat_input_t *input, va_list *args)
struct _unformat_input_t unformat_input_t
ikev2_transform_type_t
Definition: ikev2.h:196
#define foreach_ikev2_notify_msg_type
Definition: ikev2.h:108
u32 flags
Definition: vhost-user.h:73
#define foreach_ikev2_transform_dh_type
Definition: ikev2.h:287
uword unformat_ikev2_transform_esn_type(unformat_input_t *input, va_list *args)
u8 * format_ikev2_id_type(u8 *s, va_list *args)
#define foreach_ikev2_auth_method
Definition: ikev2.h:322