- code cleaned up

This commit is contained in:
Jan Hutter
2005-12-06 15:37:56 +00:00
parent 62abe4a37d
commit 6f36717843
11 changed files with 119 additions and 79 deletions
+33 -15
View File
@@ -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
*/