Skip to content

Commit

Permalink
crypto: sha512 - use crypto_[un]register_shashes
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
jkivilin authored and herbertx committed Aug 1, 2012
1 parent 6aeb49b commit 648b2a1
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions crypto/sha512_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
return 0;
}

static struct shash_alg sha512 = {
static struct shash_alg sha512_algs[2] = { {
.digestsize = SHA512_DIGEST_SIZE,
.init = sha512_init,
.update = sha512_update,
Expand All @@ -254,9 +254,7 @@ static struct shash_alg sha512 = {
.cra_blocksize = SHA512_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
};

static struct shash_alg sha384 = {
}, {
.digestsize = SHA384_DIGEST_SIZE,
.init = sha384_init,
.update = sha512_update,
Expand All @@ -268,24 +266,16 @@ static struct shash_alg sha384 = {
.cra_blocksize = SHA384_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
};
} };

static int __init sha512_generic_mod_init(void)
{
int ret = 0;

if ((ret = crypto_register_shash(&sha384)) < 0)
goto out;
if ((ret = crypto_register_shash(&sha512)) < 0)
crypto_unregister_shash(&sha384);
out:
return ret;
return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
}

static void __exit sha512_generic_mod_fini(void)
{
crypto_unregister_shash(&sha384);
crypto_unregister_shash(&sha512);
crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
}

module_init(sha512_generic_mod_init);
Expand Down

0 comments on commit 648b2a1

Please sign in to comment.