All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Cope <alexcope@google.com>
To: linux-crypto@vger.kernel.org
Cc: mhalcrow@google.com, edknapp@google.com,
	Alex Cope <alexcope@google.com>,
	Eric Biggers <ebiggers@google.com>
Subject: [RFC][PATCH 1/7] crypto: skcipher adding skciper_walk_virt_init
Date: Mon, 14 Nov 2016 13:01:12 -0800	[thread overview]
Message-ID: <1479157277-10251-2-git-send-email-alexcope@google.com> (raw)
In-Reply-To: <1479157277-10251-1-git-send-email-alexcope@google.com>

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@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 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

  reply	other threads:[~2016-11-14 21:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 21:01 [RFC][PATCH 0/7] crypto: Adding Hash-Encrypt-Hash(HEH) Alex Cope
2016-11-14 21:01 ` Alex Cope [this message]
2016-11-14 21:01 ` [RFC][PATCH 2/7] crypto: gf128mul - Refactor gf128 overflow macros Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 3/7] crypto: gf128mul - Add ble multiplication functions Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 4/7] crypto: shash - Add crypto_grab_shash() and crypto_spawn_shash_alg() Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 5/7] crypto: heh - Add Hash Encrypt Hash(HEH) algorithm Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 6/7] crypto: testmgr - Add test vectors for HEH Alex Cope

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479157277-10251-2-git-send-email-alexcope@google.com \
    --to=alexcope@google.com \
    --cc=ebiggers@google.com \
    --cc=edknapp@google.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mhalcrow@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.