parent
c4253ff5cc
commit
74ced9e249
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "prf.h"
|
||||
|
||||
#include "prf_hmac_sha1.h"
|
||||
#include "prf_hmac.h"
|
||||
#include "../hashers/hasher.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -35,9 +36,12 @@ prf_t *prf_create(pseudo_random_function_t pseudo_random_function)
|
|||
{
|
||||
case PRF_HMAC_SHA1:
|
||||
{
|
||||
return (prf_t*)prf_hmac_sha1_create();
|
||||
return (prf_t*)prf_hmac_create(HASH_SHA1);
|
||||
}
|
||||
case PRF_HMAC_MD5:
|
||||
{
|
||||
return (prf_t*)prf_hmac_create(HASH_MD5);
|
||||
}
|
||||
case PRF_HMAC_TIGER:
|
||||
case PRF_AES128_CBC:
|
||||
default:
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @file prf_hmac_sha1.c
|
||||
* @file prf_hmac.c
|
||||
*
|
||||
* @brief Implementation of prf_t interface using the
|
||||
* HMAC SHA1 algorithm. This simply wraps hmac-sha1
|
||||
* in a prf.
|
||||
* a HMAC algorithm. This simply wraps a hmac in a prf.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -22,18 +21,18 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#include "prf_hmac_sha1.h"
|
||||
#include "prf_hmac.h"
|
||||
|
||||
#include "../../utils/allocator.h"
|
||||
#include "../hmac.h"
|
||||
|
||||
typedef struct private_prf_hmac_sha1_s private_prf_hmac_sha1_t;
|
||||
typedef struct private_prf_hmac_s private_prf_hmac_t;
|
||||
|
||||
struct private_prf_hmac_sha1_s {
|
||||
struct private_prf_hmac_s {
|
||||
/**
|
||||
* public interface for this prf
|
||||
*/
|
||||
prf_hmac_sha1_t public;
|
||||
prf_hmac_t public;
|
||||
|
||||
/**
|
||||
* hmac to use for generation
|
||||
|
@ -44,7 +43,7 @@ struct private_prf_hmac_sha1_s {
|
|||
/**
|
||||
* implementation of prf_t.get_bytes
|
||||
*/
|
||||
static status_t get_bytes(private_prf_hmac_sha1_t *this, chunk_t seed, u_int8_t *buffer)
|
||||
static status_t get_bytes(private_prf_hmac_t *this, chunk_t seed, u_int8_t *buffer)
|
||||
{
|
||||
return this->hmac->get_mac(this->hmac, seed, buffer);
|
||||
}
|
||||
|
@ -52,7 +51,7 @@ static status_t get_bytes(private_prf_hmac_sha1_t *this, chunk_t seed, u_int8_t
|
|||
/**
|
||||
* implementation of prf_t.allocate_bytes
|
||||
*/
|
||||
static status_t allocate_bytes(private_prf_hmac_sha1_t *this, chunk_t seed, chunk_t *chunk)
|
||||
static status_t allocate_bytes(private_prf_hmac_t *this, chunk_t seed, chunk_t *chunk)
|
||||
{
|
||||
return this->hmac->allocate_mac(this->hmac, seed, chunk);
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ static status_t allocate_bytes(private_prf_hmac_sha1_t *this, chunk_t seed, chun
|
|||
/**
|
||||
* implementation of prf_t.get_block_size
|
||||
*/
|
||||
static size_t get_block_size(private_prf_hmac_sha1_t *this)
|
||||
static size_t get_block_size(private_prf_hmac_t *this)
|
||||
{
|
||||
return this->hmac->get_block_size(this->hmac);
|
||||
}
|
||||
|
@ -68,7 +67,7 @@ static size_t get_block_size(private_prf_hmac_sha1_t *this)
|
|||
/**
|
||||
* implementation of prf_t.set_key
|
||||
*/
|
||||
static status_t set_key(private_prf_hmac_sha1_t *this, chunk_t key)
|
||||
static status_t set_key(private_prf_hmac_t *this, chunk_t key)
|
||||
{
|
||||
this->hmac->set_key(this->hmac, key);
|
||||
return SUCCESS;
|
||||
|
@ -77,7 +76,7 @@ static status_t set_key(private_prf_hmac_sha1_t *this, chunk_t key)
|
|||
/**
|
||||
* implementation of prf_t.destroy
|
||||
*/
|
||||
static status_t destroy(private_prf_hmac_sha1_t *this)
|
||||
static status_t destroy(private_prf_hmac_t *this)
|
||||
{
|
||||
allocator_free(this);
|
||||
this->hmac->destroy(this->hmac);
|
||||
|
@ -87,9 +86,9 @@ static status_t destroy(private_prf_hmac_sha1_t *this)
|
|||
/*
|
||||
* Described in header
|
||||
*/
|
||||
prf_hmac_sha1_t *prf_hmac_sha1_create()
|
||||
prf_hmac_t *prf_hmac_create(hash_algorithm_t hash_algorithm)
|
||||
{
|
||||
private_prf_hmac_sha1_t *this = allocator_alloc_thing(private_prf_hmac_sha1_t);
|
||||
private_prf_hmac_t *this = allocator_alloc_thing(private_prf_hmac_t);
|
||||
|
||||
if (this == NULL)
|
||||
{
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @file prf_hmac_sha1.h
|
||||
* @file prf_hmac.h
|
||||
*
|
||||
* @brief Implementation of prf_t interface using the
|
||||
* HMAC SHA1 algorithm. This simply wraps hmac-sha1
|
||||
* in a prf.
|
||||
* a HMAC algorithm. This simply wraps a hmac in a prf.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -22,20 +21,21 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef PRF_HMAC_SHA1_H_
|
||||
#define PRF_HMAC_SHA1_H_
|
||||
#ifndef PRF_HMAC_H_
|
||||
#define PRF_HMAC_H_
|
||||
|
||||
#include "prf.h"
|
||||
|
||||
#include "../../types.h"
|
||||
#include "../hashers/hasher.h"
|
||||
|
||||
/**
|
||||
* Object representing a prf using HMAC-SHA1
|
||||
* Object representing a prf using HMAC
|
||||
*
|
||||
*/
|
||||
typedef struct prf_hmac_sha1_s prf_hmac_sha1_t;
|
||||
typedef struct prf_hmac_s prf_hmac_t;
|
||||
|
||||
struct prf_hmac_sha1_s {
|
||||
struct prf_hmac_s {
|
||||
|
||||
/**
|
||||
* generic prf_t interface for this prf
|
||||
|
@ -44,12 +44,13 @@ struct prf_hmac_sha1_s {
|
|||
};
|
||||
|
||||
/**
|
||||
* Creates a new prf_hmac_sha1_t object
|
||||
* Creates a new prf_hmac_t object
|
||||
*
|
||||
* @param hash_algorithm hmac's hash algorithm
|
||||
* @return
|
||||
* - prf_hmac_sha1_t if successfully
|
||||
* - prf_hmac_t if successfully
|
||||
* - NULL if out of ressources
|
||||
*/
|
||||
prf_hmac_sha1_t *prf_hmac_sha1_create();
|
||||
prf_hmac_t *prf_hmac_create(hash_algorithm_t hash_algorithm);
|
||||
|
||||
#endif /*PRF_HMAC_SHA1_H_*/
|
Loading…
Reference in New Issue