crypto: allow blkcipher walks over AEAD data
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 4 Mar 2014 05:28:39 +0000 (13:28 +0800)
committerMark Brown <broonie@linaro.org>
Wed, 18 Jun 2014 19:21:14 +0000 (20:21 +0100)
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>
(cherry picked from commit 4f7f1d7cff8f2c170ce0319eb4c01a82c328d34f)
Signed-off-by: Mark Brown <broonie@linaro.org>
crypto/blkcipher.c
include/crypto/algapi.h

index a79e7e9ab86e890d7eed95f3038b4424323a70f5..c3a9e82eff0a7d16eed40a24598c3127e73e38bc 100644 (file)
@@ -358,6 +358,20 @@ int blkcipher_walk_virt_block(struct blkcipher_desc *desc,
 }
 EXPORT_SYMBOL_GPL(blkcipher_walk_virt_block);
 
+int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc,
+                                  struct blkcipher_walk *walk,
+                                  struct crypto_aead *tfm,
+                                  unsigned int blocksize)
+{
+       walk->flags &= ~BLKCIPHER_WALK_PHYS;
+       walk->walk_blocksize = blocksize;
+       walk->cipher_blocksize = crypto_aead_blocksize(tfm);
+       walk->ivsize = crypto_aead_ivsize(tfm);
+       walk->alignmask = crypto_aead_alignmask(tfm);
+       return blkcipher_walk_first(desc, walk);
+}
+EXPORT_SYMBOL_GPL(blkcipher_aead_walk_virt_block);
+
 static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key,
                            unsigned int keylen)
 {
index 418d270e18063517750f39c68490f56fb7cd24c3..d61ac19bb5fa02ee101d0cb38d55e79303f1507c 100644 (file)
@@ -192,6 +192,10 @@ int blkcipher_walk_phys(struct blkcipher_desc *desc,
 int blkcipher_walk_virt_block(struct blkcipher_desc *desc,
                              struct blkcipher_walk *walk,
                              unsigned int blocksize);
+int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc,
+                                  struct blkcipher_walk *walk,
+                                  struct crypto_aead *tfm,
+                                  unsigned int blocksize);
 
 int ablkcipher_walk_done(struct ablkcipher_request *req,
                         struct ablkcipher_walk *walk, int err);