aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/transforms
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-11-22 15:33:08 +0000
committerMartin Willi <martin@strongswan.org>2005-11-22 15:33:08 +0000
commit74ced9e2491fd4b1b9fe3c31008d0afb283b20f5 (patch)
tree108cb5c1fc0f2e9ef3d6104b8101bd97eb172b7c /Source/charon/transforms
parentc4253ff5ccdcd70dd429db8a5f4f47b518672eb0 (diff)
downloadstrongswan-74ced9e2491fd4b1b9fe3c31008d0afb283b20f5.tar.bz2
strongswan-74ced9e2491fd4b1b9fe3c31008d0afb283b20f5.tar.xz
- prf_hmac_sha1 is now a generig prf_hmac
- supports md5
Diffstat (limited to 'Source/charon/transforms')
-rw-r--r--Source/charon/transforms/prfs/prf.c8
-rw-r--r--Source/charon/transforms/prfs/prf_hmac.c (renamed from Source/charon/transforms/prfs/prf_hmac_sha1.c)27
-rw-r--r--Source/charon/transforms/prfs/prf_hmac.h (renamed from Source/charon/transforms/prfs/prf_hmac_sha1.h)23
3 files changed, 31 insertions, 27 deletions
diff --git a/Source/charon/transforms/prfs/prf.c b/Source/charon/transforms/prfs/prf.c
index 200286437..e52c33181 100644
--- a/Source/charon/transforms/prfs/prf.c
+++ b/Source/charon/transforms/prfs/prf.c
@@ -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:
diff --git a/Source/charon/transforms/prfs/prf_hmac_sha1.c b/Source/charon/transforms/prfs/prf_hmac.c
index 6aa7d91ba..3ebe45d98 100644
--- a/Source/charon/transforms/prfs/prf_hmac_sha1.c
+++ b/Source/charon/transforms/prfs/prf_hmac.c
@@ -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)
{
diff --git a/Source/charon/transforms/prfs/prf_hmac_sha1.h b/Source/charon/transforms/prfs/prf_hmac.h
index 3b4305c81..3f5a86678 100644
--- a/Source/charon/transforms/prfs/prf_hmac_sha1.h
+++ b/Source/charon/transforms/prfs/prf_hmac.h
@@ -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_*/