diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-12-16 18:05:58 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-02-06 17:21:01 -0500 |
commit | 2e306ee016fd4750289e65c3b1856db569f1f3f2 (patch) | |
tree | 53ace6081967c640f052d53397250657af855c25 /crypto/algapi.c | |
parent | f1ddcaf3393b7a3871809b97fae90fac841a1f39 (diff) |
[CRYPTO] api: Add type-safe spawns
This patch allows spawns of specific types (e.g., cipher) to be allocated.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r-- | crypto/algapi.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 69eb504721a..0f1abca1b98 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn) | |||
377 | } | 377 | } |
378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); | 378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); |
379 | 379 | ||
380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | 380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, |
381 | u32 mask) | ||
381 | { | 382 | { |
382 | struct crypto_alg *alg; | 383 | struct crypto_alg *alg; |
383 | struct crypto_alg *alg2; | 384 | struct crypto_alg *alg2; |
@@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | |||
396 | return ERR_PTR(-EAGAIN); | 397 | return ERR_PTR(-EAGAIN); |
397 | } | 398 | } |
398 | 399 | ||
400 | tfm = ERR_PTR(-EINVAL); | ||
401 | if (unlikely((alg->cra_flags ^ type) & mask)) | ||
402 | goto out_put_alg; | ||
403 | |||
399 | tfm = __crypto_alloc_tfm(alg); | 404 | tfm = __crypto_alloc_tfm(alg); |
400 | if (IS_ERR(tfm)) | 405 | if (IS_ERR(tfm)) |
401 | crypto_mod_put(alg); | 406 | goto out_put_alg; |
407 | |||
408 | return tfm; | ||
402 | 409 | ||
410 | out_put_alg: | ||
411 | crypto_mod_put(alg); | ||
403 | return tfm; | 412 | return tfm; |
404 | } | 413 | } |
405 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); | 414 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); |