diff options
author | Stephan Mueller <smueller@chronox.de> | 2015-03-30 16:10:58 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-31 09:21:13 -0400 |
commit | f52bbf55d1957b9ab279998dd71ed1c89b36e3a7 (patch) | |
tree | 27db11a0a8fe9b7745d7667c9528201fa75a77b2 /crypto/mcryptd.c | |
parent | cd98411c36b596f5bd64e7e670c13252ad0852c7 (diff) |
crypto: mcryptd - process CRYPTO_ALG_INTERNAL
The mcryptd is used as a wrapper around internal ciphers. Therefore,
the mcryptd must process the internal cipher by marking mcryptd as
internal if the underlying cipher is an internal cipher.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/mcryptd.c')
-rw-r--r-- | crypto/mcryptd.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/crypto/mcryptd.c b/crypto/mcryptd.c index a8e870444ea9..fe5b495a434d 100644 --- a/crypto/mcryptd.c +++ b/crypto/mcryptd.c | |||
@@ -258,6 +258,20 @@ out_free_inst: | |||
258 | goto out; | 258 | goto out; |
259 | } | 259 | } |
260 | 260 | ||
261 | static inline void mcryptd_check_internal(struct rtattr **tb, u32 *type, | ||
262 | u32 *mask) | ||
263 | { | ||
264 | struct crypto_attr_type *algt; | ||
265 | |||
266 | algt = crypto_get_attr_type(tb); | ||
267 | if (IS_ERR(algt)) | ||
268 | return; | ||
269 | if ((algt->type & CRYPTO_ALG_INTERNAL)) | ||
270 | *type |= CRYPTO_ALG_INTERNAL; | ||
271 | if ((algt->mask & CRYPTO_ALG_INTERNAL)) | ||
272 | *mask |= CRYPTO_ALG_INTERNAL; | ||
273 | } | ||
274 | |||
261 | static int mcryptd_hash_init_tfm(struct crypto_tfm *tfm) | 275 | static int mcryptd_hash_init_tfm(struct crypto_tfm *tfm) |
262 | { | 276 | { |
263 | struct crypto_instance *inst = crypto_tfm_alg_instance(tfm); | 277 | struct crypto_instance *inst = crypto_tfm_alg_instance(tfm); |
@@ -480,9 +494,13 @@ static int mcryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, | |||
480 | struct ahash_instance *inst; | 494 | struct ahash_instance *inst; |
481 | struct shash_alg *salg; | 495 | struct shash_alg *salg; |
482 | struct crypto_alg *alg; | 496 | struct crypto_alg *alg; |
497 | u32 type = 0; | ||
498 | u32 mask = 0; | ||
483 | int err; | 499 | int err; |
484 | 500 | ||
485 | salg = shash_attr_alg(tb[1], 0, 0); | 501 | mcryptd_check_internal(tb, &type, &mask); |
502 | |||
503 | salg = shash_attr_alg(tb[1], type, mask); | ||
486 | if (IS_ERR(salg)) | 504 | if (IS_ERR(salg)) |
487 | return PTR_ERR(salg); | 505 | return PTR_ERR(salg); |
488 | 506 | ||
@@ -502,7 +520,10 @@ static int mcryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, | |||
502 | if (err) | 520 | if (err) |
503 | goto out_free_inst; | 521 | goto out_free_inst; |
504 | 522 | ||
505 | inst->alg.halg.base.cra_flags = CRYPTO_ALG_ASYNC; | 523 | type = CRYPTO_ALG_ASYNC; |
524 | if (alg->cra_flags & CRYPTO_ALG_INTERNAL) | ||
525 | type |= CRYPTO_ALG_INTERNAL; | ||
526 | inst->alg.halg.base.cra_flags = type; | ||
506 | 527 | ||
507 | inst->alg.halg.digestsize = salg->digestsize; | 528 | inst->alg.halg.digestsize = salg->digestsize; |
508 | inst->alg.halg.base.cra_ctxsize = sizeof(struct mcryptd_hash_ctx); | 529 | inst->alg.halg.base.cra_ctxsize = sizeof(struct mcryptd_hash_ctx); |