diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:39:29 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:39:29 -0400 |
commit | 6bfd48096ff8ecabf955958b51ddfa7988eb0a14 (patch) | |
tree | 813799f00d8402348ba6817953b1c631541be66c /crypto/cryptomgr.c | |
parent | 492e2b63eb10c28f4f0b694264d74a8755cd1be0 (diff) |
[CRYPTO] api: Added spawns
Spawns lock a specific crypto algorithm in place. They can then be used
with crypto_spawn_tfm to allocate a tfm for that algorithm. When the base
algorithm of a spawn is deregistered, all its spawns will be automatically
removed.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto/cryptomgr.c')
-rw-r--r-- | crypto/cryptomgr.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c index ae54942e3b31..9b5b15601068 100644 --- a/crypto/cryptomgr.c +++ b/crypto/cryptomgr.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/notifier.h> | 18 | #include <linux/notifier.h> |
19 | #include <linux/rtnetlink.h> | 19 | #include <linux/rtnetlink.h> |
20 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 21 | #include <linux/string.h> |
21 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
22 | 23 | ||
@@ -44,21 +45,25 @@ static void cryptomgr_probe(void *data) | |||
44 | struct cryptomgr_param *param = data; | 45 | struct cryptomgr_param *param = data; |
45 | struct crypto_template *tmpl; | 46 | struct crypto_template *tmpl; |
46 | struct crypto_instance *inst; | 47 | struct crypto_instance *inst; |
48 | int err; | ||
47 | 49 | ||
48 | tmpl = crypto_lookup_template(param->template); | 50 | tmpl = crypto_lookup_template(param->template); |
49 | if (!tmpl) | 51 | if (!tmpl) |
50 | goto err; | 52 | goto err; |
51 | 53 | ||
52 | inst = tmpl->alloc(¶m->alg, sizeof(param->alg)); | 54 | do { |
53 | if (IS_ERR(inst)) | 55 | inst = tmpl->alloc(¶m->alg, sizeof(param->alg)); |
54 | goto err; | 56 | if (IS_ERR(inst)) |
55 | else if ((err = crypto_register_instance(tmpl, inst))) { | 57 | err = PTR_ERR(inst); |
56 | tmpl->free(inst); | 58 | else if ((err = crypto_register_instance(tmpl, inst))) |
57 | goto err; | 59 | tmpl->free(inst); |
58 | } | 60 | } while (err == -EAGAIN && !signal_pending(current)); |
59 | 61 | ||
60 | crypto_tmpl_put(tmpl); | 62 | crypto_tmpl_put(tmpl); |
61 | 63 | ||
64 | if (err) | ||
65 | goto err; | ||
66 | |||
62 | out: | 67 | out: |
63 | kfree(param); | 68 | kfree(param); |
64 | return; | 69 | return; |