|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RSIP-E50D device-security path (lifecycle / debug / tamper / DPA), fail-closed. More...
#include <stdint.h>#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_rsip.h"#include "ra8_rsip_regs.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_rsip_life_get (ra8_rsip_life_state_t *out) |
| Read the device-lifecycle state. | |
| ra8_err_t | ra8_rsip_life_advance (ra8_rsip_life_state_t state) |
| Advance the device lifecycle to a new state. | |
| ra8_err_t | ra8_rsip_debug_level_get (ra8_rsip_debug_level_t *out) |
| Read the current debug authorisation level. | |
| ra8_err_t | ra8_rsip_debug_level_set (ra8_rsip_debug_level_t level) |
| Set the debug authorisation level. | |
| ra8_err_t | ra8_rsip_tamper_enable (uint32_t sources) |
| Enable or disable a set of tamper sources. | |
| ra8_err_t | ra8_rsip_tamper_status (uint32_t *out) |
| Read latched tamper-source flags. | |
| ra8_err_t | ra8_rsip_tamper_ack (uint32_t mask) |
| Acknowledge tamper-source flags (write-1-to-clear). | |
| ra8_err_t | ra8_rsip_dpa_arm (bool enable) |
| Arm or disarm SPA / DPA countermeasures. | |
Variables | |
| static const char * | s_tag = "RSIP" |
| Logger tag used by every ra8_log_* call in this TU. | |
RSIP-E50D device-security path (lifecycle / debug / tamper / DPA), fail-closed.
Device-security slice of the RA8D2 RSIP-E50D HAL: the device-lifecycle state, the three debug-authorisation levels (AL0/AL1/AL2), the tamper subsystem, and the SPA / DPA side-channel arm. It was split out of ra8_rsip_asym.c (issue #216) both to keep every translation unit under the file-size budget and because this cluster is FAIL-CLOSED for a reason distinct from the hash / key fiction in ra8_rsip_asym.c.
These functions used to drive an invented "RSIP security-state" register block (LIFE_STATE @ 0xC0, DEBUG_LEVEL @ 0xC4, TAMPER_CTRL @ 0x14, TAMPER_STATUS @ 0x18, DPA_CTRL @ 0x1C, CTRL.DPA_ARM) inside the RSIP window (base 0x403B0000) and cited HUM Ch 51 "Security Features". That register model is fiction, verified against the manual for issue #216:
The real RA8D2 device-security state does NOT live behind an RSIP MMIO read: the device lifecycle and the secure-debug (AL0/AL1/AL2) authorisation are governed by Device Lifecycle Management (DLM) via the debug / serial- programming interface and the option-setting memory, the TrustZone boundary by the SAU / IDAU registers, and tamper response by the RTC / MRAM / VBATT blocks. A security-state query that fabricates a plausible-looking "secure" answer is worse than one that refuses – a caller could trust a lie about the lifecycle or debug level – so every entry point here FAILS CLOSED in a production build: it returns k_ra8_err_not_supported and writes no fabricated state. The insecure off-target command path (which only round-trips the register fake) is retained behind the established stub-crypto guard so ra8_rsip_devsec.c is enforced by check_stub_crypto_guarded.py; a production image compiles the fail-closed #else and can never mistake the fake bytes for a real lifecycle / debug / tamper state.
Definition in file ra8_rsip_devsec.c.
|
nodiscard |
Read the current debug authorisation level.
| [out] | out | Receives the level (AL0/AL1/AL2). |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out was NULL. |
Definition at line 199 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Set the debug authorisation level.
| [in] | level | Target level. |
| k_ra8_ok | Level applied. |
| k_ra8_err_invalid_arg | level out of range. |
Definition at line 205 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported.
|
nodiscard |
Arm or disarm SPA / DPA countermeasures.
| [in] | enable | true to arm, false to disarm. |
| k_ra8_ok | Done. |
Definition at line 229 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported.
|
nodiscard |
Advance the device lifecycle to a new state.
Lifecycle transitions are one-way (HUM Ch 51.1 p 3263). The engine rejects backward moves with k_ra8_err_invalid_state.
| [in] | state | Target lifecycle state. |
| k_ra8_ok | Transition complete. |
| k_ra8_err_invalid_arg | Unknown state. |
| k_ra8_err_invalid_state | Transition would move backward. |
| k_ra8_err_hw_timeout | Engine never signalled DONE. |
Definition at line 193 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported.
|
nodiscard |
Read the device-lifecycle state.
| [out] | out | Receives the lifecycle word. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out was NULL. |
Definition at line 187 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Acknowledge tamper-source flags (write-1-to-clear).
| [in] | mask | Bits to clear. |
| k_ra8_ok | Bits cleared. |
| k_ra8_err_invalid_arg | mask had bits outside the field. |
Definition at line 223 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported.
|
nodiscard |
Enable or disable a set of tamper sources.
| [in] | sources | OR of k_ra8_rsip_tamper_src_* bits to enable. |
| k_ra8_ok | Mask applied. |
| k_ra8_err_invalid_arg | sources has bits outside the documented mask. |
Definition at line 211 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported.
|
nodiscard |
Read latched tamper-source flags.
| [out] | out | Receives the flag word. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out was NULL. |
Definition at line 217 of file ra8_rsip_devsec.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
static |
Logger tag used by every ra8_log_* call in this TU.
Kept short ("RSIP") so it fits in the fixed-width log prefix without truncation. Each RSIP translation unit keeps its own private copy.
Definition at line 82 of file ra8_rsip_devsec.c.