public declaration of all HASH_SIZEs in hasher.h

This commit is contained in:
Martin Willi
2006-09-20 06:45:19 +00:00
parent 490d267ac3
commit 995d8116e1
4 changed files with 13 additions and 14 deletions
@@ -56,6 +56,13 @@ enum hash_algorithm_t {
HASH_SHA512, HASH_SHA512,
}; };
#define HASH_SIZE_MD2 16
#define HASH_SIZE_MD5 16
#define HASH_SIZE_SHA1 20
#define HASH_SIZE_SHA256 32
#define HASH_SIZE_SHA384 48
#define HASH_SIZE_SHA512 64
/** /**
* String mappings for hash_algorithm_t. * String mappings for hash_algorithm_t.
*/ */
@@ -32,8 +32,6 @@
#include <definitions.h> #include <definitions.h>
#define BLOCK_SIZE_MD5 16
/* Constants for MD5Transform routine. */ /* Constants for MD5Transform routine. */
#define S11 7 #define S11 7
@@ -336,8 +334,8 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
MD5Update(this, chunk.ptr, chunk.len); MD5Update(this, chunk.ptr, chunk.len);
if (hash != NULL) if (hash != NULL)
{ {
allocated_hash.ptr = malloc(BLOCK_SIZE_MD5); allocated_hash.ptr = malloc(HASH_SIZE_MD5);
allocated_hash.len = BLOCK_SIZE_MD5; allocated_hash.len = HASH_SIZE_MD5;
MD5Final(this, allocated_hash.ptr); MD5Final(this, allocated_hash.ptr);
this->public.hasher_interface.reset(&(this->public.hasher_interface)); this->public.hasher_interface.reset(&(this->public.hasher_interface));
@@ -351,7 +349,7 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
*/ */
static size_t get_hash_size(private_md5_hasher_t *this) static size_t get_hash_size(private_md5_hasher_t *this)
{ {
return BLOCK_SIZE_MD5; return HASH_SIZE_MD5;
} }
/** /**
@@ -30,8 +30,6 @@
#include <definitions.h> #include <definitions.h>
#define BLOCK_SIZE_SHA1 20
/* /*
* ugly macro stuff * ugly macro stuff
*/ */
@@ -210,8 +208,8 @@ static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *h
SHA1Update(this, chunk.ptr, chunk.len); SHA1Update(this, chunk.ptr, chunk.len);
if (hash != NULL) if (hash != NULL)
{ {
allocated_hash.ptr = malloc(BLOCK_SIZE_SHA1); allocated_hash.ptr = malloc(HASH_SIZE_SHA1);
allocated_hash.len = BLOCK_SIZE_SHA1; allocated_hash.len = HASH_SIZE_SHA1;
SHA1Final(this, allocated_hash.ptr); SHA1Final(this, allocated_hash.ptr);
this->public.hasher_interface.reset(&(this->public.hasher_interface)); this->public.hasher_interface.reset(&(this->public.hasher_interface));
@@ -225,7 +223,7 @@ static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *h
*/ */
static size_t get_hash_size(private_sha1_hasher_t *this) static size_t get_hash_size(private_sha1_hasher_t *this)
{ {
return BLOCK_SIZE_SHA1; return HASH_SIZE_SHA1;
} }
/** /**
@@ -29,10 +29,6 @@
#include <definitions.h> #include <definitions.h>
#define HASH_SIZE_SHA256 32
#define HASH_SIZE_SHA384 48
#define HASH_SIZE_SHA512 64
typedef struct private_sha512_hasher_t private_sha512_hasher_t; typedef struct private_sha512_hasher_t private_sha512_hasher_t;