314 lines
12 KiB
C
314 lines
12 KiB
C
/*
|
|
******************************************************************************
|
|
* HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipike_ipsec_attributes.h,v $ $Revision: 1.9.16.2 $
|
|
* $Source: /home/interpeak/CVSRoot/ipike/src/ipike_ipsec_attributes.h,v $
|
|
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:26 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPIKE_IPSEC_ATTRIBUTE_H
|
|
#define IPIKE_IPSEC_ATTRIBUTE_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/* Attibutes from chapter 4.5 in RFC 2407 */
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipike_config.h"
|
|
#include "ipike_attributes.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#define IPIKE_IPSEC_CLS_SA_LIFE_TYPE 1 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_SA_LIFE_DURATION 2 /* Variable */
|
|
#define IPIKE_IPSEC_CLS_GROUP_DESCRIPTION 3 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_ENCAPSULATION_MODE 4 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_AUTHENTICATION_ALG 5 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_KEY_LENGTH 6 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_KEY_ROUNDS 7 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_COMPRESS_DICTIONARY_SIZE 8 /* Basic */
|
|
#define IPIKE_IPSEC_CLS_COMPRESS_PRIVATE_ALGORITHM 9 /* Variable */
|
|
|
|
#define IPIKE_IPSEC_CLS_COUNT 9
|
|
|
|
|
|
#define IPIKE_IPSEC_LIFE_TYPE_SECONDS 1
|
|
#define IPIKE_IPSEC_LIFE_TYPE_KBYTES 2
|
|
|
|
#define IPIKE_IPSEC_LIFE_TYPE_COUNT 2
|
|
|
|
|
|
#define IPIKE_IPSEC_GROUP_DESC_768_MODP 1
|
|
#define IPIKE_IPSEC_GROUP_DESC_1024_MODP 2
|
|
#define IPIKE_IPSEC_GROUP_DESC_155_EC2N 3
|
|
#define IPIKE_IPSEC_GROUP_DESC_185_EC2N 4
|
|
#define IPIKE_IPSEC_GROUP_DESC_1536_MODP 5
|
|
#define IPIKE_IPSEC_GROUP_DESC_2048_MODP 14
|
|
#define IPIKE_IPSEC_GROUP_DESC_3072_MODP 15
|
|
#define IPIKE_IPSEC_GROUP_DESC_4096_MODP 16
|
|
#define IPIKE_IPSEC_GROUP_DESC_6144_MODP 17
|
|
#define IPIKE_IPSEC_GROUP_DESC_8192_MODP 18
|
|
|
|
#define IPIKE_IPSEC_GROUP_DESC_MAX 18
|
|
|
|
|
|
#define IPIKE_IPSEC_ENCAPSULATION_MODE_TUNNEL 1
|
|
#define IPIKE_IPSEC_ENCAPSULATION_MODE_TRANSPORT 2
|
|
#define IPIKE_IPSEC_ENCAPSULATION_MODE_UDP_TUNNEL 3
|
|
#define IPIKE_IPSEC_ENCAPSULATION_MODE_UDP_TRANSPORT 4
|
|
|
|
#define IPIKE_IPSEC_ENCAPSULATION_MODE_MAX 4
|
|
|
|
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_HMAC_MD5 1
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_HMAC_SHA1 2
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_DES_MAC 3
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_KPDK 4
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_HMAC_SHA2_256_128 5
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_HMAC_SHA2_384_192 6
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_HMAC_SHA2_512_256 7
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_AES_XCBC_MAC 9
|
|
|
|
|
|
#define IPIKE_IPSEC_AUTHENTICATION_ALG_COUNT 9
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_class_to_string
|
|
*===========================================================================
|
|
* Description: Returns a string representation of the attribute type.
|
|
* Parameters: attribute_type - the attribute type.
|
|
* Returns: A string representation of the attribute type.
|
|
*/
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_class_to_string(Ip_u16 attribute_type);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_value_to_string
|
|
*===========================================================================
|
|
* Description: Returns a string representation of the IPSec attribute value.
|
|
* Parameters: type - the attribute type.
|
|
* value - the attribute value.
|
|
* Returns: A string representation of the attribute value.
|
|
*/
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_value_to_string(Ip_u16 type, Ip_u16 value);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_process_encapsulation_mode
|
|
*===========================================================================
|
|
* Description: Verifies that the suggested encapsulation mode is supported,
|
|
* if it is, set enc_name.
|
|
* Parameters: attr - the encapsulation mode attribute.
|
|
* valid_suits - the valid IPSec suites.
|
|
* call is successfull.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_SA_NO_MATCHING_ENCRYPTION_ALGORITHM
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_process_encapsulation_mode(
|
|
Ipike_attribute* attr,
|
|
Ip_u16* enc_alg);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_process_authentication_algorithm
|
|
*===========================================================================
|
|
* Description: Verifies that the suggested authenticaton algorithm is
|
|
* supported, if it is, set enc_name.
|
|
* Parameters: attr - the encapsulation mode attribute.
|
|
* valid_suits - the valid IPSec suites.
|
|
* call is successfull.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_SA_NO_MATCHING_ENCRYPTION_ALGORITHM
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_process_authentication_algorithm(
|
|
Ipike_attribute* attr,
|
|
Ip_u16* auth_alg);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_process_key_length
|
|
*===========================================================================
|
|
* Description: Verifies that the suggested key length is supported,
|
|
* if it is, set key length.
|
|
* Parameters: attr - the encapsulation mode attribute.
|
|
* key_length - a valid key length if call is successfull.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_ATTRIBUTE_INVALID_VALUE
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_process_key_length(Ipike_attribute* attr, Ip_u16* key_length);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_check_transform_identifier
|
|
*===========================================================================
|
|
* Description: Verifies that the suggested crypto/HMAC-algorithm is supported,
|
|
* and that the configuration allows us to use it.
|
|
* Parameters: security_proto_id - the proposal protocol ID.
|
|
* transform_id - the AH/ESP/IPCOMP transform ID.
|
|
* valid_suits - the valid IPSec suites.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_SA_NO_MATCHING_HASH_ALGORITHM
|
|
* IPIKE_SA_NO_MATCHING_ENCRYPTION_ALGORITHM
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_check_transform_identifier(Ip_u8 security_proto_id, Ip_u8 transform_id);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_get_esp_cipher_key_length
|
|
*===========================================================================
|
|
* Description: Returns the key length (in bytes) for the specified transform
|
|
* ID. It is only legal to call this function for transform IDs
|
|
* under the IPIKE_PROTO_IPSEC_ESP proposal protocol ID.
|
|
* Parameters: transform_id - the ESP transform ID.
|
|
* key_length - the default key length for the specified cipher.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_PROPOSAL_INVALID_ID
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_get_esp_cipher_key_length(Ip_u8 transform_id, Ip_size_t* key_length);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_get_esp_auth_key_length
|
|
*===========================================================================
|
|
* Description: Returns the key length (in bytes) for the authentication
|
|
* algorithm.
|
|
* Parameters: auth_alg - the authentication algorithm.
|
|
* key_length - the default key length for the specified cipher.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_ATTRIBUTE_UNSUPPORTED_VALUE
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_get_esp_auth_key_length(Ip_u16 auth_alg, Ip_size_t* key_length);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_get_ah_key_length
|
|
*===========================================================================
|
|
* Description: Returns the key length (in bytes) for the specified transform
|
|
* ID. It is only legal to call this function for transform IDs
|
|
* under the IPIKE_PROTO_IPSEC_AH proposal protocol ID.
|
|
* Parameters: transform_id - the AH transform ID.
|
|
* key_length - the default key length for the specified cipher.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_PROPOSAL_INVALID_ID
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_get_ah_key_length(Ip_u8 transform_id, Ip_size_t* key_length);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_xxx_to_string
|
|
*===========================================================================
|
|
* Description: Converts the numberical representation of a attribute to its
|
|
* string form.
|
|
* Parameters: s - The string representation of the value.
|
|
* Returns: The string representation of the value.
|
|
*
|
|
*/
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_ah_alg_to_string(Ip_u16 v);
|
|
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_esp_alg_to_string(Ip_u16 v);
|
|
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_integrity_alg_to_string(Ip_u16 v);
|
|
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_encap_mode_to_string(Ip_u16 v);
|
|
|
|
IP_GLOBAL const char*
|
|
ipike_ipsec_attribute_esp_key_length_alg_to_string(Ip_u16 v1, Ip_u16 v2);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_ipsec_attribute_xxx_from_string
|
|
*===========================================================================
|
|
* Description: Converts the string representation of a attribute to its
|
|
* numerical form.
|
|
* Parameters: s - The string representation of the value.
|
|
* v - Will hold the value if the call is successful.
|
|
* Returns: IPIKE_SUCCESS
|
|
* IPIKE_VALUE_NOT_FOUND
|
|
* IPIKE_INVALID_VALUE
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_ah_alg_from_string(const char *s, Ip_u16* v);
|
|
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_esp_alg_from_string(const char *s, Ip_u16* v);
|
|
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_integrity_alg_from_string(const char *s, Ip_u16* v);
|
|
|
|
IP_GLOBAL Ipike_error
|
|
ipike_ipsec_attribute_encap_mode_from_string(const char *s, Ip_u16* v);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|