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