[v3 PATCH 7/31] crypto: skcipher - Add alg reqsize field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As it is the reqsize field only exists on the tfm object which means
that in order to set it you must provide an init function for the
tfm, even if the size is actually static.

This patch adds a reqsize field to the skcipher alg object which
allows it to be set without having an init function.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
---

 crypto/skcipher.c         |    4 +++-
 include/crypto/skcipher.h |    2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/crypto/skcipher.c b/crypto/skcipher.c
index 467af525848a1..3bfa06fd25600 100644
--- a/crypto/skcipher.c
+++ b/crypto/skcipher.c
@@ -668,6 +668,8 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
 	struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm);
 	struct skcipher_alg *alg = crypto_skcipher_alg(skcipher);
 
+	skcipher->reqsize = alg->reqsize;
+
 	skcipher_set_needkey(skcipher);
 
 	if (alg->exit)
@@ -797,7 +799,7 @@ static int skcipher_prepare_alg(struct skcipher_alg *alg)
 	struct crypto_alg *base = &alg->base;
 
 	if (alg->ivsize > PAGE_SIZE / 8 || alg->chunksize > PAGE_SIZE / 8 ||
-	    alg->walksize > PAGE_SIZE / 8)
+	    alg->walksize > PAGE_SIZE / 8 || alg->reqsize > PAGE_SIZE / 8)
 		return -EINVAL;
 
 	if (!alg->chunksize)
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index fb90c3e1c26ba..c46ea1c157b29 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -100,6 +100,7 @@ struct crypto_sync_skcipher {
  * @final_chunksize: Number of bytes that must be processed together
  *		     at the end.  If set to -1 then chaining is not
  *		     possible.
+ * @reqsize: Size of the request data structure.
  * @base: Definition of a generic crypto algorithm.
  *
  * All fields except @ivsize are mandatory and must be filled.
@@ -118,6 +119,7 @@ struct skcipher_alg {
 	unsigned int chunksize;
 	unsigned int walksize;
 	int final_chunksize;
+	unsigned int reqsize;
 
 	struct crypto_alg base;
 };



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux