ike_payload_parse.h
Go to the documentation of this file.
1 /**
2  * @file ike_payload_parse.h
3  * @brief IKE payload parsing
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_PARSE_H
32 #define _IKE_PAYLOAD_PARSE_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
43 error_t ikeParseSaPayload(const IkeSaPayload *saPayload);
44 error_t ikeParseProposal(const IkeProposal *proposal, size_t length);
45 error_t ikeParseTransform(const IkeTransform *transform, size_t length);
46 
48  size_t *consumed);
49 
50 error_t ikeParseKePayload(IkeSaEntry *sa, const IkeKePayload *kePayload);
51 
52 error_t ikeParseIdPayload(IkeSaEntry *sa, const IkeIdPayload *idPayload);
53 
55  const IkeCertReqPayload *certReqPayload);
56 
57 error_t ikeParseNoncePayload(const IkeNoncePayload *noncePayload,
58  uint8_t *nonce, size_t *nonceLen);
59 
61  const IkeDeletePayload *deletePayload, bool_t response);
62 
64  const IkeNotifyPayload *notifyPayload);
65 
67  const IkeNotifyPayload *notifyPayload);
68 
70  const IkeNotifyPayload *notifyPayload);
71 
72 error_t ikeParseTs(const uint8_t *p, size_t length, IkeTsParams *tsParams);
73 
74 const IkePayloadHeader *ikeGetPayload(const uint8_t *message, size_t length,
75  uint8_t type, uint_t index);
76 
78  size_t length);
79 
81  size_t length, uint16_t type);
82 
83 error_t ikeCheckCriticalPayloads(const uint8_t *message, size_t length,
84  uint8_t *unsupportedCriticalPayload);
85 
86 //C++ guard
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif
const IkePayloadHeader * ikeGetPayload(const uint8_t *message, size_t length, uint8_t type, uint_t index)
Search an IKE message for a given payload type.
int bool_t
Definition: compiler_port.h:53
IkeCertReqPayload
Definition: ike.h:1390
error_t ikeParseTransform(const IkeTransform *transform, size_t length)
Parse Transform substructure.
IkeKePayload
Definition: ike.h:1353
uint8_t p
Definition: ndp.h:300
uint8_t message[]
Definition: chap.h:154
IkeNotifyPayload
Definition: ike.h:1439
error_t ikeParseKePayload(IkeSaEntry *sa, const IkeKePayload *kePayload)
Parse Key Exchange payload.
IkePayloadHeader
Definition: ike.h:1284
uint8_t type
Definition: coap_common.h:176
error_t ikeParseSignHashAlgosNotification(IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
Parse SIGNATURE_HASH_ALGORITHMS notification.
IkeTransform
Definition: ike.h:1328
Traffic selector parameters.
Definition: ike.h:1608
const IkeNotifyPayload * ikeGetStatusNotifyPayload(const uint8_t *message, size_t length, uint16_t type)
Search an IKE message for a given status Notify payload.
const IkeNotifyPayload * ikeGetErrorNotifyPayload(const uint8_t *message, size_t length)
Search an IKE message for an error Notify payload.
error_t
Error codes.
Definition: error.h:43
IkeIdPayload
Definition: ike.h:1366
IkeTransformAttr
Definition: ike.h:1340
uint8_t length
Definition: tcp.h:368
error_t ikeParseInvalidKeyPayloadNotification(IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
Parse INVALID_KE_PAYLOAD notification.
IkeDeletePayload
Definition: ike.h:1453
error_t ikeParseIdPayload(IkeSaEntry *sa, const IkeIdPayload *idPayload)
Parse Identification payload.
error_t ikeParseCertReqPayload(IkeSaEntry *sa, const IkeCertReqPayload *certReqPayload)
Parse Certificate Request payload.
IKEv2 (Internet Key Exchange Protocol)
IkeProposal
Definition: ike.h:1312
#define IkeSaEntry
Definition: ike.h:682
error_t ikeParseCookieNotification(IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
Parse COOKIE notification.
error_t ikeParseTs(const uint8_t *p, size_t length, IkeTsParams *tsParams)
Parse Traffic Selector substructure.
error_t ikeCheckCriticalPayloads(const uint8_t *message, size_t length, uint8_t *unsupportedCriticalPayload)
Check whether the message contains an unsupported critical payload.
error_t ikeParseNoncePayload(const IkeNoncePayload *noncePayload, uint8_t *nonce, size_t *nonceLen)
Parse Nonce payload.
error_t ikeParseSaPayload(const IkeSaPayload *saPayload)
Parse Security Association payload.
IkeNoncePayload
Definition: ike.h:1425
error_t ikeParseTransformAttr(const IkeTransformAttr *attr, size_t length, size_t *consumed)
Parse transform attribute.
unsigned int uint_t
Definition: compiler_port.h:50
error_t ikeParseProposal(const IkeProposal *proposal, size_t length)
Parse Proposal substructure.
uint8_t nonce[]
Definition: ntp_common.h:233
IkeSaPayload
Definition: ike.h:1295
error_t ikeParseDeletePayload(IkeSaEntry *sa, const IkeDeletePayload *deletePayload, bool_t response)
Parse Delete payload.