aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorTim Chen <tim.c.chen@linux.intel.com>2013-03-26 16:59:25 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2013-04-25 09:00:57 -0400
commitbf70fa9d9ee07aa175453b19a39b2b9dab602d97 (patch)
tree7c7250c9c11db90a4fc096900276b186bf50ead1 /crypto
parent8275d1aa642295edd34a11a117080384bb9d65c2 (diff)
crypto: sha512 - Expose generic sha512 routine to be callable from other modules
Other SHA512 routines 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/sha512_generic.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
index 71fcf361102d..4c5862095679 100644
--- a/crypto/sha512_generic.c
+++ b/crypto/sha512_generic.c
@@ -163,8 +163,8 @@ sha384_init(struct shash_desc *desc)
163 return 0; 163 return 0;
164} 164}
165 165
166static int 166int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
167sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) 167 unsigned int len)
168{ 168{
169 struct sha512_state *sctx = shash_desc_ctx(desc); 169 struct sha512_state *sctx = shash_desc_ctx(desc);
170 170
@@ -197,6 +197,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len)
197 197
198 return 0; 198 return 0;
199} 199}
200EXPORT_SYMBOL(crypto_sha512_update);
200 201
201static int 202static int
202sha512_final(struct shash_desc *desc, u8 *hash) 203sha512_final(struct shash_desc *desc, u8 *hash)
@@ -215,10 +216,10 @@ sha512_final(struct shash_desc *desc, u8 *hash)
215 /* Pad out to 112 mod 128. */ 216 /* Pad out to 112 mod 128. */
216 index = sctx->count[0] & 0x7f; 217 index = sctx->count[0] & 0x7f;
217 pad_len = (index < 112) ? (112 - index) : ((128+112) - index); 218 pad_len = (index < 112) ? (112 - index) : ((128+112) - index);
218 sha512_update(desc, padding, pad_len); 219 crypto_sha512_update(desc, padding, pad_len);
219 220
220 /* Append length (before padding) */ 221 /* Append length (before padding) */
221 sha512_update(desc, (const u8 *)bits, sizeof(bits)); 222 crypto_sha512_update(desc, (const u8 *)bits, sizeof(bits));
222 223
223 /* Store state in digest */ 224 /* Store state in digest */
224 for (i = 0; i < 8; i++) 225 for (i = 0; i < 8; i++)
@@ -245,7 +246,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
245static struct shash_alg sha512_algs[2] = { { 246static struct shash_alg sha512_algs[2] = { {
246 .digestsize = SHA512_DIGEST_SIZE, 247 .digestsize = SHA512_DIGEST_SIZE,
247 .init = sha512_init, 248 .init = sha512_init,
248 .update = sha512_update, 249 .update = crypto_sha512_update,
249 .final = sha512_final, 250 .final = sha512_final,
250 .descsize = sizeof(struct sha512_state), 251 .descsize = sizeof(struct sha512_state),
251 .base = { 252 .base = {
@@ -257,7 +258,7 @@ static struct shash_alg sha512_algs[2] = { {
257}, { 258}, {
258 .digestsize = SHA384_DIGEST_SIZE, 259 .digestsize = SHA384_DIGEST_SIZE,
259 .init = sha384_init, 260 .init = sha384_init,
260 .update = sha512_update, 261 .update = crypto_sha512_update,
261 .final = sha384_final, 262 .final = sha384_final,
262 .descsize = sizeof(struct sha512_state), 263 .descsize = sizeof(struct sha512_state),
263 .base = { 264 .base = {