ike.c File Reference

IKEv2 (Internet Key Exchange Protocol) More...

#include "ipsec/ipsec_misc.h"
#include "ike/ike.h"
#include "ike/ike_fsm.h"
#include "ike/ike_algorithms.h"
#include "ike/ike_certificate.h"
#include "ike/ike_message_dispatch.h"
#include "ike/ike_misc.h"
#include "ike/ike_debug.h"
#include "pkix/pem_import.h"
#include "pkix/x509_cert_parse.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   IKE_TRACE_LEVEL
 

Functions

void ikeGetDefaultSettings (IkeSettings *settings)
 Initialize settings with default values. More...
 
error_t ikeInit (IkeContext *context, const IkeSettings *settings)
 IKE service initialization. More...
 
error_t ikeStart (IkeContext *context)
 Start IKE service. More...
 
error_t ikeStop (IkeContext *context)
 Stop IKE service. More...
 
error_t ikeSetPreferredGroup (IkeContext *context, uint16_t groupNum)
 Specify the preferred key exchange method. More...
 
error_t ikeSetId (IkeContext *context, IkeIdType idType, const void *id, size_t idLen)
 Set entity's ID. More...
 
error_t ikeSetPsk (IkeContext *context, const uint8_t *psk, size_t pskLen)
 Set entity's pre-shared key. More...
 
error_t ikeSetCertificate (IkeContext *context, const char_t *certChain, size_t certChainLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password)
 Load entity's certificate. More...
 
error_t ikeCreateSa (IkeContext *context, const IpAddr *remoteIpAddr)
 Create a new IKE SA. More...
 
error_t ikeRekeySa (IkeSaEntry *sa)
 Rekey an IKE SA. More...
 
error_t ikeDeleteSa (IkeSaEntry *sa)
 Delete an IKE SA. More...
 
error_t ikeCreateChildSa (IkeContext *context, const IpsecPacketInfo *packet)
 Create a new Child SA. More...
 
error_t ikeRekeyChildSa (IkeChildSaEntry *childSa)
 Rekey a Child SA. More...
 
error_t ikeDeleteChildSa (IkeChildSaEntry *childSa)
 Delete a Child SA. More...
 
void ikeTask (IkeContext *context)
 IKE task. More...
 
void ikeDeinit (IkeContext *context)
 Release IKE context. More...
 

Detailed Description

IKEv2 (Internet Key Exchange Protocol)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2022-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneIPSEC Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.6

Definition in file ike.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   IKE_TRACE_LEVEL

Definition at line 32 of file ike.c.

Function Documentation

◆ ikeCreateChildSa()

error_t ikeCreateChildSa ( IkeContext *  context,
const IpsecPacketInfo *  packet 
)

Create a new Child SA.

Parameters
[in]contextPointer to the IKE context
[in]packetTriggering packet
Returns
Error code

Definition at line 776 of file ike.c.

◆ ikeCreateSa()

error_t ikeCreateSa ( IkeContext *  context,
const IpAddr *  remoteIpAddr 
)

Create a new IKE SA.

Parameters
[in]contextPointer to the IKE context
[in]remoteIpAddrIP address of the peer
Returns
Error code

Definition at line 639 of file ike.c.

◆ ikeDeinit()

void ikeDeinit ( IkeContext *  context)

Release IKE context.

Parameters
[in]contextPointer to the IKE context

Definition at line 1073 of file ike.c.

◆ ikeDeleteChildSa()

error_t ikeDeleteChildSa ( IkeChildSaEntry *  childSa)

Delete a Child SA.

Parameters
[in]childSaPointer to the Child SA to delete
Returns
Error code

Definition at line 924 of file ike.c.

◆ ikeDeleteSa()

error_t ikeDeleteSa ( IkeSaEntry *  sa)

Delete an IKE SA.

Parameters
[in]saPointer to the IKE SA to delete
Returns
Error code

Definition at line 741 of file ike.c.

◆ ikeGetDefaultSettings()

void ikeGetDefaultSettings ( IkeSettings *  settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains IKE settings

Definition at line 56 of file ike.c.

◆ ikeInit()

error_t ikeInit ( IkeContext *  context,
const IkeSettings *  settings 
)

IKE service initialization.

Parameters
[in]contextPointer to the IKE context
[in]settingsIKE specific settings
Returns
Error code

Definition at line 121 of file ike.c.

◆ ikeRekeyChildSa()

error_t ikeRekeyChildSa ( IkeChildSaEntry *  childSa)

Rekey a Child SA.

Parameters
[in]childSaPointer to the Child SA to rekey
Returns
Error code

Definition at line 884 of file ike.c.

◆ ikeRekeySa()

error_t ikeRekeySa ( IkeSaEntry *  sa)

Rekey an IKE SA.

Parameters
[in]saPointer to the IKE SA to rekey
Returns
Error code

Definition at line 701 of file ike.c.

◆ ikeSetCertificate()

error_t ikeSetCertificate ( IkeContext *  context,
const char_t *  certChain,
size_t  certChainLen,
const char_t *  privateKey,
size_t  privateKeyLen,
const char_t *  password 
)

Load entity's certificate.

Parameters
[in]contextPointer to the IKE context
[in]certChainCertificate chain (PEM format). This parameter is taken as reference
[in]certChainLenLength of the certificate chain
[in]privateKeyPrivate key (PEM format). This parameter is taken as reference
[in]privateKeyLenLength of the private key
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
Returns
Error code

Definition at line 516 of file ike.c.

◆ ikeSetId()

error_t ikeSetId ( IkeContext *  context,
IkeIdType  idType,
const void *  id,
size_t  idLen 
)

Set entity's ID.

Parameters
[in]contextPointer to the IKE context
[in]idTypeID type
[in]idPointer to the identification data
[in]idLenLength of the identification data, in bytes
Returns
Error code

Definition at line 449 of file ike.c.

◆ ikeSetPreferredGroup()

error_t ikeSetPreferredGroup ( IkeContext *  context,
uint16_t  groupNum 
)

Specify the preferred key exchange method.

Parameters
[in]contextPointer to the IKE context
[in]groupNumPreferred group number
Returns
Error code

Definition at line 422 of file ike.c.

◆ ikeSetPsk()

error_t ikeSetPsk ( IkeContext *  context,
const uint8_t *  psk,
size_t  pskLen 
)

Set entity's pre-shared key.

Parameters
[in]contextPointer to the IKE context
[in]pskPointer to the pre-shared key
[in]pskLenLength of the pre-shared key, in bytes
Returns
Error code

Definition at line 478 of file ike.c.

◆ ikeStart()

error_t ikeStart ( IkeContext *  context)

Start IKE service.

Parameters
[in]contextPointer to the IKE context
Returns
Error code

Definition at line 247 of file ike.c.

◆ ikeStop()

error_t ikeStop ( IkeContext *  context)

Stop IKE service.

Parameters
[in]contextPointer to the IKE context
Returns
Error code

Definition at line 368 of file ike.c.

◆ ikeTask()

void ikeTask ( IkeContext *  context)

IKE task.

Parameters
[in]contextPointer to the IKE context

Definition at line 957 of file ike.c.