diff options
author | Tim Chen <tim.c.chen@linux.intel.com> | 2013-03-26 16:58:49 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-04-02 21:06:31 -0400 |
commit | 35d2c9d0c3cfd90850dc647250610587743e1f29 (patch) | |
tree | d395d18fa88811ed2e3e477cb438e7521b9a9858 /crypto | |
parent | 873b9cafa8cae695d92f0faabe7166af10078b78 (diff) |
crypto: sha256 - Expose SHA256 generic routine to be callable externally.
Other SHA256 routine may need to use the generic routine when
FPU is not available.
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/sha256_generic.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c index c3ed4ec924e1..543366779524 100644 --- a/crypto/sha256_generic.c +++ b/crypto/sha256_generic.c | |||
@@ -246,7 +246,7 @@ static int sha256_init(struct shash_desc *desc) | |||
246 | return 0; | 246 | return 0; |
247 | } | 247 | } |
248 | 248 | ||
249 | static int sha256_update(struct shash_desc *desc, const u8 *data, | 249 | int crypto_sha256_update(struct shash_desc *desc, const u8 *data, |
250 | unsigned int len) | 250 | unsigned int len) |
251 | { | 251 | { |
252 | struct sha256_state *sctx = shash_desc_ctx(desc); | 252 | struct sha256_state *sctx = shash_desc_ctx(desc); |
@@ -277,6 +277,7 @@ static int sha256_update(struct shash_desc *desc, const u8 *data, | |||
277 | 277 | ||
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
280 | EXPORT_SYMBOL(crypto_sha256_update); | ||
280 | 281 | ||
281 | static int sha256_final(struct shash_desc *desc, u8 *out) | 282 | static int sha256_final(struct shash_desc *desc, u8 *out) |
282 | { | 283 | { |
@@ -293,10 +294,10 @@ static int sha256_final(struct shash_desc *desc, u8 *out) | |||
293 | /* Pad out to 56 mod 64. */ | 294 | /* Pad out to 56 mod 64. */ |
294 | index = sctx->count & 0x3f; | 295 | index = sctx->count & 0x3f; |
295 | pad_len = (index < 56) ? (56 - index) : ((64+56) - index); | 296 | pad_len = (index < 56) ? (56 - index) : ((64+56) - index); |
296 | sha256_update(desc, padding, pad_len); | 297 | crypto_sha256_update(desc, padding, pad_len); |
297 | 298 | ||
298 | /* Append length (before padding) */ | 299 | /* Append length (before padding) */ |
299 | sha256_update(desc, (const u8 *)&bits, sizeof(bits)); | 300 | crypto_sha256_update(desc, (const u8 *)&bits, sizeof(bits)); |
300 | 301 | ||
301 | /* Store state in digest */ | 302 | /* Store state in digest */ |
302 | for (i = 0; i < 8; i++) | 303 | for (i = 0; i < 8; i++) |
@@ -339,7 +340,7 @@ static int sha256_import(struct shash_desc *desc, const void *in) | |||
339 | static struct shash_alg sha256_algs[2] = { { | 340 | static struct shash_alg sha256_algs[2] = { { |
340 | .digestsize = SHA256_DIGEST_SIZE, | 341 | .digestsize = SHA256_DIGEST_SIZE, |
341 | .init = sha256_init, | 342 | .init = sha256_init, |
342 | .update = sha256_update, | 343 | .update = crypto_sha256_update, |
343 | .final = sha256_final, | 344 | .final = sha256_final, |
344 | .export = sha256_export, | 345 | .export = sha256_export, |
345 | .import = sha256_import, | 346 | .import = sha256_import, |
@@ -355,7 +356,7 @@ static struct shash_alg sha256_algs[2] = { { | |||
355 | }, { | 356 | }, { |
356 | .digestsize = SHA224_DIGEST_SIZE, | 357 | .digestsize = SHA224_DIGEST_SIZE, |
357 | .init = sha224_init, | 358 | .init = sha224_init, |
358 | .update = sha256_update, | 359 | .update = crypto_sha256_update, |
359 | .final = sha224_final, | 360 | .final = sha224_final, |
360 | .descsize = sizeof(struct sha256_state), | 361 | .descsize = sizeof(struct sha256_state), |
361 | .base = { | 362 | .base = { |