IKE payload formatting. More...
#include "ike/ike.h"#include "ike/ike_algorithms.h"#include "ike/ike_payload_format.h"#include "ike/ike_auth.h"#include "ike/ike_certificate.h"#include "ike/ike_key_exchange.h"#include "ike/ike_key_material.h"#include "ah/ah_algorithms.h"#include "esp/esp_algorithms.h"#include "pkix/pem_import.h"#include "debug.h"Go to the source code of this file.
Macros | |
| #define | TRACE_LEVEL IKE_TRACE_LEVEL |
Functions | |
| error_t | ikeFormatSaPayload (IkeSaEntry *sa, const uint8_t *spi, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Security Association payload (IKE protocol) More... | |
| error_t | ikeFormatSaProposal (IkeSaEntry *sa, const uint8_t *spi, uint8_t *p, size_t *written) |
| Format Proposal substructure (IKE protocol) More... | |
| error_t | ikeFormatChildSaPayload (IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Security Association payload (AH or ESP protocol) More... | |
| error_t | ikeFormatChildSaProposal (IkeChildSaEntry *childSa, uint8_t *p, size_t *written) |
| Format Proposal substructure (AH or ESP protocol) More... | |
| error_t | ikeFormatKePayload (IkeKeContext *keContext, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Key Exchange payload. More... | |
| error_t | ikeFormatIdPayload (IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Identification payload. More... | |
| error_t | ikeFormatCertPayloads (IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Certificate payloads. More... | |
| error_t | ikeFormatCertPayload (const char_t *certChain, size_t certChainLen, size_t *consumed, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Certificate payload. More... | |
| error_t | ikeFormatCertReqPayload (IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Certificate Request payload. More... | |
| error_t | ikeFormatAuthPayload (IkeSaEntry *sa, const IkeIdPayload *idPayload, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Authentication payload. More... | |
| error_t | ikeFormatNoncePayload (IkeSaEntry *sa, IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Nonce payload. More... | |
| error_t | ikeFormatNotifyPayload (IkeSaEntry *sa, IkeChildSaEntry *childSa, IkeNotifyMsgType notifyMsgType, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Notify payload. More... | |
| error_t | ikeFormatNatDetectSrcIpNotificationData (IkeSaEntry *sa, uint8_t *p, size_t *written) |
| Format NAT_DETECTION_SOURCE_IP notification data. More... | |
| error_t | ikeFormatNatDetectDestIpNotificationData (IkeSaEntry *sa, uint8_t *p, size_t *written) |
| Format NAT_DETECTION_DESTINATION_IP notification data. More... | |
| error_t | ikeFormatSignHashAlgosNotificationData (IkeSaEntry *sa, uint8_t *p, size_t *written) |
| Format SIGNATURE_HASH_ALGORITHMS notification data. More... | |
| error_t | ikeFormatDeletePayload (IkeSaEntry *sa, IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Delete payload. More... | |
| error_t | ikeFormatTsiPayload (IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Traffic Selector payload (initiator) More... | |
| error_t | ikeFormatTsrPayload (IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload) |
| Format Traffic Selector payload (responder) More... | |
| error_t | ikeFormatTsEntry (const IkeTsEntry *tsEntry, uint8_t *p, size_t *written) |
| Format Traffic Selector substructure. More... | |
Detailed Description
IKE payload formatting.
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.
- Version
- 2.6.6
Definition in file ike_payload_format.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL IKE_TRACE_LEVEL |
Definition at line 32 of file ike_payload_format.c.
Function Documentation
◆ ikeFormatAuthPayload()
| error_t ikeFormatAuthPayload | ( | IkeSaEntry * | sa, |
| const IkeIdPayload * | idPayload, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Authentication payload.
- Parameters
-
[in] sa Pointer to the IKE SA [in] idPayload Pointer to the Identification payload [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 898 of file ike_payload_format.c.
◆ ikeFormatCertPayload()
| error_t ikeFormatCertPayload | ( | const char_t * | certChain, |
| size_t | certChainLen, | ||
| size_t * | consumed, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Certificate payload.
- Parameters
-
[in] certChain Pointer to the certificate chain (PEM format) [in] certChainLen Length of the certificate chain, in bytes [out] consumed Total number of characters that have been consumed [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 739 of file ike_payload_format.c.
◆ ikeFormatCertPayloads()
| error_t ikeFormatCertPayloads | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Certificate payloads.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the payloads [out] written Length of the resulting payloads [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 646 of file ike_payload_format.c.
◆ ikeFormatCertReqPayload()
| error_t ikeFormatCertReqPayload | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Certificate Request payload.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 800 of file ike_payload_format.c.
◆ ikeFormatChildSaPayload()
| error_t ikeFormatChildSaPayload | ( | IkeChildSaEntry * | childSa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Security Association payload (AH or ESP protocol)
- Parameters
-
[in] childSa Pointer to the Child SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 242 of file ike_payload_format.c.
◆ ikeFormatChildSaProposal()
| error_t ikeFormatChildSaProposal | ( | IkeChildSaEntry * | childSa, |
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format Proposal substructure (AH or ESP protocol)
- Parameters
-
[in] childSa Pointer to the Child SA [out] p Buffer where to format the Proposal substructure [out] written Length of the resulting Proposal substructure
- Returns
- Error code
Definition at line 294 of file ike_payload_format.c.
◆ ikeFormatDeletePayload()
| error_t ikeFormatDeletePayload | ( | IkeSaEntry * | sa, |
| IkeChildSaEntry * | childSa, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Delete payload.
- Parameters
-
[in] sa Pointer to the IKE SA [in] childSa Pointer to the Child SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 1430 of file ike_payload_format.c.
◆ ikeFormatIdPayload()
| error_t ikeFormatIdPayload | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Identification payload.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 543 of file ike_payload_format.c.
◆ ikeFormatKePayload()
| error_t ikeFormatKePayload | ( | IkeKeContext * | keContext, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Key Exchange payload.
- Parameters
-
[in] keContext Pointer to the key exchange context [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 488 of file ike_payload_format.c.
◆ ikeFormatNatDetectDestIpNotificationData()
| error_t ikeFormatNatDetectDestIpNotificationData | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format NAT_DETECTION_DESTINATION_IP notification data.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the notification data [out] written Length of the notification data, in bytes
- Returns
- Error code
Definition at line 1291 of file ike_payload_format.c.
◆ ikeFormatNatDetectSrcIpNotificationData()
| error_t ikeFormatNatDetectSrcIpNotificationData | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format NAT_DETECTION_SOURCE_IP notification data.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the notification data [out] written Length of the notification data, in bytes
- Returns
- Error code
Definition at line 1209 of file ike_payload_format.c.
◆ ikeFormatNoncePayload()
| error_t ikeFormatNoncePayload | ( | IkeSaEntry * | sa, |
| IkeChildSaEntry * | childSa, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Nonce payload.
- Parameters
-
[in] sa Pointer to the IKE SA [in] childSa Pointer to the Child SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 951 of file ike_payload_format.c.
◆ ikeFormatNotifyPayload()
| error_t ikeFormatNotifyPayload | ( | IkeSaEntry * | sa, |
| IkeChildSaEntry * | childSa, | ||
| IkeNotifyMsgType | notifyMsgType, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Notify payload.
- Parameters
-
[in] sa Pointer to the IKE SA [in] childSa Pointer to the Child SA [in] notifyMsgType Type of notification [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 1039 of file ike_payload_format.c.
◆ ikeFormatSaPayload()
| error_t ikeFormatSaPayload | ( | IkeSaEntry * | sa, |
| const uint8_t * | spi, | ||
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Security Association payload (IKE protocol)
- Parameters
-
[in] sa Pointer to the IKE SA [in] spi Security parameter index (optional parameter) [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 61 of file ike_payload_format.c.
◆ ikeFormatSaProposal()
| error_t ikeFormatSaProposal | ( | IkeSaEntry * | sa, |
| const uint8_t * | spi, | ||
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format Proposal substructure (IKE protocol)
- Parameters
-
[in] sa Pointer to the IKE SA [in] spi Security parameter index (optional parameter) [out] p Buffer where to format the Proposal substructure [out] written Length of the resulting Proposal substructure
- Returns
- Error code
Definition at line 114 of file ike_payload_format.c.
◆ ikeFormatSignHashAlgosNotificationData()
| error_t ikeFormatSignHashAlgosNotificationData | ( | IkeSaEntry * | sa, |
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format SIGNATURE_HASH_ALGORITHMS notification data.
- Parameters
-
[in] sa Pointer to the IKE SA [out] p Buffer where to format the notification data [out] written Length of the notification data, in bytes
- Returns
- Error code
Definition at line 1356 of file ike_payload_format.c.
◆ ikeFormatTsEntry()
| error_t ikeFormatTsEntry | ( | const IkeTsEntry * | tsEntry, |
| uint8_t * | p, | ||
| size_t * | written | ||
| ) |
Format Traffic Selector substructure.
- Parameters
-
[in] tsEntry Traffic selector entry [out] p Buffer where to format the Traffic Selector substructure [out] written Length of the resulting Traffic Selector substructure
- Returns
- Error code
Definition at line 1770 of file ike_payload_format.c.
◆ ikeFormatTsiPayload()
| error_t ikeFormatTsiPayload | ( | IkeChildSaEntry * | childSa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Traffic Selector payload (initiator)
- Parameters
-
[in] childSa Pointer to the Child SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 1493 of file ike_payload_format.c.
◆ ikeFormatTsrPayload()
| error_t ikeFormatTsrPayload | ( | IkeChildSaEntry * | childSa, |
| uint8_t * | p, | ||
| size_t * | written, | ||
| uint8_t ** | nextPayload | ||
| ) |
Format Traffic Selector payload (responder)
- Parameters
-
[in] childSa Pointer to the Child SA [out] p Buffer where to format the payload [out] written Length of the resulting payload [in,out] nextPayload Pointer to the Next Payload field
- Returns
- Error code
Definition at line 1631 of file ike_payload_format.c.
