23 #include <linux/kernel.h>
24 #include <linux/module.h>
26 #include <linux/slab.h>
37 static inline void setbit128_bbe(
void *
b,
int bit)
62 for (i = 0; i < 128; i++) {
63 setbit128_bbe(&tmp, i);
82 struct priv *
ctx = crypto_tfm_ctx(parent);
85 const u8 *tweak = key + keylen - bsize;
88 crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
90 err = crypto_cipher_setkey(child, key, keylen - bsize);
93 crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
107 be64_add_cpu(&iv->
b, 1);
109 be64_add_cpu(&iv->
a, 1);
112 static inline void lrw_round(
struct sinfo *
s,
void *
dst,
const void *
src)
114 be128_xor(dst, &s->
t, src);
115 s->
fn(s->
tfm, dst, dst);
116 be128_xor(dst, dst, &s->
t);
126 for (p += 3, x = 0; x < 128; p--, x += 32) {
146 .
tfm = crypto_cipher_tfm(ctx->
child),
173 be128_xor(&s.
t, &s.
t,
174 &ctx->
table.mulinc[get_index128(iv)]);
178 lrw_round(&s, wdst, wsrc);
182 }
while ((avail -= bs) >= bs);
198 struct priv *ctx = crypto_blkcipher_ctx(desc->
tfm);
201 blkcipher_walk_init(&w, dst, src, nbytes);
202 return crypt(desc, &w, ctx,
203 crypto_cipher_alg(ctx->
child)->cia_encrypt);
209 struct priv *ctx = crypto_blkcipher_ctx(desc->
tfm);
212 blkcipher_walk_init(&w, dst, src, nbytes);
213 return crypt(desc, &w, ctx,
214 crypto_cipher_alg(ctx->
child)->cia_decrypt);
222 const unsigned int max_blks = req->
tbuflen / bsize;
225 unsigned int nblocks;
232 blkcipher_walk_init(&walk, sdst, ssrc, nbytes);
239 nblocks =
min(walk.
nbytes / bsize, max_blks);
255 for (i = 0; i < nblocks; i++) {
258 be128_xor(&t_buf[i], t,
259 &ctx->
mulinc[get_index128(iv)]);
265 be128_xor(dst + i, t, src + i);
273 for (i = 0; i < nblocks; i++)
274 be128_xor(dst + i, dst + i, &t_buf[i]);
278 nbytes -= nblocks * bsize;
279 nblocks =
min(nbytes / bsize, max_blks);
280 }
while (nblocks > 0);
287 nblocks =
min(nbytes / bsize, max_blks);
301 struct priv *ctx = crypto_tfm_ctx(tfm);
304 cipher = crypto_spawn_cipher(spawn);
306 return PTR_ERR(cipher);
310 crypto_free_cipher(cipher);
320 struct priv *ctx = crypto_tfm_ctx(tfm);
323 crypto_free_cipher(ctx->
child);
339 return ERR_CAST(alg);
354 inst->
alg.cra_alignmask |= 3;
356 inst->
alg.cra_blkcipher.min_keysize =
358 inst->
alg.cra_blkcipher.max_keysize =
361 inst->
alg.cra_ctxsize =
sizeof(
struct priv);
363 inst->
alg.cra_init = init_tfm;
364 inst->
alg.cra_exit = exit_tfm;
368 inst->
alg.cra_blkcipher.decrypt = decrypt;
388 static int __init crypto_module_init(
void)
393 static void __exit crypto_module_exit(
void)