Skip to content

Commit 4f7f1d7

Browse files
Ard Biesheuvelherbertx
authored andcommitted
crypto: allow blkcipher walks over AEAD data
This adds the function blkcipher_aead_walk_virt_block, which allows the caller to use the blkcipher walk API to handle the input and output scatterlists. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 822be00 commit 4f7f1d7

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎crypto/blkcipher.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,20 @@ int blkcipher_walk_virt_block(struct blkcipher_desc *desc,
357357
}
358358
EXPORT_SYMBOL_GPL(blkcipher_walk_virt_block);
359359

360+
int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc,
361+
struct blkcipher_walk *walk,
362+
struct crypto_aead *tfm,
363+
unsigned int blocksize)
364+
{
365+
walk->flags &= ~BLKCIPHER_WALK_PHYS;
366+
walk->walk_blocksize = blocksize;
367+
walk->cipher_blocksize = crypto_aead_blocksize(tfm);
368+
walk->ivsize = crypto_aead_ivsize(tfm);
369+
walk->alignmask = crypto_aead_alignmask(tfm);
370+
return blkcipher_walk_first(desc, walk);
371+
}
372+
EXPORT_SYMBOL_GPL(blkcipher_aead_walk_virt_block);
373+
360374
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key,
361375
unsigned int keylen)
362376
{

‎include/crypto/algapi.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ int blkcipher_walk_phys(struct blkcipher_desc *desc,
195195
int blkcipher_walk_virt_block(struct blkcipher_desc *desc,
196196
struct blkcipher_walk *walk,
197197
unsigned int blocksize);
198+
int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc,
199+
struct blkcipher_walk *walk,
200+
struct crypto_aead *tfm,
201+
unsigned int blocksize);
198202

199203
int ablkcipher_walk_done(struct ablkcipher_request *req,
200204
struct ablkcipher_walk *walk, int err);

0 commit comments

Comments
 (0)