diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-07-11 07:20:05 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-08-01 05:47:24 -0400 |
commit | 9935e6d2f3b5670550e48a55172cab546ae5d096 (patch) | |
tree | 4fb721d92e50233da19b07a5e83441b9fef097f0 /crypto/des_generic.c | |
parent | 70a03bff6c3f9d2983f90b74e40b0769ceb4cbd7 (diff) |
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>
Diffstat (limited to 'crypto/des_generic.c')
-rw-r--r-- | crypto/des_generic.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/crypto/des_generic.c b/crypto/des_generic.c index 873818d48e86..f6cf63f88468 100644 --- a/crypto/des_generic.c +++ b/crypto/des_generic.c | |||
@@ -943,59 +943,44 @@ static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
943 | d[1] = cpu_to_le32(L); | 943 | d[1] = cpu_to_le32(L); |
944 | } | 944 | } |
945 | 945 | ||
946 | static struct crypto_alg des_alg = { | 946 | static struct crypto_alg des_algs[2] = { { |
947 | .cra_name = "des", | 947 | .cra_name = "des", |
948 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 948 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
949 | .cra_blocksize = DES_BLOCK_SIZE, | 949 | .cra_blocksize = DES_BLOCK_SIZE, |
950 | .cra_ctxsize = sizeof(struct des_ctx), | 950 | .cra_ctxsize = sizeof(struct des_ctx), |
951 | .cra_module = THIS_MODULE, | 951 | .cra_module = THIS_MODULE, |
952 | .cra_alignmask = 3, | 952 | .cra_alignmask = 3, |
953 | .cra_list = LIST_HEAD_INIT(des_alg.cra_list), | ||
954 | .cra_u = { .cipher = { | 953 | .cra_u = { .cipher = { |
955 | .cia_min_keysize = DES_KEY_SIZE, | 954 | .cia_min_keysize = DES_KEY_SIZE, |
956 | .cia_max_keysize = DES_KEY_SIZE, | 955 | .cia_max_keysize = DES_KEY_SIZE, |
957 | .cia_setkey = des_setkey, | 956 | .cia_setkey = des_setkey, |
958 | .cia_encrypt = des_encrypt, | 957 | .cia_encrypt = des_encrypt, |
959 | .cia_decrypt = des_decrypt } } | 958 | .cia_decrypt = des_decrypt } } |
960 | }; | 959 | }, { |
961 | |||
962 | static struct crypto_alg des3_ede_alg = { | ||
963 | .cra_name = "des3_ede", | 960 | .cra_name = "des3_ede", |
964 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 961 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
965 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 962 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
966 | .cra_ctxsize = sizeof(struct des3_ede_ctx), | 963 | .cra_ctxsize = sizeof(struct des3_ede_ctx), |
967 | .cra_module = THIS_MODULE, | 964 | .cra_module = THIS_MODULE, |
968 | .cra_alignmask = 3, | 965 | .cra_alignmask = 3, |
969 | .cra_list = LIST_HEAD_INIT(des3_ede_alg.cra_list), | ||
970 | .cra_u = { .cipher = { | 966 | .cra_u = { .cipher = { |
971 | .cia_min_keysize = DES3_EDE_KEY_SIZE, | 967 | .cia_min_keysize = DES3_EDE_KEY_SIZE, |
972 | .cia_max_keysize = DES3_EDE_KEY_SIZE, | 968 | .cia_max_keysize = DES3_EDE_KEY_SIZE, |
973 | .cia_setkey = des3_ede_setkey, | 969 | .cia_setkey = des3_ede_setkey, |
974 | .cia_encrypt = des3_ede_encrypt, | 970 | .cia_encrypt = des3_ede_encrypt, |
975 | .cia_decrypt = des3_ede_decrypt } } | 971 | .cia_decrypt = des3_ede_decrypt } } |
976 | }; | 972 | } }; |
977 | 973 | ||
978 | MODULE_ALIAS("des3_ede"); | 974 | MODULE_ALIAS("des3_ede"); |
979 | 975 | ||
980 | static int __init des_generic_mod_init(void) | 976 | static int __init des_generic_mod_init(void) |
981 | { | 977 | { |
982 | int ret = 0; | 978 | return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs)); |
983 | |||
984 | ret = crypto_register_alg(&des_alg); | ||
985 | if (ret < 0) | ||
986 | goto out; | ||
987 | |||
988 | ret = crypto_register_alg(&des3_ede_alg); | ||
989 | if (ret < 0) | ||
990 | crypto_unregister_alg(&des_alg); | ||
991 | out: | ||
992 | return ret; | ||
993 | } | 979 | } |
994 | 980 | ||
995 | static void __exit des_generic_mod_fini(void) | 981 | static void __exit des_generic_mod_fini(void) |
996 | { | 982 | { |
997 | crypto_unregister_alg(&des3_ede_alg); | 983 | crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs)); |
998 | crypto_unregister_alg(&des_alg); | ||
999 | } | 984 | } |
1000 | 985 | ||
1001 | module_init(des_generic_mod_init); | 986 | module_init(des_generic_mod_init); |