28 #include <linux/module.h>
39 void *
ctx = crypto_blkcipher_ctx(desc->
tfm);
40 const unsigned int bsize = 128 / 8;
41 unsigned int nbytes,
i, func_bytes;
42 bool fpu_enabled =
false;
47 while ((nbytes = walk->
nbytes)) {
52 desc, fpu_enabled, nbytes);
55 func_bytes = bsize * gctx->
funcs[
i].num_blocks;
58 if (nbytes >= func_bytes) {
60 gctx->
funcs[
i].fn_u.ecb(ctx, wdst,
66 }
while (nbytes >= func_bytes);
77 glue_fpu_end(fpu_enabled);
87 blkcipher_walk_init(&walk, dst, src, nbytes);
88 return __glue_ecb_crypt_128bit(gctx, desc, &walk);
96 void *ctx = crypto_blkcipher_ctx(desc->
tfm);
97 const unsigned int bsize = 128 / 8;
98 unsigned int nbytes = walk->
nbytes;
104 u128_xor(
dst, src, iv);
111 }
while (nbytes >= bsize);
125 blkcipher_walk_init(&walk, dst, src, nbytes);
128 while ((nbytes = walk.
nbytes)) {
129 nbytes = __glue_cbc_encrypt_128bit(fn, desc, &walk);
142 void *ctx = crypto_blkcipher_ctx(desc->
tfm);
143 const unsigned int bsize = 128 / 8;
144 unsigned int nbytes = walk->
nbytes;
148 unsigned int num_blocks, func_bytes;
152 src += nbytes / bsize - 1;
153 dst += nbytes / bsize - 1;
158 num_blocks = gctx->
funcs[
i].num_blocks;
159 func_bytes = bsize * num_blocks;
162 if (nbytes >= func_bytes) {
164 nbytes -= func_bytes - bsize;
165 src -= num_blocks - 1;
166 dst -= num_blocks - 1;
174 u128_xor(
dst,
dst, src - 1);
177 }
while (nbytes >= func_bytes);
186 *(
u128 *)walk->
iv = last_iv;
196 const unsigned int bsize = 128 / 8;
197 bool fpu_enabled =
false;
201 blkcipher_walk_init(&walk, dst, src, nbytes);
204 while ((nbytes = walk.
nbytes)) {
206 desc, fpu_enabled, nbytes);
207 nbytes = __glue_cbc_decrypt_128bit(gctx, desc, &walk);
211 glue_fpu_end(fpu_enabled);
220 void *ctx = crypto_blkcipher_ctx(desc->
tfm);
223 unsigned int nbytes = walk->
nbytes;
227 be128_to_u128(&ctrblk, (
be128 *)walk->
iv);
229 memcpy(&tmp, src, nbytes);
230 fn_ctr(ctx, &tmp, &tmp, &ctrblk);
233 u128_to_be128((
be128 *)walk->
iv, &ctrblk);
237 static unsigned int __glue_ctr_crypt_128bit(
const struct common_glue_ctx *gctx,
241 const unsigned int bsize = 128 / 8;
242 void *ctx = crypto_blkcipher_ctx(desc->
tfm);
243 unsigned int nbytes = walk->
nbytes;
247 unsigned int num_blocks, func_bytes;
250 be128_to_u128(&ctrblk, (
be128 *)walk->
iv);
254 num_blocks = gctx->
funcs[
i].num_blocks;
255 func_bytes = bsize * num_blocks;
257 if (nbytes >= func_bytes) {
259 gctx->
funcs[
i].fn_u.ctr(ctx,
dst, src, &ctrblk);
263 nbytes -= func_bytes;
264 }
while (nbytes >= func_bytes);
272 u128_to_be128((
be128 *)walk->
iv, &ctrblk);
280 const unsigned int bsize = 128 / 8;
281 bool fpu_enabled =
false;
285 blkcipher_walk_init(&walk, dst, src, nbytes);
288 while ((nbytes = walk.
nbytes) >= bsize) {
290 desc, fpu_enabled, nbytes);
291 nbytes = __glue_ctr_crypt_128bit(gctx, desc, &walk);
295 glue_fpu_end(fpu_enabled);
298 glue_ctr_crypt_final_128bit(