Commit 43600106e32809a4dead79fec67a63e9860e3d5d
1 parent
8b55ba0303
Exists in
master
and in
4 other branches
[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>
Showing 5 changed files with 12 additions and 16 deletions Side-by-side Diff
arch/s390/crypto/sha1_s390.c
... | ... | @@ -40,19 +40,20 @@ |
40 | 40 | u8 buffer[2 * SHA1_BLOCK_SIZE]; |
41 | 41 | }; |
42 | 42 | |
43 | -static void | |
44 | -sha1_init(void *ctx) | |
43 | +static void sha1_init(void *ctx_arg) | |
45 | 44 | { |
46 | - static const struct crypt_s390_sha1_ctx initstate = { | |
47 | - .state = { | |
48 | - 0x67452301, | |
49 | - 0xEFCDAB89, | |
50 | - 0x98BADCFE, | |
51 | - 0x10325476, | |
52 | - 0xC3D2E1F0 | |
53 | - }, | |
45 | + struct crypt_s390_sha1_ctx *ctx = ctx_arg; | |
46 | + static const u32 initstate[5] = { | |
47 | + 0x67452301, | |
48 | + 0xEFCDAB89, | |
49 | + 0x98BADCFE, | |
50 | + 0x10325476, | |
51 | + 0xC3D2E1F0 | |
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 | 59 | static void |
arch/s390/crypto/sha256_s390.c
crypto/sha256.c
crypto/sha512.c
... | ... | @@ -173,7 +173,6 @@ |
173 | 173 | sctx->state[6] = H6; |
174 | 174 | sctx->state[7] = H7; |
175 | 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 | 178 | static void |
... | ... | @@ -189,7 +188,6 @@ |
189 | 188 | sctx->state[6] = HP6; |
190 | 189 | sctx->state[7] = HP7; |
191 | 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 | 193 | static void |