imxrt-rs / imxrt-hal

Rust for NXP i.MX RT
Apache License 2.0
137 stars 33 forks source link

Support iMXRT1062 TRNG #74

Closed AlyoshaVasilieva closed 4 years ago

AlyoshaVasilieva commented 4 years ago

The iMXRT1062 (and other devices?) has a True Random Number Generator, which would be useful to support. Unfortunately almost all of its documentation is contained in the Security Reference Manual, which requires a licensing agreement with NXP. Based on the site's assumption that I have a designated salesperson, I suspect I wouldn't be approved to read the SRM (and I don't really want to sign an NDA).

However, the MCUXpresso SDK contains example code for the TRNG. Reading that was enough to get it working: https://github.com/AlyoshaVasilieva/imxrt1062-trng/blob/master/src/lib.rs

This would probably fit better as part of the HAL rather than a separate driver library, but even if I wasn't currently sick I'm not sure I'd be able to design it properly, so hopefully someone here finds it useful. It depends on rand_core so I don't have to worry about messing up the block generation.

Speed: about 15 minutes to generate 1MB of random data, at least in my test. Probably best to use it to seed a (CS)PRNG.


Update: Revising the driver, should have something within a week or so.