aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/ahash.c27
-rw-r--r--crypto/shash.c2
-rw-r--r--include/crypto/hash.h3
-rw-r--r--include/crypto/internal/hash.h6
-rw-r--r--include/linux/crypto.h16
5 files changed, 1 insertions, 53 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 7f599d26086a..cc824ef25830 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -175,46 +175,19 @@ static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
175 return -ENOSYS; 175 return -ENOSYS;
176} 176}
177 177
178static int crypto_init_ahash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
179{
180 struct old_ahash_alg *alg = &tfm->__crt_alg->cra_ahash;
181 struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
182 struct ahash_alg *nalg = crypto_ahash_alg(crt);
183
184 if (alg->digestsize > PAGE_SIZE / 8)
185 return -EINVAL;
186
187 crt->init = alg->init;
188 crt->update = alg->update;
189 crt->final = alg->final;
190 crt->digest = alg->digest;
191 crt->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
192 crt->digestsize = alg->digestsize;
193
194 nalg->setkey = alg->setkey;
195 nalg->halg.digestsize = alg->digestsize;
196
197 return 0;
198}
199
200static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) 178static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
201{ 179{
202 struct crypto_ahash *hash = __crypto_ahash_cast(tfm); 180 struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
203 struct ahash_alg *alg = crypto_ahash_alg(hash); 181 struct ahash_alg *alg = crypto_ahash_alg(hash);
204 struct old_ahash_alg *oalg = crypto_old_ahash_alg(hash);
205 182
206 if (tfm->__crt_alg->cra_type != &crypto_ahash_type) 183 if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
207 return crypto_init_shash_ops_async(tfm); 184 return crypto_init_shash_ops_async(tfm);
208 185
209 if (oalg->init)
210 return crypto_init_ahash_ops(tfm, 0, 0);
211
212 hash->init = alg->init; 186 hash->init = alg->init;
213 hash->update = alg->update; 187 hash->update = alg->update;
214 hash->final = alg->final; 188 hash->final = alg->final;
215 hash->digest = alg->digest; 189 hash->digest = alg->digest;
216 hash->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey; 190 hash->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
217 hash->digestsize = alg->halg.digestsize;
218 191
219 return 0; 192 return 0;
220} 193}
diff --git a/crypto/shash.c b/crypto/shash.c
index 615a5f4d9b7a..fd92c03b38fc 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -270,7 +270,6 @@ static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
270int crypto_init_shash_ops_async(struct crypto_tfm *tfm) 270int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
271{ 271{
272 struct crypto_alg *calg = tfm->__crt_alg; 272 struct crypto_alg *calg = tfm->__crt_alg;
273 struct shash_alg *alg = __crypto_shash_alg(calg);
274 struct crypto_ahash *crt = __crypto_ahash_cast(tfm); 273 struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
275 struct crypto_shash **ctx = crypto_tfm_ctx(tfm); 274 struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
276 struct crypto_shash *shash; 275 struct crypto_shash *shash;
@@ -293,7 +292,6 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
293 crt->digest = shash_async_digest; 292 crt->digest = shash_async_digest;
294 crt->setkey = shash_async_setkey; 293 crt->setkey = shash_async_setkey;
295 294
296 crt->digestsize = alg->digestsize;
297 crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash); 295 crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
298 296
299 return 0; 297 return 0;
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 262861d8f0cb..45c2bddfdf32 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -89,7 +89,6 @@ struct crypto_ahash {
89 int (*setkey)(struct crypto_ahash *tfm, const u8 *key, 89 int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
90 unsigned int keylen); 90 unsigned int keylen);
91 91
92 unsigned int digestsize;
93 unsigned int reqsize; 92 unsigned int reqsize;
94 struct crypto_tfm base; 93 struct crypto_tfm base;
95}; 94};
@@ -137,7 +136,7 @@ static inline struct hash_alg_common *crypto_hash_alg_common(
137 136
138static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm) 137static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm)
139{ 138{
140 return tfm->digestsize; 139 return crypto_hash_alg_common(tfm)->digestsize;
141} 140}
142 141
143static inline unsigned int crypto_ahash_statesize(struct crypto_ahash *tfm) 142static inline unsigned int crypto_ahash_statesize(struct crypto_ahash *tfm)
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index e3a82514d61e..179dd8fdfa14 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -109,12 +109,6 @@ static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg)
109 halg); 109 halg);
110} 110}
111 111
112static inline struct old_ahash_alg *crypto_old_ahash_alg(
113 struct crypto_ahash *tfm)
114{
115 return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
116}
117
118static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm, 112static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm,
119 unsigned int reqsize) 113 unsigned int reqsize)
120{ 114{
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 9e7e9b62a3dc..fd929889e8dc 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -115,12 +115,10 @@ struct crypto_async_request;
115struct crypto_aead; 115struct crypto_aead;
116struct crypto_blkcipher; 116struct crypto_blkcipher;
117struct crypto_hash; 117struct crypto_hash;
118struct crypto_ahash;
119struct crypto_rng; 118struct crypto_rng;
120struct crypto_tfm; 119struct crypto_tfm;
121struct crypto_type; 120struct crypto_type;
122struct aead_givcrypt_request; 121struct aead_givcrypt_request;
123struct ahash_request;
124struct skcipher_givcrypt_request; 122struct skcipher_givcrypt_request;
125 123
126typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); 124typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
@@ -211,18 +209,6 @@ struct ablkcipher_alg {
211 unsigned int ivsize; 209 unsigned int ivsize;
212}; 210};
213 211
214struct old_ahash_alg {
215 int (*init)(struct ahash_request *req);
216 int (*reinit)(struct ahash_request *req);
217 int (*update)(struct ahash_request *req);
218 int (*final)(struct ahash_request *req);
219 int (*digest)(struct ahash_request *req);
220 int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
221 unsigned int keylen);
222
223 unsigned int digestsize;
224};
225
226struct aead_alg { 212struct aead_alg {
227 int (*setkey)(struct crypto_aead *tfm, const u8 *key, 213 int (*setkey)(struct crypto_aead *tfm, const u8 *key,
228 unsigned int keylen); 214 unsigned int keylen);
@@ -309,7 +295,6 @@ struct rng_alg {
309#define cra_cipher cra_u.cipher 295#define cra_cipher cra_u.cipher
310#define cra_digest cra_u.digest 296#define cra_digest cra_u.digest
311#define cra_hash cra_u.hash 297#define cra_hash cra_u.hash
312#define cra_ahash cra_u.ahash
313#define cra_compress cra_u.compress 298#define cra_compress cra_u.compress
314#define cra_rng cra_u.rng 299#define cra_rng cra_u.rng
315 300
@@ -337,7 +322,6 @@ struct crypto_alg {
337 struct cipher_alg cipher; 322 struct cipher_alg cipher;
338 struct digest_alg digest; 323 struct digest_alg digest;
339 struct hash_alg hash; 324 struct hash_alg hash;
340 struct old_ahash_alg ahash;
341 struct compress_alg compress; 325 struct compress_alg compress;
342 struct rng_alg rng; 326 struct rng_alg rng;
343 } cra_u; 327 } cra_u;