Re: [PATCH] prng; bring prng into better alignment with specification

Previous thread: [PATCH] prng: fix a few misc bugs in prng by Neil Horman on Wednesday, July 16, 2008 - 1:29 pm. (3 messages)

Next thread: unused Kconfig vars under drivers/ by Robert P. J. Day on Wednesday, July 16, 2008 - 1:41 pm. (3 messages)
From: Neil Horman
Date: Wednesday, July 16, 2008 - 1:32 pm

Bring prng into better alignment with specificaion:
    
 - Convert to using Generic AES 128 bit cipher
 - Convert DT to be a non-shifted counter, increasing counter period
    
 Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 prng.c |   69 +++++++++++++++++++----------------------------------------------
 1 file changed, 21 insertions(+), 48 deletions(-)

diff --git a/crypto/prng.c b/crypto/prng.c
index 933b4bc..9e2d277 100644
--- a/crypto/prng.c
+++ b/crypto/prng.c
@@ -1,7 +1,7 @@
 /*
  * PRNG: Pseudo Random Number Generator
  *       Based on NIST Recommended PRNG From ANSI X9.31 Appendix A.2.4 using
- *       AES 128 cipher in RFC3686 ctr mode
+ *       AES 128 cipher
  *
  *  (C) Neil Horman <nhorman@tuxdriver.com>
  *
@@ -32,10 +32,8 @@
 
 #define TEST_PRNG_ON_START 0
 
-#define DEFAULT_PRNG_KEY "0123456789abcdef1011"
-#define DEFAULT_PRNG_KSZ 20
-#define DEFAULT_PRNG_IV "defaultv"
-#define DEFAULT_PRNG_IVSZ 8
+#define DEFAULT_PRNG_KEY "0123456789abcdef"
+#define DEFAULT_PRNG_KSZ 16
 #define DEFAULT_BLK_SZ 16
 #define DEFAULT_V_SEED "zaybxcwdveuftgsh"
 
@@ -63,7 +61,7 @@ struct prng_context {
 	unsigned char I[DEFAULT_BLK_SZ];
 	unsigned char V[DEFAULT_BLK_SZ];
 	u32 rand_data_valid;
-	struct crypto_blkcipher *tfm;
+	struct crypto_cipher *tfm;
 	u32 flags;
 };
 
@@ -100,13 +98,8 @@ static void xor_vectors(unsigned char *in1, unsigned char *in2,
 static int _get_more_prng_bytes(struct prng_context *ctx)
 {
 	int i;
-	struct blkcipher_desc desc;
-	struct scatterlist sg_in, sg_out;
-	int ret;
 	unsigned char tmp[DEFAULT_BLK_SZ];
-
-	desc.tfm = ctx->tfm;
-	desc.flags = 0;
+	unsigned char *output = NULL;
 
 
 	dbgprint(KERN_CRIT "Calling _get_more_prng_bytes for context %p\n",
@@ -121,8 +114,6 @@ static int _get_more_prng_bytes(struct prng_context *ctx)
 	 */
 	for (i = 0; i < 3; i++) {
 
-		desc.tfm = ctx->tfm;
-		desc.flags = 0;
 		switch (i) {
 		case 0:
 			/*
@@ -130,7 +121,7 @@ static int _get_more_prng_bytes(struct ...
From: Herbert Xu
Date: Thursday, July 17, 2008 - 12:48 am

We can now kill the iv parameter too.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--

From: Neil Horman
Date: Thursday, July 17, 2008 - 4:04 am

Yeah, I was trying to decide if I should remove that or not, in the event we
wanted to support alternate [blk]ciphers in the future for the cprng.  As I
think about it, I don't think its a big deal to nix.  I'll get rid of it
shortly.

Thanks

-- 
/***************************************************
 *Neil Horman
 *nhorman@tuxdriver.com
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/
--

Previous thread: [PATCH] prng: fix a few misc bugs in prng by Neil Horman on Wednesday, July 16, 2008 - 1:29 pm. (3 messages)

Next thread: unused Kconfig vars under drivers/ by Robert P. J. Day on Wednesday, July 16, 2008 - 1:41 pm. (3 messages)