Migrated md5_hasher to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-09-28 03:44:02 +02:00
parent 0416bb1c51
commit 52c4c6a8ff
+21 -29
View File
@@ -299,12 +299,8 @@ static void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
} }
} }
METHOD(hasher_t, get_hash, void,
private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
/**
* Implementation of hasher_t.get_hash.
*/
static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{ {
MD5Update(this, chunk.ptr, chunk.len); MD5Update(this, chunk.ptr, chunk.len);
if (buffer != NULL) if (buffer != NULL)
@@ -314,11 +310,8 @@ static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer
} }
} }
METHOD(hasher_t, allocate_hash, void,
/** private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
* Implementation of hasher_t.allocate_hash.
*/
static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
{ {
chunk_t allocated_hash; chunk_t allocated_hash;
@@ -335,18 +328,14 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
} }
} }
/** METHOD(hasher_t, get_hash_size, size_t,
* Implementation of hasher_t.get_hash_size. private_md5_hasher_t *this)
*/
static size_t get_hash_size(private_md5_hasher_t *this)
{ {
return HASH_SIZE_MD5; return HASH_SIZE_MD5;
} }
/** METHOD(hasher_t, reset, void,
* Implementation of hasher_t.reset. private_md5_hasher_t *this)
*/
static void reset(private_md5_hasher_t *this)
{ {
this->state[0] = 0x67452301; this->state[0] = 0x67452301;
this->state[1] = 0xefcdab89; this->state[1] = 0xefcdab89;
@@ -356,10 +345,8 @@ static void reset(private_md5_hasher_t *this)
this->count[1] = 0; this->count[1] = 0;
} }
/** METHOD(hasher_t, destroy, void,
* Implementation of hasher_t.destroy. private_md5_hasher_t *this)
*/
static void destroy(private_md5_hasher_t *this)
{ {
free(this); free(this);
} }
@@ -375,13 +362,18 @@ md5_hasher_t *md5_hasher_create(hash_algorithm_t algo)
{ {
return NULL; return NULL;
} }
this = malloc_thing(private_md5_hasher_t);
this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash; INIT(this,
this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash; .public = {
this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size; .hasher_interface = {
this->public.hasher_interface.reset = (void (*) (hasher_t*))reset; .get_hash = _get_hash,
this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy; .allocate_hash = _allocate_hash,
.get_hash_size = _get_hash_size,
.reset = _reset,
.destroy = _destroy,
},
},
);
/* initialize */ /* initialize */
reset(this); reset(this);