Go to the documentation of this file.
36 #define IpsecSadEntry struct _IpsecSadEntry
40 #define IpsecContext struct _IpsecContext
43 #include "ipsec_config.h"
79 #ifndef GPL_LICENSE_TERMS_ACCEPTED
80 #error Before compiling CycloneIPSEC Open, you must accept the terms of the GPL license
84 #define CYCLONE_IPSEC_VERSION_STRING "2.6.0"
86 #define CYCLONE_IPSEC_MAJOR_VERSION 2
88 #define CYCLONE_IPSEC_MINOR_VERSION 6
90 #define CYCLONE_IPSEC_REV_NUMBER 0
94 #define IPSEC_SUPPORT ENABLED
95 #elif (IPSEC_SUPPORT != ENABLED && IPSEC_SUPPORT != DISABLED)
96 #error IPSEC_SUPPORT parameter is not valid
100 #ifndef IPSEC_ANTI_REPLAY_SUPPORT
101 #define IPSEC_ANTI_REPLAY_SUPPORT ENABLED
102 #elif (IPSEC_ANTI_REPLAY_SUPPORT != ENABLED && IPSEC_ANTI_REPLAY_SUPPORT != DISABLED)
103 #error IPSEC_ANTI_REPLAY_SUPPORT parameter is not valid
107 #ifndef IPSEC_ANTI_REPLAY_WINDOW_SIZE
108 #define IPSEC_ANTI_REPLAY_WINDOW_SIZE 64
109 #elif (IPSEC_ANTI_REPLAY_WINDOW_SIZE < 1)
110 #error IPSEC_ANTI_REPLAY_WINDOW_SIZE parameter is not valid
114 #ifndef IPSEC_MAX_ID_LEN
115 #define IPSEC_MAX_ID_LEN 64
116 #elif (IPSEC_MAX_ID_LEN < 0)
117 #error IPSEC_MAX_ID_LEN is not valid
121 #ifndef IPSEC_MAX_PSK_LEN
122 #define IPSEC_MAX_PSK_LEN 64
123 #elif (IPSEC_MAX_PSK_LEN < 0)
124 #error IPSEC_MAX_PSK_LEN is not valid
128 #ifndef IPSEC_MAX_ENC_KEY_LEN
129 #define IPSEC_MAX_ENC_KEY_LEN 36
130 #elif (IPSEC_MAX_ENC_KEY_LEN < 1)
131 #error IPSEC_MAX_ENC_KEY_LEN parameter is not valid
135 #ifndef IPSEC_MAX_AUTH_KEY_LEN
136 #define IPSEC_MAX_AUTH_KEY_LEN 64
137 #elif (IPSEC_MAX_AUTH_KEY_LEN < 1)
138 #error IPSEC_MAX_AUTH_KEY_LEN parameter is not valid
142 #define IPSEC_SPI_SIZE 4
145 #define IPSEC_PROTOCOL_ANY 0
148 #define IPSEC_PORT_START_ANY 0
149 #define IPSEC_PORT_END_ANY 65535
152 #define IPSEC_PORT_START_OPAQUE 65535
153 #define IPSEC_PORT_END_OPAQUE 0
156 #define IPSEC_ICMP_PORT(type, code) (((type) * 256) + (code))
373 #if (ESP_SUPPORT == ENABLED)
391 #if (IPSEC_ANTI_REPLAY_SUPPORT == ENABLED)
449 #if (AH_CMAC_SUPPORT == ENABLED || ESP_CMAC_SUPPORT == ENABLED)
452 #if (ESP_GMAC_SUPPORT == ENABLED)
455 #if (AH_HMAC_SUPPORT == ENABLED || ESP_HMAC_SUPPORT == ENABLED)
458 #if (ESP_SUPPORT == ENABLED)
uint_t numPadEntries
Number of entries in the PAD database.
IpsecAddrRange ipAddr
IPv4 or IPv6 address range.
@ IPSEC_ID_TYPE_KEY_ID
Key ID.
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
IpsecMode
IPsec protocol modes.
uint_t numSadEntries
Number of entries in the SAD database.
size_t icvLen
Length of the ICV tag, in bytes.
@ IPSEC_ID_TYPE_IPV4_ADDR
IPv4 address.
uint_t numSadEntries
Number of entries in the SAD database.
uint32_t spi
Security parameter index.
IpsecSelector selector
Traffic selector.
void * prngContext
Pseudo-random number generator context.
const CipherAlgo * authCipherAlgo
Cipher algorithm for CMAC-based integrity calculations.
IpsecSpdEntry * spd
Security Policy Database (SPD)
Collection of AEAD algorithms.
IpAddr remoteIpAddr
Remote IP address.
Generic cipher algorithm context.
bool_t antiReplayEnabled
Anti-replay mechanism enabled.
size_t pskLen
Length of the pre-shared key, in bytes.
@ IPSEC_PFP_FLAG_REMOTE_ADDR
#define IPSEC_MAX_ENC_KEY_LEN
#define IPSEC_ANTI_REPLAY_WINDOW_SIZE
systime_t lifetimeStart
Timestamp.
@ IPSEC_PFP_FLAG_LOCAL_ADDR
uint8_t authKey[IPSEC_MAX_AUTH_KEY_LEN]
Integrity protection key.
#define IPSEC_MAX_AUTH_KEY_LEN
@ IPSEC_POLICY_ACTION_PROTECT
@ IPSEC_ID_TYPE_RFC822_ADDR
RFC 822 email address.
void * prngContext
Pseudo-random number generator context.
Peer Authorization Database (PAD) entry.
uint16_t remotePort
Remote port.
bool_t esn
Extended sequence numbers.
ESP (IP Encapsulating Security Payload)
uint64_t seqNum
Sequence number counter.
IpsecSadEntry * sadEntries
Security Association Database (SAD)
IpAddr localTunnelAddr
Local tunnel IP address.
GmacContext gmacContext
GMAC context.
ICMP (Internet Control Message Protocol)
IpsecAuthMethod authMethod
Authentication method (IKEv1, IKEv2, KINK)
uint8_t nextProtocol
Next layer protocol.
uint8_t nextProtocol
Next layer protocol.
uint16_t localPort
Local port.
@ IPSEC_ID_TYPE_FQDN
Fully-qualified domain name.
IpsecPolicyAction
Policy action.
uint8_t encKey[IPSEC_MAX_ENC_KEY_LEN]
Encryption key.
IpsecPolicyAction policyAction
Processing choice (DISCARD, BYPASS or PROTECT)
@ IPSEC_PFP_FLAG_REMOTE_PORT
IpsecPortRange remotePort
Remote port range.
HmacContext hmacContext
HMAC context.
@ IPSEC_POLICY_ACTION_DISCARD
IpsecProtocol protocol
Security protocol (AH or ESP)
@ IPSEC_AUTH_METHOD_IKEV1
Security Association Database (SAD) entry.
IpsecSadEntry * sad
Security Association Database (SAD)
@ IPSEC_ID_TYPE_IPV6_ADDR
IPv6 address.
size_t saltLen
Length of the salt, in bytes.
General definitions for cryptographic algorithms.
IpAddr tunnelDestIpAddr
Tunnel header IP destination address.
void ipsecDeinit(IpsecContext *context)
Release IPsec context.
uint32_t antiReplayWindow[(IPSEC_ANTI_REPLAY_WINDOW_SIZE+31)/32]
Anti-replay window.
CmacContext cmacContext
CMAC context.
@ IPSEC_AUTH_METHOD_IKEV2
IpsecPadEntry * padEntries
Peer Authorization Database (PAD)
Block cipher modes of operation.
const CipherAlgo * cipherAlgo
Cipher algorithm.
IpsecSaState state
SAD entry state.
IpsecDfPolicy
DF flag policy.
size_t trustedCaListLen
Trusted CA list (PEM format)
IpsecMode mode
IPsec mode (tunnel or transport)
const HashAlgo * authHashAlgo
Hash algorithm for HMAC-based integrity calculations.
IpsecDirection direction
Direction.
error_t ipsecClearSpdEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in SPD database.
uint_t pfpFlags
PFP flags.
CipherMode
Cipher operation modes.
IpsecIdType idType
ID type.
AH (IP Authentication Header)
IpsecProtocol
Security protocols.
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
const char_t * trustedCaList
Collection of hash algorithms.
NetContext * netContext
TCP/IP stack context.
uint32_t systime_t
System time.
error_t ipsecClearPadEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in PAD database.
bool_t esn
Extended sequence numbers.
size_t idLen
Length of the ID, in bytes.
size_t authKeyLen
Length of the integrity protection key, in bytes.
IpsecPadEntry * pad
Peer Authorization Database (PAD)
TCP (Transmission Control Protocol)
uint_t numPadEntries
Number of entries in the PAD database.
uint8_t iv[16]
Initialization vector.
uint_t numSpdEntries
Number of entries in the SPD database.
IpsecAddrRange localIpAddr
Local IP address range.
@ IPSEC_POLICY_ACTION_INVALID
IpAddr localIpAddr
Local IP address.
@ IPSEC_PFP_FLAG_NEXT_PROTOCOL
uint_t numSpdEntries
Number of entries in the SPD database.
UDP (User Datagram Protocol)
@ IPSEC_ID_TYPE_DN
X.500 distinguished name.
CipherMode cipherMode
Cipher mode of operation.
IpAddr remoteTunnelAddr
Remote tunnel IP address.
@ IPSEC_PFP_FLAG_LOCAL_PORT
Common interface for encryption algorithms.
@ IPSEC_POLICY_ACTION_BYPASS
#define IPSEC_MAX_PSK_LEN
Collection of MAC algorithms.
@ IPSEC_AUTH_METHOD_INVALID
void ipsecGetDefaultSettings(IpsecSettings *settings)
Initialize settings with default values.
IpsecProtocol protocol
Security protocol (AH or ESP)
IpsecSaState
IPsec SAD entry state.
Common interface for hash algorithms.
error_t ipsecSetSpdEntry(IpsecContext *context, uint_t index, IpsecSpdEntry *params)
Set entry at specified index in SPD database.
error_t ipsecSetPadEntry(IpsecContext *context, uint_t index, IpsecPadEntry *params)
Set entry at specified index in PAD database.
IpsecAuthMethod
Authentication methods.
Security Policy Database (SPD) entry.
size_t ivLen
Length of the initialization vector, in bytes.
IpsecSelector selector
Traffic selector.
NetContext * netContext
TCP/IP stack context.
CipherContext cipherContext
Cipher context.
@ IPSEC_SA_STATE_RESERVED
error_t ipsecInit(IpsecContext *context, const IpsecSettings *settings)
IPsec service initialization.
uint8_t buffer[ESP_BUFFER_SIZE]
Memory buffer for input/output operations.
IpsecDfPolicy dfPolicy
DF flag policy.
error_t ipsecClearSadEntry(IpsecContext *context, uint_t index)
Clear entry at specified index in SAD database.
IpsecPortRange localPort
Local port range.
size_t encKeyLen
Length of the encryption key, in bytes.
IpsecAddrRange remoteIpAddr
Remote IP address range.
IpsecMode mode
IPsec mode (tunnel or transport)
IpsecSpdEntry * spdEntries
Security Policy Database (SPD)
error_t ipsecSetSadEntry(IpsecContext *context, uint_t index, IpsecSadEntry *params)
Set entry at specified index in SAD database.