|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Secure-only symmetric key store. More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_key_vault_limits_t : uint16_t { k_ra8_key_vault_slots = 8U , k_ra8_key_vault_key_bytes = 32U , k_ra8_key_vault_chal_bytes = 32U , k_ra8_key_vault_digest_bytes = 32U , k_ra8_key_vault_mac_key_bytes = 32U } |
| Sizing constants for the vault. More... | |
Functions | |
| ra8_err_t | ra8_key_vault_init (void) |
| Initialise the vault (zero every slot). | |
| ra8_err_t | ra8_key_vault_store (uint16_t slot, const uint8_t *key) |
| Programme a 256-bit symmetric key into a vault slot. | |
| ra8_err_t | ra8_key_vault_sha256_xor_challenge (uint16_t slot, const uint8_t *challenge, uint8_t *out) |
| Compute SHA-256(key XOR challenge) for slot. | |
| ra8_err_t | ra8_key_vault_set_mac_key (const uint8_t *key, uint16_t key_len) |
| Provision the key-authentication key (KAK) used to MAC key imports. | |
| ra8_err_t | ra8_key_vault_load_mac_key (uint8_t *out, uint16_t out_cap, uint16_t *out_len) |
| Copy the provisioned key-authentication key for a secure caller. | |
Secure-only symmetric key store.
deliverable. Stores up to k_ra8_key_vault_slots 256-bit symmetric keys in a Secure-side static array that is unreachable from the Non-Secure world after the SAU partition is enabled.
ships the in-memory vault. The hardened storage path (MRAM-backed Secure region or SCE7 hardware key wrap) is a future deliverable that depends on the SCE driver gaining key-injection support.
The vault is intentionally minimal:
Definition in file key_vault.h.
| enum ra8_key_vault_limits_t : uint16_t |
Sizing constants for the vault.
Definition at line 56 of file key_vault.h.
|
nodiscard |
Initialise the vault (zero every slot).
Definition at line 562 of file key_vault.c.
References k_ra8_err_not_supported.
|
nodiscard |
Copy the provisioned key-authentication key for a secure caller.
Secure-world-only accessor used by key_import.c to key the AES-CMAC. It copies the KAK into a caller-supplied secure buffer; the material never crosses to Non-Secure code (no NSC veneer exposes it). The caller wipes the copy after use.
| [out] | out | Destination for the KAK (secure scratch). |
| [in] | out_cap | Capacity of out in bytes (>= key_len). |
| [out] | out_len | Receives the KAK length actually copied. |
| k_ra8_ok | KAK copied and *out_len set. |
| k_ra8_err_null_ptr | out or out_len was NULL. |
| k_ra8_err_not_found | No KAK has been provisioned yet. |
| k_ra8_err_invalid_size | out_cap was smaller than the KAK. |
Definition at line 589 of file key_vault.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_verify_cmac(), and priv_ra8_key_import_build_blob().
|
nodiscard |
Provision the key-authentication key (KAK) used to MAC key imports.
The KAK is the secret that keys the AES-CMAC over a wrapped-key blob in priv_ra8_key_import_seal. It is stored in dedicated secure-side storage that is separate from the NS-importable slot array, so it can never be overwritten or read through the ra8_key_import_* / NSC path a Non-Secure caller reaches. Secure boot (or the host test harness) provisions it once before any import can occur. This is the single answer to "where does the CMAC key come from": the secure key vault, never NS.
| [in] | key | Raw AES-CMAC key material. |
| [in] | key_len | Key length: 16 (AES-128) or 32 (AES-256) bytes. |
| k_ra8_ok | KAK stored. |
| k_ra8_err_null_ptr | key was NULL. |
| k_ra8_err_invalid_arg | key_len was neither 16 nor 32. |
Definition at line 582 of file key_vault.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Compute SHA-256(key XOR challenge) for slot.
This is the only operation the Non-Secure world can reach via the ra8_nsc_key_vault_challenge veneer. The raw key never leaves the secure world; what crosses the boundary is the 32-byte SHA-256 digest of (key XOR challenge), which depends on both the key and the challenge but reveals neither.
| [in] | slot | Slot index 0..k_ra8_key_vault_slots-1. |
| [in] | challenge | 32-byte challenge from the NS caller. |
| [out] | out | 32-byte digest destination. |
| k_ra8_ok | Digest computed. |
| k_ra8_err_invalid_arg | slot out of range. |
| k_ra8_err_null_ptr | challenge or out was NULL. |
Definition at line 574 of file key_vault.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_nsc_key_vault_challenge().
|
nodiscard |
Programme a 256-bit symmetric key into a vault slot.
| [in] | slot | Slot index 0..k_ra8_key_vault_slots-1. |
| [in] | key | 32-byte symmetric key. |
| k_ra8_ok | Key stored. |
| k_ra8_err_invalid_arg | slot out of range. |
| k_ra8_err_null_ptr | key was NULL. |
Definition at line 567 of file key_vault.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by priv_ra8_key_import_seal().