All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Spelvin <linux@horizon.com>
To: nhorman@tuxdriver.com, linux-crypto@vger.kernel.org
Cc: smueller@chronox.de, herbert@gondor.apana.org.au, linux@horizon.com
Subject: [PATCH v2 13/25] crypto: Add appropriate consts to RNG API
Date: Sun,  7 Dec 2014 07:26:21 -0500	[thread overview]
Message-ID: <622c0b1320fe555f0ce97f4c342a0877f14d63b6.1417951990.git.linux@horizon.com> (raw)
In-Reply-To: <cover.1417951990.git.linux@horizon.com>
In-Reply-To: <cover.1417951990.git.linux@horizon.com>

Signed-off-by: George Spelvin <linux@horizon.com>
---
 crypto/ansi_cprng.c    | 11 ++++++-----
 crypto/krng.c          |  2 +-
 crypto/rng.c           |  3 ++-
 include/crypto/rng.h   |  2 +-
 include/linux/crypto.h |  6 ++++--
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 249b944f..c1c81266 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -299,11 +299,11 @@ static int cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
  *  V and KEY are required during reset, and DT is optional, detected
  *  as being present by testing the length of the seed
  */
-static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
+static int cprng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
 {
 	struct prng_context *prng = crypto_rng_ctx(tfm);
-	u8 *key = seed + DEFAULT_BLK_SZ;
-	u8 *dt = NULL;
+	const u8 *key = seed + DEFAULT_BLK_SZ;
+	const u8 *dt = NULL;
 
 	if (slen < DEFAULT_PRNG_KSZ + DEFAULT_BLK_SZ)
 		return -EINVAL;
@@ -327,9 +327,10 @@ static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
 	return get_prng_bytes(rdata, dlen, prng, true);
 }
 
-static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
+static int fips_cprng_reset(struct crypto_rng *tfm, const u8 *seed,
+			    unsigned int slen)
 {
-	u8 *key = seed + DEFAULT_BLK_SZ;
+	const u8 *key = seed + DEFAULT_BLK_SZ;
 	int rc;
 
 	struct prng_context *prng = crypto_rng_ctx(tfm);
diff --git a/crypto/krng.c b/crypto/krng.c
index a2d2b72f..007ea7e3 100644
--- a/crypto/krng.c
+++ b/crypto/krng.c
@@ -22,7 +22,7 @@ static int krng_get_random(struct crypto_rng *tfm, u8 *rdata, unsigned int dlen)
 	return 0;
 }
 
-static int krng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
+static int krng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
 {
 	return 0;
 }
diff --git a/crypto/rng.c b/crypto/rng.c
index e0a25c24..9e3a6efd 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -29,7 +29,8 @@ struct crypto_rng *crypto_default_rng;
 EXPORT_SYMBOL_GPL(crypto_default_rng);
 static int crypto_default_rng_refcnt;
 
-static int rngapi_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
+static int rngapi_reset(struct crypto_rng *tfm, const u8 *seed,
+			unsigned int slen)
 {
 	u8 *buf = NULL;
 	int err;
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index c93f9b91..9659300a 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -62,7 +62,7 @@ static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
 }
 
 static inline int crypto_rng_reset(struct crypto_rng *tfm,
-				   u8 *seed, unsigned int slen)
+				   const u8 *seed, unsigned int slen)
 {
 	return crypto_rng_crt(tfm)->rng_reset(tfm, seed, slen);
 }
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index d45e9496..8aa6350b 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -264,7 +264,8 @@ struct compress_alg {
 struct rng_alg {
 	int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata,
 			       unsigned int dlen);
-	int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
+	int (*rng_reset)(struct crypto_rng *tfm, const u8 *seed,
+			       unsigned int slen);
 
 	unsigned int seedsize;
 };
@@ -399,7 +400,8 @@ struct compress_tfm {
 struct rng_tfm {
 	int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
 			      unsigned int dlen);
-	int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
+	int (*rng_reset)(struct crypto_rng *tfm, const u8 *seed,
+			 unsigned int slen);
 };
 
 #define crt_ablkcipher	crt_u.ablkcipher
-- 
2.1.3

  parent reply	other threads:[~2014-12-07 12:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07 12:26 [PATCH v2 00/25] Multiple changes to crypto/ansi_cprng.c George Spelvin
2014-12-07 12:26 ` [PATCH v2 01/25] crypto: ansi_cprng - unroll _get_more_prng_bytes George Spelvin
2014-12-07 12:26 ` [PATCH v2 02/25] crypto: ansi_cprng - Additional _get_more_prng_bytes cleanup George Spelvin
2014-12-07 12:26 ` [PATCH v2 03/25] crypto: ansi_cprng - Use %phN rather than print_hex_dump for debug George Spelvin
2014-12-07 12:26 ` [PATCH v2 04/25] crypto: ansi_cprng - Make debug output more like NIST test vectors George Spelvin
2014-12-07 12:26 ` [PATCH v2 05/25] crypto: ansi_cprng - Eliminate ctx->I and ctx->last_rand_data George Spelvin
2014-12-14 11:50   ` Stephan Mueller
2014-12-14 19:22     ` George Spelvin
2014-12-07 12:26 ` [PATCH v2 06/25] crypto: ansi_cprng - Make cont_test a bool George Spelvin
2014-12-07 12:26 ` [PATCH v2 07/25] crypto: ansi_cprng - Shrink context some more George Spelvin
2014-12-07 12:26 ` [PATCH v2 08/25] crypto: ansi_cprng - Don't call reset_prng_context from cprng_init George Spelvin
2014-12-07 12:26 ` [PATCH v2 09/25] crypto: ansi_cprng - Make length types consistent George Spelvin
2014-12-07 12:26 ` [PATCH v2 10/25] crypto: ansi_cprng - Use u8 data types consistently internally George Spelvin
2014-12-07 12:26 ` [PATCH v2 11/25] crypto: ansi_cprng - Eliminate unused PRNG_FIXED_SIZE flag George Spelvin
2014-12-07 12:26 ` [PATCH v2 12/25] crypto: ansi_cprng - Get rid of rdata buffer in fips_cprng_reset George Spelvin
2014-12-07 12:26 ` George Spelvin [this message]
2014-12-14 11:39   ` [PATCH v2 13/25] crypto: Add appropriate consts to RNG API Stephan Mueller
2014-12-07 12:26 ` [PATCH v2 14/25] crypto: tcrypt - Add const qualifiers all over the test code George Spelvin
2014-12-07 12:26 ` [PATCH v2 15/25] crypto: testmgr - Merge seed arrays in struct cprng_testvec George Spelvin
2014-12-07 12:26 ` [PATCH v2 16/25] crypto: testmgr - Report failure on zero-length crypto_rng_get_bytes George Spelvin
2014-12-07 12:26 ` [PATCH v2 17/25] crypto: testmgr - Don't crash if CPRNG test result is large George Spelvin
2014-12-07 12:26 ` [PATCH v2 18/25] crypto: testmgr - Add CPRNG stutter test George Spelvin
2014-12-07 12:26 ` [PATCH v2 19/25] crypto: ansi_cprng - simplify get_prng_bytes George Spelvin
2014-12-07 12:26 ` [PATCH v2 20/25] crypto: ansi_cprng - simplify xor_vectors() to xor_block() George Spelvin
2014-12-07 12:26 ` [PATCH v2 21/25] crypto: ansi_cprng - Rename rand_data_valid more sensibly George Spelvin
2014-12-07 12:26 ` [PATCH v2 22/25] crypto: ansi_cprng - Tweak comments George Spelvin
2014-12-07 12:26 ` [PATCH v2 23/25] crypto: ansi_cprng - Introduce a "union cipherblock" George Spelvin
2014-12-07 12:26 ` [PATCH v2 24/25] crypto: ansi_cprng - Introduce non-deterministic mode George Spelvin
2014-12-07 12:26 ` [PATCH v2 25/25] crypto: ansi_cprng - If non-deterministic, don't buffer old output George Spelvin
2014-12-07 22:49   ` George Spelvin
2014-12-08 14:22     ` Neil Horman
2014-12-08 16:43       ` George Spelvin
2014-12-08 18:07         ` Neil Horman
2014-12-08 20:34           ` George Spelvin
2014-12-14 12:06 ` [PATCH v2 00/25] Multiple changes to crypto/ansi_cprng.c Stephan Mueller
2014-12-14 19:47   ` George Spelvin
2014-12-15  6:18     ` Stephan Mueller
2014-12-14 20:37   ` George Spelvin
2014-12-15  6:14     ` Stephan Mueller
2014-12-15  8:42       ` George Spelvin
2014-12-15  8:50         ` Stephan Mueller
2014-12-15 10:45           ` George Spelvin
2014-12-15 11:08             ` Stephan Mueller
2014-12-15  5:53   ` George Spelvin
2014-12-15  6:27     ` Stephan Mueller
2014-12-15  8:28       ` George Spelvin
2014-12-15  8:56         ` Stephan Mueller
2014-12-15 10:21           ` George Spelvin
2014-12-15 10:46             ` Stephan Mueller
2014-12-15 11:32               ` Neil Horman
2014-12-15 22:01                 ` George Spelvin
2014-12-16  7:22                   ` Stephan Mueller
2014-12-16 11:32                   ` Neil Horman

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=622c0b1320fe555f0ce97f4c342a0877f14d63b6.1417951990.git.linux@horizon.com \
    --to=linux@horizon.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=smueller@chronox.de \
    /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.