72static const char*
s_tag =
"RSIP";
92#if defined(RA8_INSECURE_STUB_CRYPTO) || defined(RA8_OFF_TARGET)
135 if ((msg ==
nullptr) && (msg_len != 0U)) {
138 const uint32_t n = internal_hash_size(alg);
151static void internal_hash_pull_digest(uint8_t* digest, uint32_t to_read)
165 for (uint32_t b = 0U; (i + b) < to_read; ++b) {
179 uint32_t needed = 0U;
180 const ra8_err_t v_err = internal_hash_validate(alg, msg, msg_len, digest_len, &needed);
194 const uint32_t to_read =
196 internal_hash_pull_digest(digest, to_read);
208 if ((msg ==
nullptr) && (msg_len != 0U)) {
212 uint32_t needed = 0U;
231 if (mac_len < needed) {
253 handle->
body[w] = 0U;
267 for (uint32_t b = 0U; (i + b) < len; ++b) {
284 for (uint32_t b = 0U; (i + b) < len; ++b) {
417static void internal_kw_pull_blob(uint8_t* blob)
430 for (uint32_t w = 0U; w < src->
body_words; ++w) {
447 internal_kw_stage_kek(kek, iv);
448 internal_kw_push_src(src);
456 internal_kw_pull_blob(blob);
471 for (uint32_t w = 0U; w < words; ++w) {
490 internal_kw_stage_kek(kek, iv);
502 return internal_kw_pull_handle(dest);
514 const uint8_t* label,
520 if ((label ==
nullptr) && (label_len != 0U)) {
523 if ((salt ==
nullptr) && (salt_len != 0U)) {
542 const uint8_t* label,
550 if (ikm !=
nullptr) {
554 if (label_len > 0U) {
569 for (uint32_t w = 0U; w < out->
body_words; ++w) {
577 const uint8_t* label,
585 const ra8_err_t v_err = internal_kdf_validate(op, ikm, label, label_len, salt, salt_len, out_len);
588 internal_kdf_stage(op, ikm, label, label_len, salt, salt_len, out_len);
595 internal_kdf_pull_handle(out);
729 const uint8_t* label,
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
ra8_err_t priv_hash_wait_done(void)
Wait for the HASH engine to raise DONE after the trailing block.
Renesas Secure IP (RSIP-E50D) HAL driver – public API.
ra8_err_t ra8_rsip_kv_erase(uint8_t slot)
Zeroise a vault slot.
ra8_err_t ra8_rsip_oem_bl_version_increment(void)
Increment the OEM boot loader version (anti-rollback step).
ra8_err_t ra8_rsip_hmac(const ra8_rsip_key_handle_t *key, const uint8_t *msg, uint32_t msg_len, uint8_t *mac, uint32_t mac_len)
HMAC-SHA-2 / HMAC-SHA-3 over a buffer using a wrapped key.
ra8_err_t ra8_rsip_hash(ra8_rsip_hash_alg_t alg, const uint8_t *msg, uint32_t msg_len, uint8_t *digest, uint32_t digest_len)
Compute a hash of an in-memory buffer using the selected algorithm.
ra8_err_t ra8_rsip_key_wrap(const ra8_rsip_key_handle_t *kek, const uint8_t *iv, const ra8_rsip_key_handle_t *src, uint8_t *blob)
Wrap a key handle into a transportable blob using a KEK.
ra8_err_t ra8_rsip_kv_count(uint32_t *out)
Snapshot the populated-slot count.
ra8_err_t ra8_rsip_kv_write(uint8_t slot, const uint8_t *in)
Write a wrapped-key blob into a vault slot.
ra8_err_t ra8_rsip_dotf_route(uint8_t which, uint8_t slot, bool on)
Route a wrapped-key vault slot to one of the DOTF instances.
ra8_err_t ra8_rsip_kv_read(uint8_t slot, uint8_t *out)
Read a wrapped-key blob from a vault slot.
ra8_err_t ra8_rsip_oem_bl_version_lock(void)
Latch the OEM_BL_LOCK so further increments are rejected.
ra8_err_t ra8_rsip_oem_bl_version_get(uint32_t *out)
Read the latched OEM boot loader version counter.
ra8_err_t ra8_rsip_kdf(ra8_rsip_kdf_op_t op, const ra8_rsip_key_handle_t *ikm, const uint8_t *label, uint32_t label_len, const uint8_t *salt, uint32_t salt_len, uint32_t out_len, ra8_rsip_key_handle_t *out)
Derive a key from input keying material + label/salt/info.
ra8_err_t ra8_rsip_key_unwrap(const ra8_rsip_key_handle_t *kek, const uint8_t *iv, const uint8_t *blob, ra8_rsip_key_handle_t *dest)
Unwrap a transportable blob into a key handle.
Cross-TU surface shared by the RSIP asymmetric + RSA split.
void internal_zero_handle_tail(ra8_rsip_key_handle_t *handle, uint32_t words)
Zero-fill the unused tail of a key-handle body buffer.
void internal_asym_push(ra8_rsip_off_t off, const uint8_t *buf, uint32_t len)
Stream a byte buffer into an asymmetric input lane.
void internal_asym_pull(ra8_rsip_off_t off, uint8_t *buf, uint32_t len)
Pull a byte buffer back through an asymmetric output lane.
uint8_t priv_aes_alg_byte(uint32_t alg)
Pick the AES algorithm byte that matches the wrapped key.
void priv_unpack_le(uint32_t word, uint8_t *p)
Unpack a uint32_t into 4 little-endian bytes.
void priv_push_bytes_to_port(ra8_rsip_off_t off, const uint8_t *in, uint32_t len)
Implementation of priv_push_bytes_to_port() – LE word stream + zero-padded tail.
uint32_t priv_handle_words_for(ra8_rsip_oem_cmd_t cmd)
Map an OEM opcode to the wrapped-key body word count.
void priv_load_handle(const ra8_rsip_key_handle_t *handle)
Stream a wrapped-key body into the engine input FIFO.
void priv_push_handle_body(const ra8_rsip_key_handle_t *handle)
Implementation of priv_push_handle_body() – KEY_STAGE body word stream.
uint32_t priv_pack_le(const uint8_t *p)
Pack 4 little-endian bytes into a uint32_t.
void priv_push_iv_lanes(ra8_rsip_off_t base, const uint8_t *iv, uint32_t iv_len)
Implementation of priv_push_iv_lanes() – bounded 4-lane LE IV window writer.
ra8_err_t priv_complete(uint32_t done_mask)
Drive a single mailbox completion (DONE poll + ack).
Cross-TU surface for the ra8_rsip driver split.
@ k_ra8_rsip_iv_words
IV / nonce register lanes.
@ k_ra8_rsip_kv_slot_w
64-byte slot = 16 * uint32_t.
@ k_ra8_rsip_byte_bits
Shift one byte.
@ k_ra8_rsip_byte_mask
Mask one byte out of a word.
@ k_ra8_rsip_byte_shift_2
Shift to high half of low word.
Renesas Secure IP (RSIP-E50D) register layout for the RA8D2.
ra8_rsip_kdf_op_t
KDF mode selector written to KDF_CTRL.
@ k_ra8_rsip_kdf_op_hkdf_sha384
HKDF SHA-384.
@ k_ra8_rsip_kdf_op_hkdf_sha512
HKDF SHA-512.
@ k_ra8_rsip_kdf_op_hkdf_sha256
HKDF SHA-256.
@ k_ra8_rsip_kw_op_wrap
Wrap a plaintext handle -> blob.
@ k_ra8_rsip_kw_op_unwrap
Unwrap a blob -> handle.
@ k_ra8_rsip_handle_words_rsa4096_priv
RSA-4096 wrapped private.
@ k_ra8_rsip_handle_words_hmac_sha256
HMAC-SHA-256 wrapped key.
@ k_ra8_rsip_dotf_on
Feed key from slot bits 31..16.
@ k_ra8_rsip_dotf_off
Disable key feed.
ra8_rsip_hash_alg_t
Algorithm selector value written to the HASH CTRL word.
@ k_ra8_rsip_hash_sha3_512
SHA3-512 FIPS PUB 202.
@ k_ra8_rsip_hash_sha512_224
SHA-512/224.
@ k_ra8_rsip_hash_shake256
SHAKE256 FIPS PUB 202.
@ k_ra8_rsip_hash_sha384
SHA-384.
@ k_ra8_rsip_hash_sha3_256
SHA3-256 FIPS PUB 202.
@ k_ra8_rsip_hash_sha256
SHA-256.
@ k_ra8_rsip_hash_sha512
SHA-512.
@ k_ra8_rsip_hash_shake128
SHAKE128 FIPS PUB 202.
@ k_ra8_rsip_hash_sha512_256
SHA-512/256.
@ k_ra8_rsip_hash_sha3_224
SHA3-224 FIPS PUB 202.
@ k_ra8_rsip_hash_sha224
SHA-224.
@ k_ra8_rsip_hash_sha3_384
SHA3-384 FIPS PUB 202.
ra8_rsip_oem_cmd_t
OEM-key install opcode written to OEM_CTRL.
@ k_ra8_rsip_oem_cmd_hmac_sha384
HMAC-SHA-384.
@ k_ra8_rsip_oem_cmd_hmac_sha512_224
HMAC-SHA-512/224.
@ k_ra8_rsip_oem_cmd_hmac_sha224
HMAC-SHA-224.
@ k_ra8_rsip_oem_cmd_hmac_sha512
HMAC-SHA-512.
@ k_ra8_rsip_oem_cmd_hmac_sha256
HMAC-SHA-256.
@ k_ra8_rsip_oem_cmd_hmac_sha512_256
HMAC-SHA-512/256.
static volatile uint32_t * ra8_rsip_reg32(ra8_rsip_off_t offset)
Volatile pointer to a 32-bit RSIP register at offset.
@ k_ra8_rsip_kv_slot_count
Number of vault slots.
@ k_ra8_rsip_trng_word_bytes
Bytes per TRNG read.
@ k_ra8_rsip_sha512_digest_bytes
SHA-512 digest length.
@ k_ra8_rsip_sha256_digest_bytes
SHA-256 digest length.
@ k_ra8_rsip_sha384_digest_bytes
SHA-384 digest length.
@ k_ra8_rsip_sha224_digest_bytes
SHA-224 digest length.
@ k_ra8_rsip_mask_isr_kv_done
ISR.KV_DONE bit.
@ k_ra8_rsip_mask_isr_done
ISR.DONE bit.
@ k_ra8_rsip_mask_isr_kdf_done
ISR.KDF_DONE bit.
ra8_rsip_kv_op_t
Key-vault command word values written to KV_CTRL.
@ k_ra8_rsip_kv_op_write
Write KV_DATA -> slot.
@ k_ra8_rsip_kv_op_read
Read slot -> KV_DATA.
@ k_ra8_rsip_kv_op_erase
Zeroise slot.
ra8_rsip_off_t
Byte offsets of every register the HAL touches.
@ k_ra8_rsip_off_kdf_len
Output length (bytes).
@ k_ra8_rsip_off_kv_data
Vault data port.
@ k_ra8_rsip_off_kv_ctrl
Vault command (read/write/erase).
@ k_ra8_rsip_off_kdf_out
Derived-key output handle.
@ k_ra8_rsip_off_hash_digest
HASH output digest base.
@ k_ra8_rsip_off_kv_count
Vault populated-slot count.
@ k_ra8_rsip_off_dotf0_ctrl
DOTF0 key route enable + slot.
@ k_ra8_rsip_off_kdf_ctrl
KDF request word.
@ k_ra8_rsip_off_hash_status
HASH ready / done flags.
@ k_ra8_rsip_off_oem_bl_lock
Lock-after-validation latch.
@ k_ra8_rsip_off_oem_bl_ver
Latched OEM BL Ver counter.
@ k_ra8_rsip_off_hash_ctrl
HASH control (algorithm select).
@ k_ra8_rsip_off_kw_iv0
Wrap IV lane 0.
@ k_ra8_rsip_off_hash_hmac
HMAC mode + key-handle slot.
@ k_ra8_rsip_off_mbox_op
Opcode written by host.
@ k_ra8_rsip_off_kw_blob_out
Wrapped-blob output lane.
@ k_ra8_rsip_off_hash_data_in
HASH input window (32-bit each).
@ k_ra8_rsip_off_kw_blob_in
Wrapped-blob input lane.
@ k_ra8_rsip_off_kv_slot
Vault slot index.
@ k_ra8_rsip_off_kdf_salt
HKDF salt lane.
@ k_ra8_rsip_off_dotf1_ctrl
DOTF1 key route enable + slot.
@ k_ra8_rsip_off_kw_kek
KEK handle slot.
@ k_ra8_rsip_off_kw_ctrl
Key-wrap command word.
@ k_ra8_rsip_off_kdf_ikm
Input keying material handle.
@ k_ra8_rsip_off_kw_handle
Source / destination handle slot.
@ k_ra8_rsip_off_kdf_label
KDF context label slot.
@ k_ra8_rsip_off_oem_bl_inc
Increment trigger (W1).
Opaque wrapped-key handle.
uint32_t body_words
Number of body words (1..261).
uint32_t body[k_ra8_rsip_handle_words_rsa4096_priv]
Wrapped body.
uint32_t alg
OEM-cmd algorithm selector.