- added definitions from IKEv2 draft
authorMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:12:31 +0000 (16:12 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:12:31 +0000 (16:12 -0000)
Source/charon/payloads/transform_attribute.c
Source/charon/payloads/transform_attribute.h
Source/charon/payloads/transform_substructure.c
Source/charon/payloads/transform_substructure.h

index 3dc714e..3b24048 100644 (file)
@@ -68,6 +68,16 @@ struct private_transform_attribute_s {
 };
 
 
+
+/** 
+ * string mappings for transform_attribute_type_t
+ */
+mapping_t transform_attribute_type_m[] = {
+       {ATTRIBUTE_UNDEFINED, "ATTRIBUTE_UNDEFINED"},
+       {KEY_LENGTH, "KEY_LENGTH"},
+       {MAPPING_END, NULL}
+};
+
 /**
  * Encoding rules to parse or generate a Transform attribute
  * 
@@ -157,7 +167,7 @@ static size_t get_length(private_transform_attribute_t *this)
  * Implements transform_attribute_t's set_value function.
  * See #transform_attribute_s.set_value for description.
  */
-static status_t set_value (private_transform_attribute_t *this, chunk_t value)
+static status_t set_value_chunk(private_transform_attribute_t *this, chunk_t value)
 {
        if (this->attribute_value.ptr != NULL)
        {
@@ -188,10 +198,28 @@ static status_t set_value (private_transform_attribute_t *this, chunk_t value)
 }
 
 /**
- * Implements transform_attribute_t's get_value function.
- * See #transform_attribute_s.get_value for description.
+ * Implements transform_attribute_t's set_value function.
+ * See #transform_attribute_s.set_value for description.
+ */
+static status_t set_value(private_transform_attribute_t *this, u_int16_t value)
+{
+       if (this->attribute_value.ptr != NULL)
+       {
+               /* free existing value */
+               allocator_free(this->attribute_value.ptr);
+               this->attribute_value.ptr = NULL;
+               this->attribute_value.len = 0;
+               
+       }
+       this->attribute_length_or_value = value;
+       return SUCCESS;
+}
+
+/**
+ * Implements transform_attribute_t's get_value_chunk function.
+ * See #transform_attribute_s.get_value_chunk for description.
  */
-static chunk_t get_value (private_transform_attribute_t *this)
+static chunk_t get_value_chunk (private_transform_attribute_t *this)
 {
        chunk_t value;
 
@@ -210,6 +238,16 @@ static chunk_t get_value (private_transform_attribute_t *this)
 }
 
 /**
+ * Implements transform_attribute_t's get_value function.
+ * See #transform_attribute_s.get_value for description.
+ */
+static u_int16_t get_value (private_transform_attribute_t *this)
+{
+       return this->attribute_length_or_value;
+}
+
+
+/**
  * Implements transform_attribute_t's set_attribute_type function.
  * See #transform_attribute_s.set_attribute_type for description.
  */
@@ -245,8 +283,10 @@ transform_attribute_t *transform_attribute_create()
        this->public.payload_interface.set_next_type = (status_t (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (status_t (*) (payload_t *))destroy;
-       this->public.set_value = (status_t (*) (transform_attribute_t *,chunk_t value)) set_value;
-       this->public.get_value = (chunk_t (*) (transform_attribute_t *)) get_value;
+       this->public.set_value_chunk = (status_t (*) (transform_attribute_t *,chunk_t)) set_value_chunk;
+       this->public.set_value = (status_t (*) (transform_attribute_t *,u_int16_t)) set_value;
+       this->public.get_value_chunk = (chunk_t (*) (transform_attribute_t *)) get_value_chunk;
+       this->public.get_value = (u_int16_t (*) (transform_attribute_t *)) get_value;
        this->public.set_attribute_type = (status_t (*) (transform_attribute_t *,u_int16_t type)) set_attribute_type;
        this->public.get_attribute_type = (u_int16_t (*) (transform_attribute_t *)) get_attribute_type;
        this->public.destroy = (status_t (*) (transform_attribute_t *)) destroy;
index c0355a4..0dea2b7 100644 (file)
 #include "../types.h"
 #include "payload.h"
 
+
+/**
+ * Type of the attribute, as in IKEv2 draft 3.3.5
+ */
+typedef enum transform_attribute_type_e transform_attribute_type_t;
+
+enum transform_attribute_type_e {
+       ATTRIBUTE_UNDEFINED = 16384,
+       KEY_LENGTH = 14
+};
+
+/** 
+ * string mappings for transform_attribute_type_t
+ */
+extern mapping_t transform_attribute_type_m[];
+
 /**
  * Object representing an IKEv2- TRANSFORM Attribute
  * 
@@ -50,7 +66,17 @@ struct transform_attribute_s {
         * @param this  calling transform_attribute_t object
         * @return              chunk_t pointing to the value
         */
-       chunk_t (*get_value) (transform_attribute_t *this);
+       chunk_t (*get_value_chunk) (transform_attribute_t *this);
+       
+       /**
+        * @brief Returns the currently set value of the attribute
+        *      
+        * @warning Returned data are not copied
+        * 
+        * @param this  calling transform_attribute_t object
+        * @return              value
+        */
+       u_int16_t (*get_value) (transform_attribute_t *this);
        
        /**
         * @brief Sets the value of the attribute.
@@ -63,7 +89,18 @@ struct transform_attribute_s {
         *                              - SUCCESS or
         *                              - OUT_OF_RES
         */
-       status_t (*set_value) (transform_attribute_t *this, chunk_t value);
+       status_t (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
+
+       /**
+        * @brief Sets the value of the attribute.
+        * 
+        * @param this  calling transform_attribute_t object
+        * @param value value to set
+        * @return              
+        *                              - SUCCESS or
+        *                              - OUT_OF_RES
+        */
+       status_t (*set_value) (transform_attribute_t *this, u_int16_t value);
 
        /**
         * @brief Sets the type of the attribute.
index bb7718a..ec52ec8 100644 (file)
@@ -83,6 +83,90 @@ struct private_transform_substructure_s {
 };
 
 
+/** 
+ * string mappings for transform_type_t
+ */
+mapping_t transform_type_m[] = {
+       {UNDEFINED_TRANSFORM_TYPE, "UNDEFINED_TRANSFORM_TYPE"},
+       {ENCRYPTION_ALGORITHM, "ENCRYPTION_ALGORITHM"},
+       {PSEUDO_RANDOM_FUNCTION, "PSEUDO_RANDOM_FUNCTION"},
+       {INTEGRITIY_ALGORITHM, "INTEGRITIY_ALGORITHM"},
+       {DIFFIE_HELLMAN_GROUP, "DIFFIE_HELLMAN_GROUP"},
+       {EXTENDED_SEQUENCE_NUNBERS, "EXTENDED_SEQUENCE_NUNBERS"},
+       {MAPPING_END, NULL}
+};
+
+
+/** 
+ * string mappings for encryption_algorithm_t
+ */
+mapping_t encryption_algorithm_m[] = {
+       {ENCR_UNDEFINED, "ENCR_UNDEFINED"},
+       {ENCR_DES_IV64, "ENCR_DES_IV64"},
+       {ENCR_DES, "ENCR_DES"},
+       {ENCR_3DES, "ENCR_3DES"},
+       {ENCR_RC5, "ENCR_RC5"},
+       {ENCR_IDEA, "ENCR_IDEA"},
+       {ENCR_CAST, "ENCR_CAST"},
+       {ENCR_BLOWFISH, "ENCR_BLOWFISH"},
+       {ENCR_3IDEA, "ENCR_3IDEA"},
+       {ENCR_DES_IV32, "ENCR_DES_IV32"},
+       {ENCR_NULL, "ENCR_NULL"},
+       {ENCR_AES_CBC, "ENCR_AES_CBC"},
+       {ENCR_AES_CTR, "ENCR_AES_CTR"},
+       {MAPPING_END, NULL}
+};
+
+/** 
+ * string mappings for encryption_algorithm_t
+ */
+mapping_t pseudo_random_function_m[] = {
+       {PRF_UNDEFINED, "PRF_UNDEFINED"},
+       {PRF_HMAC_MD5, "PRF_HMAC_SHA1"},
+       {PRF_HMAC_SHA1, "PRF_HMAC_SHA1"},
+       {PRF_HMAC_TIGER, "PRF_HMAC_TIGER"},
+       {PRF_AES128_CBC, "PRF_AES128_CBC"},
+       {MAPPING_END, NULL}
+};
+
+/** 
+ * string mappings for integrity_algorithm_t
+ */
+mapping_t integrity_algorithm_m[] = {
+       {AUTH_UNDEFINED, "AUTH_UNDEFINED"},
+       {AUTH_HMAC_MD5_96, "AUTH_HMAC_MD5_96"},
+       {AUTH_HMAC_SHA1_96, "AUTH_HMAC_SHA1_96"},
+       {AUTH_DES_MAC, "AUTH_DES_MAC"},
+       {AUTH_KPDK_MD5, "AUTH_KPDK_MD5"},
+       {AUTH_AES_XCBC_96, "AUTH_AES_XCBC_96"},
+       {MAPPING_END, NULL}
+};
+
+/** 
+ * string mappings for diffie_hellman_group_t
+ */
+mapping_t diffie_hellman_group_m[] = {
+       {MODP_UNDEFINED, "MODP_UNDEFINED"},
+       {MODP_768_BIT, "MODP_768_BIT"},
+       {MODP_1024_BIT, "MODP_1024_BIT"},
+       {MODP_1536_BIT, "MODP_1536_BIT"},
+       {MODP_2048_BIT, "MODP_2048_BIT"},
+       {MODP_3072_BIT, "MODP_3072_BIT"},
+       {MODP_4096_BIT, "MODP_4096_BIT"},
+       {MODP_6144_BIT, "MODP_6144_BIT"},
+       {MODP_8192_BIT, "MODP_8192_BIT"},
+       {MAPPING_END, NULL}
+};
+
+/** 
+ * string mappings for extended_sequence_numbers_t
+ */
+mapping_t extended_sequence_numbers_m[] = {
+       {NO_EXT_SEQ_NUMBERS, "NO_EXT_SEQ_NUMBERS"},
+       {EXT_SEQ_NUMBERS, "EXT_SEQ_NUMBERS"},
+       {MAPPING_END, NULL}
+};
+
 /**
  * Encoding rules to parse or generate a Transform substructure
  * 
index 661c94f..ca4f2ee 100644 (file)
@@ -26,7 +26,9 @@
 #define TRANSFORM_SUBSTRUCTURE_H_
 
 #include "../types.h"
+#include "../definitions.h"
 #include "payload.h"
+#include "../definitions.h"
 #include "../utils/linked_list.h"
 #include "transform_attribute.h"
 
  */
 #define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
 
+
+/**
+ * Type of a transform, as in IKEv2 draft 3.3.2
+ */
+typedef enum transform_type_e transform_type_t;
+
+enum transform_type_e {
+       UNDEFINED_TRANSFORM_TYPE = 241,
+       ENCRYPTION_ALGORITHM = 1,
+       PSEUDO_RANDOM_FUNCTION = 2,
+       INTEGRITIY_ALGORITHM = 3,
+       DIFFIE_HELLMAN_GROUP = 4,
+       EXTENDED_SEQUENCE_NUNBERS = 5
+};
+
+/** 
+ * string mappings for transform_type_t
+ */
+extern mapping_t transform_type_m[];
+
+/**
+ * Encryption algorithm, as in IKEv2 draft 3.3.2
+ */
+typedef enum encryption_algorithm_e encryption_algorithm_t;
+
+enum encryption_algorithm_e {
+       ENCR_UNDEFINED = 1024,
+       ENCR_DES_IV64 = 1,
+       ENCR_DES = 2,
+       ENCR_3DES = 3,
+       ENCR_RC5 = 4,
+       ENCR_IDEA = 5,
+       ENCR_CAST = 6,
+       ENCR_BLOWFISH = 7,
+       ENCR_3IDEA = 8,
+       ENCR_DES_IV32 = 9,
+       RESERVED = 10,
+       ENCR_NULL = 11,
+       ENCR_AES_CBC = 12,
+       ENCR_AES_CTR = 13
+};
+
+/** 
+ * string mappings for encryption_algorithm_t
+ */
+extern mapping_t encryption_algorithm_m[];
+
+/**
+ * Pseudo random function, as in IKEv2 draft 3.3.2
+ */
+typedef enum pseudo_random_function_e pseudo_random_function_t;
+
+enum pseudo_random_function_e {
+       PRF_UNDEFINED = 1024,
+       PRF_HMAC_MD5 = 1,
+       PRF_HMAC_SHA1 = 2,
+       PRF_HMAC_TIGER = 3,
+       PRF_AES128_CBC = 4
+};
+
+/** 
+ * string mappings for encryption_algorithm_t
+ */
+extern mapping_t pseudo_random_function_m[];
+
+/**
+ * Integrity algorithm, as in IKEv2 draft 3.3.2
+ */
+typedef enum integrity_algorithm_e integrity_algorithm_t;
+
+enum integrity_algorithm_e {
+       AUTH_UNDEFINED = 1024,
+       AUTH_HMAC_MD5_96 = 1,
+       AUTH_HMAC_SHA1_96 = 2,
+       AUTH_DES_MAC = 3,
+       AUTH_KPDK_MD5 = 4,
+       AUTH_AES_XCBC_96 = 5
+};
+
+/** 
+ * string mappings for integrity_algorithm_t
+ */
+extern mapping_t integrity_algorithm_m[];
+
+
+/** 
+ * Diffie-Hellman group, as in IKEv2 draft 3.3.2 and RFC 3526
+ */
+typedef enum diffie_hellman_group_e diffie_hellman_group_t;
+
+enum diffie_hellman_group_e {
+       MODP_UNDEFINED = 1024,
+       MODP_768_BIT = 1,
+       MODP_1024_BIT = 2,
+       MODP_1536_BIT = 5,
+       MODP_2048_BIT = 14,
+       MODP_3072_BIT = 15,
+       MODP_4096_BIT = 16,
+       MODP_6144_BIT = 17,
+       MODP_8192_BIT = 18
+};
+
+/** 
+ * string mappings for diffie_hellman_group_t
+ */
+extern mapping_t diffie_hellman_group_m[];
+
+/** 
+ * Extended sequence numbers, as in IKEv2 draft 3.3.2
+ */
+typedef enum extended_sequence_numbers_e extended_sequence_numbers_t;
+
+enum extended_sequence_numbers_e {
+       NO_EXT_SEQ_NUMBERS = 0,
+       EXT_SEQ_NUMBERS = 1
+};
+
+/** 
+ * string mappings for extended_sequence_numbers_t
+ */
+extern mapping_t extended_sequence_numbers_m[];
+
 /**
  * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE
  *