Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: petri on September 22, 2012, 08:06:31 pm

Title: Random numbers from HW_DIGCTL_ENTROPY
Post by: petri on September 22, 2012, 08:06:31 pm
Hi community!

I am working on to initialize operating system's random number generator.
I'd like to have pseudo-random number to feed OS's random pool.
I tried to read random number from i.MX23's HW_DIGCTL_ENTROPY register which, kinda works on
OLinuXino-MAXI but there's but:

I am powering the system from the 5V (no battery)

I only able get stable feed of random numebers from HW_DIGCTL_ENTROPY if I press POWER/REC button
same time as I read the values. Values here are values from the HW_DIGCTL_ENTROPY register:

Reset:

loop1        0x39b08cf0
loop2        0xc95f2999
loop3        0x3a65687f
loop4        0xa7ac7ec5         <-- POWER/REC button released.
loop5        0xa7ac7ec5
loop6        0xa7ac7ec5
loop7        0xa7ac7ec5
...

I don't have a problem if random number changes after every boot, but it constantly stays same if I don't
fiddle with the POWER/REC button. Is this known problem to someone? Has anyone figured workaround for this?
I don't want to tell users to press POWER/REC button when they boot the device manually. And I i reboot the
device remotely, there are no one to hold the button to feed random pool...

Kindly yours,
Petri
Title: Re: Random numbers from HW_DIGCTL_ENTROPY
Post by: davidjf2001 on September 23, 2012, 07:49:45 pm
Per i.mx233 Product Data Sheet "A 32-bit entropy register begins running a pseudo-random number algorithm from the time reset is removed until the PSWITCH is released by the user."

Title: Re: Random numbers from HW_DIGCTL_ENTROPY
Post by: davidjf2001 on September 23, 2012, 09:23:27 pm
I just read "HW_DIGCTL_CTRL Bit Field Descriptions"

Bit 0 LATCH_ENTROPY RW 0x0
Setting this bit latches the current value of the entropy register into HW_DIGCTL_ENTROPY_VALUE. This
can be used get a stable value on players that do not deassert the PSWITCH while powered up.
Title: Re: Random numbers from HW_DIGCTL_ENTROPY
Post by: davidjf2001 on September 25, 2012, 05:47:46 am
Later thinking about this I am not sure how random this is.  Reset to some particular point in running code is repeatable.  Variations in how long linux boots and loads modules, connects to networks would probably add enough variability.
Title: Re: Random numbers from HW_DIGCTL_ENTROPY
Post by: petri on September 25, 2012, 12:08:29 pm
Quote from: davidjf2001 on September 25, 2012, 05:47:46 am
Later thinking about this I am not sure how random this is.  Reset to some particular point in running code is repeatable.  Variations in how long linux boots and loads modules, connects to networks would probably add enough variability.


Now just test on boot that if HW_DIGCTL_ENTROPY is emitting changing numbers. If it does, someone is pressing the button and I use the values. If not, well, I am not going to accumulate randomness...