|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
On-silicon FIPS 180-4 known-answer test for the RSIP HASH engine. More...
#include <stdint.h>#include <string.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_rsip_core.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | kat_const_t : uint32_t { k_kat_baud = 115200U , k_kat_period_ms = 1000U } |
| Demo tunables. More... | |
| enum | kat_msg_len_t : uint8_t { k_kat_msg2_len = 56U } |
| Length of the 56-byte NIST two-block message (excludes the NUL). More... | |
Functions | |
| static void | internal_kat_panic_halt (void) |
| Park the processor after fatal setup or KAT control-flow failure. | |
| static void | internal_kat_setup_or_halt (void) |
| Initialize clocks, timing, console, and status LEDs for the KAT. | |
| static bool | internal_kat_one (const uint8_t *msg, uint32_t len, const uint8_t *expect) |
| Hash one message on the RSIP engine and compare to a known answer. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_msg_abc [] = {'a', 'b', 'c'} |
| NIST vector 2 input: "abc". | |
| static const uint8_t | s_msg_two_block [] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" |
| NIST vector 3 input: the 448-bit two-block message. | |
| static const uint8_t | s_exp_empty [k_ra8_rsip_sha256_digest_bytes] |
| Expected SHA-256("") – FIPS 180-4. | |
| static const uint8_t | s_exp_abc [k_ra8_rsip_sha256_digest_bytes] |
| Expected SHA-256("abc") – FIPS 180-4. | |
| static const uint8_t | s_exp_two_block [k_ra8_rsip_sha256_digest_bytes] |
| Expected SHA-256(56-byte two-block message) – FIPS 180-4. | |
| static const uint8_t | s_kat_msg_ok [] = "rsip sha256: KAT OK\r\n" |
| HIL verdict emitted after all SHA-256 vectors pass. | |
| static const uint8_t | s_kat_msg_fail [] = "rsip sha256: KAT FAIL\r\n" |
| HIL verdict emitted after one or more SHA-256 vectors fail. | |
On-silicon FIPS 180-4 known-answer test for the RSIP HASH engine.
Validates ra8_rsip_sha256 – the exact primitive ra8_rot uses to re-compute an image digest on silicon – against the published FIPS 180-4 NIST vectors, running on the real EK-RA8D2 hardware. ra8_rsip_sha256 is backed by the in-tree software SHA-256: the RSIP-E50D HASH hardware has no usable register interface (HUM Ch 52 documents none) and is non-functional on silicon – this app first proved that, then the driver was fixed to route the digest through software (see libs/ra8_hal/src/ra8_rsip.c). The software backend is the working implementation until the FSP procedural RSIP driver is ported.
Vectors (FIPS 180-4):
Reporting:
Definition in file main.c.
| enum kat_const_t : uint32_t |
| enum kat_msg_len_t : uint8_t |
|
staticnodiscard |
Hash one message on the RSIP engine and compare to a known answer.
Computes a bounded SHA-256 digest into local storage and compares all digest bytes with the supplied FIPS 180-4 known answer.
| [in] | msg | Message bytes; may be NULL only when len is 0. |
| [in] | len | Message length in bytes. |
| [in] | expect | k_ra8_rsip_sha256_digest_bytes expected digest; non-NULL. |
expect exactly. | true | Hashing succeeded and every digest byte matched expect. |
| false | Hashing failed or at least one digest byte differed. |
expect addresses k_ra8_rsip_sha256_digest_bytes readable bytes. Definition at line 170 of file main.c.
References k_ra8_ok, k_ra8_rsip_sha256_digest_bytes, memcmp(), and ra8_rsip_sha256().
Referenced by main().
|
static |
Park the processor after fatal setup or KAT control-flow failure.
Executes wait-for-interrupt indefinitely, preventing any failed diagnostic state from returning into normal application execution.
Definition at line 102 of file main.c.
References RA8_INTERNAL.
Referenced by internal_kat_setup_or_halt(), and main().
|
static |
Initialize clocks, timing, console, and status LEDs for the KAT.
Brings each prerequisite up in dependency order and transfers to internal_kat_panic_halt if any required operation fails.
Definition at line 122 of file main.c.
References internal_kat_panic_halt(), k_kat_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Definition at line 179 of file main.c.
References internal_kat_one(), internal_kat_panic_halt(), internal_kat_setup_or_halt(), k_kat_msg2_len, k_kat_period_ms, k_ra8_board_led1, k_ra8_board_led2, ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), s_exp_abc, s_exp_empty, s_exp_two_block, s_kat_msg_fail, s_kat_msg_ok, s_msg_abc, and s_msg_two_block.
|
static |
Expected SHA-256("abc") – FIPS 180-4.
Definition at line 70 of file main.c.
Referenced by main().
|
static |
Expected SHA-256("") – FIPS 180-4.
Definition at line 63 of file main.c.
Referenced by main().
|
static |
Expected SHA-256(56-byte two-block message) – FIPS 180-4.
Definition at line 77 of file main.c.
Referenced by main().
|
static |
|
static |
|
static |