diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-21 23:48:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-22 02:38:12 -0400 |
commit | 1f38ad8389bbca038d320c29d30aa1d6ed96b48d (patch) | |
tree | 78f458530e16980b9298c09f1b2c1f9c14c09411 /crypto | |
parent | ac95301f271f32901e4007096aa3516def49eed2 (diff) |
crypto: sha512 - Export struct sha512_state
This patch renames struct sha512_ctx and exports it as struct
sha512_state so that other sha512 implementations can use it
as the reference structure for exporting their state.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/sha512_generic.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 3bea38d1224..4fe95eb0322 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
@@ -21,12 +21,6 @@ | |||
21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
22 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
23 | 23 | ||
24 | struct sha512_ctx { | ||
25 | u64 state[8]; | ||
26 | u32 count[4]; | ||
27 | u8 buf[128]; | ||
28 | }; | ||
29 | |||
30 | static DEFINE_PER_CPU(u64[80], msg_schedule); | 24 | static DEFINE_PER_CPU(u64[80], msg_schedule); |
31 | 25 | ||
32 | static inline u64 Ch(u64 x, u64 y, u64 z) | 26 | static inline u64 Ch(u64 x, u64 y, u64 z) |
@@ -141,7 +135,7 @@ sha512_transform(u64 *state, const u8 *input) | |||
141 | static int | 135 | static int |
142 | sha512_init(struct shash_desc *desc) | 136 | sha512_init(struct shash_desc *desc) |
143 | { | 137 | { |
144 | struct sha512_ctx *sctx = shash_desc_ctx(desc); | 138 | struct sha512_state *sctx = shash_desc_ctx(desc); |
145 | sctx->state[0] = SHA512_H0; | 139 | sctx->state[0] = SHA512_H0; |
146 | sctx->state[1] = SHA512_H1; | 140 | sctx->state[1] = SHA512_H1; |
147 | sctx->state[2] = SHA512_H2; | 141 | sctx->state[2] = SHA512_H2; |
@@ -158,7 +152,7 @@ sha512_init(struct shash_desc *desc) | |||
158 | static int | 152 | static int |
159 | sha384_init(struct shash_desc *desc) | 153 | sha384_init(struct shash_desc *desc) |
160 | { | 154 | { |
161 | struct sha512_ctx *sctx = shash_desc_ctx(desc); | 155 | struct sha512_state *sctx = shash_desc_ctx(desc); |
162 | sctx->state[0] = SHA384_H0; | 156 | sctx->state[0] = SHA384_H0; |
163 | sctx->state[1] = SHA384_H1; | 157 | sctx->state[1] = SHA384_H1; |
164 | sctx->state[2] = SHA384_H2; | 158 | sctx->state[2] = SHA384_H2; |
@@ -175,7 +169,7 @@ sha384_init(struct shash_desc *desc) | |||
175 | static int | 169 | static int |
176 | sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) | 170 | sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) |
177 | { | 171 | { |
178 | struct sha512_ctx *sctx = shash_desc_ctx(desc); | 172 | struct sha512_state *sctx = shash_desc_ctx(desc); |
179 | 173 | ||
180 | unsigned int i, index, part_len; | 174 | unsigned int i, index, part_len; |
181 | 175 | ||
@@ -214,7 +208,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) | |||
214 | static int | 208 | static int |
215 | sha512_final(struct shash_desc *desc, u8 *hash) | 209 | sha512_final(struct shash_desc *desc, u8 *hash) |
216 | { | 210 | { |
217 | struct sha512_ctx *sctx = shash_desc_ctx(desc); | 211 | struct sha512_state *sctx = shash_desc_ctx(desc); |
218 | static u8 padding[128] = { 0x80, }; | 212 | static u8 padding[128] = { 0x80, }; |
219 | __be64 *dst = (__be64 *)hash; | 213 | __be64 *dst = (__be64 *)hash; |
220 | __be32 bits[4]; | 214 | __be32 bits[4]; |
@@ -240,7 +234,7 @@ sha512_final(struct shash_desc *desc, u8 *hash) | |||
240 | dst[i] = cpu_to_be64(sctx->state[i]); | 234 | dst[i] = cpu_to_be64(sctx->state[i]); |
241 | 235 | ||
242 | /* Zeroize sensitive information. */ | 236 | /* Zeroize sensitive information. */ |
243 | memset(sctx, 0, sizeof(struct sha512_ctx)); | 237 | memset(sctx, 0, sizeof(struct sha512_state)); |
244 | 238 | ||
245 | return 0; | 239 | return 0; |
246 | } | 240 | } |
@@ -262,7 +256,7 @@ static struct shash_alg sha512 = { | |||
262 | .init = sha512_init, | 256 | .init = sha512_init, |
263 | .update = sha512_update, | 257 | .update = sha512_update, |
264 | .final = sha512_final, | 258 | .final = sha512_final, |
265 | .descsize = sizeof(struct sha512_ctx), | 259 | .descsize = sizeof(struct sha512_state), |
266 | .base = { | 260 | .base = { |
267 | .cra_name = "sha512", | 261 | .cra_name = "sha512", |
268 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, | 262 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
@@ -276,7 +270,7 @@ static struct shash_alg sha384 = { | |||
276 | .init = sha384_init, | 270 | .init = sha384_init, |
277 | .update = sha512_update, | 271 | .update = sha512_update, |
278 | .final = sha384_final, | 272 | .final = sha384_final, |
279 | .descsize = sizeof(struct sha512_ctx), | 273 | .descsize = sizeof(struct sha512_state), |
280 | .base = { | 274 | .base = { |
281 | .cra_name = "sha384", | 275 | .cra_name = "sha384", |
282 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, | 276 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |