aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/algapi.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index f21ae672e8a8..f3946baf0c07 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -55,6 +55,34 @@ struct scatter_walk {
55 unsigned int offset; 55 unsigned int offset;
56}; 56};
57 57
58struct blkcipher_walk {
59 union {
60 struct {
61 struct page *page;
62 unsigned long offset;
63 } phys;
64
65 struct {
66 u8 *page;
67 u8 *addr;
68 } virt;
69 } src, dst;
70
71 struct scatter_walk in;
72 unsigned int nbytes;
73
74 struct scatter_walk out;
75 unsigned int total;
76
77 void *page;
78 u8 *buffer;
79 u8 *iv;
80
81 int flags;
82};
83
84extern const struct crypto_type crypto_blkcipher_type;
85
58int crypto_register_template(struct crypto_template *tmpl); 86int crypto_register_template(struct crypto_template *tmpl);
59void crypto_unregister_template(struct crypto_template *tmpl); 87void crypto_unregister_template(struct crypto_template *tmpl);
60struct crypto_template *crypto_lookup_template(const char *name); 88struct crypto_template *crypto_lookup_template(const char *name);
@@ -69,15 +97,52 @@ struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
69struct crypto_instance *crypto_alloc_instance(const char *name, 97struct crypto_instance *crypto_alloc_instance(const char *name,
70 struct crypto_alg *alg); 98 struct crypto_alg *alg);
71 99
100int blkcipher_walk_done(struct blkcipher_desc *desc,
101 struct blkcipher_walk *walk, int err);
102int blkcipher_walk_virt(struct blkcipher_desc *desc,
103 struct blkcipher_walk *walk);
104int blkcipher_walk_phys(struct blkcipher_desc *desc,
105 struct blkcipher_walk *walk);
106
107static inline void *crypto_tfm_ctx_aligned(struct crypto_tfm *tfm)
108{
109 unsigned long addr = (unsigned long)crypto_tfm_ctx(tfm);
110 unsigned long align = crypto_tfm_alg_alignmask(tfm);
111
112 if (align <= crypto_tfm_ctx_alignment())
113 align = 1;
114 return (void *)ALIGN(addr, align);
115}
116
72static inline void *crypto_instance_ctx(struct crypto_instance *inst) 117static inline void *crypto_instance_ctx(struct crypto_instance *inst)
73{ 118{
74 return inst->__ctx; 119 return inst->__ctx;
75} 120}
76 121
122static inline void *crypto_blkcipher_ctx(struct crypto_blkcipher *tfm)
123{
124 return crypto_tfm_ctx(&tfm->base);
125}
126
127static inline void *crypto_blkcipher_ctx_aligned(struct crypto_blkcipher *tfm)
128{
129 return crypto_tfm_ctx_aligned(&tfm->base);
130}
131
77static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm) 132static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
78{ 133{
79 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher; 134 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
80} 135}
81 136
137static inline void blkcipher_walk_init(struct blkcipher_walk *walk,
138 struct scatterlist *dst,
139 struct scatterlist *src,
140 unsigned int nbytes)
141{
142 walk->in.sg = src;
143 walk->out.sg = dst;
144 walk->total = nbytes;
145}
146
82#endif /* _CRYPTO_ALGAPI_H */ 147#endif /* _CRYPTO_ALGAPI_H */
83 148