diff options
Diffstat (limited to 'Source/charon/transforms/prfs')
-rw-r--r-- | Source/charon/transforms/prfs/hmac_prf.c | 20 | ||||
-rw-r--r-- | Source/charon/transforms/prfs/hmac_prf.h | 13 | ||||
-rw-r--r-- | Source/charon/transforms/prfs/prf.c | 5 | ||||
-rw-r--r-- | Source/charon/transforms/prfs/prf.h | 48 |
4 files changed, 55 insertions, 31 deletions
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 */ |