use specific reset method
authorAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 28 Sep 2011 04:45:59 +0000 (06:45 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 28 Sep 2011 04:45:59 +0000 (06:45 +0200)
src/libstrongswan/plugins/sha2/sha2_hasher.c

index 4482f36..60fe4bd 100644 (file)
@@ -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)
 {