1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _CRYPTO_AKCIPHER_INT_H
14#define _CRYPTO_AKCIPHER_INT_H
15#include <crypto/akcipher.h>
16#include <crypto/algapi.h>
17
18struct akcipher_instance {
19 void (*free)(struct akcipher_instance *inst);
20 union {
21 struct {
22 char head[offsetof(struct akcipher_alg, base)];
23 struct crypto_instance base;
24 } s;
25 struct akcipher_alg alg;
26 };
27};
28
29struct crypto_akcipher_spawn {
30 struct crypto_spawn base;
31};
32
33
34
35
36static inline void *akcipher_request_ctx(struct akcipher_request *req)
37{
38 return req->__ctx;
39}
40
41static inline void akcipher_set_reqsize(struct crypto_akcipher *akcipher,
42 unsigned int reqsize)
43{
44 crypto_akcipher_alg(akcipher)->reqsize = reqsize;
45}
46
47static inline void *akcipher_tfm_ctx(struct crypto_akcipher *tfm)
48{
49 return tfm->base.__crt_ctx;
50}
51
52static inline void akcipher_request_complete(struct akcipher_request *req,
53 int err)
54{
55 req->base.complete(&req->base, err);
56}
57
58static inline const char *akcipher_alg_name(struct crypto_akcipher *tfm)
59{
60 return crypto_akcipher_tfm(tfm)->__crt_alg->cra_name;
61}
62
63static inline struct crypto_instance *akcipher_crypto_instance(
64 struct akcipher_instance *inst)
65{
66 return container_of(&inst->alg.base, struct crypto_instance, alg);
67}
68
69static inline struct akcipher_instance *akcipher_instance(
70 struct crypto_instance *inst)
71{
72 return container_of(&inst->alg, struct akcipher_instance, alg.base);
73}
74
75static inline struct akcipher_instance *akcipher_alg_instance(
76 struct crypto_akcipher *akcipher)
77{
78 return akcipher_instance(crypto_tfm_alg_instance(&akcipher->base));
79}
80
81static inline void *akcipher_instance_ctx(struct akcipher_instance *inst)
82{
83 return crypto_instance_ctx(akcipher_crypto_instance(inst));
84}
85
86static inline void crypto_set_akcipher_spawn(
87 struct crypto_akcipher_spawn *spawn,
88 struct crypto_instance *inst)
89{
90 crypto_set_spawn(&spawn->base, inst);
91}
92
93int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn, const char *name,
94 u32 type, u32 mask);
95
96static inline struct crypto_akcipher *crypto_spawn_akcipher(
97 struct crypto_akcipher_spawn *spawn)
98{
99 return crypto_spawn_tfm2(&spawn->base);
100}
101
102static inline void crypto_drop_akcipher(struct crypto_akcipher_spawn *spawn)
103{
104 crypto_drop_spawn(&spawn->base);
105}
106
107static inline struct akcipher_alg *crypto_spawn_akcipher_alg(
108 struct crypto_akcipher_spawn *spawn)
109{
110 return container_of(spawn->base.alg, struct akcipher_alg, base);
111}
112
113
114
115
116
117
118
119
120
121
122int crypto_register_akcipher(struct akcipher_alg *alg);
123
124
125
126
127
128
129
130
131void crypto_unregister_akcipher(struct akcipher_alg *alg);
132
133
134
135
136
137
138
139
140
141
142int akcipher_register_instance(struct crypto_template *tmpl,
143 struct akcipher_instance *inst);
144#endif
145