Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2350 TRNG support #3338

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Conversation

ionspin
Copy link
Contributor

@ionspin ionspin commented Sep 15, 2024

This is a driver for RP2350 TRNG, I used RNG driver from embassy-nrf as a template, but adapted to be more in line with other drivers in embassy-rp.

From 2350 datasheet:

12.12.1. Overview
RP2350 contains an Arm IP-based True Random Number Generator block. It supports the following features:
• Compliance with FIPS Publication 140-2, BSI AIS-31, and NIST SP 800-90B
• Produces approximately 7.5 kb/s of entropy when the core runs at 150 MHz
On request, the TRNG block generates a block of 192 entropy bits generated by automatically processing a series of
periodic samples from the TRNG block’s internal Ring Oscillator (ROSC).

The TRNG block’s ROSC is a free-running oscillator with no direct connection to the system clocks on RP2350. As a
result, the ROSC generally runs asynchronously to the system clocks.
After a sufficient number of samples have been collected, the TRNG block completes the generation process and
presents the random number in the EHR_DATA[x] result registers.

They go on to note that Pico SDK and Pico Bootrom disable all entropy checks and sample as fast as possible from the TRNG ROSC directly, and then pass the data through SHA256 before using it (hardware accelerated in case of Bootrom) or xiroshiro128** (in case of pico-random library in Pico SDK , note that xiroshiro128** is verions 1.0 there) .

I've decided to leave the entropy checks enabled and datasheet recommended config for the TRNG default config as they seem to be sane.

Related to #3241

@ionspin ionspin force-pushed the add-rp2350-trng-support branch 6 times, most recently from faeab00 to 9de7fa1 Compare September 15, 2024 20:08
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
@ionspin ionspin force-pushed the add-rp2350-trng-support branch 2 times, most recently from 1f3f775 to 9422c21 Compare September 16, 2024 19:42
@ionspin ionspin marked this pull request as ready for review September 16, 2024 19:47
@ionspin ionspin changed the title [WIP] RP2350 TRNG support RP2350 TRNG support Sep 16, 2024
@ionspin ionspin changed the title RP2350 TRNG support [WIP] RP2350 TRNG support Sep 16, 2024
@ionspin ionspin changed the title [WIP] RP2350 TRNG support RP2350 TRNG support Sep 16, 2024
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
embassy-rp/src/trng.rs Outdated Show resolved Hide resolved
@ionspin ionspin force-pushed the add-rp2350-trng-support branch 2 times, most recently from 08a9597 to 707a946 Compare September 17, 2024 19:22
Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@Dirbaio Dirbaio added this pull request to the merge queue Sep 17, 2024
Merged via the queue into embassy-rs:main with commit d12e98a Sep 17, 2024
6 checks passed
@ionspin ionspin deleted the add-rp2350-trng-support branch September 18, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants