dect
/
linux-2.6
Archived
13
0
Fork 0

crypto: whirlpool - 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>
This commit is contained in:
Jussi Kivilinna 2012-07-11 14:20:41 +03:00 committed by Herbert Xu
parent 648b2a102d
commit f4b0277e7e
1 changed files with 6 additions and 33 deletions

View File

@ -1119,7 +1119,7 @@ static int wp256_final(struct shash_desc *desc, u8 *out)
return 0; return 0;
} }
static struct shash_alg wp512 = { static struct shash_alg wp_algs[3] = { {
.digestsize = WP512_DIGEST_SIZE, .digestsize = WP512_DIGEST_SIZE,
.init = wp512_init, .init = wp512_init,
.update = wp512_update, .update = wp512_update,
@ -1131,9 +1131,7 @@ static struct shash_alg wp512 = {
.cra_blocksize = WP512_BLOCK_SIZE, .cra_blocksize = WP512_BLOCK_SIZE,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
}; }, {
static struct shash_alg wp384 = {
.digestsize = WP384_DIGEST_SIZE, .digestsize = WP384_DIGEST_SIZE,
.init = wp512_init, .init = wp512_init,
.update = wp512_update, .update = wp512_update,
@ -1145,9 +1143,7 @@ static struct shash_alg wp384 = {
.cra_blocksize = WP512_BLOCK_SIZE, .cra_blocksize = WP512_BLOCK_SIZE,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
}; }, {
static struct shash_alg wp256 = {
.digestsize = WP256_DIGEST_SIZE, .digestsize = WP256_DIGEST_SIZE,
.init = wp512_init, .init = wp512_init,
.update = wp512_update, .update = wp512_update,
@ -1159,39 +1155,16 @@ static struct shash_alg wp256 = {
.cra_blocksize = WP512_BLOCK_SIZE, .cra_blocksize = WP512_BLOCK_SIZE,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
}; } };
static int __init wp512_mod_init(void) static int __init wp512_mod_init(void)
{ {
int ret = 0; return crypto_register_shashes(wp_algs, ARRAY_SIZE(wp_algs));
ret = crypto_register_shash(&wp512);
if (ret < 0)
goto out;
ret = crypto_register_shash(&wp384);
if (ret < 0)
{
crypto_unregister_shash(&wp512);
goto out;
}
ret = crypto_register_shash(&wp256);
if (ret < 0)
{
crypto_unregister_shash(&wp512);
crypto_unregister_shash(&wp384);
}
out:
return ret;
} }
static void __exit wp512_mod_fini(void) static void __exit wp512_mod_fini(void)
{ {
crypto_unregister_shash(&wp512); crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs));
crypto_unregister_shash(&wp384);
crypto_unregister_shash(&wp256);
} }
MODULE_ALIAS("wp384"); MODULE_ALIAS("wp384");