|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Secure-only symmetric key store implementation. More...
#include "key_vault.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_secure.h"Go to the source code of this file.
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. | |
Variables | |
| static const char * | s_tag = "KEYV" |
Secure-only symmetric key store implementation.
implementation. Stores 8 symmetric keys in a static array that lives in the secure SRAM partition. Provides three operations:
The SHA-256 implementation is a small fixed-iteration sponge baked into this file – no external libraries, no heap. It is NIST FIPS 180-4 compliant for the single-block case used here (32-byte input, 32-byte output, single padding block).
Definition in file key_vault.c.
|
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().
|
static |
Definition at line 37 of file key_vault.c.