How to read random number generated using CAAM-RNG in imx6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read random number generated using CAAM-RNG in imx6

2,868 Views
ma_sreelakshmi
Contributor II

Hi 

I understood that for generating random numbers we have to instantiate RNG and then generate random number(with job descriptors) and we will be using job ring registers to do the operation...

1.May i know how to read the generated random number? Is it possible?

2.The number which i will be reading is the correct number or the encrypted one?

I tried to execute it with sdk rng job descriptors...

3.How i will understand whether the random number is generated or not?

job ring output status register is

CAAM_JRSTAR0 = 0x40001f04

Thanks in advance

Sreelakshmy 

Labels (1)
0 Kudos
4 Replies

2,744 Views
igorpadykov
NXP Employee
NXP Employee

Hi Sreelakshmy 

for rng usage one can look at

NIST statistical test failure on RNG 

Random number generator hangs for a long time - Toradex Community 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,744 Views
ma_sreelakshmi
Contributor II

Hi Igor,

I need to generate a random number and i have to read it.. I used the below descriptors and calling them in job ring queue... Are these descriptors correct? 

and also i used fifo store to store the random number generated to the address pointer which i will provide during run time...Is this correct? When i tried to print the value in that address pointer i am getting a data abort... 

my reference is SDK codes...

#define RNG_DESC1 0xB0800006 //header
#define RNG_DESC2 0x82500004 //instantiate RNG
#define RNG_DESC3 0xA2000001 //jump
#define RNG_DESC4 0x82501000 //generate random number
#define RNG_DESC5 0x60340010 //fifostore
#define RNG_DESC6 0x00000000 //pointer

Thanks in advance

Sreelakshmy M A

0 Kudos

2,744 Views
igorpadykov
NXP Employee
NXP Employee

Hi Sreelakshmy

there is example in baremetal sdk

rt-thread/caam.c at master · RT-Thread/rt-thread · GitHub 

Best regards
igor

0 Kudos

2,744 Views
ma_sreelakshmi
Contributor II

Hi Igor,

I tried to generate JDKEK,TDKEK,TDSK keys using the same code (baremetal sdk)without changing anything(only caam_open(), used it  in u-boot)...

But....2 problems

1.I am not getting any key values in the corresponding registers

2.RNG is not instantiating....

i tried to print the registers...

TRNG program mode
CAAM_JDKEKR = 0x00000000
CAAM_RDSTA = 0x00000000
CAAM_RTFRQMAX = 0x00000640
CAAM_RTFRQMIN = 0x00000064
CAAM_RTSDCTL = 0x00c809c4
CAAM_RTMCTL = 0x00012000


osc div
CAAM_JDKEKR = 0x00000000
CAAM_RDSTA = 0x00000000
CAAM_RTFRQMAX = 0x00000640
CAAM_RTFRQMIN = 0x00000064
CAAM_RTSDCTL = 0x00c809c4
CAAM_RTMCTL = 0x00012000


set delay
CAAM_JDKEKR = 0x00000000
CAAM_RDSTA = 0x00000000
CAAM_RTFRQMAX = 0x00001900
CAAM_RTFRQMIN = 0x00000190
CAAM_RTSDCTL = 0x032009c4
CAAM_RTMCTL = 0x00012000


TRNG run mode
CAAM_JDKEKR = 0x00000000
CAAM_RDSTA = 0x00000000
CAAM_RTFRQMAX = 0x00000000
CAAM_RTFRQMIN = 0x00000000
CAAM_RTSDCTL = 0x00000000
CAAM_RTMCTL = 0x00000000

i could not understand the problem...kindly help me to figure out the problem...

Thanks in advance

Sreelakshmy 

0 Kudos