ike_payload_format.h
Go to the documentation of this file.
1 /**
2  * @file ike_payload_format.h
3  * @brief IKE payload formatting
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 _IKE_PAYLOAD_FORMAT_H
32 #define _IKE_PAYLOAD_FORMAT_H
33 
34 //Dependencies
35 #include "ike/ike.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 //IKE related functions
44  uint8_t *p, size_t *written, uint8_t **nextPayload);
45 
46 error_t ikeFormatSaProposal(IkeSaEntry *sa, const uint8_t *spi, uint8_t *p,
47  size_t *written);
48 
50  IpsecProtocol protocolId, const uint8_t *spi, uint8_t *p, size_t *written);
51 
52 error_t ikeFormatKePayload(IkeSaEntry *sa, uint8_t *p, size_t *written,
53  uint8_t **nextPayload);
54 
55 error_t ikeFormatIdPayload(IkeSaEntry *sa, uint8_t *p, size_t *written,
56  uint8_t **nextPayload);
57 
58 error_t ikeFormatCertPayloads(IkeSaEntry *sa, uint8_t *p, size_t *written,
59  uint8_t **nextPayload);
60 
61 error_t ikeFormatCertPayload(const char_t *certChain, size_t certChainLen,
62  size_t *consumed, uint8_t *p, size_t *written, uint8_t **nextPayload);
63 
64 error_t ikeFormatCertReqPayload(IkeSaEntry *sa, uint8_t *p, size_t *written,
65  uint8_t **nextPayload);
66 
68  uint8_t *p, size_t *written, uint8_t **nextPayload);
69 
71  uint8_t *p, size_t *written, uint8_t **nextPayload);
72 
74  IkeNotifyMsgType notifyMsgType, uint8_t *p, size_t *written,
75  uint8_t **nextPayload);
76 
78  size_t *written);
79 
81  uint8_t *p, size_t *written, uint8_t **nextPayload);
82 
83 error_t ikeFormatTsiPayload(IkeChildSaEntry *childSa, uint8_t *p,
84  size_t *written, uint8_t **nextPayload);
85 
86 error_t ikeFormatTsrPayload(IkeChildSaEntry *childSa, uint8_t *p,
87  size_t *written, uint8_t **nextPayload);
88 
89 error_t ikeFormatTs(const IkeTsParams *tsParams, uint8_t *p, size_t *written);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
uint32_t spi
Definition: ah.h:143
uint8_t p
Definition: ndp.h:300
error_t ikeFormatSaPayload(IkeSaEntry *sa, IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Security Association payload.
Traffic selector parameters.
Definition: ike.h:1608
uint16_t notifyMsgType
Definition: ike.h:1437
error_t ikeFormatTsrPayload(IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Traffic Selector payload (responder)
error_t
Error codes.
Definition: error.h:43
IkeIdPayload
Definition: ike.h:1366
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.
error_t ikeFormatTsiPayload(IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Traffic Selector payload (initiator)
uint8_t protocolId[]
error_t ikeFormatIdPayload(IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Identification payload.
error_t ikeFormatAuthPayload(IkeSaEntry *sa, const IkeIdPayload *idPayload, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Authentication payload.
error_t ikeFormatTs(const IkeTsParams *tsParams, uint8_t *p, size_t *written)
Format Traffic Selector substructure.
error_t ikeFormatKePayload(IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Key Exchange payload.
IpsecProtocol
Security protocols.
Definition: ipsec.h:190
IKEv2 (Internet Key Exchange Protocol)
error_t ikeFormatNotifyPayload(IkeSaEntry *sa, IkeChildSaEntry *childSa, IkeNotifyMsgType notifyMsgType, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Notify payload.
char char_t
Definition: compiler_port.h:48
#define IkeSaEntry
Definition: ike.h:682
error_t ikeFormatChildSaProposal(IkeChildSaEntry *childSa, IpsecProtocol protocolId, const uint8_t *spi, uint8_t *p, size_t *written)
Format Proposal substructure (AH or ESP protocol)
IkeNotifyMsgType
Notify message types.
Definition: ike.h:1004
uint8_t nextPayload
Definition: ike.h:1254
error_t ikeFormatSignHashAlgosNotificationData(IkeSaEntry *sa, uint8_t *p, size_t *written)
Format SIGNATURE_HASH_ALGORITHMS notification data.
error_t ikeFormatSaProposal(IkeSaEntry *sa, const uint8_t *spi, uint8_t *p, size_t *written)
Format Proposal substructure (IKE protocol)
error_t ikeFormatDeletePayload(IkeSaEntry *sa, IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Delete payload.
error_t ikeFormatCertReqPayload(IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Certificate Request payload.
error_t ikeFormatNoncePayload(IkeSaEntry *sa, IkeChildSaEntry *childSa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Nonce payload.
#define IkeChildSaEntry
Definition: ike.h:686
error_t ikeFormatCertPayloads(IkeSaEntry *sa, uint8_t *p, size_t *written, uint8_t **nextPayload)
Format Certificate payloads.