23 #include <linux/kernel.h>
25 #include <linux/module.h>
28 #include <linux/string.h>
48 crypto_ablkcipher_alignmask(geniv) + 1),
49 crypto_ablkcipher_ivsize(geniv));
59 eseqiv_complete2(req);
62 skcipher_givcrypt_complete(req, err);
86 ablkcipher_request_set_tfm(subreq, skcipher_geniv_cipher(geniv));
89 complete = req->
creq.base.complete;
90 data = req->
creq.base.data;
99 ivsize = crypto_ablkcipher_ivsize(geniv);
101 if (vsrc != giv + ivsize && vdst != giv + ivsize) {
103 crypto_ablkcipher_alignmask(geniv) + 1);
104 complete = eseqiv_complete;
108 ablkcipher_request_set_callback(subreq, req->
creq.base.flags, complete,
112 sg_set_buf(reqctx->
src, giv, ivsize);
113 scatterwalk_crypto_chain(reqctx->
src, osrc, vsrc == giv + ivsize, 2);
118 sg_set_buf(reqctx->
dst, giv, ivsize);
119 scatterwalk_crypto_chain(reqctx->
dst, odst, vdst == giv + ivsize, 2);
124 ablkcipher_request_set_crypt(subreq, reqctx->
src, dst,
125 req->
creq.nbytes + ivsize,
131 if (ivsize >
sizeof(
u64)) {
136 memcpy(req->
giv + ivsize - len, &seq, len);
138 err = crypto_ablkcipher_encrypt(subreq);
143 eseqiv_complete2(req);
152 struct eseqiv_ctx *ctx = crypto_ablkcipher_ctx(geniv);
155 spin_lock_bh(&ctx->
lock);
156 if (crypto_ablkcipher_crt(geniv)->givencrypt != eseqiv_givencrypt_first)
159 crypto_ablkcipher_crt(geniv)->givencrypt = eseqiv_givencrypt;
161 crypto_ablkcipher_ivsize(geniv));
164 spin_unlock_bh(&ctx->
lock);
169 return eseqiv_givencrypt(req);
172 static int eseqiv_init(
struct crypto_tfm *tfm)
175 struct eseqiv_ctx *ctx = crypto_ablkcipher_ctx(geniv);
176 unsigned long alignmask;
177 unsigned int reqsize;
181 alignmask = crypto_tfm_ctx_alignment() - 1;
184 if (alignmask & reqsize) {
185 alignmask &= reqsize;
189 alignmask = ~alignmask;
190 alignmask &= crypto_ablkcipher_alignmask(geniv);
192 reqsize += alignmask;
193 reqsize += crypto_ablkcipher_ivsize(geniv);
194 reqsize =
ALIGN(reqsize, crypto_tfm_ctx_alignment());
198 tfm->crt_ablkcipher.reqsize = reqsize +
220 if (inst->
alg.cra_ablkcipher.ivsize != inst->
alg.cra_blocksize)
223 inst->
alg.cra_ablkcipher.givencrypt = eseqiv_givencrypt_first;
225 inst->
alg.cra_init = eseqiv_init;
229 inst->
alg.cra_ctxsize += inst->
alg.cra_ablkcipher.ivsize;
250 .alloc = eseqiv_alloc,
255 static int __init eseqiv_module_init(
void)
260 static void __exit eseqiv_module_exit(
void)