From: Andreas Steffen Date: Wed, 28 Sep 2011 04:45:59 +0000 (+0200) Subject: use specific reset method X-Git-Tag: 4.6.0~338 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c741b3d18f27b1dc82a99459bf23e708d1da86bc;p=thirdparty%2Fstrongswan.git use specific reset method --- diff --git a/src/libstrongswan/plugins/sha2/sha2_hasher.c b/src/libstrongswan/plugins/sha2/sha2_hasher.c index 4482f361fc..60fe4bd20c 100644 --- a/src/libstrongswan/plugins/sha2/sha2_hasher.c +++ b/src/libstrongswan/plugins/sha2/sha2_hasher.c @@ -426,6 +426,40 @@ static void sha512_final(private_sha512_hasher_t *ctx) } while(++j < 8); } +METHOD(hasher_t, reset224, void, + private_sha256_hasher_t *this) +{ + memcpy(&this->sha_H[0], &sha224_hashInit[0], sizeof(this->sha_H)); + this->sha_blocks = 0; + this->sha_bufCnt = 0; +} + +METHOD(hasher_t, reset256, void, + private_sha256_hasher_t *this) +{ + memcpy(&this->sha_H[0], &sha256_hashInit[0], sizeof(this->sha_H)); + this->sha_blocks = 0; + this->sha_bufCnt = 0; +} + +METHOD(hasher_t, reset384, void, + private_sha512_hasher_t *this) +{ + memcpy(&this->sha_H[0], &sha384_hashInit[0], sizeof(this->sha_H)); + this->sha_blocks = 0; + this->sha_blocksMSB = 0; + this->sha_bufCnt = 0; +} + +METHOD(hasher_t, reset512, void, + private_sha512_hasher_t *this) +{ + memcpy(&this->sha_H[0], &sha512_hashInit[0], sizeof(this->sha_H)); + this->sha_blocks = 0; + this->sha_blocksMSB = 0; + this->sha_bufCnt = 0; +} + METHOD(hasher_t, get_hash224, void, private_sha256_hasher_t *this, chunk_t chunk, u_int8_t *buffer) { @@ -434,7 +468,7 @@ METHOD(hasher_t, get_hash224, void, { sha256_final(this); memcpy(buffer, this->sha_out, HASH_SIZE_SHA224); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset224(this); } } @@ -446,7 +480,7 @@ METHOD(hasher_t, get_hash256, void, { sha256_final(this); memcpy(buffer, this->sha_out, HASH_SIZE_SHA256); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset256(this); } } @@ -458,7 +492,7 @@ METHOD(hasher_t, get_hash384, void, { sha512_final(this); memcpy(buffer, this->sha_out, HASH_SIZE_SHA384); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset384(this); } } @@ -470,7 +504,7 @@ METHOD(hasher_t, get_hash512, void, { sha512_final(this); memcpy(buffer, this->sha_out, HASH_SIZE_SHA512); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset512(this); } } @@ -485,7 +519,7 @@ METHOD(hasher_t, allocate_hash224, void, sha256_final(this); allocated_hash = chunk_alloc(HASH_SIZE_SHA224); memcpy(allocated_hash.ptr, this->sha_out, HASH_SIZE_SHA224); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset224(this); *hash = allocated_hash; } } @@ -501,7 +535,7 @@ METHOD(hasher_t, allocate_hash256, void, sha256_final(this); allocated_hash = chunk_alloc(HASH_SIZE_SHA256); memcpy(allocated_hash.ptr, this->sha_out, HASH_SIZE_SHA256); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset256(this); *hash = allocated_hash; } } @@ -517,7 +551,7 @@ METHOD(hasher_t, allocate_hash384, void, sha512_final(this); allocated_hash = chunk_alloc(HASH_SIZE_SHA384); memcpy(allocated_hash.ptr, this->sha_out, HASH_SIZE_SHA384); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset384(this); *hash = allocated_hash; } } @@ -533,7 +567,7 @@ METHOD(hasher_t, allocate_hash512, void, sha512_final(this); allocated_hash = chunk_alloc(HASH_SIZE_SHA512); memcpy(allocated_hash.ptr, this->sha_out, HASH_SIZE_SHA512); - this->public.hasher_interface.reset(&(this->public.hasher_interface)); + reset512(this); *hash = allocated_hash; } } @@ -562,40 +596,6 @@ METHOD(hasher_t, get_hash_size512, size_t, return HASH_SIZE_SHA512; } -METHOD(hasher_t, reset224, void, - private_sha256_hasher_t *this) -{ - memcpy(&this->sha_H[0], &sha224_hashInit[0], sizeof(this->sha_H)); - this->sha_blocks = 0; - this->sha_bufCnt = 0; -} - -METHOD(hasher_t, reset256, void, - private_sha256_hasher_t *this) -{ - memcpy(&this->sha_H[0], &sha256_hashInit[0], sizeof(this->sha_H)); - this->sha_blocks = 0; - this->sha_bufCnt = 0; -} - -METHOD(hasher_t, reset384, void, - private_sha512_hasher_t *this) -{ - memcpy(&this->sha_H[0], &sha384_hashInit[0], sizeof(this->sha_H)); - this->sha_blocks = 0; - this->sha_blocksMSB = 0; - this->sha_bufCnt = 0; -} - -METHOD(hasher_t, reset512, void, - private_sha512_hasher_t *this) -{ - memcpy(&this->sha_H[0], &sha512_hashInit[0], sizeof(this->sha_H)); - this->sha_blocks = 0; - this->sha_blocksMSB = 0; - this->sha_bufCnt = 0; -} - METHOD(hasher_t, destroy, void, sha2_hasher_t *this) {