aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/algapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/crypto/algapi.h')
-rw-r--r--include/crypto/algapi.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index d0c190b4d02f..469f511315c5 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -13,6 +13,8 @@
13#define _CRYPTO_ALGAPI_H 13#define _CRYPTO_ALGAPI_H
14 14
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/list.h>
17#include <linux/kernel.h>
16 18
17struct module; 19struct module;
18struct rtattr; 20struct rtattr;
@@ -51,6 +53,14 @@ struct crypto_spawn {
51 struct crypto_instance *inst; 53 struct crypto_instance *inst;
52}; 54};
53 55
56struct crypto_queue {
57 struct list_head list;
58 struct list_head *backlog;
59
60 unsigned int qlen;
61 unsigned int max_qlen;
62};
63
54struct scatter_walk { 64struct scatter_walk {
55 struct scatterlist *sg; 65 struct scatterlist *sg;
56 unsigned int offset; 66 unsigned int offset;
@@ -82,6 +92,7 @@ struct blkcipher_walk {
82 int flags; 92 int flags;
83}; 93};
84 94
95extern const struct crypto_type crypto_ablkcipher_type;
85extern const struct crypto_type crypto_blkcipher_type; 96extern const struct crypto_type crypto_blkcipher_type;
86extern const struct crypto_type crypto_hash_type; 97extern const struct crypto_type crypto_hash_type;
87 98
@@ -103,6 +114,12 @@ struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask);
103struct crypto_instance *crypto_alloc_instance(const char *name, 114struct crypto_instance *crypto_alloc_instance(const char *name,
104 struct crypto_alg *alg); 115 struct crypto_alg *alg);
105 116
117void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen);
118int crypto_enqueue_request(struct crypto_queue *queue,
119 struct crypto_async_request *request);
120struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
121int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm);
122
106int blkcipher_walk_done(struct blkcipher_desc *desc, 123int blkcipher_walk_done(struct blkcipher_desc *desc,
107 struct blkcipher_walk *walk, int err); 124 struct blkcipher_walk *walk, int err);
108int blkcipher_walk_virt(struct blkcipher_desc *desc, 125int blkcipher_walk_virt(struct blkcipher_desc *desc,
@@ -125,6 +142,17 @@ static inline void *crypto_instance_ctx(struct crypto_instance *inst)
125 return inst->__ctx; 142 return inst->__ctx;
126} 143}
127 144
145static inline struct ablkcipher_alg *crypto_ablkcipher_alg(
146 struct crypto_ablkcipher *tfm)
147{
148 return &crypto_ablkcipher_tfm(tfm)->__crt_alg->cra_ablkcipher;
149}
150
151static inline void *crypto_ablkcipher_ctx(struct crypto_ablkcipher *tfm)
152{
153 return crypto_tfm_ctx(&tfm->base);
154}
155
128static inline void *crypto_blkcipher_ctx(struct crypto_blkcipher *tfm) 156static inline void *crypto_blkcipher_ctx(struct crypto_blkcipher *tfm)
129{ 157{
130 return crypto_tfm_ctx(&tfm->base); 158 return crypto_tfm_ctx(&tfm->base);
@@ -172,5 +200,35 @@ static inline void blkcipher_walk_init(struct blkcipher_walk *walk,
172 walk->total = nbytes; 200 walk->total = nbytes;
173} 201}
174 202
203static inline struct crypto_async_request *crypto_get_backlog(
204 struct crypto_queue *queue)
205{
206 return queue->backlog == &queue->list ? NULL :
207 container_of(queue->backlog, struct crypto_async_request, list);
208}
209
210static inline int ablkcipher_enqueue_request(struct ablkcipher_alg *alg,
211 struct ablkcipher_request *request)
212{
213 return crypto_enqueue_request(alg->queue, &request->base);
214}
215
216static inline struct ablkcipher_request *ablkcipher_dequeue_request(
217 struct ablkcipher_alg *alg)
218{
219 return ablkcipher_request_cast(crypto_dequeue_request(alg->queue));
220}
221
222static inline void *ablkcipher_request_ctx(struct ablkcipher_request *req)
223{
224 return req->__ctx;
225}
226
227static inline int ablkcipher_tfm_in_queue(struct crypto_ablkcipher *tfm)
228{
229 return crypto_tfm_in_queue(crypto_ablkcipher_alg(tfm)->queue,
230 crypto_ablkcipher_tfm(tfm));
231}
232
175#endif /* _CRYPTO_ALGAPI_H */ 233#endif /* _CRYPTO_ALGAPI_H */
176 234