#include <crypto/algapi.h>
#include <crypto/internal/skcipher.h>
#include <linux/kernel.h>
#include <linux/module.h>
static int crypto_ofb_crypt(struct skcipher_request *req)
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct crypto_cipher *cipher = skcipher_cipher_simple(tfm);
const unsigned int bsize = crypto_cipher_blocksize(cipher);
struct skcipher_walk walk;
err = skcipher_walk_virt(&walk, req, false);
while (walk.nbytes >= bsize) {
const u8 *src = walk.src.virt.addr;
u8 *dst = walk.dst.virt.addr;
unsigned int nbytes = walk.nbytes;
crypto_cipher_encrypt_one(cipher, iv, iv);
crypto_xor_cpy(dst, src, iv, bsize);
} while ((nbytes -= bsize) >= bsize);
err = skcipher_walk_done(&walk, nbytes);
crypto_cipher_encrypt_one(cipher, walk.iv, walk.iv);
crypto_xor_cpy(walk.dst.virt.addr, walk.src.virt.addr, walk.iv,
err = skcipher_walk_done(&walk, 0);
static int crypto_ofb_create(struct crypto_template *tmpl, struct rtattr **tb)
struct skcipher_instance *inst;
inst = skcipher_alloc_instance_simple(tmpl, tb, &alg);
inst->alg.base.cra_blocksize = 1;