ike_payload_parse.c File Reference

IKE payload parsing. More...

#include "ike/ike.h"
#include "ike/ike_algorithms.h"
#include "ike/ike_payload_parse.h"
#include "ike/ike_auth.h"
#include "ike/ike_certificate.h"
#include "ike/ike_key_exchange.h"
#include "ike/ike_key_material.h"
#include "ike/ike_sign_misc.h"
#include "ike/ike_misc.h"
#include "ah/ah_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 ikeParseSaPayload (const IkeSaPayload *saPayload)
 Parse Security Association payload. More...
 
error_t ikeParseProposal (const IkeProposal *proposal, size_t length)
 Parse Proposal substructure. More...
 
error_t ikeParseTransform (const IkeTransform *transform, size_t length)
 Parse Transform substructure. More...
 
error_t ikeParseTransformAttr (const IkeTransformAttr *attr, size_t length, size_t *consumed)
 Parse transform attribute. More...
 
error_t ikeParseKePayload (IkeSaEntry *sa, const IkeKePayload *kePayload)
 Parse Key Exchange payload. More...
 
error_t ikeParseIdPayload (IkeSaEntry *sa, const IkeIdPayload *idPayload)
 Parse Identification payload. More...
 
error_t ikeParseCertReqPayload (IkeSaEntry *sa, const IkeCertReqPayload *certReqPayload)
 Parse Certificate Request payload. More...
 
error_t ikeParseNoncePayload (const IkeNoncePayload *noncePayload, uint8_t *nonce, size_t *nonceLen)
 Parse Nonce payload. More...
 
error_t ikeParseDeletePayload (IkeSaEntry *sa, const IkeDeletePayload *deletePayload, bool_t response)
 Parse Delete payload. More...
 
error_t ikeParseInvalidKeyPayloadNotification (IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
 Parse INVALID_KE_PAYLOAD notification. More...
 
error_t ikeParseCookieNotification (IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
 Parse COOKIE notification. More...
 
error_t ikeParseSignHashAlgosNotification (IkeSaEntry *sa, const IkeNotifyPayload *notifyPayload)
 Parse SIGNATURE_HASH_ALGORITHMS notification. More...
 
error_t ikeParseTs (const uint8_t *p, size_t length, IkeTsParams *tsParams)
 Parse Traffic Selector substructure. More...
 
const IkePayloadHeaderikeGetPayload (const uint8_t *message, size_t length, uint8_t type, uint_t index)
 Search an IKE message for a given payload type. More...
 
const IkeNotifyPayloadikeGetErrorNotifyPayload (const uint8_t *message, size_t length)
 Search an IKE message for an error Notify payload. More...
 
const IkeNotifyPayloadikeGetStatusNotifyPayload (const uint8_t *message, size_t length, uint16_t type)
 Search an IKE message for a given status Notify payload. More...
 
error_t ikeCheckCriticalPayloads (const uint8_t *message, size_t length, uint8_t *unsupportedCriticalPayload)
 Check whether the message contains an unsupported critical payload. More...
 

Detailed Description

IKE payload parsing.

License

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

Copyright (C) 2022-2024 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.4.4

Definition in file ike_payload_parse.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   IKE_TRACE_LEVEL

Definition at line 32 of file ike_payload_parse.c.

Function Documentation

◆ ikeCheckCriticalPayloads()

error_t ikeCheckCriticalPayloads ( const uint8_t *  message,
size_t  length,
uint8_t *  unsupportedCriticalPayload 
)

Check whether the message contains an unsupported critical payload.

Parameters
[in]messagePointer to the IKE message
[in]lengthLength of the IKE message, in bytes
[out]unsupportedCriticalPayloadType of the unsupported critical payload, if any
Returns
Error code

Definition at line 1035 of file ike_payload_parse.c.

◆ ikeGetErrorNotifyPayload()

const IkeNotifyPayload* ikeGetErrorNotifyPayload ( const uint8_t *  message,
size_t  length 
)

Search an IKE message for an error Notify payload.

Parameters
[in]messagePointer to the received IKE message
[in]lengthLength of the IKE message, in bytes
Returns
Pointer to the error Notify payload, if any

Definition at line 871 of file ike_payload_parse.c.

◆ ikeGetPayload()

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.

Parameters
[in]messagePointer to the IKE message
[in]lengthLength of the IKE message, in bytes
[in]typePayload type
[in]indexPayload occurrence index
Returns
If the specified payload type is found, a pointer to the payload header is returned. Otherwise NULL pointer is returned

Definition at line 799 of file ike_payload_parse.c.

◆ ikeGetStatusNotifyPayload()

const IkeNotifyPayload* ikeGetStatusNotifyPayload ( const uint8_t *  message,
size_t  length,
uint16_t  type 
)

Search an IKE message for a given status Notify payload.

Parameters
[in]messagePointer to the received IKE message
[in]lengthLength of the IKE message, in bytes
[in]typeNotify message type
Returns
Pointer to the error Notify payload, if any

Definition at line 953 of file ike_payload_parse.c.

◆ ikeParseCertReqPayload()

error_t ikeParseCertReqPayload ( IkeSaEntry sa,
const IkeCertReqPayload certReqPayload 
)

Parse Certificate Request payload.

Parameters
[in]saPointer to the IKE SA
[in]certReqPayloadPointer to the Certificate Request payload
Returns
Error code

Definition at line 383 of file ike_payload_parse.c.

◆ ikeParseCookieNotification()

error_t ikeParseCookieNotification ( IkeSaEntry sa,
const IkeNotifyPayload notifyPayload 
)

Parse COOKIE notification.

Parameters
[in]saPointer to the IKE SA
[in]notifyPayloadPointer to the Notify payload
Returns
Error code

Definition at line 603 of file ike_payload_parse.c.

◆ ikeParseDeletePayload()

error_t ikeParseDeletePayload ( IkeSaEntry sa,
const IkeDeletePayload deletePayload,
bool_t  response 
)

Parse Delete payload.

Parameters
[in]saPointer to the IKE SA
[in]deletePayloadPointer to the Delete payload
[in]responseTRUE if the received INFORMATIONAL message is a response
Returns
Error code

Definition at line 454 of file ike_payload_parse.c.

◆ ikeParseIdPayload()

error_t ikeParseIdPayload ( IkeSaEntry sa,
const IkeIdPayload idPayload 
)

Parse Identification payload.

Parameters
[in]saPointer to the IKE SA
[in]idPayloadPointer to the Identification payload
Returns
Error code

Definition at line 348 of file ike_payload_parse.c.

◆ ikeParseInvalidKeyPayloadNotification()

error_t ikeParseInvalidKeyPayloadNotification ( IkeSaEntry sa,
const IkeNotifyPayload notifyPayload 
)

Parse INVALID_KE_PAYLOAD notification.

Parameters
[in]saPointer to the IKE SA
[in]notifyPayloadPointer to the Notify payload
Returns
Error code

Definition at line 562 of file ike_payload_parse.c.

◆ ikeParseKePayload()

error_t ikeParseKePayload ( IkeSaEntry sa,
const IkeKePayload kePayload 
)

Parse Key Exchange payload.

Parameters
[in]saPointer to the IKE SA
[in]kePayloadPointer to the Key Exchange payload
Returns
Error code

Definition at line 309 of file ike_payload_parse.c.

◆ ikeParseNoncePayload()

error_t ikeParseNoncePayload ( const IkeNoncePayload noncePayload,
uint8_t *  nonce,
size_t *  nonceLen 
)

Parse Nonce payload.

Parameters
[in]noncePayloadPointer to the Nonce payload
[out]noncePointer to the buffer where to store the nonce
[out]nonceLenLength of the nonce, in bytes
Returns
Error code

Definition at line 417 of file ike_payload_parse.c.

◆ ikeParseProposal()

error_t ikeParseProposal ( const IkeProposal proposal,
size_t  length 
)

Parse Proposal substructure.

Parameters
[in]proposalPointer to the Proposal substructure
[in]lengthLength of the Proposal substructure, in bytes
Returns
Error code

Definition at line 131 of file ike_payload_parse.c.

◆ ikeParseSaPayload()

error_t ikeParseSaPayload ( const IkeSaPayload saPayload)

Parse Security Association payload.

Parameters
[in]saPayloadPointer to the Security Association payload
Returns
Error code

Definition at line 58 of file ike_payload_parse.c.

◆ ikeParseSignHashAlgosNotification()

error_t ikeParseSignHashAlgosNotification ( IkeSaEntry sa,
const IkeNotifyPayload notifyPayload 
)

Parse SIGNATURE_HASH_ALGORITHMS notification.

Parameters
[in]saPointer to the IKE SA
[in]notifyPayloadPointer to the Notify payload
Returns
Error code

Definition at line 637 of file ike_payload_parse.c.

◆ ikeParseTransform()

error_t ikeParseTransform ( const IkeTransform transform,
size_t  length 
)

Parse Transform substructure.

Parameters
[in]transformPointer to the Transform substructure
[in]lengthLength of the Transform substructure, in bytes
Returns
Error code

Definition at line 205 of file ike_payload_parse.c.

◆ ikeParseTransformAttr()

error_t ikeParseTransformAttr ( const IkeTransformAttr attr,
size_t  length,
size_t *  consumed 
)

Parse transform attribute.

Parameters
[in]attrPointer to the transform attribute
[in]lengthNumber of bytes available in the input stream
[out]consumedTotal number of characters that have been consumed
Returns
Error code

Definition at line 268 of file ike_payload_parse.c.

◆ ikeParseTs()

error_t ikeParseTs ( const uint8_t *  p,
size_t  length,
IkeTsParams tsParams 
)

Parse Traffic Selector substructure.

Parameters
[in]pPointer to the input data to parse
[in]lengthNumber of bytes available in the input data
[out]tsParamsTraffic selector parameters
Returns
Error code

Definition at line 691 of file ike_payload_parse.c.