- moved algorithm definitions from payloads to corresponding transforms
- cleanup of docs in transforms
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file prf.c
|
||||
*
|
||||
* @brief Generic interface for pseudo-random-functions
|
||||
* @brief Generic constructor for all prf_t
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,19 @@
|
||||
#include <transforms/prfs/prf_hmac.h>
|
||||
|
||||
|
||||
/**
|
||||
* string mappings for encryption_algorithm_t
|
||||
*/
|
||||
mapping_t pseudo_random_function_m[] = {
|
||||
{PRF_UNDEFINED, "PRF_UNDEFINED"},
|
||||
{PRF_HMAC_MD5, "PRF_HMAC_MD5"},
|
||||
{PRF_HMAC_SHA1, "PRF_HMAC_SHA1"},
|
||||
{PRF_HMAC_TIGER, "PRF_HMAC_TIGER"},
|
||||
{PRF_AES128_CBC, "PRF_AES128_CBC"},
|
||||
{MAPPING_END, NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file prf.h
|
||||
*
|
||||
* @brief Generic interface for pseudo-random-functions
|
||||
* @brief Interface of prf_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -23,35 +23,53 @@
|
||||
#ifndef PRF_H_
|
||||
#define PRF_H_
|
||||
|
||||
#include <encoding/payloads/transform_substructure.h>
|
||||
#include <types.h>
|
||||
|
||||
typedef enum pseudo_random_function_t pseudo_random_function_t;
|
||||
|
||||
/**
|
||||
* @brief Pseudo random function, as in IKEv2 draft 3.3.2.
|
||||
*/
|
||||
enum pseudo_random_function_t {
|
||||
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[];
|
||||
|
||||
|
||||
typedef struct prf_t prf_t;
|
||||
|
||||
/**
|
||||
* Object representing a diffie hellman exchange
|
||||
* @brief Generic interface for pseudo-random-functions.
|
||||
*
|
||||
* @ingroup prfs
|
||||
*/
|
||||
struct prf_t {
|
||||
/**
|
||||
* @brief generates pseudo random bytes and writes them
|
||||
* in the buffer
|
||||
* in the buffer.
|
||||
*
|
||||
* @param this calling prf
|
||||
* @param seed a chunk containing the seed for the next bytes
|
||||
* @param [out]buffer pointer where the generated bytes will be written
|
||||
* @param[out] buffer pointer where the generated bytes will be written
|
||||
* @return
|
||||
* - SUCCESS in any case
|
||||
*/
|
||||
status_t (*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 seed a chunk containing the seed for the next bytes
|
||||
* @param [out]chunk chunk which will hold generated bytes
|
||||
* @param[out] chunk chunk which will hold generated bytes
|
||||
* @return
|
||||
* - SUCCESS in any case
|
||||
* - OUT_OF_RES if space could not be allocated
|
||||
@@ -59,7 +77,7 @@ struct prf_t {
|
||||
status_t (*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.
|
||||
*
|
||||
* @param this calling prf
|
||||
* @return block size in bytes
|
||||
@@ -67,25 +85,27 @@ struct prf_t {
|
||||
size_t (*get_block_size) (prf_t *this);
|
||||
|
||||
/**
|
||||
* @brief Set the key for this prf
|
||||
* @brief Set the key for this prf.
|
||||
*
|
||||
* @param this calling prf
|
||||
* @return block size in bytes
|
||||
* @param key key to set
|
||||
* @return
|
||||
* - SUCCESS in any case
|
||||
*/
|
||||
status_t (*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 prf_t object to destroy
|
||||
* @return
|
||||
* SUCCESS in any case
|
||||
* - SUCCESS in any case
|
||||
*/
|
||||
status_t (*destroy) (prf_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new prf_t object
|
||||
* @brief Generic constructor for a prf_t.
|
||||
*
|
||||
* @param pseudo_random_function Algorithm to use
|
||||
* @return
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* @file prf_hmac.c
|
||||
*
|
||||
* @brief Implementation of prf_t interface using the
|
||||
* a HMAC algorithm. This simply wraps a hmac in a prf.
|
||||
* @brief Implementation for prf_hmac_t.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* @file prf_hmac.h
|
||||
*
|
||||
* @brief Implementation of prf_t interface using the
|
||||
* a HMAC algorithm. This simply wraps a hmac in a prf.
|
||||
* @brief Interface for prf_hmac_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -24,32 +23,38 @@
|
||||
#ifndef PRF_HMAC_H_
|
||||
#define PRF_HMAC_H_
|
||||
|
||||
#include "prf.h"
|
||||
|
||||
#include <types.h>
|
||||
#include <transforms/prfs/prf.h>
|
||||
#include <transforms/hashers/hasher.h>
|
||||
|
||||
typedef struct prf_hmac_t prf_hmac_t;
|
||||
|
||||
/**
|
||||
* Object representing a prf using HMAC
|
||||
* @brief Implementation of prf_t interface using the
|
||||
* a HMAC algorithm.
|
||||
*
|
||||
* This simply wraps a hmac_t in a prf_t. More a question of
|
||||
* interface matchig.
|
||||
*
|
||||
* @ingroup prfs
|
||||
*/
|
||||
struct prf_hmac_t {
|
||||
|
||||
/**
|
||||
* generic prf_t interface for this prf
|
||||
* Generic prf_t interface for this prf_hmac_t class.
|
||||
*/
|
||||
prf_t prf_interface;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new prf_hmac_t object
|
||||
* @brief Creates a new prf_hmac_t object
|
||||
*
|
||||
* @param hash_algorithm hmac's hash algorithm
|
||||
* @return
|
||||
* - prf_hmac_t if successfully
|
||||
* - NULL if out of ressources
|
||||
*
|
||||
* @ingroup prfs
|
||||
*/
|
||||
prf_hmac_t *prf_hmac_create(hash_algorithm_t hash_algorithm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user