[PATCH v2 20/25] crypto: ansi_cprng - simplify xor_vectors() to xor_block()

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

 



It doesn't need a second input or a length parameter.

Signed-off-by: George Spelvin <linux@xxxxxxxxxxx>
---
 crypto/ansi_cprng.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index a8cf98a5..f345b575 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -63,15 +63,14 @@ if (dbg)\
 	printk(format, ##args);\
 } while (0)
 
-static void xor_vectors(const u8 *in1, const u8 *in2,
-			u8 *out, unsigned int size)
+static void xor_block(const u8 in[DEFAULT_BLK_SZ], u8 out[DEFAULT_BLK_SZ])
 {
 	int i;
 
-	for (i = 0; i < size; i++)
-		out[i] = in1[i] ^ in2[i];
-
+	for (i = 0; i < DEFAULT_BLK_SZ; i++)
+		out[i] ^= in[i];
 }
+
 /*
  * Returns DEFAULT_BLK_SZ bytes of random data per call
  * returns 0 if generation succeeded, <0 if something went wrong
@@ -100,7 +99,7 @@ static int _get_more_prng_bytes(struct prng_context *ctx, bool cont_test)
 	 * keep that output in ctx->V for the moment; we need the
 	 * previous rand_data for ons more thing.
 	 */
-	xor_vectors(tmp, ctx->V, ctx->V, DEFAULT_BLK_SZ);
+	xor_block(tmp, ctx->V);
 	hexdump("V^I", ctx->V);
 	crypto_cipher_encrypt_one(ctx->tfm, ctx->V, ctx->V);
 	hexdump("R", ctx->V);
@@ -128,7 +127,7 @@ static int _get_more_prng_bytes(struct prng_context *ctx, bool cont_test)
 	 * Lastly xor the random data with I and encrypt that to obtain
 	 * a new secret vector V.
 	 */
-	xor_vectors(tmp, ctx->V, ctx->V, DEFAULT_BLK_SZ);
+	xor_block(tmp, ctx->V);
 	hexdump("R^I", ctx->V);
 	memzero_explicit(tmp, DEFAULT_BLK_SZ);
 	crypto_cipher_encrypt_one(ctx->tfm, ctx->V, ctx->V);
-- 
2.1.3

--
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




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

  Powered by Linux