Add Vorago VA416x0 hardware TRNG support#10671
Draft
dgarske wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new hardware-entropy backend for Vorago VA416x0 by implementing wc_GenerateSeed() using the on-chip TRNG, gated behind WOLFSSL_VA416X0_TRNG, and documents the new build macro.
Changes:
- Add a VA416x0 TRNG-based
wc_GenerateSeed()implementation with retry/timeout behavior and stack scrubbing. - Document the new
WOLFSSL_VA416X0_TRNGmacro inrandom.cand register it in.wolfssl_known_macro_extras.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| wolfcrypt/src/random.c | Adds the VA416x0 TRNG seed generator implementation and documents the new macro/tuning defines. |
| .wolfssl_known_macro_extras | Adds WOLFSSL_VA416X0_TRNG to the known macro list (and also removes two existing macros in the same hunk). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+5287
to
+5299
| /* health-test failure: stop, clear, re-collect */ | ||
| VOR_TRNG->RND_SOURCE_ENABLE = 0; | ||
| VOR_TRNG->ICR = TRNG_ICR_AUTOCORR_ERR_Msk | | ||
| TRNG_ICR_CRNGT_ERR_Msk | | ||
| TRNG_ICR_VN_ERR_Msk; | ||
| if (++retry > WOLFSSL_VA416X0_TRNG_MAX_RETRY) { | ||
| ForceZero(ehr, sizeof(ehr)); | ||
| return RNG_FAILURE_E; | ||
| } | ||
| timeout = WOLFSSL_VA416X0_TRNG_TIMEOUT; | ||
| VOR_TRNG->RND_SOURCE_ENABLE = | ||
| TRNG_RND_SOURCE_ENABLE_RND_SRC_EN_Msk; | ||
| continue; |
| * entropy block before failing | ||
| * default: 1000000 | ||
| */ | ||
| #include "va416xx.h" |
Comment on lines
+5226
to
+5228
| #ifndef WOLFSSL_VA416X0_TRNG_SAMPLE_CNT | ||
| #define WOLFSSL_VA416X0_TRNG_SAMPLE_CNT 1000 | ||
| #endif |
Comment on lines
972
to
974
| WOLF_CRYPTO_CB_CMD | ||
| WOLF_CRYPTO_CB_NO_SHA512_FALLBACK | ||
| WOLF_CRYPTO_CB_ONLY_SHA512 | ||
| WOLF_CRYPTO_DEV | ||
| WOLF_NO_TRAILING_ENUM_COMMAS |
Comment on lines
+5269
to
+5286
| if ((reg & (TRNG_ISR_AUTOCORR_ERR_Msk | | ||
| TRNG_ISR_CRNGT_ERR_Msk | | ||
| TRNG_ISR_VN_ERR_Msk)) != 0) { | ||
| /* health-test failure: stop, clear, re-collect */ | ||
| VOR_TRNG->RND_SOURCE_ENABLE = 0; | ||
| VOR_TRNG->ICR = TRNG_ICR_AUTOCORR_ERR_Msk | | ||
| TRNG_ICR_CRNGT_ERR_Msk | | ||
| TRNG_ICR_VN_ERR_Msk; | ||
| if (++retry > WOLFSSL_VA416X0_TRNG_MAX_RETRY) { | ||
| ForceZero(ehr, sizeof(ehr)); | ||
| wolfSSL_CryptHwMutexUnLock(); | ||
| return RNG_FAILURE_E; | ||
| } | ||
| timeout = WOLFSSL_VA416X0_TRNG_TIMEOUT; | ||
| VOR_TRNG->RND_SOURCE_ENABLE = | ||
| TRNG_RND_SOURCE_ENABLE_RND_SRC_EN_Msk; | ||
| continue; | ||
| } |
Comment on lines
+5188
to
+5190
| * it is accessed at the register level below. The tuning macros | ||
| * (WOLFSSL_VA416X0_TRNG_SAMPLE_CNT / _MAX_RETRY / _TIMEOUT) are documented | ||
| * with the other Hardware RNG build options at the top of this file. |
Comment on lines
+5253
to
+5257
| /* select ring-oscillator source, set sample rate, keep health | ||
| * tests enabled (no DEBUG_CONTROL bypass) */ | ||
| VOR_TRNG->CONFIG = 0; | ||
| VOR_TRNG->SAMPLE_CNT1 = WOLFSSL_VA416X0_TRNG_SAMPLE_CNT; | ||
| VOR_TRNG->DEBUG_CONTROL = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Vorago VA416x0 hardware TRNG support
Adds a
wc_GenerateSeed()implementation for the Vorago VA416x0 (Cortex-M4F) on-chip True Random Number Generator, gated by a newWOLFSSL_VA416X0_TRNGbuild macro. The TRNG is an Arm CryptoCell-style entropy block (192-bit EHR, ring-oscillator source, Von-Neumann / CRNGT / autocorrelation health tests), accessed register-only via the VA416xx SDK (va416xx.h); no SDK HAL driver exists for it.Because the TRNG produces only ~1.25 kb/s of entropy, it is used as a seed source for the SP800-90A Hash-DRBG (keep
HAVE_HASHDRBGon), not for bulk generation.Usage
Optional tuning defines (with defaults):
WOLFSSL_VA416X0_TRNG_SAMPLE_CNT(1000),WOLFSSL_VA416X0_TRNG_MAX_RETRY(10),WOLFSSL_VA416X0_TRNG_TIMEOUT(1000000).Notes
PERIPHERAL_RESET(active-low) before use; without this, all TRNG register writes are silently ignored.MAX_RETRYtimes; a per-block poll cap returnsRNG_FAILURE_Einstead of hanging.ForceZero().Testing
Validated on the VA416XX EVK (J-Link/SWD) via the wolfBoot test-app with
WOLFCRYPT_TEST=1: wolfCryptRANDOM test passed!(DRBG instantiate + SP800-90A health checks), alongside the SHA and ECC self-tests.