⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
Firefox2005
Offline
Last seen:1 week 2 days ago
加入:2016-04-13 09:36
TRNG DA14531

Hi,

how to call thetrng_acquirefunction right?

I do not know where I get the address foruint8_t *sram_puf.

没有任何演示应用程序或参考实现吗?

/** **************************************************************************************** * @brief Acquires 128 random bits using uninitialized RAM data. * * @param[out] trng_bits_ptr Pointer to the buffer where random data will be stored. * @note Its address must be aligned to 32 bits. * @param[in] sram_puf Pointer to the base address of the uninitialized SRAM area. * @note Its address must be aligned to 32 bits. * @param[in] sram_puf_blocks Number of 16byte blocks to use (28 minimum). * @return Status code **************************************************************************************** */ uint8_t trng_acquire(uint8_t *trng_bits_ptr, uint8_t *sram_puf, const uint16_t sram_puf_blocks);

Keywords:
Device:
PM_Dialog
Offline
Last seen:2 days 13 hours ago
工作人员
加入:2018-02-08 11:03
Hi Firefox2005

Hi Firefox2005

Please check init_rand_seed_from_trng() that invokes the trng_acquire(). There isn’t any example for this, but why don’t you use the init_rand_seed_from_trng() in order to initialize random number generator seed using random bits acquired from TRNG? The purpose of the trng_aquire() is to seed the random function.

Thanks, PM_Dialog

Firefox2005
Offline
Last seen:1 week 2 days ago
加入:2016-04-13 09:36
Hi,

Hi,

so I missunderstood the function...

In that case I just have toinit_rand_seed_from_trng ();和使用the generated random value to initialize e.g. thesrand(trng\u state\u val);函数并从rand();

But I do get always the same random number over and over again if I restart the same firmware build. I do not think this is correct.

我什么时候必须重新初始化init_rand_seed_from_trng ();一遍吗?

为什么trng_aquire(...)函数不是静态的,如果我不必在trng.c之外使用它?

Thank you so far

PM_Dialog
Offline
Last seen:2 days 13 hours ago
工作人员
加入:2018-02-08 11:03
Hi There,

Hi There,

What is the same random number that you are getting? Coudl you please share the results?

Thanks, PM_Dialog

Firefox2005
Offline
Last seen:1 week 2 days ago
加入:2016-04-13 09:36
I always get the same output

I always get the same output if I reload and start the firmware. This should not be in my opinion.

Code:

void user_app_init(void) { arch_printf("\r\n\r\nuser_app_init\r\n"); // Initialize random number generator seed using random bits acquired from TRNG init_rand_seed_from_trng(); //Initialise standard c rand() function with trng random number srand(trng_state_val); // Test: Loop through the random number generator to test the random numbers generator... for(uint8_t i=0; i<10; i++){ //Get 16byte random numbers for AES-128 key for(uint8_t i=0; i

控制台输出:

user_app_init CHALLENGE d816f9d60c6c876abab0a74a11828fae CHALLENGE a832652ba76aa59c374db76d6cbcd48a CHALLENGE 2fd232c58303414c7a264221f0a8bc89 CHALLENGE a4e64f980420b48af8d631d962c4767e CHALLENGE b1740409a2f0c9b945cf4f9a8750e9ea CHALLENGE c694072749e4ce4764ce643001c7d134 CHALLENGE 756796e7a5a12e6129d5cae5a2d8d0df CHALLENGE 470e8f5c067b89b08aa309bf495c0c48 CHALLENGE 952486692eed4f8e7bace731b5cec0d4 CHALLENGE e3b460feaf935240c3918cd46146de34

PM_Dialog
Offline
Last seen:2 days 13 hours ago
工作人员
加入:2018-02-08 11:03
Hi There,

Hi There,

Thanks for your inputs. Let me check the provided code snippet and I'll revert back to you shorlty.

Thanks, PM_Dialog

PM_Dialog
Offline
Last seen:2 days 13 hours ago
工作人员
加入:2018-02-08 11:03
Hi There,

Hi There,

My apologies for the confusion. If the CFG_TRNG macro is defined in the da1458x_config_advanced.h, then the init_rand_seed_from_trng() is automatically called by the SDK. Please check line 1324 in the arch_system.c file. This means that the SDK will initialize random number generator seed automatically. In case you want to generate random numbers, you should just use the rand() function.

Thanks, PM_Dialog