Files
m241Neelima/components/ip_net2-6.9/ipike/src/ipike_payload_nonce.h
T
2026-07-30 11:19:44 +05:30

218 lines
7.4 KiB
C

/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipike_payload_nonce.h,v $ $Revision: 1.4.14.1 $
* $Source: /home/interpeak/CVSRoot/ipike/src/ipike_payload_nonce.h,v $
* $Author: zan $ $Date: 2013-01-10 03:36:54 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
******************************************************************************
*/
#ifndef IPIKE_PAYLOAD_NONCE_H
#define IPIKE_PAYLOAD_NONCE_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/* Nonce payload (RFC 2408, chapter 3.13) */
/* IKE version 1 and 2 */
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipike_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include "ipike_payload.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPIKE_NONCE_HEADER_LENGTH sizeof(Ipike_nonce_payload)
#define IPIKE_NONCE_MIN_LEN 8
#define IPIKE_NONCE_MAX_LEN 256
#define IPIKE2_NONCE_MIN_LEN 16
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
Nonce Payload Format
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Next Payload ! RESERVED ! Payload Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! !
~ Nonce Data ~
! !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
typedef struct Ipike_payload_nonce_struct
{
/* The generic ISAKMP payload header, the length includes the length
of all transforms associated with the proposal */
Ipike_payload_header header;
/* Nonce Data follows (variable length). Contains the random data generated
by the transmitting entity. */
}
Ipike_nonce_payload;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipike_payload_nonce_new
*===========================================================================
* Description: Creates a new nonce payload.
* Parameters: nonce_data - nonce data.
* nonce_len - the length of the nonce.
* Returns: A new nonce payload or IP_NULL if out of memory.
*
*
*/
IP_GLOBAL Ipike_nonce_payload*
ipike_payload_nonce_new(const Ip_u8* nonce_data, Ip_u16 nonce_len);
/*
*===========================================================================
* ipike_payload_nonce_create
*===========================================================================
* Description: Creates a new nonce payload from the information created
* in the exchange.
* Parameters: n - the nonce value.
* nonce - will point to a new nonce payload if the
* call was successful.
* Returns: IPIKE_SUCCESS
* IPIKE_OUT_OF_MEMORY
*
*/
IP_GLOBAL Ipike_error
ipike_payload_nonce_create(Ipike_value* n, Ipike_nonce_payload** nonce);
/*
*===========================================================================
* ipike_payload_nonce_check_payload
*===========================================================================
* Description: Verifies that the nonce payload is sane.
* Parameters: ke - a pointer to a nonce payload.
* Returns: IPIKE_SUCCESS
*
*
*/
IP_GLOBAL Ipike_error
ipike_payload_nonce_check(Ipike_nonce_payload* nonce);
#ifdef IPIKE_USE_VERSION2
/*
*===========================================================================
* ipike2_payload_nonce_check_payload
*===========================================================================
* Description: Verifies that the nonce payload is sane.
* Parameters: ke - a pointer to a nonce payload.
* Returns: IPIKE_SUCCESS
*
*
*/
IP_GLOBAL Ipike_error
ipike2_payload_nonce_check(Ipike_nonce_payload* nonce);
#endif
/*
*===========================================================================
* ipike_payload_nonce_print_payload
*===========================================================================
* Description: Prints the content of the nonce payload to the
* system log.
* Parameters: nonce - a pointer to a nonce payload.
* Returns:
*
*
*/
IP_GLOBAL void
ipike_payload_nonce_print(Ipike_nonce_payload* nonce);
/*
*===========================================================================
* ipike_payload_nonce_extract
*===========================================================================
* Description: Extracts the nonce data from the payload.
* Parameters: payload - a nonce payload.
* nonce - the nonce data will be added here if the call was
* successful.
* Returns: IPIKE_SUCCESS
* IPIKE_OUT_OF_MEMORY
*
*/
IP_GLOBAL Ipike_error
ipike_payload_nonce_extract(Ipike_nonce_payload* payload, Ipike_value* nonce);
/*
*===========================================================================
* ipike_payload_nonce_generate
*===========================================================================
* Description: Generates some random data and stores in as a nonce.
* Parameters: nonce - pointer to where the nonce should be stored.
* Returns: IPIKE_SUCCESS
* IPIKE_OUT_OF_MEMORY
*
*/
IP_GLOBAL Ipike_error
ipike_payload_nonce_generate(Ipike_value* nonce);
/*
*===========================================================================
* ipike_payload_nonce_cmp
*===========================================================================
* Description: Compares two nonces.
* Parameters: nonce1 - Pointer to the first nonce.
* nonce2 - Pointer to the second nonce.
* Returns: -1 if nonce1 < nonce2
* 1 if nonce1 > nonce2
* 0 if nonce1 == nonce2
*/
IP_GLOBAL int
ipike_payload_nonce_cmp(Ipike_value* nonce1, Ipike_value* nonce2);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/