diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-07-11 07:20:41 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-08-01 05:47:27 -0400 |
commit | f4b0277e7ef435733b888a62cf9c4c12b219e7c5 (patch) | |
tree | 199ece67ddd98bf67d1b29b9b42c8fd54296d74e /crypto | |
parent | 648b2a102d268d41d8116abde9081327c1be82e8 (diff) |
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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/wp512.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/crypto/wp512.c b/crypto/wp512.c index 71719a2be25a..180f1d6e03f4 100644 --- a/crypto/wp512.c +++ b/crypto/wp512.c | |||
@@ -1119,7 +1119,7 @@ static int wp256_final(struct shash_desc *desc, u8 *out) | |||
1119 | return 0; | 1119 | return 0; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | static struct shash_alg wp512 = { | 1122 | static struct shash_alg wp_algs[3] = { { |
1123 | .digestsize = WP512_DIGEST_SIZE, | 1123 | .digestsize = WP512_DIGEST_SIZE, |
1124 | .init = wp512_init, | 1124 | .init = wp512_init, |
1125 | .update = wp512_update, | 1125 | .update = wp512_update, |
@@ -1131,9 +1131,7 @@ static struct shash_alg wp512 = { | |||
1131 | .cra_blocksize = WP512_BLOCK_SIZE, | 1131 | .cra_blocksize = WP512_BLOCK_SIZE, |
1132 | .cra_module = THIS_MODULE, | 1132 | .cra_module = THIS_MODULE, |
1133 | } | 1133 | } |
1134 | }; | 1134 | }, { |
1135 | |||
1136 | static struct shash_alg wp384 = { | ||
1137 | .digestsize = WP384_DIGEST_SIZE, | 1135 | .digestsize = WP384_DIGEST_SIZE, |
1138 | .init = wp512_init, | 1136 | .init = wp512_init, |
1139 | .update = wp512_update, | 1137 | .update = wp512_update, |
@@ -1145,9 +1143,7 @@ static struct shash_alg wp384 = { | |||
1145 | .cra_blocksize = WP512_BLOCK_SIZE, | 1143 | .cra_blocksize = WP512_BLOCK_SIZE, |
1146 | .cra_module = THIS_MODULE, | 1144 | .cra_module = THIS_MODULE, |
1147 | } | 1145 | } |
1148 | }; | 1146 | }, { |
1149 | |||
1150 | static struct shash_alg wp256 = { | ||
1151 | .digestsize = WP256_DIGEST_SIZE, | 1147 | .digestsize = WP256_DIGEST_SIZE, |
1152 | .init = wp512_init, | 1148 | .init = wp512_init, |
1153 | .update = wp512_update, | 1149 | .update = wp512_update, |
@@ -1159,39 +1155,16 @@ static struct shash_alg wp256 = { | |||
1159 | .cra_blocksize = WP512_BLOCK_SIZE, | 1155 | .cra_blocksize = WP512_BLOCK_SIZE, |
1160 | .cra_module = THIS_MODULE, | 1156 | .cra_module = THIS_MODULE, |
1161 | } | 1157 | } |
1162 | }; | 1158 | } }; |
1163 | 1159 | ||
1164 | static int __init wp512_mod_init(void) | 1160 | static int __init wp512_mod_init(void) |
1165 | { | 1161 | { |
1166 | int ret = 0; | 1162 | return crypto_register_shashes(wp_algs, ARRAY_SIZE(wp_algs)); |
1167 | |||
1168 | ret = crypto_register_shash(&wp512); | ||
1169 | |||
1170 | if (ret < 0) | ||
1171 | goto out; | ||
1172 | |||
1173 | ret = crypto_register_shash(&wp384); | ||
1174 | if (ret < 0) | ||
1175 | { | ||
1176 | crypto_unregister_shash(&wp512); | ||
1177 | goto out; | ||
1178 | } | ||
1179 | |||
1180 | ret = crypto_register_shash(&wp256); | ||
1181 | if (ret < 0) | ||
1182 | { | ||
1183 | crypto_unregister_shash(&wp512); | ||
1184 | crypto_unregister_shash(&wp384); | ||
1185 | } | ||
1186 | out: | ||
1187 | return ret; | ||
1188 | } | 1163 | } |
1189 | 1164 | ||
1190 | static void __exit wp512_mod_fini(void) | 1165 | static void __exit wp512_mod_fini(void) |
1191 | { | 1166 | { |
1192 | crypto_unregister_shash(&wp512); | 1167 | crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs)); |
1193 | crypto_unregister_shash(&wp384); | ||
1194 | crypto_unregister_shash(&wp256); | ||
1195 | } | 1168 | } |
1196 | 1169 | ||
1197 | MODULE_ALIAS("wp384"); | 1170 | MODULE_ALIAS("wp384"); |