16 #include <linux/kernel.h>
17 #include <linux/module.h>
19 #include <linux/slab.h>
33 crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
35 err = crypto_cipher_setkey(child, key, keylen);
36 crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
46 int bsize = crypto_cipher_blocksize(tfm);
52 while ((nbytes = walk->
nbytes)) {
57 fn(crypto_cipher_tfm(tfm), wdst, wsrc);
61 }
while ((nbytes -= bsize) >= bsize);
78 blkcipher_walk_init(&walk, dst, src, nbytes);
79 return crypto_ecb_crypt(desc, &walk, child,
80 crypto_cipher_alg(child)->cia_encrypt);
92 blkcipher_walk_init(&walk, dst, src, nbytes);
93 return crypto_ecb_crypt(desc, &walk, child,
94 crypto_cipher_alg(child)->cia_decrypt);
97 static int crypto_ecb_init_tfm(
struct crypto_tfm *tfm)
104 cipher = crypto_spawn_cipher(spawn);
106 return PTR_ERR(cipher);
112 static void crypto_ecb_exit_tfm(
struct crypto_tfm *tfm)
115 crypto_free_cipher(ctx->
child);
131 return ERR_CAST(alg);
143 inst->
alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
144 inst->
alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize;
148 inst->
alg.cra_init = crypto_ecb_init_tfm;
149 inst->
alg.cra_exit = crypto_ecb_exit_tfm;
151 inst->
alg.cra_blkcipher.setkey = crypto_ecb_setkey;
152 inst->
alg.cra_blkcipher.encrypt = crypto_ecb_encrypt;
153 inst->
alg.cra_blkcipher.decrypt = crypto_ecb_decrypt;
168 .alloc = crypto_ecb_alloc,
169 .free = crypto_ecb_free,
173 static int __init crypto_ecb_module_init(
void)
178 static void __exit crypto_ecb_module_exit(
void)