diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-05-16 08:06:54 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-06-26 03:34:38 -0400 |
commit | 43600106e32809a4dead79fec67a63e9860e3d5d (patch) | |
tree | 20590746b98c41d6cc8b590b01cecddf9a185270 | |
parent | 8b55ba0303bb59c34fab8e015634018780491614 (diff) |
[CRYPTO] digest: Remove unnecessary zeroing during init
Various digest algorithms operate one block at a time and therefore
keep a temporary buffer of partial blocks. This buffer does not need
to be initialised since there is a counter which indicates what is and
isn't valid in it.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | arch/s390/crypto/sha1_s390.c | 23 | ||||
-rw-r--r-- | arch/s390/crypto/sha256_s390.c | 1 | ||||
-rw-r--r-- | crypto/sha256.c | 1 | ||||
-rw-r--r-- | crypto/sha512.c | 2 | ||||
-rw-r--r-- | crypto/tgr192.c | 1 |
5 files changed, 12 insertions, 16 deletions
diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c index 98c896b86dcd..36bb5346a8c4 100644 --- a/arch/s390/crypto/sha1_s390.c +++ b/arch/s390/crypto/sha1_s390.c | |||
@@ -40,19 +40,20 @@ struct crypt_s390_sha1_ctx { | |||
40 | u8 buffer[2 * SHA1_BLOCK_SIZE]; | 40 | u8 buffer[2 * SHA1_BLOCK_SIZE]; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static void | 43 | static void sha1_init(void *ctx_arg) |
44 | sha1_init(void *ctx) | ||
45 | { | 44 | { |
46 | static const struct crypt_s390_sha1_ctx initstate = { | 45 | struct crypt_s390_sha1_ctx *ctx = ctx_arg; |
47 | .state = { | 46 | static const u32 initstate[5] = { |
48 | 0x67452301, | 47 | 0x67452301, |
49 | 0xEFCDAB89, | 48 | 0xEFCDAB89, |
50 | 0x98BADCFE, | 49 | 0x98BADCFE, |
51 | 0x10325476, | 50 | 0x10325476, |
52 | 0xC3D2E1F0 | 51 | 0xC3D2E1F0 |
53 | }, | ||
54 | }; | 52 | }; |
55 | memcpy(ctx, &initstate, sizeof(initstate)); | 53 | |
54 | ctx->count = 0; | ||
55 | memcpy(ctx->state, &initstate, sizeof(initstate)); | ||
56 | ctx->buf_len = 0; | ||
56 | } | 57 | } |
57 | 58 | ||
58 | static void | 59 | static void |
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c index 1ec5e92b3454..2c76e7bee41c 100644 --- a/arch/s390/crypto/sha256_s390.c +++ b/arch/s390/crypto/sha256_s390.c | |||
@@ -44,7 +44,6 @@ static void sha256_init(void *ctx) | |||
44 | sctx->state[6] = 0x1f83d9ab; | 44 | sctx->state[6] = 0x1f83d9ab; |
45 | sctx->state[7] = 0x5be0cd19; | 45 | sctx->state[7] = 0x5be0cd19; |
46 | sctx->count = 0; | 46 | sctx->count = 0; |
47 | memset(sctx->buf, 0, sizeof(sctx->buf)); | ||
48 | } | 47 | } |
49 | 48 | ||
50 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) | 49 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) |
diff --git a/crypto/sha256.c b/crypto/sha256.c index d62264a8a33e..4533a0564895 100644 --- a/crypto/sha256.c +++ b/crypto/sha256.c | |||
@@ -242,7 +242,6 @@ static void sha256_init(void *ctx) | |||
242 | sctx->state[6] = H6; | 242 | sctx->state[6] = H6; |
243 | sctx->state[7] = H7; | 243 | sctx->state[7] = H7; |
244 | sctx->count[0] = sctx->count[1] = 0; | 244 | sctx->count[0] = sctx->count[1] = 0; |
245 | memset(sctx->buf, 0, sizeof(sctx->buf)); | ||
246 | } | 245 | } |
247 | 246 | ||
248 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) | 247 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) |
diff --git a/crypto/sha512.c b/crypto/sha512.c index 7dbec4f6b947..bc77a66d9de2 100644 --- a/crypto/sha512.c +++ b/crypto/sha512.c | |||
@@ -173,7 +173,6 @@ sha512_init(void *ctx) | |||
173 | sctx->state[6] = H6; | 173 | sctx->state[6] = H6; |
174 | sctx->state[7] = H7; | 174 | sctx->state[7] = H7; |
175 | sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; | 175 | sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; |
176 | memset(sctx->buf, 0, sizeof(sctx->buf)); | ||
177 | } | 176 | } |
178 | 177 | ||
179 | static void | 178 | static void |
@@ -189,7 +188,6 @@ sha384_init(void *ctx) | |||
189 | sctx->state[6] = HP6; | 188 | sctx->state[6] = HP6; |
190 | sctx->state[7] = HP7; | 189 | sctx->state[7] = HP7; |
191 | sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; | 190 | sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; |
192 | memset(sctx->buf, 0, sizeof(sctx->buf)); | ||
193 | } | 191 | } |
194 | 192 | ||
195 | static void | 193 | static void |
diff --git a/crypto/tgr192.c b/crypto/tgr192.c index 1eae1bb7e495..004bb841cc5b 100644 --- a/crypto/tgr192.c +++ b/crypto/tgr192.c | |||
@@ -500,7 +500,6 @@ static void tgr192_init(void *ctx) | |||
500 | { | 500 | { |
501 | struct tgr192_ctx *tctx = ctx; | 501 | struct tgr192_ctx *tctx = ctx; |
502 | 502 | ||
503 | memset (tctx->hash, 0, 64); | ||
504 | tctx->a = 0x0123456789abcdefULL; | 503 | tctx->a = 0x0123456789abcdefULL; |
505 | tctx->b = 0xfedcba9876543210ULL; | 504 | tctx->b = 0xfedcba9876543210ULL; |
506 | tctx->c = 0xf096a5b4c3b2e187ULL; | 505 | tctx->c = 0xf096a5b4c3b2e187ULL; |