aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mpi/mpiutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mpi/mpiutil.c')
0 files changed, 0 insertions, 0 deletions
opt">}; static int crypto_ecb_setkey(struct crypto_tfm *parent, const u8 *key, unsigned int keylen) { struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(parent); struct crypto_cipher *child = ctx->child; int err; crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) & CRYPTO_TFM_REQ_MASK); err = crypto_cipher_setkey(child, key, keylen); crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) & CRYPTO_TFM_RES_MASK); return err; } static int crypto_ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk, struct crypto_cipher *tfm, void (*fn)(struct crypto_tfm *, u8 *, const u8 *)) { int bsize = crypto_cipher_blocksize(tfm); unsigned int nbytes; int err; err = blkcipher_walk_virt(desc, walk); while ((nbytes = walk->nbytes)) { u8 *wsrc = walk->src.virt.addr; u8 *wdst = walk->dst.virt.addr; do { fn(crypto_cipher_tfm(tfm), wdst, wsrc); wsrc += bsize; wdst += bsize; } while ((nbytes -= bsize) >= bsize); err = blkcipher_walk_done(desc, walk, nbytes); } return err; } static int crypto_ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct blkcipher_walk walk; struct crypto_blkcipher *tfm = desc->tfm; struct crypto_ecb_ctx *ctx = crypto_blkcipher_ctx(tfm); struct crypto_cipher *child = ctx->child; blkcipher_walk_init(&walk, dst, src, nbytes); return crypto_ecb_crypt(desc, &walk, child, crypto_cipher_alg(child)->cia_encrypt); }