summaryrefslogtreecommitdiff
path: root/Core/NetworkPkg/IpSecDxe/Ikev2/Payload.h
blob: 7a85792ed7fe567a52ecfdbe07111b395f999e65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
/** @file
  The Definitions related to IKEv2 payload.

  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/
#ifndef _IKE_V2_PAYLOAD_H_
#define _IKE_V2_PAYLOAD_H_

//
// Payload Type for IKEv2
//
#define IKEV2_PAYLOAD_TYPE_NONE     0
#define IKEV2_PAYLOAD_TYPE_SA       33
#define IKEV2_PAYLOAD_TYPE_KE       34
#define IKEV2_PAYLOAD_TYPE_ID_INIT  35
#define IKEV2_PAYLOAD_TYPE_ID_RSP   36
#define IKEV2_PAYLOAD_TYPE_CERT     37
#define IKEV2_PAYLOAD_TYPE_CERTREQ  38
#define IKEV2_PAYLOAD_TYPE_AUTH     39
#define IKEV2_PAYLOAD_TYPE_NONCE    40
#define IKEV2_PAYLOAD_TYPE_NOTIFY   41
#define IKEV2_PAYLOAD_TYPE_DELETE   42
#define IKEV2_PAYLOAD_TYPE_VENDOR   43
#define IKEV2_PAYLOAD_TYPE_TS_INIT  44
#define IKEV2_PAYLOAD_TYPE_TS_RSP   45
#define IKEV2_PAYLOAD_TYPE_ENCRYPT  46
#define IKEV2_PAYLOAD_TYPE_CP       47
#define IKEV2_PAYLOAD_TYPE_EAP      48

//
// IKE header Flag (1 octet) for IKEv2, defined in RFC 4306 section 3.1 
//
// I(nitiator) (bit 3 of Flags, 0x08) - This bit MUST be set in messages sent by the 
//                                      original initiator of the IKE_SA
//
// R(esponse) (bit 5 of Flags, 0x20)  - This bit indicates that this message is a response to 
//                                      a message containing the same message ID.
//
#define IKE_HEADER_FLAGS_INIT       0x08
#define IKE_HEADER_FLAGS_RESPOND    0x20

//
// IKE Header Exchange Type for IKEv2
//
#define IKEV2_EXCHANGE_TYPE_INIT         34
#define IKEV2_EXCHANGE_TYPE_AUTH         35
#define IKEV2_EXCHANGE_TYPE_CREATE_CHILD 36
#define IKEV2_EXCHANGE_TYPE_INFO         37

#pragma pack(1)
typedef struct {
  UINT8   NextPayload;
  UINT8   Reserved;
  UINT16  PayloadLength;
} IKEV2_COMMON_PAYLOAD_HEADER;
#pragma pack()

#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  // 
  // Proposals
  //
} IKEV2_SA;
#pragma pack()

#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       ProposalIndex;
  UINT8                       ProtocolId;
  UINT8                       SpiSize;
  UINT8                       NumTransforms;
} IKEV2_PROPOSAL;
#pragma pack()

//
// IKEv2 Transform Type Values presented within Transform Payload
//
#define IKEV2_TRANSFORM_TYPE_ENCR      1  // Encryption Algorithm
#define IKEV2_TRANSFORM_TYPE_PRF       2  // Pseduo-Random Func
#define IKEV2_TRANSFORM_TYPE_INTEG     3  // Integrity Algorithm
#define IKEV2_TRANSFORM_TYPE_DH        4  // DH Group
#define IKEV2_TRANSFORM_TYPE_ESN       5  // Extended Sequence Number

//
// IKEv2 Transform ID for Encrypt Algorithm (ENCR)
// 
#define IKEV2_TRANSFORM_ID_ENCR_DES_IV64 1
#define IKEV2_TRANSFORM_ID_ENCR_DES      2
#define IKEV2_TRANSFORM_ID_ENCR_3DES     3
#define IKEV2_TRANSFORM_ID_ENCR_RC5      4
#define IKEV2_TRANSFORM_ID_ENCR_IDEA     5
#define IKEV2_TRANSFORM_ID_ENCR_CAST     6
#define IKEV2_TRANSFORM_ID_ENCR_BLOWFISH 7
#define IKEV2_TRANSFORM_ID_ENCR_3IDEA    8
#define IKEV2_TRANSFORM_ID_ENCR_DES_IV32 9
#define IKEV2_TRANSFORM_ID_ENCR_NULL     11
#define IKEV2_TRANSFORM_ID_ENCR_AES_CBC  12
#define IKEV2_TRANSFORM_ID_ENCR_AES_CTR  13

//
// IKEv2 Transform ID for Pseudo-Random Function (PRF)
//
#define IKEV2_TRANSFORM_ID_PRF_HMAC_MD5     1
#define IKEV2_TRANSFORM_ID_PRF_HMAC_SHA1    2
#define IKEV2_TRANSFORM_ID_PRF_HMAC_TIGER   3
#define IKEV2_TRANSFORM_ID_PRF_AES128_XCBC  4

//
// IKEv2 Transform ID for Integrity Algorithm (INTEG)
//
#define IKEV2_TRANSFORM_ID_AUTH_NONE              0
#define IKEV2_TRANSFORM_ID_AUTH_HMAC_MD5_96       1
#define IKEV2_TRANSFORM_ID_AUTH_HMAC_SHA1_96      2
#define IKEV2_TRANSFORM_ID_AUTH_HMAC_DES_MAC      3
#define IKEV2_TRANSFORM_ID_AUTH_HMAC_KPDK_MD5     4
#define IKEV2_TRANSFORM_ID_AUTH_HMAC_AES_XCBC_96  5

//
// IKEv2 Transform ID for Diffie-Hellman Group (DH)
//
#define IKEV2_TRANSFORM_ID_DH_768MODP             1
#define IKEV2_TRANSFORM_ID_DH_1024MODP            2
#define IKEV2_TRANSFORM_ID_DH_2048MODP            14

//
// IKEv2 Attribute Type Values
//
#define IKEV2_ATTRIBUTE_TYPE_KEYLEN               14

//
// Transform Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       TransformType;
  UINT8                       Reserved;
  UINT16                      TransformId;
  //
  // SA Attributes
  //
} IKEV2_TRANSFORM;
#pragma pack()

#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT16                      DhGroup;
  UINT16                      Reserved;
  //
  // Remaining part contains the key exchanged
  //
} IKEV2_KEY_EXCHANGE;
#pragma pack()

//
// Identification Type Values presented within Ikev2 ID payload
//
#define IKEV2_ID_TYPE_IPV4_ADDR        1
#define IKEV2_ID_TYPE_FQDN             2
#define IKEV2_ID_TYPE_RFC822_ADDR      3
#define IKEV2_ID_TYPE_IPV6_ADDR        5
#define IKEV2_ID_TYPE_DER_ASN1_DN      9
#define IKEV2_ID_TYPE_DER_ASN1_GN      10
#define IKEV2_ID_TYPE_KEY_ID           11

//
// Identification Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       IdType;
  UINT8                       Reserver1;
  UINT16                      Reserver2;
  //
  // Identification Data
  //
} IKEV2_ID;
#pragma pack()

//
// Encoding Type presented in IKEV2 Cert Payload
//
#define IKEV2_CERT_ENCODEING_RESERVED                  0
#define IKEV2_CERT_ENCODEING_X509_CERT_WRAP            1
#define IKEV2_CERT_ENCODEING_PGP_CERT                  2
#define IKEV2_CERT_ENCODEING_DNS_SIGN_KEY              3
#define IKEV2_CERT_ENCODEING_X509_CERT_SIGN            4
#define IKEV2_CERT_ENCODEING_KERBEROS_TOKEN            6
#define IKEV2_CERT_ENCODEING_REVOCATION_LIST_CERT      7
#define IKEV2_CERT_ENCODEING_AUTH_REVOCATION_LIST      8
#define IKEV2_CERT_ENCODEING_SPKI_CERT                 9
#define IKEV2_CERT_ENCODEING_X509_CERT_ATTRIBUTE       10
#define IKEV2_CERT_ENCODEING_RAW_RSA_KEY               11
#define IKEV2_CERT_ENCODEING_HASH_AND_URL_OF_X509_CERT 12

//
// IKEV2 Certificate Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       CertEncoding;
  //
  // Cert Data
  //
} IKEV2_CERT;
#pragma pack()

//
// IKEV2 Certificate Request Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       CertEncoding;
  //
  // Cert Authority
  //
} IKEV2_CERT_REQ;
#pragma pack()

//
// Authentication Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       AuthMethod;
  UINT8                       Reserved1;
  UINT16                      Reserved2;
  //
  // Auth Data
  //
} IKEV2_AUTH;
#pragma pack()

//
// Authmethod in Authentication Payload
//
#define IKEV2_AUTH_METHOD_RSA        1; // RSA Digital Signature
#define IKEV2_AUTH_METHOD_SKMI       2; // Shared Key Message Integrity
#define IKEV2_AUTH_METHOD_DSS        3; // DSS Digital Signature

//
// IKEv2 Nonce Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  //
  // Nonce Data
  //
} IKEV2_NONCE;
#pragma pack()

//
// Notification Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       ProtocolId;
  UINT8                       SpiSize;
  UINT16                      MessageType;
  //
  // SPI and Notification Data
  //
} IKEV2_NOTIFY;
#pragma pack()

//
//  Notify Message Types presented within IKEv2 Notify Payload
//
#define IKEV2_NOTIFICATION_UNSUPPORT_CRITICAL_PAYLOAD       1
#define IKEV2_NOTIFICATION_INVALID_IKE_SPI                  4
#define IKEV2_NOTIFICATION_INVALID_MAJOR_VERSION            5
#define IKEV2_NOTIFICATION_INVALID_SYNTAX                   7
#define IKEV2_NOTIFICATION_INVALID_MESSAGE_ID               9
#define IKEV2_NOTIFICATION_INVALID_SPI                     11
#define IKEV2_NOTIFICATION_NO_PROPOSAL_CHOSEN              14
#define IKEV2_NOTIFICATION_INVALID_KEY_PAYLOAD             17
#define IKEV2_NOTIFICATION_AUTHENTICATION_FAILED           24
#define IKEV2_NOTIFICATION_SINGLE_PAIR_REQUIRED            34
#define IKEV2_NOTIFICATION_NO_ADDITIONAL_SAS               35
#define IKEV2_NOTIFICATION_INTERNAL_ADDRESS_FAILURE        36
#define IKEV2_NOTIFICATION_FAILED_CP_REQUIRED              37
#define IKEV2_NOTIFICATION_TS_UNCCEPTABLE                  38
#define IKEV2_NOTIFICATION_INVALID_SELECTORS               39
#define IKEV2_NOTIFICATION_COOKIE                          16390
#define IKEV2_NOTIFICATION_USE_TRANSPORT_MODE              16391
#define IKEV2_NOTIFICATION_REKEY_SA                        16393

//
// IKEv2 Protocol ID
//
//
// IKEv2 Delete Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       ProtocolId;
  UINT8                       SpiSize;
  UINT16                      NumSpis;
  //
  // SPIs
  //
} IKEV2_DELETE;
#pragma pack()

//
// Traffic Selector Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       TSNumbers;
  UINT8                       Reserved1;
  UINT16                      Reserved2;
  //
  // Traffic Selector
  //
} IKEV2_TS;
#pragma pack()

//
// Traffic Selector
//
#pragma pack(1)
typedef struct {
  UINT8                       TSType;
  UINT8                       IpProtocolId;
  UINT16                      SelecorLen;
  UINT16                      StartPort;
  UINT16                      EndPort;
  //
  // Starting Address && Ending Address
  //
} TRAFFIC_SELECTOR;
#pragma pack()

//
// Ts Type in Traffic Selector
//
#define IKEV2_TS_TYPE_IPV4_ADDR_RANGE     7
#define IKEV2_TS_TYPS_IPV6_ADDR_RANGE     8

//
// Vendor Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  //
  // Vendor ID
  //
} IKEV2_VENDOR;
#pragma pack()

//
// Encrypted Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  //
  // IV, Encrypted IKE Payloads, Padding, PAD length, Integrity CheckSum
  //
} IKEV2_ENCRYPTED;
#pragma pack()

#pragma pack(1)
typedef struct {
  UINT8 PadLength;
} IKEV2_PAD_LEN;
#pragma pack()

//
// Configuration Payload
//
#pragma pack(1)
typedef struct {
  IKEV2_COMMON_PAYLOAD_HEADER Header;
  UINT8                       CfgType;
  UINT8                       Reserve1;
  UINT16                      Reserve2;
  //
  // Configuration Attributes
  //
} IKEV2_CFG;
#pragma pack()

//
// Configuration Payload CPG type
//
#define IKEV2_CFG_TYPE_REQUEST    1
#define IKEV2_CFG_TYPE_REPLY      2
#define IKEV2_CFG_TYPE_SET        3
#define IKEV2_CFG_TYPE_ACK        4

//
// Configuration Attributes
//
#pragma pack(1)
typedef struct {
  UINT16    AttritType;
  UINT16    ValueLength;
} IKEV2_CFG_ATTRIBUTES;
#pragma pack()

//
// Configuration Attributes
//
#define IKEV2_CFG_ATTR_INTERNAL_IP4_ADDRESS      1
#define IKEV2_CFG_ATTR_INTERNAL_IP4_NBTMASK      2
#define IKEV2_CFG_ATTR_INTERNAL_IP4_DNS          3
#define IKEV2_CFG_ATTR_INTERNAL_IP4_NBNS         4
#define IKEV2_CFG_ATTR_INTERNA_ADDRESS_BXPIRY    5
#define IKEV2_CFG_ATTR_INTERNAL_IP4_DHCP         6
#define IKEV2_CFG_ATTR_APPLICATION_VERSION       7
#define IKEV2_CFG_ATTR_INTERNAL_IP6_ADDRESS      8
#define IKEV2_CFG_ATTR_INTERNAL_IP6_DNS          10
#define IKEV2_CFG_ATTR_INTERNAL_IP6_NBNS         11
#define IKEV2_CFG_ATTR_INTERNAL_IP6_DHCP         12
#define IKEV2_CFG_ATTR_INTERNAL_IP4_SUBNET       13
#define IKEV2_CFG_ATTR_SUPPORTED_ATTRIBUTES      14
#define IKEV2_CFG_ATTR_IP6_SUBNET                15

#endif