aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-12-06 15:37:56 +0000
committerJan Hutter <jhutter@hsr.ch>2005-12-06 15:37:56 +0000
commit6f36717843c71a46c5cfb8d4d4f9b74d0585de1f (patch)
treeffa1345c68767e8660a6bf917eeef9d5ce15b947
parent62abe4a37dade51bc122e97d566ec7b728648638 (diff)
downloadstrongswan-6f36717843c71a46c5cfb8d4d4f9b74d0585de1f.tar.bz2
strongswan-6f36717843c71a46c5cfb8d4d4f9b74d0585de1f.tar.xz
- code cleaned up
-rw-r--r--Source/charon/transforms/crypters/crypter.h2
-rw-r--r--Source/charon/transforms/hashers/hasher.c6
-rw-r--r--Source/charon/transforms/hashers/hasher.h56
-rw-r--r--Source/charon/transforms/hashers/md5_hasher.c18
-rw-r--r--Source/charon/transforms/hashers/md5_hasher.h4
-rw-r--r--Source/charon/transforms/hashers/sha1_hasher.c22
-rw-r--r--Source/charon/transforms/hashers/sha1_hasher.h4
-rw-r--r--Source/charon/transforms/prfs/hmac_prf.c20
-rw-r--r--Source/charon/transforms/prfs/hmac_prf.h13
-rw-r--r--Source/charon/transforms/prfs/prf.c5
-rw-r--r--Source/charon/transforms/prfs/prf.h48
11 files changed, 119 insertions, 79 deletions
diff --git a/Source/charon/transforms/crypters/crypter.h b/Source/charon/transforms/crypters/crypter.h
index d4ba40e1d..6c0d4d6fb 100644
--- a/Source/charon/transforms/crypters/crypter.h
+++ b/Source/charon/transforms/crypters/crypter.h
@@ -1,7 +1,7 @@
/**
* @file crypter.h
*
- * @brief Interface of crypter_t
+ * @brief Interface crypter_t
*
*/
diff --git a/Source/charon/transforms/hashers/hasher.c b/Source/charon/transforms/hashers/hasher.c
index 0b86eef37..71811c16a 100644
--- a/Source/charon/transforms/hashers/hasher.c
+++ b/Source/charon/transforms/hashers/hasher.c
@@ -1,7 +1,7 @@
/**
* @file hasher.c
*
- * @brief Generic constructor for hasher_t
+ * @brief Generic constructor for hasher_t.
*
*/
@@ -27,7 +27,7 @@
#include <transforms/hashers/md5_hasher.h>
/**
- * mappings for hash_algorithm_t
+ * String mappings for hash_algorithm_t.
*/
mapping_t hash_algorithm_m[] = {
{HASH_MD2,"HASH_MD2"},
@@ -40,7 +40,7 @@ mapping_t hash_algorithm_m[] = {
};
/*
- * Described in header
+ * Described in header.
*/
hasher_t *hasher_create(hash_algorithm_t hash_algorithm)
{
diff --git a/Source/charon/transforms/hashers/hasher.h b/Source/charon/transforms/hashers/hasher.h
index e207b30f1..00ea0a724 100644
--- a/Source/charon/transforms/hashers/hasher.h
+++ b/Source/charon/transforms/hashers/hasher.h
@@ -1,7 +1,7 @@
/**
* @file hasher.h
*
- * @brief Interface for hasher_t.
+ * @brief Interface hasher_t.
*
*/
@@ -26,22 +26,36 @@
#include <types.h>
+
typedef enum hash_algorithm_t hash_algorithm_t;
/**
* @brief Algorithms to use for hashing.
+ *
+ * Currently only the following algorithms are implemented and therefore supported:
+ * - HASH_MD5
+ * - HASH_SHA1
+ *
+ * @ingroup hashers
+ *
*/
enum hash_algorithm_t {
HASH_MD2,
- HASH_MD5, /* supported */
- HASH_SHA1, /* supported */
+ /**
+ * Implemented in class md5_hasher_t.
+ */
+ HASH_MD5,
+ /**
+ * Implemented in class sha1_hasher_t.
+ */
+ HASH_SHA1,
HASH_SHA256,
HASH_SHA384,
HASH_SHA512,
};
/**
- * string mappings for hash_algorithm_t
+ * String mappings for hash_algorithm_t.
*/
extern mapping_t hash_algorithm_m[];
@@ -52,37 +66,43 @@ typedef struct hasher_t hasher_t;
* @brief Generic interface for all hash functions.
*
* @b Constructors:
- * - hasher_create()
+ * - hasher_create()
+ * - md5_hasher_create()
+ * - sha1_hasher_create()
+ *
+ * @see
+ * - md5_hasher_t
+ * - sha1_hasher_t
*
- * @see md5_hasher_t, sha1_hasher_t
+ * @todo Implement more hash algorithms
*
* @ingroup hashers
*/
struct hasher_t {
/**
- * @brief hash data and write it in the buffer
+ * @brief Hash data and write it in the buffer.
*
* If the parameter hash is NULL, no result is written back
* an more data can be appended to already hashed data.
- * If not, the result is written back and the hasher is reset.
+ * If not, the result is written back and the hasher is reseted.
*
* @warning: the hash output parameter must hold at least
* hash_t.get_block_size bytes.
*
- * @param this calling hasher
+ * @param this calling object
* @param data data to hash
- * @param [out]buffer pointer where the hash will be written
+ * @param [out]hash pointer where the hash will be written
*/
void (*get_hash) (hasher_t *this, chunk_t data, u_int8_t *hash);
/**
- * @brief hash data and allocate space for the hash
+ * @brief Hash data and allocate space for the hash.
*
* If the parameter hash is NULL, no result is written back
* an more data can be appended to already hashed data.
- * If not, the result is written back and the hasher is reset.
+ * If not, the result is written back and the hasher is reseted.
*
- * @param this calling hasher
+ * @param this calling object
* @param data chunk with data to hash
* @param [out]hash chunk which will hold allocated hash
*/
@@ -91,23 +111,23 @@ struct hasher_t {
/**
* @brief Get the block size of this hashing function.
*
- * @param this calling hasher
+ * @param this calling object
* @return block size in bytes
*/
size_t (*get_block_size) (hasher_t *this);
/**
* @brief Resets the hashers state, which allows
- * computation of a completly new hash.
+ * computation of a completely new hash.
*
- * @param this calling hasher
+ * @param this calling object
*/
void (*reset) (hasher_t *this);
/**
* @brief Destroys a hasher object.
*
- * @param this hasher_t object to destroy
+ * @param this calling object
*/
void (*destroy) (hasher_t *this);
};
@@ -117,7 +137,7 @@ struct hasher_t {
*
* @param hash_algorithm Algorithm to use for hashing
* @return
- * - hasher_t if successfully
+ * - hasher_t object
* - NULL if algorithm not supported
*
* @ingroup hashers
diff --git a/Source/charon/transforms/hashers/md5_hasher.c b/Source/charon/transforms/hashers/md5_hasher.c
index bdb0b9eb9..cd883d92c 100644
--- a/Source/charon/transforms/hashers/md5_hasher.c
+++ b/Source/charon/transforms/hashers/md5_hasher.c
@@ -100,16 +100,16 @@ Rotation is separate from addition to prevent recomputation.
typedef struct private_md5_hasher_t private_md5_hasher_t;
/**
- * private data structure with hasing context
+ * Private data structure with hasing context.
*/
struct private_md5_hasher_t {
/**
- * public interface for this hasher
+ * Public interface for this hasher.
*/
md5_hasher_t public;
/*
- * state of the hasher
+ * State of the hasher.
*/
u_int32_t state[5];
u_int32_t count[2];
@@ -311,7 +311,7 @@ static void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
/**
- * implementation of hasher_t.get_hash for md5
+ * Implementation of hasher_t.get_hash.
*/
static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{
@@ -325,7 +325,7 @@ static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer
/**
- * implementation of hasher_t.allocate_hash for md5
+ * Implementation of hasher_t.allocate_hash.
*/
static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
{
@@ -345,7 +345,7 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
}
/**
- * implementation of hasher_t.get_block_size for md5
+ * Implementation of hasher_t.get_block_size.
*/
static size_t get_block_size(private_md5_hasher_t *this)
{
@@ -353,7 +353,7 @@ static size_t get_block_size(private_md5_hasher_t *this)
}
/**
- * implementation of hasher_t.reset for md5
+ * Implementation of hasher_t.reset.
*/
static void reset(private_md5_hasher_t *this)
{
@@ -366,7 +366,7 @@ static void reset(private_md5_hasher_t *this)
}
/**
- * implementation of hasher_t.destroy for md5
+ * Implementation of hasher_t.destroy.
*/
static void destroy(private_md5_hasher_t *this)
{
@@ -374,7 +374,7 @@ static void destroy(private_md5_hasher_t *this)
}
/*
- * Described in header
+ * Described in header.
*/
md5_hasher_t *md5_hasher_create()
{
diff --git a/Source/charon/transforms/hashers/md5_hasher.h b/Source/charon/transforms/hashers/md5_hasher.h
index 9a4b53e15..b32acc062 100644
--- a/Source/charon/transforms/hashers/md5_hasher.h
+++ b/Source/charon/transforms/hashers/md5_hasher.h
@@ -33,7 +33,7 @@ typedef struct md5_hasher_t md5_hasher_t;
* MD5 algorithm.
*
* @b Constructors:
- * - hasher_create() using HASH_MD5
+ * - hasher_create() using HASH_MD5 as algorithm
* - md5_hasher_create()
*
* @see hasher_t
@@ -43,7 +43,7 @@ typedef struct md5_hasher_t md5_hasher_t;
struct md5_hasher_t {
/**
- * generic hasher_t interface for this hasher
+ * Generic hasher_t interface for this hasher.
*/
hasher_t hasher_interface;
};
diff --git a/Source/charon/transforms/hashers/sha1_hasher.c b/Source/charon/transforms/hashers/sha1_hasher.c
index 609571b4c..2fa659f74 100644
--- a/Source/charon/transforms/hashers/sha1_hasher.c
+++ b/Source/charon/transforms/hashers/sha1_hasher.c
@@ -55,16 +55,16 @@
typedef struct private_sha1_hasher_t private_sha1_hasher_t;
/**
- * private data structure with hasing context
+ * Private data structure with hasing context.
*/
struct private_sha1_hasher_t {
/**
- * public interface for this hasher
+ * Public interface for this hasher.
*/
sha1_hasher_t public;
/*
- * state of the hasher
+ * State of the hasher.
*/
u_int32_t state[5];
u_int32_t count[2];
@@ -185,7 +185,7 @@ static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
/**
- * implementation of hasher_t.get_hash for sha1
+ * Implementation of hasher_t.get_hash.
*/
static void get_hash(private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{
@@ -199,7 +199,7 @@ static void get_hash(private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffe
/**
- * implementation of hasher_t.allocate_hash for sha1
+ * Implementation of hasher_t.allocate_hash.
*/
static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *hash)
{
@@ -219,7 +219,7 @@ static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *h
}
/**
- * implementation of hasher_t.get_block_size for sha1
+ * Implementation of hasher_t.get_block_size.
*/
static size_t get_block_size(private_sha1_hasher_t *this)
{
@@ -227,7 +227,7 @@ static size_t get_block_size(private_sha1_hasher_t *this)
}
/**
- * implementation of hasher_t.reset for sha1
+ * Implementation of hasher_t.reset.
*/
static void reset(private_sha1_hasher_t *this)
{
@@ -240,7 +240,7 @@ static void reset(private_sha1_hasher_t *this)
this->count[1] = 0;
}
/**
- * implementation of hasher_t.destroy for sha1
+ * Implementation of hasher_t.destroy.
*/
static void destroy(private_sha1_hasher_t *this)
{
@@ -249,15 +249,11 @@ static void destroy(private_sha1_hasher_t *this)
/*
- * Described in header
+ * Described in header.
*/
sha1_hasher_t *sha1_hasher_create()
{
private_sha1_hasher_t *this = allocator_alloc_thing(private_sha1_hasher_t);
- if (this == NULL)
- {
- return NULL;
- }
this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
diff --git a/Source/charon/transforms/hashers/sha1_hasher.h b/Source/charon/transforms/hashers/sha1_hasher.h
index d5c0c3230..43ad0ae20 100644
--- a/Source/charon/transforms/hashers/sha1_hasher.h
+++ b/Source/charon/transforms/hashers/sha1_hasher.h
@@ -33,7 +33,7 @@ typedef struct sha1_hasher_t sha1_hasher_t;
* SHA1 algorithm.
*
* @b Constructors:
- * - hasher_create() using HASH_SHA1
+ * - hasher_create() using HASH_SHA1 as algorithm
* - sha1_hasher_create()
*
* @see hasher_t
@@ -43,7 +43,7 @@ typedef struct sha1_hasher_t sha1_hasher_t;
struct sha1_hasher_t {
/**
- * generic hasher_t interface for this hasher
+ * Generic hasher_t interface for this hasher.
*/
hasher_t hasher_interface;
};
diff --git a/Source/charon/transforms/prfs/hmac_prf.c b/Source/charon/transforms/prfs/hmac_prf.c
index 07a3cd854..af307a4d0 100644
--- a/Source/charon/transforms/prfs/hmac_prf.c
+++ b/Source/charon/transforms/prfs/hmac_prf.c
@@ -25,22 +25,26 @@
#include <utils/allocator.h>
#include <transforms/hmac.h>
+
typedef struct private_hmac_prf_t private_hmac_prf_t;
+/**
+ * Private data of a hma_prf_t object.
+ */
struct private_hmac_prf_t {
/**
- * public interface for this prf
+ * Public hmac_prf_t interface.
*/
hmac_prf_t public;
/**
- * hmac to use for generation
+ * Hmac to use for generation.
*/
hmac_t *hmac;
};
/**
- * implementation of prf_t.get_bytes
+ * Implementation of prf_t.get_bytes.
*/
static void get_bytes(private_hmac_prf_t *this, chunk_t seed, u_int8_t *buffer)
{
@@ -48,7 +52,7 @@ static void get_bytes(private_hmac_prf_t *this, chunk_t seed, u_int8_t *buffer)
}
/**
- * implementation of prf_t.allocate_bytes
+ * Implementation of prf_t.allocate_bytes.
*/
static void allocate_bytes(private_hmac_prf_t *this, chunk_t seed, chunk_t *chunk)
{
@@ -56,7 +60,7 @@ static void allocate_bytes(private_hmac_prf_t *this, chunk_t seed, chunk_t *chun
}
/**
- * implementation of prf_t.get_block_size
+ * Implementation of prf_t.get_block_size.
*/
static size_t get_block_size(private_hmac_prf_t *this)
{
@@ -64,7 +68,7 @@ static size_t get_block_size(private_hmac_prf_t *this)
}
/**
- * implementation of prf_t.set_key
+ * Implementation of prf_t.set_key.
*/
static void set_key(private_hmac_prf_t *this, chunk_t key)
{
@@ -72,7 +76,7 @@ static void set_key(private_hmac_prf_t *this, chunk_t key)
}
/**
- * implementation of prf_t.destroy
+ * Implementation of prf_t.destroy.
*/
static void destroy(private_hmac_prf_t *this)
{
@@ -81,7 +85,7 @@ static void destroy(private_hmac_prf_t *this)
}
/*
- * Described in header
+ * Described in header.
*/
hmac_prf_t *hmac_prf_create(hash_algorithm_t hash_algorithm)
{
diff --git a/Source/charon/transforms/prfs/hmac_prf.h b/Source/charon/transforms/prfs/hmac_prf.h
index 70605ff0e..6ccfceef2 100644
--- a/Source/charon/transforms/prfs/hmac_prf.h
+++ b/Source/charon/transforms/prfs/hmac_prf.h
@@ -1,7 +1,7 @@
/**
* @file hmac_prf.h
*
- * @brief Interface for hmac_prf_t.
+ * @brief Interface of hmac_prf_t.
*
*/
@@ -31,10 +31,13 @@ typedef struct hmac_prf_t hmac_prf_t;
/**
* @brief Implementation of prf_t interface using the
- * a HMAC algorithm.
+ * HMAC algorithm.
*
* This simply wraps a hmac_t in a prf_t. More a question of
- * interface matchig.
+ * interface matching.
+ *
+ * @b Constructors:
+ * - hmac_prf_create()
*
* @ingroup prfs
*/
@@ -47,11 +50,11 @@ struct hmac_prf_t {
};
/**
- * @brief Creates a new hmac_prf_t object
+ * @brief Creates a new hmac_prf_t object.
*
* @param hash_algorithm hmac's hash algorithm
* @return
- * - hmac_prf_t if successfully
+ * - hmac_prf_t object
* - NULL if hash not supported
*
* @ingroup prfs
diff --git a/Source/charon/transforms/prfs/prf.c b/Source/charon/transforms/prfs/prf.c
index 732c91c51..b9bd7a51a 100644
--- a/Source/charon/transforms/prfs/prf.c
+++ b/Source/charon/transforms/prfs/prf.c
@@ -28,7 +28,7 @@
/**
- * string mappings for encryption_algorithm_t
+ * String mappings for encryption_algorithm_t.
*/
mapping_t pseudo_random_function_m[] = {
{PRF_UNDEFINED, "PRF_UNDEFINED"},
@@ -39,9 +39,8 @@ mapping_t pseudo_random_function_m[] = {
{MAPPING_END, NULL}
};
-
/*
- * Described in header
+ * Described in header.
*/
prf_t *prf_create(pseudo_random_function_t pseudo_random_function)
{
diff --git a/Source/charon/transforms/prfs/prf.h b/Source/charon/transforms/prfs/prf.h
index 470556dc8..d96fc66ae 100644
--- a/Source/charon/transforms/prfs/prf.h
+++ b/Source/charon/transforms/prfs/prf.h
@@ -1,7 +1,7 @@
/**
* @file prf.h
*
- * @brief Interface of prf_t.
+ * @brief Interface prf_t.
*
*/
@@ -29,17 +29,29 @@ typedef enum pseudo_random_function_t pseudo_random_function_t;
/**
* @brief Pseudo random function, as in IKEv2 draft 3.3.2.
+ *
+ * Currently only the following algorithms are implemented and therefore supported:
+ * - PRF_HMAC_MD5
+ * - PRF_HMAC_SHA1
+ *
+ * @ingroup prfs
*/
enum pseudo_random_function_t {
PRF_UNDEFINED = 1024,
+ /**
+ * Implemented in class hmac_prf_t.
+ */
PRF_HMAC_MD5 = 1,
+ /**
+ * Implemented in class hmac_prf_t.
+ */
PRF_HMAC_SHA1 = 2,
PRF_HMAC_TIGER = 3,
PRF_AES128_CBC = 4
};
/**
- * string mappings for encryption_algorithm_t
+ * String mappings for encryption_algorithm_t.
*/
extern mapping_t pseudo_random_function_m[];
@@ -49,59 +61,65 @@ typedef struct prf_t prf_t;
/**
* @brief Generic interface for pseudo-random-functions.
*
+ * @b Constructors:
+ * - prf_create()
+ * - hmac_prf_create()
+ *
+ * @todo Implement more prf algorithms
+ *
* @ingroup prfs
*/
struct prf_t {
/**
- * @brief generates pseudo random bytes and writes them
+ * @brief Generates pseudo random bytes and writes them
* in the buffer.
*
- * @param this calling prf
+ * @param this calling object
* @param seed a chunk containing the seed for the next bytes
* @param[out] buffer pointer where the generated bytes will be written
*/
void (*get_bytes) (prf_t *this, chunk_t seed, u_int8_t *buffer);
/**
- * @brief generates pseudo random bytes and allocate space for them.
+ * @brief Generates pseudo random bytes and allocate space for them.
*
- * @param this calling prf
+ * @param this calling object
* @param seed a chunk containing the seed for the next bytes
* @param[out] chunk chunk which will hold generated bytes
*/
void (*allocate_bytes) (prf_t *this, chunk_t seed, chunk_t *chunk);
/**
- * @brief get the block size of this prf.
+ * @brief Get the block size of this prf_t object.
*
- * @param this calling prf
+ * @param this calling object
* @return block size in bytes
*/
size_t (*get_block_size) (prf_t *this);
/**
- * @brief Set the key for this prf.
+ * @brief Set the key for this prf_t object.
*
- * @param this calling prf
+ * @param this calling object
* @param key key to set
*/
void (*set_key) (prf_t *this, chunk_t key);
/**
- * @brief Destroys a prf object..
+ * @brief Destroys a prf object.
*
- * @param this prf_t object to destroy
+ * @param this calling object
*/
void (*destroy) (prf_t *this);
};
/**
- * @brief Generic constructor for a prf_t.
+ * @brief Generic constructor for a prf_t oject.
*
* @param pseudo_random_function Algorithm to use
* @return
- * - prf_t if successfully
- * - NULL if prf not supported
+ * - prf_t object
+ * - NULL if prf algorithm not supported
*
* @ingroup prfs
*/