[PATCH v2 21/25] crypto: ansi_cprng - Rename rand_data_valid more sensibly
From: George Spelvin <hidden>
Date: 2014-12-07 12:27:07
Subsystem:
crypto api, the rest · Maintainers:
Herbert Xu, "David S. Miller", Linus Torvalds
Since it counts the number of bytes in rand_data which have been output, and are no longer available for output, it's hardly a count of "valid" bytes. rand_data_pos is more appropriate. Signed-off-by: George Spelvin <redacted> --- crypto/ansi_cprng.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index f345b575..f3e280c4 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c@@ -41,7 +41,7 @@ struct prng_context { spinlock_t prng_lock; u8 flags; - u8 rand_data_valid; + u8 rand_read_pos; u8 rand_data[DEFAULT_BLK_SZ]; u8 DT[DEFAULT_BLK_SZ]; u8 V[DEFAULT_BLK_SZ];
@@ -165,7 +165,7 @@ static int get_prng_bytes(u8 *buf, unsigned int nbytes, if (ctx->flags & PRNG_NEED_RESET) goto done; - read_pos = ctx->rand_data_valid; + read_pos = ctx->rand_read_pos; if (byte_count > DEFAULT_BLK_SZ - read_pos) { /* Leading partial block */ unsigned int avail = DEFAULT_BLK_SZ - read_pos;
@@ -191,7 +191,7 @@ static int get_prng_bytes(u8 *buf, unsigned int nbytes, /* The final partial block; read_pos + byte_count <= DEFAULT_BLK_SZ */ memcpy(ptr, ctx->rand_data + read_pos, byte_count); - ctx->rand_data_valid = read_pos + byte_count; + ctx->rand_read_pos = read_pos + byte_count; err = nbytes; done:
@@ -213,7 +213,7 @@ static int reset_prng_context(struct prng_context *ctx, const u8 *key, spin_lock_bh(&ctx->prng_lock); ctx->flags |= PRNG_NEED_RESET; - ctx->rand_data_valid = DEFAULT_BLK_SZ; + ctx->rand_read_pos = DEFAULT_BLK_SZ; memset(ctx->rand_data, 0, DEFAULT_BLK_SZ);
@@ -324,7 +324,7 @@ static int fips_cprng_reset(struct crypto_rng *tfm, const u8 *seed, /* this primes our continuity test */ rc = _get_more_prng_bytes(prng, false); - prng->rand_data_valid = DEFAULT_BLK_SZ; + prng->rand_read_pos = DEFAULT_BLK_SZ; out: return rc;
--
2.1.3