diff options
-rw-r--r-- | src/libstrongswan/crypto/hashers/hasher.h | 7 | ||||
-rw-r--r-- | src/libstrongswan/crypto/hashers/md5_hasher.c | 8 | ||||
-rw-r--r-- | src/libstrongswan/crypto/hashers/sha1_hasher.c | 8 | ||||
-rw-r--r-- | src/libstrongswan/crypto/hashers/sha2_hasher.c | 4 |
4 files changed, 13 insertions, 14 deletions
diff --git a/src/libstrongswan/crypto/hashers/hasher.h b/src/libstrongswan/crypto/hashers/hasher.h index c92378abd..8db252f25 100644 --- a/src/libstrongswan/crypto/hashers/hasher.h +++ b/src/libstrongswan/crypto/hashers/hasher.h @@ -56,6 +56,13 @@ enum hash_algorithm_t { 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. */ diff --git a/src/libstrongswan/crypto/hashers/md5_hasher.c b/src/libstrongswan/crypto/hashers/md5_hasher.c index e1630737f..5cf4643b8 100644 --- a/src/libstrongswan/crypto/hashers/md5_hasher.c +++ b/src/libstrongswan/crypto/hashers/md5_hasher.c @@ -32,8 +32,6 @@ #include <definitions.h> -#define BLOCK_SIZE_MD5 16 - /* Constants for MD5Transform routine. */ #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); if (hash != NULL) { - allocated_hash.ptr = malloc(BLOCK_SIZE_MD5); - allocated_hash.len = BLOCK_SIZE_MD5; + allocated_hash.ptr = malloc(HASH_SIZE_MD5); + allocated_hash.len = HASH_SIZE_MD5; MD5Final(this, allocated_hash.ptr); 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) { - return BLOCK_SIZE_MD5; + return HASH_SIZE_MD5; } /** diff --git a/src/libstrongswan/crypto/hashers/sha1_hasher.c b/src/libstrongswan/crypto/hashers/sha1_hasher.c index f3f3158c3..33eec5969 100644 --- a/src/libstrongswan/crypto/hashers/sha1_hasher.c +++ b/src/libstrongswan/crypto/hashers/sha1_hasher.c @@ -30,8 +30,6 @@ #include <definitions.h> -#define BLOCK_SIZE_SHA1 20 - /* * 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); if (hash != NULL) { - allocated_hash.ptr = malloc(BLOCK_SIZE_SHA1); - allocated_hash.len = BLOCK_SIZE_SHA1; + allocated_hash.ptr = malloc(HASH_SIZE_SHA1); + allocated_hash.len = HASH_SIZE_SHA1; SHA1Final(this, allocated_hash.ptr); 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) { - return BLOCK_SIZE_SHA1; + return HASH_SIZE_SHA1; } /** diff --git a/src/libstrongswan/crypto/hashers/sha2_hasher.c b/src/libstrongswan/crypto/hashers/sha2_hasher.c index 5378dbc9a..2c59438c0 100644 --- a/src/libstrongswan/crypto/hashers/sha2_hasher.c +++ b/src/libstrongswan/crypto/hashers/sha2_hasher.c @@ -29,10 +29,6 @@ #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; |