summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/md5/md5_hasher.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/md5/md5_hasher.c')
-rw-r--r--src/libstrongswan/plugins/md5/md5_hasher.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/libstrongswan/plugins/md5/md5_hasher.c b/src/libstrongswan/plugins/md5/md5_hasher.c
index 45c2391ef..99b505e58 100644
--- a/src/libstrongswan/plugins/md5/md5_hasher.c
+++ b/src/libstrongswan/plugins/md5/md5_hasher.c
@@ -299,33 +299,42 @@ static void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
}
}
-METHOD(hasher_t, get_hash, void,
+METHOD(hasher_t, reset, bool,
+ private_md5_hasher_t *this)
+{
+ this->state[0] = 0x67452301;
+ this->state[1] = 0xefcdab89;
+ this->state[2] = 0x98badcfe;
+ this->state[3] = 0x10325476;
+ this->count[0] = 0;
+ this->count[1] = 0;
+
+ return TRUE;
+}
+
+METHOD(hasher_t, get_hash, bool,
private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{
MD5Update(this, chunk.ptr, chunk.len);
if (buffer != NULL)
{
MD5Final(this, buffer);
- this->public.hasher_interface.reset(&(this->public.hasher_interface));
+ reset(this);
}
+ return TRUE;
}
-METHOD(hasher_t, allocate_hash, void,
+METHOD(hasher_t, allocate_hash, bool,
private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
{
- chunk_t allocated_hash;
-
MD5Update(this, chunk.ptr, chunk.len);
if (hash != NULL)
{
- 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));
-
- *hash = allocated_hash;
+ *hash = chunk_alloc(HASH_SIZE_MD5);
+ MD5Final(this, hash->ptr);
+ reset(this);
}
+ return TRUE;
}
METHOD(hasher_t, get_hash_size, size_t,
@@ -334,17 +343,6 @@ METHOD(hasher_t, get_hash_size, size_t,
return HASH_SIZE_MD5;
}
-METHOD(hasher_t, reset, void,
- private_md5_hasher_t *this)
-{
- this->state[0] = 0x67452301;
- this->state[1] = 0xefcdab89;
- this->state[2] = 0x98badcfe;
- this->state[3] = 0x10325476;
- this->count[0] = 0;
- this->count[1] = 0;
-}
-
METHOD(hasher_t, destroy, void,
private_md5_hasher_t *this)
{