Commit d35d2454ce2175be77d2a366c2648597fd33a98f
1 parent
3751f402e0
Exists in
master
and in
4 other branches
crypto: null - Switch to shash
This patch changes digest_null to the new shash interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 2 changed files with 42 additions and 23 deletions Side-by-side Diff
crypto/Kconfig
crypto/crypto_null.c
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | * |
18 | 18 | */ |
19 | 19 | |
20 | +#include <crypto/internal/hash.h> | |
20 | 21 | #include <crypto/internal/skcipher.h> |
21 | 22 | #include <linux/init.h> |
22 | 23 | #include <linux/module.h> |
23 | 24 | |
24 | 25 | |
25 | 26 | |
... | ... | @@ -38,16 +39,32 @@ |
38 | 39 | return 0; |
39 | 40 | } |
40 | 41 | |
41 | -static void null_init(struct crypto_tfm *tfm) | |
42 | -{ } | |
42 | +static int null_init(struct shash_desc *desc) | |
43 | +{ | |
44 | + return 0; | |
45 | +} | |
43 | 46 | |
44 | -static void null_update(struct crypto_tfm *tfm, const u8 *data, | |
45 | - unsigned int len) | |
46 | -{ } | |
47 | +static int null_update(struct shash_desc *desc, const u8 *data, | |
48 | + unsigned int len) | |
49 | +{ | |
50 | + return 0; | |
51 | +} | |
47 | 52 | |
48 | -static void null_final(struct crypto_tfm *tfm, u8 *out) | |
49 | -{ } | |
53 | +static int null_final(struct shash_desc *desc, u8 *out) | |
54 | +{ | |
55 | + return 0; | |
56 | +} | |
50 | 57 | |
58 | +static int null_digest(struct shash_desc *desc, const u8 *data, | |
59 | + unsigned int len, u8 *out) | |
60 | +{ | |
61 | + return 0; | |
62 | +} | |
63 | + | |
64 | +static int null_hash_setkey(struct crypto_shash *tfm, const u8 *key, | |
65 | + unsigned int keylen) | |
66 | +{ return 0; } | |
67 | + | |
51 | 68 | static int null_setkey(struct crypto_tfm *tfm, const u8 *key, |
52 | 69 | unsigned int keylen) |
53 | 70 | { return 0; } |
... | ... | @@ -89,19 +106,20 @@ |
89 | 106 | .coa_decompress = null_compress } } |
90 | 107 | }; |
91 | 108 | |
92 | -static struct crypto_alg digest_null = { | |
93 | - .cra_name = "digest_null", | |
94 | - .cra_flags = CRYPTO_ALG_TYPE_DIGEST, | |
95 | - .cra_blocksize = NULL_BLOCK_SIZE, | |
96 | - .cra_ctxsize = 0, | |
97 | - .cra_module = THIS_MODULE, | |
98 | - .cra_list = LIST_HEAD_INIT(digest_null.cra_list), | |
99 | - .cra_u = { .digest = { | |
100 | - .dia_digestsize = NULL_DIGEST_SIZE, | |
101 | - .dia_setkey = null_setkey, | |
102 | - .dia_init = null_init, | |
103 | - .dia_update = null_update, | |
104 | - .dia_final = null_final } } | |
109 | +static struct shash_alg digest_null = { | |
110 | + .digestsize = NULL_DIGEST_SIZE, | |
111 | + .setkey = null_hash_setkey, | |
112 | + .init = null_init, | |
113 | + .update = null_update, | |
114 | + .finup = null_digest, | |
115 | + .digest = null_digest, | |
116 | + .final = null_final, | |
117 | + .base = { | |
118 | + .cra_name = "digest_null", | |
119 | + .cra_flags = CRYPTO_ALG_TYPE_SHASH, | |
120 | + .cra_blocksize = NULL_BLOCK_SIZE, | |
121 | + .cra_module = THIS_MODULE, | |
122 | + } | |
105 | 123 | }; |
106 | 124 | |
107 | 125 | static struct crypto_alg cipher_null = { |
... | ... | @@ -154,7 +172,7 @@ |
154 | 172 | if (ret < 0) |
155 | 173 | goto out_unregister_cipher; |
156 | 174 | |
157 | - ret = crypto_register_alg(&digest_null); | |
175 | + ret = crypto_register_shash(&digest_null); | |
158 | 176 | if (ret < 0) |
159 | 177 | goto out_unregister_skcipher; |
160 | 178 | |
... | ... | @@ -166,7 +184,7 @@ |
166 | 184 | return ret; |
167 | 185 | |
168 | 186 | out_unregister_digest: |
169 | - crypto_unregister_alg(&digest_null); | |
187 | + crypto_unregister_shash(&digest_null); | |
170 | 188 | out_unregister_skcipher: |
171 | 189 | crypto_unregister_alg(&skcipher_null); |
172 | 190 | out_unregister_cipher: |
... | ... | @@ -177,7 +195,7 @@ |
177 | 195 | static void __exit crypto_null_mod_fini(void) |
178 | 196 | { |
179 | 197 | crypto_unregister_alg(&compress_null); |
180 | - crypto_unregister_alg(&digest_null); | |
198 | + crypto_unregister_shash(&digest_null); | |
181 | 199 | crypto_unregister_alg(&skcipher_null); |
182 | 200 | crypto_unregister_alg(&cipher_null); |
183 | 201 | } |