aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2011-09-28 06:45:59 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2011-09-28 06:45:59 +0200
commitc741b3d18f27b1dc82a99459bf23e708d1da86bc (patch)
tree06d43352fc13b2448e0edee9b71747473eee33c7 /src
parent13f90f833f7f505fa48a3cecec38d210c7b4094f (diff)
downloadstrongswan-c741b3d18f27b1dc82a99459bf23e708d1da86bc.tar.bz2
strongswan-c741b3d18f27b1dc82a99459bf23e708d1da86bc.tar.xz
use specific reset method
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/sha2/sha2_hasher.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/libstrongswan/plugins/sha2/sha2_hasher.c b/src/libstrongswan/plugins/sha2/sha2_hasher.c
index 4482f361f..60fe4bd20 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)
{