Adding skcipher_walk_virt_init to allow a skciper_walk to specify length and input/output sg. Provides similar funcationalty to blkcipher_walk_init Signed-off-by: Alex Cope <alexcope@xxxxxxxxxx> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx> --- crypto/skcipher.c | 32 +++++++++++++++++++++++--------- include/crypto/internal/skcipher.h | 4 ++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/crypto/skcipher.c b/crypto/skcipher.c index e1633e6..df4b2de 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -447,16 +447,19 @@ static int skcipher_walk_first(struct skcipher_walk *walk) } static int skcipher_walk_skcipher(struct skcipher_walk *walk, - struct skcipher_request *req) + struct skcipher_request *req, + struct scatterlist *src, + struct scatterlist *dst, + unsigned int len) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - scatterwalk_start(&walk->in, req->src); - scatterwalk_start(&walk->out, req->dst); + scatterwalk_start(&walk->in, src); + scatterwalk_start(&walk->out, dst); - walk->in.sg = req->src; - walk->out.sg = req->dst; - walk->total = req->cryptlen; + walk->in.sg = src; + walk->out.sg = dst; + walk->total = len; walk->iv = req->iv; walk->oiv = req->iv; @@ -474,17 +477,27 @@ static int skcipher_walk_skcipher(struct skcipher_walk *walk, int skcipher_walk_virt(struct skcipher_walk *walk, struct skcipher_request *req, bool atomic) { + return skcipher_walk_virt_init(walk, req, atomic, req->src, req->dst, + req->cryptlen); +} +EXPORT_SYMBOL_GPL(skcipher_walk_virt); + +int skcipher_walk_virt_init(struct skcipher_walk *walk, + struct skcipher_request *req, bool atomic, + struct scatterlist *src, struct scatterlist *dst, + unsigned int len) +{ int err; walk->flags &= ~SKCIPHER_WALK_PHYS; - err = skcipher_walk_skcipher(walk, req); + err = skcipher_walk_skcipher(walk, req, src, dst, len); walk->flags &= atomic ? ~SKCIPHER_WALK_SLEEP : ~0; return err; } -EXPORT_SYMBOL_GPL(skcipher_walk_virt); +EXPORT_SYMBOL_GPL(skcipher_walk_virt_init); void skcipher_walk_atomise(struct skcipher_walk *walk) { @@ -499,7 +512,8 @@ int skcipher_walk_async(struct skcipher_walk *walk, INIT_LIST_HEAD(&walk->buffers); - return skcipher_walk_skcipher(walk, req); + return skcipher_walk_skcipher(walk, req, req->src, req->dst, + req->cryptlen); } EXPORT_SYMBOL_GPL(skcipher_walk_async); diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index 26934a6..1173701 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h @@ -144,6 +144,10 @@ int skcipher_walk_done(struct skcipher_walk *walk, int err); int skcipher_walk_virt(struct skcipher_walk *walk, struct skcipher_request *req, bool atomic); +int skcipher_walk_virt_init(struct skcipher_walk *walk, + struct skcipher_request *req, + bool atomic, struct scatterlist *src, + struct scatterlist *dst, unsigned int len); void skcipher_walk_atomise(struct skcipher_walk *walk); int skcipher_walk_async(struct skcipher_walk *walk, struct skcipher_request *req); -- 2.8.0.rc3.226.g39d4020 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html