|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Renesas Secure IP (RSIP-E50D) HAL driver implementation. More...
#include "ra8_rsip.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_hw_err.h"#include "ra8_log.h"#include "ra8_mstp.h"#include "ra8_rsip_internal.h"#include "ra8_rsip_regs.h"Go to the source code of this file.
Macros | |
| #define | RA8_RSIP_SOFTWARE_BACKEND (1) |
| RA8 RSIP SOFTWARE BACKEND. | |
Functions | |
| static void | internal_sw_sha256 (const uint8_t *msg, uint32_t msg_len, uint8_t *digest) |
| One-shot software SHA-256 over a contiguous message buffer. | |
| ra8_err_t | priv_wait_bit (ra8_rsip_off_t offset, uint32_t mask) |
| Implementation of priv_wait_bit() – bounded MMIO mask spin. | |
| static ra8_err_t | internal_run_bist (void) |
| Arm the BIST and wait for STATUS.BIST_OK. | |
| ra8_err_t | priv_hash_wait_done (void) |
| Wait for the HASH engine to raise DONE after the trailing block. | |
| ra8_err_t | ra8_rsip_init (const ra8_rsip_config_t *cfg) |
| Power on the RSIP engine and (optionally) run BIST. | |
| ra8_err_t | ra8_rsip_deinit (void) |
| Power off the RSIP engine. | |
| ra8_err_t | ra8_rsip_get_status (uint32_t *out) |
| Snapshot the STATUS mailbox word. | |
| ra8_err_t | ra8_rsip_clear_status (uint32_t mask) |
| Acknowledge ISR bits via write-1-to-clear. | |
| ra8_err_t | ra8_rsip_attach_handler (ra8_rsip_event_fn_t fn, void *ctx) |
| Attach a single shared interrupt callback. | |
| void | ra8_rsip_dispatch (void) |
| Run the attached callback with the current ISR snapshot. | |
| ra8_err_t | ra8_rsip_trng_read (uint8_t *buf, uint32_t len) |
| Drain len bytes from the RSIP true RNG – fail-closed, no backend. | |
| ra8_err_t | ra8_rsip_sha256 (const uint8_t *msg, uint32_t msg_len, uint8_t *digest) |
| Compute SHA-256 of an in-memory buffer. | |
| static uint32_t | internal_sw_rotr (uint32_t x, uint32_t n) |
| static void | internal_sw_sha256_schedule (uint32_t w[k_ra8_rsip_sw_sha256_round_cnt], const uint8_t block[k_ra8_rsip_sha256_block]) |
| static void | internal_sw_sha256_rounds (uint32_t s[k_ra8_rsip_sw_sha256_state_w], const uint32_t w[k_ra8_rsip_sw_sha256_round_cnt]) |
| Run the 64-round SHA-256 compression loop over one message schedule. | |
| static void | internal_sw_sha256_compress (uint32_t state[k_ra8_rsip_sw_sha256_state_w], const uint8_t block[k_ra8_rsip_sha256_block]) |
| static void | internal_sw_sha256_finalize (ra8_rsip_sha256_ctx_t *ctx) |
| Finalize one streaming SHA-256 chaining state. | |
| static void | internal_sw_sha256_emit (const uint32_t state[k_ra8_rsip_sw_sha256_state_w], uint8_t *digest) |
| static ra8_err_t | internal_sha256_dispatch (const uint8_t *msg, uint32_t msg_len, uint8_t *digest) |
| ra8_err_t | ra8_rsip_sha256_init (ra8_rsip_sha256_ctx_t *ctx) |
| Initialise a streaming SHA-256 context. | |
| ra8_err_t | ra8_rsip_sha256_update (ra8_rsip_sha256_ctx_t *ctx, const uint8_t *data, uint32_t len) |
| Absorb additional bytes into a streaming SHA-256 context. | |
| ra8_err_t | ra8_rsip_sha256_final (ra8_rsip_sha256_ctx_t *ctx, uint8_t *digest_out) |
| Emit the digest of a streaming SHA-256 context. | |
| static ra8_err_t | internal_hmac_prep_key (const uint8_t *key, uint32_t key_len, uint8_t block[k_ra8_rsip_sha256_block]) |
| ra8_err_t | ra8_rsip_hmac_sha256_init (ra8_rsip_hmac_sha256_ctx_t *ctx, const uint8_t *key, uint32_t key_len) |
| Initialise a streaming HMAC-SHA-256 context. | |
| ra8_err_t | ra8_rsip_hmac_sha256_update (ra8_rsip_hmac_sha256_ctx_t *ctx, const uint8_t *data, uint32_t len) |
| Absorb additional bytes into a streaming HMAC-SHA-256 context. | |
| static ra8_err_t | internal_hmac_outer (const uint8_t key_block[k_ra8_rsip_sha256_block], const uint8_t inner[k_ra8_rsip_sha256_digest_bytes], uint8_t *mac_out) |
| Compute SHA256(K_opad || inner_digest) for HMAC. | |
| ra8_err_t | ra8_rsip_hmac_sha256_final (ra8_rsip_hmac_sha256_ctx_t *ctx, uint8_t *mac_out) |
| Emit the MAC of a streaming HMAC-SHA-256 context. | |
| ra8_err_t | ra8_rsip_enter_stop (void) |
| Park the engine for software-standby entry. | |
| ra8_err_t | ra8_rsip_exit_stop (void) |
| Re-enable the engine after software-standby exit. | |
Variables | |
| static const char * | s_tag = "RSIP" |
| Logger tag used by every ra8_log_* call in this TU. | |
| static ra8_rsip_event_fn_t | s_rsip_fn |
| Currently attached interrupt callback, or nullptr. | |
| static void * | s_rsip_ctx |
| Caller context paired with s_rsip_fn. | |
| static const uint32_t | s_sw_sha256_k [k_ra8_rsip_sw_sha256_round_cnt] |
| FIPS PUB 180-4 Section 4.1.2 SHA-256 round constants K[0..63]. | |
| static const uint32_t | s_sw_sha256_h0 [k_ra8_rsip_sw_sha256_state_w] |
| FIPS PUB 180-4 Section 5.3.3 initial hash value H(0). | |
Renesas Secure IP (RSIP-E50D) HAL driver implementation.
Round-3 driver for the RA8D2 RSIP-E50D engine covering the full HUM Ch 51 (Security Features p 3263-3301) + Ch 52 (RSIP-E50D mailbox p 3302-3307) surface:
The engine itself is opaque (HUM Ch 52, p 3302-3307); sequences here are derived from the FSP RSIP primitive layer but no FSP code is included verbatim.
The host unit-test build runs every register access through ra8_fake_mmap-backed pages and routes the bounded BIST / DONE polls through the ra8_fake_mmio wait seam (issue #238): an unarmed register satisfies its wait on the first poll, and a test arms ra8_fake_mmio_fail_wait / ra8_fake_mmio_satisfy_after to drive the timeout / continuation legs of the real loop. The driver itself runs the identical register sequence on every build and never forges an engine-side status bit.
Definition in file ra8_rsip.c.
| #define RA8_RSIP_SOFTWARE_BACKEND (1) |
RA8 RSIP SOFTWARE BACKEND.
Definition at line 76 of file ra8_rsip.c.
| enum ra8_rsip_sw_sha256_t : uint32_t |
File-private constants for the software SHA-256 fall-back.
Used only when RA8_RSIP_SOFTWARE_BACKEND is defined. Values are straight FIPS PUB 180-4 Section 4.2.2 / 6.2.1 references.
Definition at line 450 of file ra8_rsip.c.
| enum sha256_lane_t : uint8_t |
FIPS 180-4 6.2.2 SHA-256 working-state lane indices a..h.
Definition at line 546 of file ra8_rsip.c.
|
static |
Compute SHA256(K_opad || inner_digest) for HMAC.
Uses a stack-local 96-byte buffer (K_opad + inner_digest = 64 + 32) directly through internal_sha256_dispatch. The dispatcher's streaming context retains only one partial SHA-256 block, so this composition remains comfortably inside the firmware's 2200-byte stack ceiling.
| [in] | key_block | 64-byte prepared HMAC key block. |
| [in] | inner | 32-byte inner-hash digest. |
| [out] | mac_out | 32-byte MAC output buffer. |
| k_ra8_ok | Operation completed successfully. |
| other | Non-zero error code from the underlying operation. |
Definition at line 910 of file ra8_rsip.c.
References internal_sha256_dispatch(), k_ra8_rsip_hmac_outer_pad, k_ra8_rsip_sha256_block, and k_ra8_rsip_sha256_digest_bytes.
Referenced by ra8_rsip_hmac_sha256_final().
|
static |
Definition at line 823 of file ra8_rsip.c.
References internal_sha256_dispatch(), k_ra8_ok, k_ra8_rsip_sha256_block, and k_ra8_rsip_sha256_digest_bytes.
Referenced by ra8_rsip_hmac_sha256_init().
|
static |
Arm the BIST and wait for STATUS.BIST_OK.
Sets CTRL.BIST and spins on STATUS.BIST_OK, which the access-management circuit asserts once the on-board firmware finishes the self-test. The driver never forges the bit itself: on the host build the bounded wait routes through the ra8_fake_mmio seam (unarmed = pass on the first poll; a test arms ra8_fake_mmio_fail_wait to reach the failure leg).
| k_ra8_ok | Operation completed successfully. |
| other | Non-zero error code from the underlying operation. |
Definition at line 166 of file ra8_rsip.c.
References k_ra8_err_hw_init_failed, k_ra8_ok, k_ra8_rsip_mask_ctrl_bist, k_ra8_rsip_mask_status_bistok, k_ra8_rsip_off_ctrl, k_ra8_rsip_off_status, priv_wait_bit(), and ra8_rsip_reg32().
Referenced by ra8_rsip_exit_stop(), and ra8_rsip_init().
|
static |
Definition at line 736 of file ra8_rsip.c.
References internal_sw_sha256(), k_ra8_ok, and ra8_rsip_sha256().
Referenced by internal_hmac_outer(), and internal_hmac_prep_key().
|
inlinestatic |
Definition at line 477 of file ra8_rsip.c.
References k_ra8_rsip_sw_word_bits.
Referenced by internal_sw_sha256_rounds(), and internal_sw_sha256_schedule().
|
static |
One-shot software SHA-256 over a contiguous message buffer.
Pure-software FIPS PUB 180-4 SHA-256 and the only working RSIP HASH backend: seeds the eight-word hash state from the standard initial constants (s_sw_sha256_h0), folds in each full 64-byte block through internal_sw_sha256_compress, length-pads and compresses the trailing partial block via internal_sw_sha256_pad, then serialises the state as a big-endian 32-byte digest with internal_sw_sha256_emit. Compiled under RA8_RSIP_SOFTWARE_BACKEND; a forward declaration near the top of the file lets the earlier ra8_rsip_sha256 dispatch to it so the RoT image digest works on silicon.
| [in] | msg | Message bytes to hash; read-only, msg_len bytes long. |
| [in] | msg_len | Message length in bytes. |
| [out] | digest | Output buffer receiving the 32-byte big-endian digest. |
Definition at line 724 of file ra8_rsip.c.
References ra8_rsip_sha256_final(), ra8_rsip_sha256_init(), and ra8_rsip_sha256_update().
Referenced by internal_sha256_dispatch(), and ra8_rsip_sha256().
|
static |
Definition at line 623 of file ra8_rsip.c.
References internal_sw_sha256_rounds(), internal_sw_sha256_schedule(), k_ra8_rsip_sha256_block, k_ra8_rsip_sw_sha256_round_cnt, and k_ra8_rsip_sw_sha256_state_w.
Referenced by internal_sw_sha256_finalize(), and ra8_rsip_sha256_update().
|
static |
Definition at line 681 of file ra8_rsip.c.
References k_ra8_rsip_byte_bits, k_ra8_rsip_byte_mask, k_ra8_rsip_byte_shift_2, k_ra8_rsip_byte_shift_3, k_ra8_rsip_sw_sha256_state_w, and k_ra8_rsip_trng_word_bytes.
Referenced by ra8_rsip_sha256_final().
|
static |
Finalize one streaming SHA-256 chaining state.
Appends the FIPS 180-4 marker, zero padding, and big-endian 64-bit message length, compressing one or two final blocks as required.
| [in,out] | ctx | Initialized streaming context to pad and compress. |
Definition at line 657 of file ra8_rsip.c.
References ra8_rsip_sha256_ctx_t::block, internal_sw_sha256_compress(), k_ra8_rsip_byte_bits, k_ra8_rsip_byte_mask, k_ra8_rsip_sha256_block, k_ra8_rsip_sw_sha256_len_bytes, k_ra8_rsip_sw_sha256_pad_byte, ra8_rsip_sha256_ctx_t::state, ra8_rsip_sha256_ctx_t::total_bytes, and ra8_rsip_sha256_ctx_t::used.
Referenced by ra8_rsip_sha256_final().
|
static |
Run the 64-round SHA-256 compression loop over one message schedule.
FIPS PUB 180-4 Section 6.2.2: copies the eight working-state lanes a..h out of the hash state, iterates the round function across the expanded message schedule plus the round constants, and folds the results back into the state in place. Pure software fallback used when the RSIP hardware path is unavailable.
| [in,out] | s | Eight-word SHA-256 hash state (lanes a..h), updated in place. |
| [in] | w | Expanded 64-word message schedule for the current block. |
Definition at line 578 of file ra8_rsip.c.
References internal_sw_rotr(), k_ra8_rsip_sw_rotr_11, k_ra8_rsip_sw_rotr_13, k_ra8_rsip_sw_rotr_2, k_ra8_rsip_sw_rotr_22, k_ra8_rsip_sw_rotr_25, k_ra8_rsip_sw_rotr_6, k_ra8_rsip_sw_sha256_round_cnt, k_ra8_rsip_sw_sha256_state_w, k_sha256_lane_a, k_sha256_lane_b, k_sha256_lane_c, k_sha256_lane_d, k_sha256_lane_e, k_sha256_lane_f, k_sha256_lane_g, k_sha256_lane_h, and s_sw_sha256_k.
Referenced by internal_sw_sha256_compress().
|
static |
Definition at line 522 of file ra8_rsip.c.
References internal_sw_rotr(), k_ra8_rsip_byte_bits, k_ra8_rsip_byte_shift_2, k_ra8_rsip_byte_shift_3, k_ra8_rsip_sha256_block, k_ra8_rsip_sw_rotr_10, k_ra8_rsip_sw_rotr_17, k_ra8_rsip_sw_rotr_18, k_ra8_rsip_sw_rotr_19, k_ra8_rsip_sw_rotr_3, k_ra8_rsip_sw_rotr_7, k_ra8_rsip_sw_sha256_block_w, k_ra8_rsip_sw_sha256_round_cnt, k_ra8_rsip_sw_sha256_w_back_15, k_ra8_rsip_sw_sha256_w_back_16, k_ra8_rsip_sw_sha256_w_back_2, k_ra8_rsip_sw_sha256_w_back_7, and k_ra8_rsip_trng_word_bytes.
Referenced by internal_sw_sha256_compress().
| ra8_err_t priv_hash_wait_done | ( | void | ) |
Wait for the HASH engine to raise DONE after the trailing block.
On hardware the engine raises HASH_STATUS.DONE once it absorbs the trailing block + length. The bounded wait routes through the host ra8_fake_mmio seam inside priv_wait_bit (never forged by the driver). Defined in ra8_rsip.c; shared with the generic hash / HMAC path in ra8_rsip_cipher.c.
| k_ra8_ok | Operation completed successfully. |
| other | Non-zero error code from the underlying operation. |
Definition at line 204 of file ra8_rsip.c.
References k_ra8_rsip_mask_isr_done, k_ra8_rsip_off_hash_status, and priv_wait_bit().
Referenced by ra8_rsip_sha256().
| ra8_err_t priv_wait_bit | ( | ra8_rsip_off_t | offset, |
| uint32_t | mask ) |
Implementation of priv_wait_bit() – bounded MMIO mask spin.
Spin until mask is set in the register at offset.
Definition at line 120 of file ra8_rsip.c.
References k_ra8_err_hw_timeout, k_ra8_ok, k_ra8_rsip_poll_budget, and ra8_rsip_reg32().
Referenced by internal_run_bist(), priv_complete(), priv_hash_wait_done(), ra8_rsip_sha256(), and ra8_rsip_trng_read().
|
nodiscard |
Attach a single shared interrupt callback.
The RSIP routes a small number of edge-triggered events (DONE / RND / HASH / TAMPER) into one peripheral IRQ line. The driver fans them out by passing the live ISR snapshot to a single callback.
| [in] | fn | Callback fired by ra8_rsip_dispatch; may be NULL to detach. |
| [in] | ctx | Opaque context forwarded to fn. |
| k_ra8_ok | Callback installed. |
Definition at line 307 of file ra8_rsip.c.
References k_ra8_ok, s_rsip_ctx, and s_rsip_fn.
|
nodiscard |
Acknowledge ISR bits via write-1-to-clear.
Writes mask to the ISR register; only the bits listed in k_ra8_rsip_mask_isr_* are valid. The write masks unrelated bits before issuing.
| [in] | mask | OR of k_ra8_rsip_mask_isr_* values. |
| k_ra8_ok | Bits cleared. |
| k_ra8_err_invalid_arg | mask had bits outside the ISR field. |
Definition at line 293 of file ra8_rsip.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rsip_mask_isr_all, k_ra8_rsip_off_isr, and ra8_rsip_reg32().
|
nodiscard |
Power off the RSIP engine.
Clears CTRL.ENABLE, scrubs any pending ISR bits, releases the shared callback slot, and asks ra8_mstp to gate MSTPC31.
| k_ra8_ok | Engine gated. |
| k_ra8_err_invalid_state | ra8_mstp had no matching enable. |
| k_ra8_err_hw_timeout | MSTP read-back loop expired. |
Definition at line 267 of file ra8_rsip.c.
References k_ra8_mstp_rsip, k_ra8_rsip_mask_isr_all, k_ra8_rsip_off_ctrl, k_ra8_rsip_off_isr, ra8_mstp_disable(), ra8_rsip_reg32(), s_rsip_ctx, and s_rsip_fn.
| void ra8_rsip_dispatch | ( | void | ) |
Run the attached callback with the current ISR snapshot.
Called from the secure-world ICU dispatch when the RSIP IRQ fires. Reads the live ISR word, fires the registered callback (if any), and acks the bits the callback observed via ra8_rsip_clear_status.
Definition at line 315 of file ra8_rsip.c.
References k_ra8_rsip_off_isr, ra8_rsip_reg32(), s_rsip_ctx, and s_rsip_fn.
|
nodiscard |
Park the engine for software-standby entry.
HUM Ch 52.3.1 p 3307 ("Software Standby Mode") requires the engine to be idle before software-standby; this helper clears CTRL.ENABLE then gates MSTPC31.
| k_ra8_ok | Engine parked. |
| k_ra8_err_invalid_state | ra8_mstp had no matching enable. |
| k_ra8_err_hw_timeout | MSTP read-back loop expired. |
Definition at line 947 of file ra8_rsip.c.
References k_ra8_mstp_rsip, k_ra8_rsip_off_ctrl, ra8_mstp_disable(), and ra8_rsip_reg32().
|
nodiscard |
Re-enable the engine after software-standby exit.
Calls ra8_mstp_enable to clock the block, sets CTRL.ENABLE, and re-runs BIST so a side-channel injection during standby does not silently leak.
| k_ra8_ok | Engine ready, BIST passed. |
| k_ra8_err_hw_init_failed | BIST did not pass. |
| k_ra8_err_hw_timeout | MSTP read-back loop expired. |
Definition at line 955 of file ra8_rsip.c.
References internal_run_bist(), k_ra8_mstp_rsip, k_ra8_ok, k_ra8_rsip_mask_ctrl_enable, k_ra8_rsip_off_ctrl, ra8_mstp_disable(), ra8_mstp_enable(), RA8_RETURN_ON_ERROR, ra8_rsip_reg32(), and s_tag.
|
nodiscard |
Snapshot the STATUS mailbox word.
| [out] | out | Receives the raw STATUS word; never NULL. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out was nullptr. |
Definition at line 284 of file ra8_rsip.c.
References k_ra8_ok, k_ra8_rsip_off_status, RA8_CHECK_NULL_PTR, ra8_rsip_reg32(), and s_tag.
|
nodiscard |
Emit the MAC of a streaming HMAC-SHA-256 context.
| [in,out] | ctx | Context populated by prior update() calls. |
| [out] | mac_out | 32-byte MAC output buffer; never NULL. |
| k_ra8_ok | MAC written. |
| k_ra8_err_null_ptr | ctx or mac_out was nullptr. |
| k_ra8_err_invalid_state | ctx was not initialized. |
| k_ra8_err_hw_timeout | Either SHA pass timed out. |
Definition at line 927 of file ra8_rsip.c.
References ra8_rsip_hmac_sha256_ctx_t::initialized, ra8_rsip_hmac_sha256_ctx_t::inner, internal_hmac_outer(), k_ra8_err_invalid_state, k_ra8_ok, k_ra8_rsip_sha256_block, k_ra8_rsip_sha256_digest_bytes, ra8_rsip_hmac_sha256_ctx_t::key_block, RA8_CHECK_NULL_PTR, ra8_rsip_sha256_final(), and s_tag.
|
nodiscard |
Initialise a streaming HMAC-SHA-256 context.
| [out] | ctx | Streaming HMAC state; never NULL. |
| [in] | key | HMAC key bytes; never NULL when key_len > 0. |
| [in] | key_len | Length of key in bytes (may be 0). |
| k_ra8_ok | Context ready. |
| k_ra8_err_null_ptr | ctx was nullptr or key was NULL with non-zero key_len. |
| k_ra8_err_hw_timeout | Internal SHA collapse of an oversized key timed out. |
Definition at line 846 of file ra8_rsip.c.
References ra8_rsip_hmac_sha256_ctx_t::initialized, ra8_rsip_sha256_ctx_t::initialized, ra8_rsip_hmac_sha256_ctx_t::inner, internal_hmac_prep_key(), k_ra8_err_null_ptr, k_ra8_ok, k_ra8_rsip_hmac_inner_pad, k_ra8_rsip_sha256_block, ra8_rsip_hmac_sha256_ctx_t::key_block, RA8_CHECK_NULL_PTR, ra8_rsip_sha256_init(), ra8_rsip_sha256_update(), and s_tag.
|
nodiscard |
Absorb additional bytes into a streaming HMAC-SHA-256 context.
| [in,out] | ctx | Context primed by ra8_rsip_hmac_sha256_init. |
| [in] | data | Bytes to absorb; may be NULL only if len is 0. |
| [in] | len | Number of bytes in data. |
| k_ra8_ok | Bytes accumulated. |
| k_ra8_err_null_ptr | ctx was nullptr or data NULL with non-zero len. |
| k_ra8_err_invalid_state | ctx was not initialized. |
| k_ra8_err_invalid_size | Cumulative input exceeds SHA-256's encoded length range. |
Definition at line 874 of file ra8_rsip.c.
References ra8_rsip_hmac_sha256_ctx_t::initialized, ra8_rsip_hmac_sha256_ctx_t::inner, k_ra8_err_invalid_state, RA8_CHECK_NULL_PTR, ra8_rsip_sha256_update(), and s_tag.
|
nodiscard |
Power on the RSIP engine and (optionally) run BIST.
Sequence:
| [in] | cfg | Non-NULL configuration descriptor. |
| k_ra8_ok | Engine ready, BIST passed. |
| k_ra8_err_null_ptr | cfg was nullptr. |
| k_ra8_err_hw_init_failed | BIST did not pass within budget. |
Definition at line 234 of file ra8_rsip.c.
References internal_run_bist(), k_ra8_mstp_rsip, k_ra8_ok, k_ra8_rsip_mask_ctrl_enable, k_ra8_rsip_mask_ctrl_reset, k_ra8_rsip_mask_isr_all, k_ra8_rsip_off_ctrl, k_ra8_rsip_off_isr, RA8_CHECK_NULL_PTR, ra8_log_info, ra8_mstp_disable(), ra8_mstp_enable(), RA8_RETURN_ON_ERROR, ra8_rsip_reg32(), ra8_rsip_config_t::run_bist, and s_tag.
Referenced by demo_setup_or_halt(), internal_demo_setup_or_halt(), and internal_run().
|
nodiscard |
Compute SHA-256 of an in-memory buffer.
Streams msg through the HASH engine 32 bits at a time, then reads back the 8-word (32-byte) digest from HASH_DIGEST. Algorithm select is hard-wired to k_ra8_rsip_hash_sha256. Suitable for short messages; incremental update / final API is deferred to a future revision.
| [in] | msg | Pointer to the input buffer; never NULL. |
| [in] | msg_len | Length of msg in bytes; may be 0. |
| [out] | digest | 32-byte output buffer; never NULL. |
| k_ra8_ok | Digest written. |
| k_ra8_err_null_ptr | msg or digest was nullptr. |
| k_ra8_err_hw_timeout | HASH engine did not signal done. |
Definition at line 397 of file ra8_rsip.c.
References internal_sw_sha256(), k_ra8_ok, k_ra8_rsip_hash_sha256, k_ra8_rsip_mask_status_ready, k_ra8_rsip_off_hash_ctrl, k_ra8_rsip_off_hash_status, priv_hash_wait_done(), priv_wait_bit(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, ra8_rsip_reg32(), and s_tag.
Referenced by app_stage_images(), internal_demo_verify_cert_pin(), internal_kat_one(), and internal_sha256_dispatch().
|
nodiscard |
Emit the digest of a streaming SHA-256 context.
| [in,out] | ctx | Context populated by prior update() calls. |
| [out] | digest_out | 32-byte digest output buffer; never NULL. |
| k_ra8_ok | Digest written. |
| k_ra8_err_null_ptr | ctx or digest_out was nullptr. |
| k_ra8_err_invalid_state | ctx was not initialized. |
Definition at line 794 of file ra8_rsip.c.
References ra8_rsip_sha256_ctx_t::block, ra8_rsip_sha256_ctx_t::initialized, internal_sw_sha256_emit(), internal_sw_sha256_finalize(), k_ra8_err_invalid_state, k_ra8_ok, k_ra8_rsip_sha256_block, k_ra8_rsip_sha256_state_words, RA8_CHECK_NULL_PTR, s_tag, ra8_rsip_sha256_ctx_t::state, ra8_rsip_sha256_ctx_t::total_bytes, and ra8_rsip_sha256_ctx_t::used.
Referenced by app_sha_final(), internal_sha_final(), internal_sw_sha256(), and ra8_rsip_hmac_sha256_final().
|
nodiscard |
Initialise a streaming SHA-256 context.
| [out] | ctx | Streaming state; never NULL. |
| k_ra8_ok | Context ready for update(). |
| k_ra8_err_null_ptr | ctx was nullptr. |
Definition at line 747 of file ra8_rsip.c.
References ra8_rsip_sha256_ctx_t::initialized, k_ra8_ok, k_ra8_rsip_sha256_state_words, RA8_CHECK_NULL_PTR, s_sw_sha256_h0, s_tag, ra8_rsip_sha256_ctx_t::state, ra8_rsip_sha256_ctx_t::total_bytes, and ra8_rsip_sha256_ctx_t::used.
Referenced by app_sha_init(), internal_sha_init(), internal_sw_sha256(), and ra8_rsip_hmac_sha256_init().
|
nodiscard |
Absorb additional bytes into a streaming SHA-256 context.
| [in,out] | ctx | Context primed by ra8_rsip_sha256_init. |
| [in] | data | Bytes to absorb; may be NULL only if len is 0. |
| [in] | len | Number of bytes in data. |
| k_ra8_ok | Bytes compressed or retained. |
| k_ra8_err_null_ptr | ctx was nullptr or data was NULL with non-zero len. |
| k_ra8_err_invalid_state | ctx was not initialized. |
| k_ra8_err_invalid_size | Cumulative input cannot be represented by SHA-256's 64-bit bit-length field. |
Definition at line 759 of file ra8_rsip.c.
References ra8_rsip_sha256_ctx_t::block, ra8_rsip_sha256_ctx_t::initialized, internal_sw_sha256_compress(), k_ra8_err_invalid_size, k_ra8_err_invalid_state, k_ra8_err_null_ptr, k_ra8_ok, k_ra8_rsip_byte_bits, k_ra8_rsip_sha256_block, RA8_CHECK_NULL_PTR, s_tag, ra8_rsip_sha256_ctx_t::state, ra8_rsip_sha256_ctx_t::total_bytes, and ra8_rsip_sha256_ctx_t::used.
Referenced by app_sha_update(), internal_sha_update(), internal_sw_sha256(), ra8_rsip_hmac_sha256_init(), and ra8_rsip_hmac_sha256_update().
|
nodiscard |
Drain len bytes from the RSIP true RNG – fail-closed, no backend.
The RSIP-E50D TRNG has no documented register interface (HUM Ch 52 is a 6-page feature overview with no register map), so the hand-written RND_* access is invented and non-functional on silicon: RND_STATUS.READY never asserts. This routine therefore fails closed with k_ra8_err_not_supported rather than spin to a timeout or hand back a deterministic / all-zero value – predictable "entropy" is far more dangerous than an honest error. A working TRNG needs an FSP-derived RSIP primitive sequence; the register path is retained behind RA8_RSIP_TRNG_HARDWARE (never defined) for a future port. A software PRNG is NOT a substitute here.
| [out] | buf | Destination buffer (>= len bytes); never NULL. |
| [in] | len | Bytes to fetch; must be a non-zero multiple of 4. |
| k_ra8_err_not_supported | No working RSIP TRNG register interface exists (the shipped, fail-closed path). |
| k_ra8_err_null_ptr | buf was nullptr. |
| k_ra8_err_invalid_arg | len is zero or not a multiple of k_ra8_rsip_trng_word_bytes. |
Definition at line 338 of file ra8_rsip.c.
References k_ra8_err_invalid_arg, k_ra8_err_not_supported, k_ra8_ok, k_ra8_rsip_byte_bits, k_ra8_rsip_byte_mask, k_ra8_rsip_byte_shift_2, k_ra8_rsip_byte_shift_3, k_ra8_rsip_mask_ctrl_enable, k_ra8_rsip_mask_status_ready, k_ra8_rsip_off_rnd_ctrl, k_ra8_rsip_off_rnd_data, k_ra8_rsip_off_rnd_status, k_ra8_rsip_trng_word_bytes, k_ra8_rsip_word_shift, priv_wait_bit(), RA8_CHECK_NULL_PTR, ra8_rsip_reg32(), and s_tag.
Referenced by internal_demo_entropy_source(), and mbedtls_psa_external_get_random().
|
static |
Caller context paired with s_rsip_fn.
Definition at line 117 of file ra8_rsip.c.
Referenced by ra8_rsip_attach_handler(), ra8_rsip_deinit(), and ra8_rsip_dispatch().
|
static |
Currently attached interrupt callback, or nullptr.
Updated by ra8_rsip_attach_handler and read by ra8_rsip_dispatch. There is one shared slot because the RSIP routes every event through one peripheral IRQ line.
Definition at line 107 of file ra8_rsip.c.
Referenced by ra8_rsip_attach_handler(), ra8_rsip_deinit(), and ra8_rsip_dispatch().
|
static |
FIPS PUB 180-4 Section 5.3.3 initial hash value H(0).
Definition at line 514 of file ra8_rsip.c.
Referenced by ra8_rsip_sha256_init().
|
static |
FIPS PUB 180-4 Section 4.1.2 SHA-256 round constants K[0..63].
Definition at line 489 of file ra8_rsip.c.
Referenced by internal_sw_sha256_rounds().
|
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.
Definition at line 92 of file ra8_rsip.c.