Skip to content

rp2: Use RP2350 hardware TRNG for os.urandom #18831

Closed

Description

@mimi89999

Description

The RP2350 has a dedicated hardware TRNG peripheral with built-in health tests aligned with NIST SP 800-90B. The Pico SDK already uses it, pico_rand auto-detects HAS_RP2350_TRNG and sources entropy from it.

The current implementation is using ROSC for both rp2 microcontrollers. The RP2040 datasheet (§2.17.5) warns this "does not meet the requirements of randomness for security systems because it can be compromised."

Code Size

I expect the new code size to be rather small

Implementation

I would like to sponsor development of this feature

Code of Conduct

Yes, I agree

Activity

  1. ricksorensen commented on Feb 17, 2026

    @ricksorensen
    Contributor

    Also see discussion #16420. Using 2350 new/updated TRNG should be evaluated in my opinion.

  2. mimi89999 commented on Feb 17, 2026

    @mimi89999
    ContributorAuthor

    I'd be happy to implement this. My approach would be to mix entropy from both TRNG and ROSC (similar to pico_rand), but condition the output through SHA-256 rather than splitmix64/xoroshiro128**. The Linux kernel's RNG used SHA-1 for entropy mixing before switching to BLAKE2s. CircuitPython also conditions through SHA-256 on its RP2 port: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/common-hal/os/__init__.c

    On RP2040, the existing ROSC path would remain unchanged.

  3. mimi89999 commented on Feb 27, 2026

    @mimi89999
    ContributorAuthor

    Landed in 158cbd6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions