drivers/crypto/fsl: enable raw data instead of von Neumann data
authorAlex Porosanu <alexandru.porosanu@freescale.com>
Tue, 5 May 2015 13:48:35 +0000 (16:48 +0300)
committerYork Sun <yorksun@freescale.com>
Mon, 3 Aug 2015 19:06:37 +0000 (12:06 -0700)
The sampling of the oscillator can be done in multiple modes for
generating the entropy value. By default, this is set to von
Neumann. This patch changes the sampling to raw data, since it
has been discovered that the generated entropy has a better
'quality'.

Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com>
Acked-by: Ruchika Gupta<ruchika.gupta@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
drivers/crypto/fsl/jr.c
include/fsl_sec.h

index aa527ec954dc27cdf4e33126d9d9c9edd804cfb0..35606688af89a44d576b7d6a298b814494592e3d 100644 (file)
@@ -408,8 +408,17 @@ static void kick_trng(int ent_delay)
        sec_out32(&rng->rtfreqmin, ent_delay >> 2);
        /* disable maximum frequency count */
        sec_out32(&rng->rtfreqmax, RTFRQMAX_DISABLE);
+       /* read the control register */
+       val = sec_in32(&rng->rtmctl);
+       /*
+        * select raw sampling in both entropy shifter
+        * and statistical checker
+        */
+       sec_setbits32(&val, RTMCTL_SAMP_MODE_RAW_ES_SC);
        /* put RNG4 into run mode */
-       sec_clrbits32(&rng->rtmctl, RTMCTL_PRGM);
+       sec_clrbits32(&val, RTMCTL_PRGM);
+       /* write back the control register */
+       sec_out32(&rng->rtmctl, val);
 }
 
 static int rng_init(void)
index c84b6ad8d8fb310f0fc4137eb40c7e9fd1b695d6..672bcef2f3b71f97c045e3552be122ad8b33f279 100644 (file)
 /* RNG4 TRNG test registers */
 struct rng4tst {
 #define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */
+#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC     0 /* use von Neumann data in
+                                                   both entropy shifter and
+                                                   statistical checker */
+#define RTMCTL_SAMP_MODE_RAW_ES_SC             1 /* use raw data in both
+                                                   entropy shifter and
+                                                   statistical checker */
+#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC 2 /* use von Neumann data in
+                                                   entropy shifter, raw data
+                                                   in statistical checker */
+#define RTMCTL_SAMP_MODE_INVALID               3 /* invalid combination */
        u32 rtmctl;             /* misc. control register */
        u32 rtscmisc;           /* statistical check misc. register */
        u32 rtpkrrng;           /* poker range register */