Commit 35d2c9d0c3cfd90850dc647250610587743e1f29

Authored by Tim Chen
Committed by Herbert Xu
1 parent 873b9cafa8

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>

Showing 2 changed files with 8 additions and 5 deletions Side-by-side Diff

crypto/sha256_generic.c
... ... @@ -246,7 +246,7 @@
246 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 250 unsigned int len)
251 251 {
252 252 struct sha256_state *sctx = shash_desc_ctx(desc);
... ... @@ -277,6 +277,7 @@
277 277  
278 278 return 0;
279 279 }
  280 +EXPORT_SYMBOL(crypto_sha256_update);
280 281  
281 282 static int sha256_final(struct shash_desc *desc, u8 *out)
282 283 {
283 284  
... ... @@ -293,10 +294,10 @@
293 294 /* Pad out to 56 mod 64. */
294 295 index = sctx->count & 0x3f;
295 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 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 302 /* Store state in digest */
302 303 for (i = 0; i < 8; i++)
... ... @@ -339,7 +340,7 @@
339 340 static struct shash_alg sha256_algs[2] = { {
340 341 .digestsize = SHA256_DIGEST_SIZE,
341 342 .init = sha256_init,
342   - .update = sha256_update,
  343 + .update = crypto_sha256_update,
343 344 .final = sha256_final,
344 345 .export = sha256_export,
345 346 .import = sha256_import,
... ... @@ -355,7 +356,7 @@
355 356 }, {
356 357 .digestsize = SHA224_DIGEST_SIZE,
357 358 .init = sha224_init,
358   - .update = sha256_update,
  359 + .update = crypto_sha256_update,
359 360 .final = sha224_final,
360 361 .descsize = sizeof(struct sha256_state),
361 362 .base = {
include/crypto/sha.h
... ... @@ -87,5 +87,7 @@
87 87 extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
88 88 unsigned int len);
89 89  
  90 +extern int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
  91 + unsigned int len);
90 92 #endif