ipsec.h
Go to the documentation of this file.
1 /**
2  * @file ipsec.h
3  * @brief IPsec (IP security)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneIPSEC Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _IPSEC_H
32 #define _IPSEC_H
33 
34 //Forward declaration of IpsecSadEntry structure
35 struct _IpsecSadEntry;
36 #define IpsecSadEntry struct _IpsecSadEntry
37 
38 //Dependencies
39 #include "ipsec_config.h"
40 #include "core/net.h"
41 #include "core/udp.h"
42 #include "core/tcp.h"
43 #include "ipv4/icmp.h"
44 #include "core/crypto.h"
45 #include "ah/ah.h"
46 #include "esp/esp.h"
49 #include "hash/hash_algorithms.h"
50 #include "mac/mac_algorithms.h"
51 
52 
53 /*
54  * CycloneIPSEC Open is licensed under GPL version 2. In particular:
55  *
56  * - If you link your program to CycloneIPSEC Open, the result is a derivative
57  * work that can only be distributed under the same GPL license terms.
58  *
59  * - If additions or changes to CycloneIPSEC Open are made, the result is a
60  * derivative work that can only be distributed under the same license terms.
61  *
62  * - The GPL license requires that you make the source code available to
63  * whoever you make the binary available to.
64  *
65  * - If you sell or distribute a hardware product that runs CycloneIPSEC Open,
66  * the GPL license requires you to provide public and full access to all
67  * source code on a nondiscriminatory basis.
68  *
69  * If you fully understand and accept the terms of the GPL license, then edit
70  * the os_port_config.h header and add the following directive:
71  *
72  * #define GPL_LICENSE_TERMS_ACCEPTED
73  */
74 
75 #ifndef GPL_LICENSE_TERMS_ACCEPTED
76  #error Before compiling CycloneIPSEC Open, you must accept the terms of the GPL license
77 #endif
78 
79 //Version string
80 #define CYCLONE_IPSEC_VERSION_STRING "2.4.4"
81 //Major version
82 #define CYCLONE_IPSEC_MAJOR_VERSION 2
83 //Minor version
84 #define CYCLONE_IPSEC_MINOR_VERSION 4
85 //Revision number
86 #define CYCLONE_IPSEC_REV_NUMBER 4
87 
88 //IPsec support
89 #ifndef IPSEC_SUPPORT
90  #define IPSEC_SUPPORT ENABLED
91 #elif (IPSEC_SUPPORT != ENABLED && IPSEC_SUPPORT != DISABLED)
92  #error IPSEC_SUPPORT parameter is not valid
93 #endif
94 
95 //Anti-replay mechanism
96 #ifndef IPSEC_ANTI_REPLAY_SUPPORT
97  #define IPSEC_ANTI_REPLAY_SUPPORT ENABLED
98 #elif (IPSEC_ANTI_REPLAY_SUPPORT != ENABLED && IPSEC_ANTI_REPLAY_SUPPORT != DISABLED)
99  #error IPSEC_ANTI_REPLAY_SUPPORT parameter is not valid
100 #endif
101 
102 //Size of the sliding window for replay protection
103 #ifndef IPSEC_ANTI_REPLAY_WINDOW_SIZE
104  #define IPSEC_ANTI_REPLAY_WINDOW_SIZE 64
105 #elif (IPSEC_ANTI_REPLAY_WINDOW_SIZE < 1)
106  #error IPSEC_ANTI_REPLAY_WINDOW_SIZE parameter is not valid
107 #endif
108 
109 //Maximum length of ID
110 #ifndef IPSEC_MAX_ID_LEN
111  #define IPSEC_MAX_ID_LEN 64
112 #elif (IPSEC_MAX_ID_LEN < 0)
113  #error IPSEC_MAX_ID_LEN is not valid
114 #endif
115 
116 //Maximum length of pre-shared keys
117 #ifndef IPSEC_MAX_PSK_LEN
118  #define IPSEC_MAX_PSK_LEN 64
119 #elif (IPSEC_MAX_PSK_LEN < 0)
120  #error IPSEC_MAX_PSK_LEN is not valid
121 #endif
122 
123 //Maximum length of encryption keys
124 #ifndef IPSEC_MAX_ENC_KEY_LEN
125  #define IPSEC_MAX_ENC_KEY_LEN 36
126 #elif (IPSEC_MAX_ENC_KEY_LEN < 1)
127  #error IPSEC_MAX_ENC_KEY_LEN parameter is not valid
128 #endif
129 
130 //Maximum length of integrity protection keys
131 #ifndef IPSEC_MAX_AUTH_KEY_LEN
132  #define IPSEC_MAX_AUTH_KEY_LEN 64
133 #elif (IPSEC_MAX_AUTH_KEY_LEN < 1)
134  #error IPSEC_MAX_AUTH_KEY_LEN parameter is not valid
135 #endif
136 
137 //Size of SPI for AH and ESP protocols
138 #define IPSEC_SPI_SIZE 4
139 
140 //ANY protocol selector
141 #define IPSEC_PROTOCOL_ANY 0
142 
143 //ANY port selector
144 #define IPSEC_PORT_START_ANY 0
145 #define IPSEC_PORT_END_ANY 65535
146 
147 //OPAQUE port selector
148 #define IPSEC_PORT_START_OPAQUE 65535
149 #define IPSEC_PORT_END_OPAQUE 0
150 
151 //ICMP port selector
152 #define IPSEC_ICMP_PORT(type, code) (((type) * 256) + (code))
153 
154 //C++ guard
155 #ifdef __cplusplus
156 extern "C" {
157 #endif
158 
159 
160 /**
161  * @brief Direction
162  **/
163 
164 typedef enum
165 {
170 
171 
172 /**
173  * @brief Authentication methods
174  **/
175 
176 typedef enum
177 {
183 
184 
185 /**
186  * @brief Security protocols
187  **/
188 
189 typedef enum
190 {
195 
196 
197 /**
198  * @brief IPsec protocol modes
199  **/
200 
201 typedef enum
202 {
207 
208 
209 /**
210  * @brief ID types
211  **/
212 
213 typedef enum
214 {
215  IPSEC_ID_TYPE_IPV4_ADDR = 1, ///<IPv4 address
216  IPSEC_ID_TYPE_FQDN = 2, ///<Fully-qualified domain name
217  IPSEC_ID_TYPE_RFC822_ADDR = 3, ///<RFC 822 email address
218  IPSEC_ID_TYPE_IPV6_ADDR = 5, ///<IPv6 address
219  IPSEC_ID_TYPE_DN = 9, ///<X.500 distinguished name
220  IPSEC_ID_TYPE_KEY_ID = 11 ///<Key ID
222 
223 
224 /**
225  * @brief Policy action
226  **/
227 
228 typedef enum
229 {
235 
236 
237 /**
238  * @brief PFP flags
239  **/
240 
241 typedef enum
242 {
249 
250 
251 /**
252  * @brief DF flag policy
253  **/
254 
255 typedef enum
256 {
261 
262 
263 /**
264  * @brief IPsec SAD entry state
265  **/
266 
267 typedef enum
268 {
273 
274 
275 /**
276  * @brief IP address range
277  **/
278 
279 typedef struct
280 {
284 
285 
286 /**
287  * @brief Port range
288  **/
289 
290 typedef struct
291 {
292  uint16_t start;
293  uint16_t end;
295 
296 
297 /**
298  * @brief IPsec selector
299  **/
300 
301 typedef struct
302 {
303  IpsecAddrRange localIpAddr; ///<Local IP address range
304  IpsecAddrRange remoteIpAddr; ///<Remote IP address range
305  uint8_t nextProtocol; ///<Next layer protocol
306  IpsecPortRange localPort; ///<Local port range
307  IpsecPortRange remotePort; ///<Remote port range
308 } IpsecSelector;
309 
310 
311 /**
312  * @brief IP packet information
313  **/
314 
315 typedef struct
316 {
317  IpAddr localIpAddr; ///<Local IP address
318  IpAddr remoteIpAddr; ///<Remote IP address
319  uint8_t nextProtocol; ///<Next layer protocol
320  uint16_t localPort; ///<Local port
321  uint16_t remotePort; ///<Remote port
323 
324 
325 /**
326  * @brief IPsec ID
327  **/
328 
329 typedef union
330 {
331  char_t fqdn[IPSEC_MAX_ID_LEN + 1]; ///<Fully-qualified domain name
332  char_t email[IPSEC_MAX_ID_LEN + 1]; ///<RFC 822 email address
333  uint8_t dn[IPSEC_MAX_ID_LEN]; ///<X.500 Distinguished Name
334  uint8_t keyId[IPSEC_MAX_ID_LEN]; ///<Key ID
335  IpsecAddrRange ipAddr; ///<IPv4 or IPv6 address range
336 } IpsecId;
337 
338 
339 /**
340  * @brief Security Policy Database (SPD) entry
341  **/
342 
343 typedef struct
344 {
345  IpsecPolicyAction policyAction; ///<Processing choice (DISCARD, BYPASS or PROTECT)
346  uint_t pfpFlags; ///<PFP flags
347  IpsecSelector selector; ///<Traffic selector
348  IpsecMode mode; ///<IPsec mode (tunnel or transport)
349  IpsecProtocol protocol; ///<Security protocol (AH or ESP)
350  bool_t esn; ///<Extended sequence numbers
351  IpAddr localTunnelAddr; ///<Local tunnel IP address
352  IpAddr remoteTunnelAddr; ///<Remote tunnel IP address
353 } IpsecSpdEntry;
354 
355 
356 /**
357  * @brief Security Association Database (SAD) entry
358  **/
359 
361 {
362  IpsecSaState state; ///<SAD entry state
363  IpsecDirection direction; ///<Direction
364  IpsecMode mode; ///<IPsec mode (tunnel or transport)
365  IpsecProtocol protocol; ///<Security protocol (AH or ESP)
366  IpsecSelector selector; ///<Traffic selector
367  IpsecDfPolicy dfPolicy; ///<DF flag policy
368  uint32_t spi; ///<Security parameter index
369 #if (ESP_SUPPORT == ENABLED)
370  CipherMode cipherMode; ///<Cipher mode of operation
371  const CipherAlgo *cipherAlgo; ///<Cipher algorithm
372  CipherContext cipherContext; ///<Cipher context
373  uint8_t encKey[IPSEC_MAX_ENC_KEY_LEN]; ///<Encryption key
374  size_t encKeyLen; ///<Length of the encryption key, in bytes
375  size_t saltLen; ///<Length of the salt, in bytes
376  uint8_t iv[16]; ///<Initialization vector
377  size_t ivLen; ///<Length of the initialization vector, in bytes
378 #endif
379  const HashAlgo *authHashAlgo; ///<Hash algorithm for HMAC-based integrity calculations
380  const CipherAlgo *authCipherAlgo; ///<Cipher algorithm for CMAC-based integrity calculations
381  uint8_t authKey[IPSEC_MAX_AUTH_KEY_LEN]; ///<Integrity protection key
382  size_t authKeyLen; ///<Length of the integrity protection key, in bytes
383  size_t icvLen; ///<Length of the ICV tag, in bytes
384  bool_t esn; ///<Extended sequence numbers
385  uint64_t seqNum; ///<Sequence number counter
386  systime_t lifetimeStart; ///<Timestamp
387 #if (IPSEC_ANTI_REPLAY_SUPPORT == ENABLED)
388  bool_t antiReplayEnabled; ///<Anti-replay mechanism enabled
389  uint32_t antiReplayWindow[(IPSEC_ANTI_REPLAY_WINDOW_SIZE + 31) / 32]; ///<Anti-replay window
390 #endif
391  IpAddr tunnelDestIpAddr; ///<Tunnel header IP destination address
392 };
393 
394 
395 /**
396  * @brief Peer Authorization Database (PAD) entry
397  **/
398 
399 typedef struct
400 {
401  IpsecAuthMethod authMethod; ///<Authentication method (IKEv1, IKEv2, KINK)
402  IpsecIdType idType; ///<ID type
403  IpsecId id; ///<ID
404  size_t idLen; ///<Length of the ID, in bytes
405  uint8_t psk[IPSEC_MAX_PSK_LEN]; ///<Pre-shared key
406  size_t pskLen; ///<Length of the pre-shared key, in bytes
407  const char_t *trustedCaList; ///Trusted CA list (PEM format)
408  size_t trustedCaListLen; ///<Total length of the trusted CA list
409 } IpsecPadEntry;
410 
411 
412 /**
413  * @brief IPsec settings
414  **/
415 
416 typedef struct
417 {
418  const PrngAlgo *prngAlgo; ///<Pseudo-random number generator to be used
419  void *prngContext; ///<Pseudo-random number generator context
420  IpsecSpdEntry *spdEntries; ///<Security Policy Database (SPD)
421  uint_t numSpdEntries; ///<Number of entries in the SPD database
422  IpsecSadEntry *sadEntries; ///<Security Association Database (SAD)
423  uint_t numSadEntries; ///<Number of entries in the SAD database
424  IpsecPadEntry *padEntries; ///<Peer Authorization Database (PAD)
425  uint_t numPadEntries; ///<Number of entries in the PAD database
426 } IpsecSettings;
427 
428 
429 /**
430  * @brief IPsec context
431  **/
432 
433 typedef struct
434 {
435  const PrngAlgo *prngAlgo; ///<Pseudo-random number generator to be used
436  void *prngContext; ///<Pseudo-random number generator context
437  IpsecSpdEntry *spd; ///<Security Policy Database (SPD)
438  uint_t numSpdEntries; ///<Number of entries in the SPD database
439  IpsecSadEntry *sad; ///<Security Association Database (SAD)
440  uint_t numSadEntries; ///<Number of entries in the SAD database
441  IpsecPadEntry *pad; ///<Peer Authorization Database (PAD)
442  uint_t numPadEntries; ///<Number of entries in the PAD database
443 #if (AH_CMAC_SUPPORT == ENABLED || ESP_CMAC_SUPPORT == ENABLED)
444  CmacContext cmacContext; ///<CMAC context
445 #endif
446 #if (AH_HMAC_SUPPORT == ENABLED || ESP_HMAC_SUPPORT == ENABLED)
447  HmacContext hmacContext; ///<HMAC context
448 #endif
449 #if (ESP_SUPPORT == ENABLED)
450  uint8_t buffer[ESP_BUFFER_SIZE]; ///<Memory buffer for input/output operations
451 #endif
452 } IpsecContext;
453 
454 
455 //IPsec related functions
456 void ipsecGetDefaultSettings(IpsecSettings *settings);
457 
458 error_t ipsecInit(IpsecContext *context, const IpsecSettings *settings);
459 
461  IpsecSpdEntry *params);
462 
464 
466  IpsecSadEntry *params);
467 
469 
471  IpsecPadEntry *params);
472 
474 
475 //C++ guard
476 #ifdef __cplusplus
477 }
478 #endif
479 
480 #endif
IpsecSadEntry * sad
Security Association Database (SAD)
Definition: ipsec.h:439
IpsecAddrRange ipAddr
IPv4 or IPv6 address range.
Definition: ipsec.h:335
@ IPSEC_ID_TYPE_KEY_ID
Key ID.
Definition: ipsec.h:220
@ IPSEC_DIR_INVALID
Definition: ipsec.h:166
IpsecMode
IPsec protocol modes.
Definition: ipsec.h:202
int bool_t
Definition: compiler_port.h:53
HMAC algorithm context.
Definition: hmac.h:59
uint_t numSadEntries
Number of entries in the SAD database.
Definition: ipsec.h:423
size_t icvLen
Length of the ICV tag, in bytes.
Definition: ipsec.h:383
uint16_t end
Definition: ipsec.h:293
@ IPSEC_SA_STATE_CLOSED
Definition: ipsec.h:269
@ IPSEC_ID_TYPE_IPV4_ADDR
IPv4 address.
Definition: ipsec.h:215
uint_t numPadEntries
Number of entries in the PAD database.
Definition: ipsec.h:442
@ IPSEC_DIR_INBOUND
Definition: ipsec.h:167
@ IPSEC_PROTOCOL_AH
Definition: ipsec.h:192
@ IPSEC_AUTH_METHOD_KINK
Definition: ipsec.h:181
uint32_t spi
Security parameter index.
Definition: ipsec.h:368
IPsec selector.
Definition: ipsec.h:302
IP network address.
Definition: ip.h:90
#define PrngAlgo
Definition: crypto.h:938
IpsecSelector selector
Traffic selector.
Definition: ipsec.h:366
void * prngContext
Pseudo-random number generator context.
Definition: ipsec.h:419
IpsecDirection
Direction.
Definition: ipsec.h:165
const CipherAlgo * authCipherAlgo
Cipher algorithm for CMAC-based integrity calculations.
Definition: ipsec.h:380
IpsecIdType
ID types.
Definition: ipsec.h:214
Collection of AEAD algorithms.
IpAddr remoteIpAddr
Remote IP address.
Definition: ipsec.h:318
Generic cipher algorithm context.
bool_t antiReplayEnabled
Anti-replay mechanism enabled.
Definition: ipsec.h:388
IpAddr end
Definition: ipsec.h:282
size_t pskLen
Length of the pre-shared key, in bytes.
Definition: ipsec.h:406
@ IPSEC_PFP_FLAG_REMOTE_ADDR
Definition: ipsec.h:244
#define IPSEC_MAX_ENC_KEY_LEN
Definition: ipsec.h:125
IpsecId id
ID.
Definition: ipsec.h:403
#define IPSEC_ANTI_REPLAY_WINDOW_SIZE
Definition: ipsec.h:104
systime_t lifetimeStart
Timestamp.
Definition: ipsec.h:386
#define ESP_BUFFER_SIZE
Definition: esp.h:228
@ IPSEC_PFP_FLAG_LOCAL_ADDR
Definition: ipsec.h:243
uint8_t authKey[IPSEC_MAX_AUTH_KEY_LEN]
Integrity protection key.
Definition: ipsec.h:381
@ IPSEC_MODE_TUNNEL
Definition: ipsec.h:204
uint_t numSadEntries
Number of entries in the SAD database.
Definition: ipsec.h:440
#define IPSEC_MAX_AUTH_KEY_LEN
Definition: ipsec.h:132
@ IPSEC_POLICY_ACTION_PROTECT
Definition: ipsec.h:233
@ IPSEC_ID_TYPE_RFC822_ADDR
RFC 822 email address.
Definition: ipsec.h:217
@ IPSEC_PROTOCOL_ESP
Definition: ipsec.h:193
@ IPSEC_DIR_OUTBOUND
Definition: ipsec.h:168
Peer Authorization Database (PAD) entry.
Definition: ipsec.h:400
uint16_t remotePort
Remote port.
Definition: ipsec.h:321
bool_t esn
Extended sequence numbers.
Definition: ipsec.h:384
ESP (IP Encapsulating Security Payload)
uint64_t seqNum
Sequence number counter.
Definition: ipsec.h:385
IpsecSadEntry * sadEntries
Security Association Database (SAD)
Definition: ipsec.h:422
IpAddr localTunnelAddr
Local tunnel IP address.
Definition: ipsec.h:351
IpsecSpdEntry * spd
Security Policy Database (SPD)
Definition: ipsec.h:437
ICMP (Internet Control Message Protocol)
IpsecAuthMethod authMethod
Authentication method (IKEv1, IKEv2, KINK)
Definition: ipsec.h:401
uint8_t nextProtocol
Next layer protocol.
Definition: ipsec.h:319
uint8_t nextProtocol
Next layer protocol.
Definition: ipsec.h:305
uint16_t localPort
Local port.
Definition: ipsec.h:320
@ IPSEC_MODE_TRANSPORT
Definition: ipsec.h:205
@ IPSEC_DF_POLICY_COPY
Definition: ipsec.h:259
error_t
Error codes.
Definition: error.h:43
@ IPSEC_ID_TYPE_FQDN
Fully-qualified domain name.
Definition: ipsec.h:216
IpsecPolicyAction
Policy action.
Definition: ipsec.h:229
uint8_t encKey[IPSEC_MAX_ENC_KEY_LEN]
Encryption key.
Definition: ipsec.h:373
IpsecPolicyAction policyAction
Processing choice (DISCARD, BYPASS or PROTECT)
Definition: ipsec.h:345
@ IPSEC_PFP_FLAG_REMOTE_PORT
Definition: ipsec.h:247
IpsecPortRange remotePort
Remote port range.
Definition: ipsec.h:307
@ IPSEC_POLICY_ACTION_DISCARD
Definition: ipsec.h:231
IpsecPadEntry * pad
Peer Authorization Database (PAD)
Definition: ipsec.h:441
IpsecProtocol protocol
Security protocol (AH or ESP)
Definition: ipsec.h:349
@ IPSEC_AUTH_METHOD_IKEV1
Definition: ipsec.h:179
Security Association Database (SAD) entry.
Definition: ipsec.h:361
@ IPSEC_ID_TYPE_IPV6_ADDR
IPv6 address.
Definition: ipsec.h:218
size_t saltLen
Length of the salt, in bytes.
Definition: ipsec.h:375
General definitions for cryptographic algorithms.
IpAddr tunnelDestIpAddr
Tunnel header IP destination address.
Definition: ipsec.h:391
uint32_t antiReplayWindow[(IPSEC_ANTI_REPLAY_WINDOW_SIZE+31)/32]
Anti-replay window.
Definition: ipsec.h:389
@ IPSEC_AUTH_METHOD_IKEV2
Definition: ipsec.h:180
IpsecPadEntry * padEntries
Peer Authorization Database (PAD)
Definition: ipsec.h:424
Block cipher modes of operation.
const CipherAlgo * cipherAlgo
Cipher algorithm.
Definition: ipsec.h:371
IpsecSaState state
SAD entry state.
Definition: ipsec.h:362
IPsec context.
Definition: ipsec.h:434
IpsecDfPolicy
DF flag policy.
Definition: ipsec.h:256
size_t trustedCaListLen
Trusted CA list (PEM format)
Definition: ipsec.h:408
IpsecMode mode
IPsec mode (tunnel or transport)
Definition: ipsec.h:348
const HashAlgo * authHashAlgo
Hash algorithm for HMAC-based integrity calculations.
Definition: ipsec.h:379
IpsecDirection direction
Direction.
Definition: ipsec.h:363
@ IPSEC_DF_POLICY_SET
Definition: ipsec.h:258
error_t ipsecClearSpdEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in SPD database.
Definition: ipsec.c:159
uint_t pfpFlags
PFP flags.
Definition: ipsec.h:346
CipherMode
Cipher operation modes.
Definition: crypto.h:962
IpsecIdType idType
ID type.
Definition: ipsec.h:402
AH (IP Authentication Header)
CMAC algorithm context.
Definition: cmac.h:54
IpsecProtocol
Security protocols.
Definition: ipsec.h:190
IpAddr start
Definition: ipsec.h:281
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
Definition: ipsec.h:418
#define IpsecSadEntry
Definition: ipsec.h:36
const char_t * trustedCaList
Definition: ipsec.h:407
uint16_t start
Definition: ipsec.h:292
Collection of hash algorithms.
uint32_t systime_t
System time.
IPsec ID.
Definition: ipsec.h:330
error_t ipsecClearPadEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in PAD database.
Definition: ipsec.c:347
bool_t esn
Extended sequence numbers.
Definition: ipsec.h:350
@ IPSEC_DF_POLICY_CLEAR
Definition: ipsec.h:257
char char_t
Definition: compiler_port.h:48
size_t idLen
Length of the ID, in bytes.
Definition: ipsec.h:404
size_t authKeyLen
Length of the integrity protection key, in bytes.
Definition: ipsec.h:382
IpsecPfpFlags
PFP flags.
Definition: ipsec.h:242
Port range.
Definition: ipsec.h:291
#define IPSEC_MAX_ID_LEN
Definition: ipsec.h:111
TCP (Transmission Control Protocol)
uint_t numPadEntries
Number of entries in the PAD database.
Definition: ipsec.h:425
uint8_t iv[16]
Initialization vector.
Definition: ipsec.h:376
IP packet information.
Definition: ipsec.h:316
uint_t numSpdEntries
Number of entries in the SPD database.
Definition: ipsec.h:421
IpsecAddrRange localIpAddr
Local IP address range.
Definition: ipsec.h:303
@ IPSEC_POLICY_ACTION_INVALID
Definition: ipsec.h:230
IpAddr localIpAddr
Local IP address.
Definition: ipsec.h:317
@ IPSEC_PFP_FLAG_NEXT_PROTOCOL
Definition: ipsec.h:245
UDP (User Datagram Protocol)
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
Definition: ipsec.h:435
@ IPSEC_ID_TYPE_DN
X.500 distinguished name.
Definition: ipsec.h:219
CipherMode cipherMode
Cipher mode of operation.
Definition: ipsec.h:370
IpAddr remoteTunnelAddr
Remote tunnel IP address.
Definition: ipsec.h:352
uint_t numSpdEntries
Number of entries in the SPD database.
Definition: ipsec.h:438
@ IPSEC_PFP_FLAG_LOCAL_PORT
Definition: ipsec.h:246
Common interface for encryption algorithms.
Definition: crypto.h:1068
CmacContext cmacContext
CMAC context.
Definition: ipsec.h:444
@ IPSEC_POLICY_ACTION_BYPASS
Definition: ipsec.h:232
#define IPSEC_MAX_PSK_LEN
Definition: ipsec.h:118
Collection of MAC algorithms.
@ IPSEC_MODE_INVALID
Definition: ipsec.h:203
@ IPSEC_AUTH_METHOD_INVALID
Definition: ipsec.h:178
void ipsecGetDefaultSettings(IpsecSettings *settings)
Initialize settings with default values.
Definition: ipsec.c:48
IpsecProtocol protocol
Security protocol (AH or ESP)
Definition: ipsec.h:365
IpsecSaState
IPsec SAD entry state.
Definition: ipsec.h:268
Common interface for hash algorithms.
Definition: crypto.h:1046
IP address range.
Definition: ipsec.h:280
error_t ipsecSetSpdEntry(IpsecContext *context, uint_t index, IpsecSpdEntry *params)
Set entry at specified index in SPD database.
Definition: ipsec.c:133
error_t ipsecSetPadEntry(IpsecContext *context, uint_t index, IpsecPadEntry *params)
Set entry at specified index in PAD database.
Definition: ipsec.c:321
IpsecAuthMethod
Authentication methods.
Definition: ipsec.h:177
Security Policy Database (SPD) entry.
Definition: ipsec.h:344
HmacContext hmacContext
HMAC context.
Definition: ipsec.h:447
unsigned int uint_t
Definition: compiler_port.h:50
size_t ivLen
Length of the initialization vector, in bytes.
Definition: ipsec.h:377
TCP/IP stack core.
IpsecSelector selector
Traffic selector.
Definition: ipsec.h:347
CipherContext cipherContext
Cipher context.
Definition: ipsec.h:372
@ IPSEC_SA_STATE_RESERVED
Definition: ipsec.h:270
error_t ipsecInit(IpsecContext *context, const IpsecSettings *settings)
IPsec service initialization.
Definition: ipsec.c:75
void * prngContext
Pseudo-random number generator context.
Definition: ipsec.h:436
IpsecDfPolicy dfPolicy
DF flag policy.
Definition: ipsec.h:367
@ IPSEC_SA_STATE_OPEN
Definition: ipsec.h:271
error_t ipsecClearSadEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in SAD database.
Definition: ipsec.c:260
@ IPSEC_PROTOCOL_INVALID
Definition: ipsec.h:191
IpsecPortRange localPort
Local port range.
Definition: ipsec.h:306
size_t encKeyLen
Length of the encryption key, in bytes.
Definition: ipsec.h:374
IpsecAddrRange remoteIpAddr
Remote IP address range.
Definition: ipsec.h:304
IpsecMode mode
IPsec mode (tunnel or transport)
Definition: ipsec.h:364
IpsecSpdEntry * spdEntries
Security Policy Database (SPD)
Definition: ipsec.h:420
error_t ipsecSetSadEntry(IpsecContext *context, uint_t index, IpsecSadEntry *params)
Set entry at specified index in SAD database.
Definition: ipsec.c:185
IPsec settings.
Definition: ipsec.h:417