aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2012-07-11 07:20:36 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-01 05:47:26 -0400
commit648b2a102d268d41d8116abde9081327c1be82e8 (patch)
treed1a56dedee32cdb68c7ceac3740e06c4167020b0 /crypto
parent6aeb49bc5a6fffe2f8ba0668cf7459b6a4b672dc (diff)
crypto: sha512 - use crypto_[un]register_shashes
Combine all shash algs to be registered and use new crypto_[un]register_shashes functions. This simplifies init/exit code. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/sha512_generic.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
index dd30f40af9f5..71fcf361102d 100644
--- a/crypto/sha512_generic.c
+++ b/crypto/sha512_generic.c
@@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
242 return 0; 242 return 0;
243} 243}
244 244
245static struct shash_alg sha512 = { 245static struct shash_alg sha512_algs[2] = { {
246 .digestsize = SHA512_DIGEST_SIZE, 246 .digestsize = SHA512_DIGEST_SIZE,
247 .init = sha512_init, 247 .init = sha512_init,
248 .update = sha512_update, 248 .update = sha512_update,
@@ -254,9 +254,7 @@ static struct shash_alg sha512 = {
254 .cra_blocksize = SHA512_BLOCK_SIZE, 254 .cra_blocksize = SHA512_BLOCK_SIZE,
255 .cra_module = THIS_MODULE, 255 .cra_module = THIS_MODULE,
256 } 256 }
257}; 257}, {
258
259static struct shash_alg sha384 = {
260 .digestsize = SHA384_DIGEST_SIZE, 258 .digestsize = SHA384_DIGEST_SIZE,
261 .init = sha384_init, 259 .init = sha384_init,
262 .update = sha512_update, 260 .update = sha512_update,
@@ -268,24 +266,16 @@ static struct shash_alg sha384 = {
268 .cra_blocksize = SHA384_BLOCK_SIZE, 266 .cra_blocksize = SHA384_BLOCK_SIZE,
269 .cra_module = THIS_MODULE, 267 .cra_module = THIS_MODULE,
270 } 268 }
271}; 269} };
272 270
273static int __init sha512_generic_mod_init(void) 271static int __init sha512_generic_mod_init(void)
274{ 272{
275 int ret = 0; 273 return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
276
277 if ((ret = crypto_register_shash(&sha384)) < 0)
278 goto out;
279 if ((ret = crypto_register_shash(&sha512)) < 0)
280 crypto_unregister_shash(&sha384);
281out:
282 return ret;
283} 274}
284 275
285static void __exit sha512_generic_mod_fini(void) 276static void __exit sha512_generic_mod_fini(void)
286{ 277{
287 crypto_unregister_shash(&sha384); 278 crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
288 crypto_unregister_shash(&sha512);
289} 279}
290 280
291module_init(sha512_generic_mod_init); 281module_init(sha512_generic_mod_init);