crypto: des - use crypto_[un]register_algs
Combine all crypto_alg to be registered and use new crypto_[un]register_algs 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:
parent
70a03bff6c
commit
9935e6d2f3
@ -943,59 +943,44 @@ static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
|||||||
d[1] = cpu_to_le32(L);
|
d[1] = cpu_to_le32(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct crypto_alg des_alg = {
|
static struct crypto_alg des_algs[2] = { {
|
||||||
.cra_name = "des",
|
.cra_name = "des",
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||||
.cra_blocksize = DES_BLOCK_SIZE,
|
.cra_blocksize = DES_BLOCK_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct des_ctx),
|
.cra_ctxsize = sizeof(struct des_ctx),
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
.cra_alignmask = 3,
|
.cra_alignmask = 3,
|
||||||
.cra_list = LIST_HEAD_INIT(des_alg.cra_list),
|
|
||||||
.cra_u = { .cipher = {
|
.cra_u = { .cipher = {
|
||||||
.cia_min_keysize = DES_KEY_SIZE,
|
.cia_min_keysize = DES_KEY_SIZE,
|
||||||
.cia_max_keysize = DES_KEY_SIZE,
|
.cia_max_keysize = DES_KEY_SIZE,
|
||||||
.cia_setkey = des_setkey,
|
.cia_setkey = des_setkey,
|
||||||
.cia_encrypt = des_encrypt,
|
.cia_encrypt = des_encrypt,
|
||||||
.cia_decrypt = des_decrypt } }
|
.cia_decrypt = des_decrypt } }
|
||||||
};
|
}, {
|
||||||
|
|
||||||
static struct crypto_alg des3_ede_alg = {
|
|
||||||
.cra_name = "des3_ede",
|
.cra_name = "des3_ede",
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct des3_ede_ctx),
|
.cra_ctxsize = sizeof(struct des3_ede_ctx),
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
.cra_alignmask = 3,
|
.cra_alignmask = 3,
|
||||||
.cra_list = LIST_HEAD_INIT(des3_ede_alg.cra_list),
|
|
||||||
.cra_u = { .cipher = {
|
.cra_u = { .cipher = {
|
||||||
.cia_min_keysize = DES3_EDE_KEY_SIZE,
|
.cia_min_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cia_max_keysize = DES3_EDE_KEY_SIZE,
|
.cia_max_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cia_setkey = des3_ede_setkey,
|
.cia_setkey = des3_ede_setkey,
|
||||||
.cia_encrypt = des3_ede_encrypt,
|
.cia_encrypt = des3_ede_encrypt,
|
||||||
.cia_decrypt = des3_ede_decrypt } }
|
.cia_decrypt = des3_ede_decrypt } }
|
||||||
};
|
} };
|
||||||
|
|
||||||
MODULE_ALIAS("des3_ede");
|
MODULE_ALIAS("des3_ede");
|
||||||
|
|
||||||
static int __init des_generic_mod_init(void)
|
static int __init des_generic_mod_init(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs));
|
||||||
|
|
||||||
ret = crypto_register_alg(&des_alg);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ret = crypto_register_alg(&des3_ede_alg);
|
|
||||||
if (ret < 0)
|
|
||||||
crypto_unregister_alg(&des_alg);
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit des_generic_mod_fini(void)
|
static void __exit des_generic_mod_fini(void)
|
||||||
{
|
{
|
||||||
crypto_unregister_alg(&des3_ede_alg);
|
crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs));
|
||||||
crypto_unregister_alg(&des_alg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(des_generic_mod_init);
|
module_init(des_generic_mod_init);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user