Commit 648b2a10 authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Herbert Xu

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: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 6aeb49bc
...@@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash) ...@@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
return 0; return 0;
} }
static struct shash_alg sha512 = { static struct shash_alg sha512_algs[2] = { {
.digestsize = SHA512_DIGEST_SIZE, .digestsize = SHA512_DIGEST_SIZE,
.init = sha512_init, .init = sha512_init,
.update = sha512_update, .update = sha512_update,
...@@ -254,9 +254,7 @@ static struct shash_alg sha512 = { ...@@ -254,9 +254,7 @@ static struct shash_alg sha512 = {
.cra_blocksize = SHA512_BLOCK_SIZE, .cra_blocksize = SHA512_BLOCK_SIZE,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
}; }, {
static struct shash_alg sha384 = {
.digestsize = SHA384_DIGEST_SIZE, .digestsize = SHA384_DIGEST_SIZE,
.init = sha384_init, .init = sha384_init,
.update = sha512_update, .update = sha512_update,
...@@ -268,24 +266,16 @@ static struct shash_alg sha384 = { ...@@ -268,24 +266,16 @@ static struct shash_alg sha384 = {
.cra_blocksize = SHA384_BLOCK_SIZE, .cra_blocksize = SHA384_BLOCK_SIZE,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
}; } };
static int __init sha512_generic_mod_init(void) static int __init sha512_generic_mod_init(void)
{ {
int ret = 0; return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
if ((ret = crypto_register_shash(&sha384)) < 0)
goto out;
if ((ret = crypto_register_shash(&sha512)) < 0)
crypto_unregister_shash(&sha384);
out:
return ret;
} }
static void __exit sha512_generic_mod_fini(void) static void __exit sha512_generic_mod_fini(void)
{ {
crypto_unregister_shash(&sha384); crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
crypto_unregister_shash(&sha512);
} }
module_init(sha512_generic_mod_init); module_init(sha512_generic_mod_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment