I am trying to get some random data from K81 hardware and I'm using TRNG_GetRandomData from fsl_trng.c.
I'm using it in connection with :
//***********************************************************************************************************
return_code = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(key, trng_ctr_drbg_random, NULL, MBEDTLS_RSA_PUBLIC, sizeof(_pers_kbpk), (const uint8_t*)&_pers_kbpk.data, enc_pers_kbpk_ptr);
static int trng_ctr_drbg_random(void* notused, unsigned char* output, size_t output_len)
{
return ( TRNG_GetRandomData(TRNG0, output, output_len) );
}
//***********************************************************************************************************
In TRNG_GetRandomData it hangs in the check while loop:
while ((TRNG_RD_MCTL_ENT_VAL(base) == 0) && (TRNG_RD_MCTL_ERR(base) == 0))
{
}
and never gets out.
If I run debug one step at a time it works perfect but if it runs normal it hangs.
Is there a workaround for this issue ?
It is configured with TRNG_Init and default config.
uint32_t trng_enable()
{
trng_config_t trngConfig;
TRNG_GetDefaultConfig(&trngConfig);
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;
return (TRNG_Init(TRNG0, &trngConfig));
}
Hi Christian,
I can't reproduce you problem at my board. Did you try the trng example in the SDK?
Regards,
Jing