- moved hasher_*_t to *_hasher_t
- some logging improvements
This commit is contained in:
@@ -18,10 +18,10 @@ OBJS+= $(BUILD_DIR)hasher.o
|
||||
$(BUILD_DIR)hasher.o : $(HASHERS_DIR)hasher.c $(HASHERS_DIR)hasher.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
OBJS+= $(BUILD_DIR)hasher_sha1.o
|
||||
$(BUILD_DIR)hasher_sha1.o : $(HASHERS_DIR)hasher_sha1.c $(HASHERS_DIR)hasher_sha1.h
|
||||
OBJS+= $(BUILD_DIR)sha1_hasher.o
|
||||
$(BUILD_DIR)sha1_hasher.o : $(HASHERS_DIR)sha1_hasher.c $(HASHERS_DIR)sha1_hasher.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
OBJS+= $(BUILD_DIR)hasher_md5.o
|
||||
$(BUILD_DIR)hasher_md5.o : $(HASHERS_DIR)hasher_md5.c $(HASHERS_DIR)hasher_md5.h
|
||||
OBJS+= $(BUILD_DIR)md5_hasher.o
|
||||
$(BUILD_DIR)md5_hasher.o : $(HASHERS_DIR)md5_hasher.c $(HASHERS_DIR)md5_hasher.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
#include "hasher.h"
|
||||
|
||||
#include <transforms/hashers/hasher_sha1.h>
|
||||
#include <transforms/hashers/hasher_md5.h>
|
||||
#include <transforms/hashers/sha1_hasher.h>
|
||||
#include <transforms/hashers/md5_hasher.h>
|
||||
|
||||
/**
|
||||
* mappings for hash_algorithm_t
|
||||
@@ -44,11 +44,11 @@ hasher_t *hasher_create(hash_algorithm_t hash_algorithm)
|
||||
{
|
||||
case HASH_SHA1:
|
||||
{
|
||||
return (hasher_t*)hasher_sha1_create();
|
||||
return (hasher_t*)sha1_hasher_create();
|
||||
}
|
||||
case HASH_MD5:
|
||||
{
|
||||
return (hasher_t*)hasher_md5_create();
|
||||
return (hasher_t*)md5_hasher_create();
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
|
||||
+15
-15
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file hasher_md5.c
|
||||
* @file md5_hasher.c
|
||||
*
|
||||
* @brief Implementation of hasher_md5_t.
|
||||
* @brief Implementation of md5_hasher_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "hasher_md5.h"
|
||||
#include "md5_hasher.h"
|
||||
|
||||
#include <definitions.h>
|
||||
#include <utils/allocator.h>
|
||||
@@ -97,16 +97,16 @@ Rotation is separate from addition to prevent recomputation.
|
||||
|
||||
|
||||
|
||||
typedef struct private_hasher_md5_t private_hasher_md5_t;
|
||||
typedef struct private_md5_hasher_t private_md5_hasher_t;
|
||||
|
||||
/**
|
||||
* private data structure with hasing context
|
||||
*/
|
||||
struct private_hasher_md5_t {
|
||||
struct private_md5_hasher_t {
|
||||
/**
|
||||
* public interface for this hasher
|
||||
*/
|
||||
hasher_md5_t public;
|
||||
md5_hasher_t public;
|
||||
|
||||
/*
|
||||
* state of the hasher
|
||||
@@ -244,7 +244,7 @@ static void MD5Transform(u_int32_t state[4], u_int8_t block[64])
|
||||
* operation, processing another message block, and updating the
|
||||
* context.
|
||||
*/
|
||||
void MD5Update(private_hasher_md5_t *this, u_int8_t *input, size_t inputLen)
|
||||
void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputLen)
|
||||
{
|
||||
u_int32_t i;
|
||||
size_t index, partLen;
|
||||
@@ -285,7 +285,7 @@ void MD5Update(private_hasher_md5_t *this, u_int8_t *input, size_t inputLen)
|
||||
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
* the message digest and zeroizing the context.
|
||||
*/
|
||||
void MD5Final (private_hasher_md5_t *this, u_int8_t digest[16])
|
||||
void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
|
||||
{
|
||||
u_int8_t bits[8];
|
||||
size_t index, padLen;
|
||||
@@ -313,7 +313,7 @@ void MD5Final (private_hasher_md5_t *this, u_int8_t digest[16])
|
||||
/**
|
||||
* implementation of hasher_t.get_hash for md5
|
||||
*/
|
||||
static status_t get_hash(private_hasher_md5_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
static status_t get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
{
|
||||
MD5Update(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
@@ -328,7 +328,7 @@ static status_t get_hash(private_hasher_md5_t *this, chunk_t chunk, u_int8_t *bu
|
||||
/**
|
||||
* implementation of hasher_t.allocate_hash for md5
|
||||
*/
|
||||
static status_t allocate_hash(private_hasher_md5_t *this, chunk_t chunk, chunk_t *hash)
|
||||
static status_t allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
|
||||
{
|
||||
chunk_t allocated_hash;
|
||||
|
||||
@@ -353,7 +353,7 @@ static status_t allocate_hash(private_hasher_md5_t *this, chunk_t chunk, chunk_t
|
||||
/**
|
||||
* implementation of hasher_t.get_block_size for md5
|
||||
*/
|
||||
static size_t get_block_size(private_hasher_md5_t *this)
|
||||
static size_t get_block_size(private_md5_hasher_t *this)
|
||||
{
|
||||
return BLOCK_SIZE_MD5;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ static size_t get_block_size(private_hasher_md5_t *this)
|
||||
/**
|
||||
* implementation of hasher_t.reset for md5
|
||||
*/
|
||||
static status_t reset(private_hasher_md5_t *this)
|
||||
static status_t reset(private_md5_hasher_t *this)
|
||||
{
|
||||
this->state[0] = 0x67452301;
|
||||
this->state[1] = 0xefcdab89;
|
||||
@@ -374,7 +374,7 @@ static status_t reset(private_hasher_md5_t *this)
|
||||
/**
|
||||
* implementation of hasher_t.destroy for md5
|
||||
*/
|
||||
static status_t destroy(private_hasher_md5_t *this)
|
||||
static status_t destroy(private_md5_hasher_t *this)
|
||||
{
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
@@ -384,9 +384,9 @@ static status_t destroy(private_hasher_md5_t *this)
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
hasher_md5_t *hasher_md5_create()
|
||||
md5_hasher_t *md5_hasher_create()
|
||||
{
|
||||
private_hasher_md5_t *this = allocator_alloc_thing(private_hasher_md5_t);
|
||||
private_md5_hasher_t *this = allocator_alloc_thing(private_md5_hasher_t);
|
||||
if (this == NULL)
|
||||
{
|
||||
return NULL;
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file hasher_md5.h
|
||||
* @file md5_hasher.h
|
||||
*
|
||||
* @brief Interface for hasher_md5_t.
|
||||
* @brief Interface for md5_hasher_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef HASHER_MD5_H_
|
||||
#define HASHER_MD5_H_
|
||||
#ifndef MD5_HASHER_H_
|
||||
#define MD5_HASHER_H_
|
||||
|
||||
#include <transforms/hashers/hasher.h>
|
||||
|
||||
|
||||
typedef struct hasher_md5_t hasher_md5_t;
|
||||
typedef struct md5_hasher_t md5_hasher_t;
|
||||
|
||||
/**
|
||||
* @brief Implementation of hasher_t interface using the
|
||||
@@ -34,7 +34,7 @@ typedef struct hasher_md5_t hasher_md5_t;
|
||||
*
|
||||
* @ingroup hashers
|
||||
*/
|
||||
struct hasher_md5_t {
|
||||
struct md5_hasher_t {
|
||||
|
||||
/**
|
||||
* generic hasher_t interface for this hasher
|
||||
@@ -43,14 +43,14 @@ struct hasher_md5_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Creates a new hasher_md5_t.
|
||||
* @brief Creates a new md5_hasher_t.
|
||||
*
|
||||
* @return
|
||||
* - hasher_md5_t if successfully
|
||||
* - md5_hasher_t if successfully
|
||||
* - NULL if out of ressources
|
||||
*
|
||||
* @ingroup hashers
|
||||
*/
|
||||
hasher_md5_t *hasher_md5_create();
|
||||
md5_hasher_t *md5_hasher_create();
|
||||
|
||||
#endif /*HASHER_md5_H_*/
|
||||
#endif /*MD5_HASHER_H_*/
|
||||
+14
-14
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file hasher_sha1.c
|
||||
* @file sha1_hasher.c
|
||||
*
|
||||
* @brief Implementation of hasher_sha_t.
|
||||
*
|
||||
@@ -23,7 +23,7 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "hasher_sha1.h"
|
||||
#include "sha1_hasher.h"
|
||||
|
||||
#include <definitions.h>
|
||||
#include <utils/allocator.h>
|
||||
@@ -52,16 +52,16 @@
|
||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
||||
|
||||
|
||||
typedef struct private_hasher_sha1_t private_hasher_sha1_t;
|
||||
typedef struct private_sha1_hasher_t private_sha1_hasher_t;
|
||||
|
||||
/**
|
||||
* private data structure with hasing context
|
||||
*/
|
||||
struct private_hasher_sha1_t {
|
||||
struct private_sha1_hasher_t {
|
||||
/**
|
||||
* public interface for this hasher
|
||||
*/
|
||||
hasher_sha1_t public;
|
||||
sha1_hasher_t public;
|
||||
|
||||
/*
|
||||
* state of the hasher
|
||||
@@ -125,7 +125,7 @@ void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
|
||||
/*
|
||||
* Run your data through this.
|
||||
*/
|
||||
void SHA1Update(private_hasher_sha1_t* this, u_int8_t *data, u_int32_t len)
|
||||
void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
|
||||
{
|
||||
u_int32_t i;
|
||||
u_int32_t j;
|
||||
@@ -158,7 +158,7 @@ void SHA1Update(private_hasher_sha1_t* this, u_int8_t *data, u_int32_t len)
|
||||
/*
|
||||
* Add padding and return the message digest.
|
||||
*/
|
||||
void SHA1Final(private_hasher_sha1_t *this, u_int8_t *digest)
|
||||
void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
|
||||
{
|
||||
u_int32_t i;
|
||||
u_int8_t finalcount[8];
|
||||
@@ -187,7 +187,7 @@ void SHA1Final(private_hasher_sha1_t *this, u_int8_t *digest)
|
||||
/**
|
||||
* implementation of hasher_t.get_hash for sha1
|
||||
*/
|
||||
static status_t get_hash(private_hasher_sha1_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
static status_t get_hash(private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
{
|
||||
SHA1Update(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
@@ -202,7 +202,7 @@ static status_t get_hash(private_hasher_sha1_t *this, chunk_t chunk, u_int8_t *b
|
||||
/**
|
||||
* implementation of hasher_t.allocate_hash for sha1
|
||||
*/
|
||||
static status_t allocate_hash(private_hasher_sha1_t *this, chunk_t chunk, chunk_t *hash)
|
||||
static status_t allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *hash)
|
||||
{
|
||||
chunk_t allocated_hash;
|
||||
|
||||
@@ -227,7 +227,7 @@ static status_t allocate_hash(private_hasher_sha1_t *this, chunk_t chunk, chunk_
|
||||
/**
|
||||
* implementation of hasher_t.get_block_size for sha1
|
||||
*/
|
||||
static size_t get_block_size(private_hasher_sha1_t *this)
|
||||
static size_t get_block_size(private_sha1_hasher_t *this)
|
||||
{
|
||||
return BLOCK_SIZE_SHA1;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ static size_t get_block_size(private_hasher_sha1_t *this)
|
||||
/**
|
||||
* implementation of hasher_t.reset for sha1
|
||||
*/
|
||||
static status_t reset(private_hasher_sha1_t *this)
|
||||
static status_t reset(private_sha1_hasher_t *this)
|
||||
{
|
||||
this->state[0] = 0x67452301;
|
||||
this->state[1] = 0xEFCDAB89;
|
||||
@@ -249,7 +249,7 @@ static status_t reset(private_hasher_sha1_t *this)
|
||||
/**
|
||||
* implementation of hasher_t.destroy for sha1
|
||||
*/
|
||||
static status_t destroy(private_hasher_sha1_t *this)
|
||||
static status_t destroy(private_sha1_hasher_t *this)
|
||||
{
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
@@ -259,9 +259,9 @@ static status_t destroy(private_hasher_sha1_t *this)
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
hasher_sha1_t *hasher_sha1_create()
|
||||
sha1_hasher_t *sha1_hasher_create()
|
||||
{
|
||||
private_hasher_sha1_t *this = allocator_alloc_thing(private_hasher_sha1_t);
|
||||
private_sha1_hasher_t *this = allocator_alloc_thing(private_sha1_hasher_t);
|
||||
if (this == NULL)
|
||||
{
|
||||
return NULL;
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file hasher_sha1.h
|
||||
* @file sha1_hasher.h
|
||||
*
|
||||
* @brief Interface of hasher_sha1_t
|
||||
* @brief Interface of sha1_hasher_t
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef HASHER_SHA1_H_
|
||||
#define HASHER_SHA1_H_
|
||||
#ifndef SHA1_HASHER_H_
|
||||
#define SHA1_HASHER_H_
|
||||
|
||||
#include <transforms/hashers/hasher.h>
|
||||
|
||||
|
||||
typedef struct hasher_sha1_t hasher_sha1_t;
|
||||
typedef struct sha1_hasher_t sha1_hasher_t;
|
||||
|
||||
/**
|
||||
* @brief Implementation of hasher_t interface using the
|
||||
@@ -34,7 +34,7 @@ typedef struct hasher_sha1_t hasher_sha1_t;
|
||||
*
|
||||
* @ingroup hashers
|
||||
*/
|
||||
struct hasher_sha1_t {
|
||||
struct sha1_hasher_t {
|
||||
|
||||
/**
|
||||
* generic hasher_t interface for this hasher
|
||||
@@ -43,14 +43,14 @@ struct hasher_sha1_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Creates a new hasher_sha1_t.
|
||||
* @brief Creates a new sha1_hasher_t.
|
||||
*
|
||||
* @return
|
||||
* - hasher_sha1_t if successfully
|
||||
* - sha1_hasher_t if successfully
|
||||
* - NULL if out of ressources
|
||||
*
|
||||
* @ingroup hashers
|
||||
*/
|
||||
hasher_sha1_t *hasher_sha1_create();
|
||||
sha1_hasher_t *sha1_hasher_create();
|
||||
|
||||
#endif /*HASHER_SHA1_H_*/
|
||||
#endif /*SHA1_HASHER_H_*/
|
||||
Reference in New Issue
Block a user