diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/algapi.c | 2 | ||||
-rw-r--r-- | crypto/api.c | 25 | ||||
-rw-r--r-- | crypto/blkcipher.c | 5 | ||||
-rw-r--r-- | crypto/hash.c | 5 | ||||
-rw-r--r-- | crypto/internal.h | 3 |
5 files changed, 22 insertions, 18 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 0f1abca1b98c..f7d2185b2c8f 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -401,7 +401,7 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, | |||
401 | if (unlikely((alg->cra_flags ^ type) & mask)) | 401 | if (unlikely((alg->cra_flags ^ type) & mask)) |
402 | goto out_put_alg; | 402 | goto out_put_alg; |
403 | 403 | ||
404 | tfm = __crypto_alloc_tfm(alg); | 404 | tfm = __crypto_alloc_tfm(alg, type, mask); |
405 | if (IS_ERR(tfm)) | 405 | if (IS_ERR(tfm)) |
406 | goto out_put_alg; | 406 | goto out_put_alg; |
407 | 407 | ||
diff --git a/crypto/api.c b/crypto/api.c index 8b80baec853a..55af8bb0f050 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -212,12 +212,12 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask) | |||
212 | } | 212 | } |
213 | EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup); | 213 | EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup); |
214 | 214 | ||
215 | static int crypto_init_ops(struct crypto_tfm *tfm) | 215 | static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask) |
216 | { | 216 | { |
217 | const struct crypto_type *type = tfm->__crt_alg->cra_type; | 217 | const struct crypto_type *type_obj = tfm->__crt_alg->cra_type; |
218 | 218 | ||
219 | if (type) | 219 | if (type_obj) |
220 | return type->init(tfm); | 220 | return type_obj->init(tfm, type, mask); |
221 | 221 | ||
222 | switch (crypto_tfm_alg_type(tfm)) { | 222 | switch (crypto_tfm_alg_type(tfm)) { |
223 | case CRYPTO_ALG_TYPE_CIPHER: | 223 | case CRYPTO_ALG_TYPE_CIPHER: |
@@ -266,14 +266,14 @@ static void crypto_exit_ops(struct crypto_tfm *tfm) | |||
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | static unsigned int crypto_ctxsize(struct crypto_alg *alg) | 269 | static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask) |
270 | { | 270 | { |
271 | const struct crypto_type *type = alg->cra_type; | 271 | const struct crypto_type *type_obj = alg->cra_type; |
272 | unsigned int len; | 272 | unsigned int len; |
273 | 273 | ||
274 | len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); | 274 | len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); |
275 | if (type) | 275 | if (type_obj) |
276 | return len + type->ctxsize(alg); | 276 | return len + type_obj->ctxsize(alg, type, mask); |
277 | 277 | ||
278 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { | 278 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { |
279 | default: | 279 | default: |
@@ -303,20 +303,21 @@ void crypto_shoot_alg(struct crypto_alg *alg) | |||
303 | } | 303 | } |
304 | EXPORT_SYMBOL_GPL(crypto_shoot_alg); | 304 | EXPORT_SYMBOL_GPL(crypto_shoot_alg); |
305 | 305 | ||
306 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg) | 306 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
307 | u32 mask) | ||
307 | { | 308 | { |
308 | struct crypto_tfm *tfm = NULL; | 309 | struct crypto_tfm *tfm = NULL; |
309 | unsigned int tfm_size; | 310 | unsigned int tfm_size; |
310 | int err = -ENOMEM; | 311 | int err = -ENOMEM; |
311 | 312 | ||
312 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg); | 313 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask); |
313 | tfm = kzalloc(tfm_size, GFP_KERNEL); | 314 | tfm = kzalloc(tfm_size, GFP_KERNEL); |
314 | if (tfm == NULL) | 315 | if (tfm == NULL) |
315 | goto out_err; | 316 | goto out_err; |
316 | 317 | ||
317 | tfm->__crt_alg = alg; | 318 | tfm->__crt_alg = alg; |
318 | 319 | ||
319 | err = crypto_init_ops(tfm); | 320 | err = crypto_init_ops(tfm, type, mask); |
320 | if (err) | 321 | if (err) |
321 | goto out_free_tfm; | 322 | goto out_free_tfm; |
322 | 323 | ||
@@ -372,7 +373,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask) | |||
372 | goto err; | 373 | goto err; |
373 | } | 374 | } |
374 | 375 | ||
375 | tfm = __crypto_alloc_tfm(alg); | 376 | tfm = __crypto_alloc_tfm(alg, type, mask); |
376 | if (!IS_ERR(tfm)) | 377 | if (!IS_ERR(tfm)) |
377 | return tfm; | 378 | return tfm; |
378 | 379 | ||
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index cbb4c4e5c229..b5befe8c3a96 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -349,7 +349,8 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, | |||
349 | return cipher->setkey(tfm, key, keylen); | 349 | return cipher->setkey(tfm, key, keylen); |
350 | } | 350 | } |
351 | 351 | ||
352 | static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg) | 352 | static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type, |
353 | u32 mask) | ||
353 | { | 354 | { |
354 | struct blkcipher_alg *cipher = &alg->cra_blkcipher; | 355 | struct blkcipher_alg *cipher = &alg->cra_blkcipher; |
355 | unsigned int len = alg->cra_ctxsize; | 356 | unsigned int len = alg->cra_ctxsize; |
@@ -362,7 +363,7 @@ static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg) | |||
362 | return len; | 363 | return len; |
363 | } | 364 | } |
364 | 365 | ||
365 | static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm) | 366 | static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask) |
366 | { | 367 | { |
367 | struct blkcipher_tfm *crt = &tfm->crt_blkcipher; | 368 | struct blkcipher_tfm *crt = &tfm->crt_blkcipher; |
368 | struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher; | 369 | struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher; |
diff --git a/crypto/hash.c b/crypto/hash.c index cdec23d885fe..12c4514f3478 100644 --- a/crypto/hash.c +++ b/crypto/hash.c | |||
@@ -16,12 +16,13 @@ | |||
16 | 16 | ||
17 | #include "internal.h" | 17 | #include "internal.h" |
18 | 18 | ||
19 | static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg) | 19 | static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg, u32 type, |
20 | u32 mask) | ||
20 | { | 21 | { |
21 | return alg->cra_ctxsize; | 22 | return alg->cra_ctxsize; |
22 | } | 23 | } |
23 | 24 | ||
24 | static int crypto_init_hash_ops(struct crypto_tfm *tfm) | 25 | static int crypto_init_hash_ops(struct crypto_tfm *tfm, u32 type, u32 mask) |
25 | { | 26 | { |
26 | struct hash_tfm *crt = &tfm->crt_hash; | 27 | struct hash_tfm *crt = &tfm->crt_hash; |
27 | struct hash_alg *alg = &tfm->__crt_alg->cra_hash; | 28 | struct hash_alg *alg = &tfm->__crt_alg->cra_hash; |
diff --git a/crypto/internal.h b/crypto/internal.h index 784a7745315f..60acad9788c5 100644 --- a/crypto/internal.h +++ b/crypto/internal.h | |||
@@ -120,7 +120,8 @@ void crypto_exit_compress_ops(struct crypto_tfm *tfm); | |||
120 | void crypto_larval_error(const char *name, u32 type, u32 mask); | 120 | void crypto_larval_error(const char *name, u32 type, u32 mask); |
121 | 121 | ||
122 | void crypto_shoot_alg(struct crypto_alg *alg); | 122 | void crypto_shoot_alg(struct crypto_alg *alg); |
123 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg); | 123 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
124 | u32 mask); | ||
124 | 125 | ||
125 | int crypto_register_instance(struct crypto_template *tmpl, | 126 | int crypto_register_instance(struct crypto_template *tmpl, |
126 | struct crypto_instance *inst); | 127 | struct crypto_instance *inst); |