46static const char*
s_tag =
"KEYIMP";
49typedef enum : uint8_t {
63typedef enum : uint8_t {
69typedef enum : uint32_t {
128 return (value << bits) | (value >> (32U - bits));
188 uint16_t mac_key_len = 0U;
284 const uint16_t bit = (uint16_t)((uint16_t)1U << i);
333 const uint16_t bit = (uint16_t)((uint16_t)1U << i);
374 uint16_t mac_key_len = 0U;
381 out_blob[i] = material[i];
ra8_err_t priv_ra8_key_import_seal(const uint8_t *blob, uint32_t blob_len, uint32_t *out_handle)
Verify, store, and assign an opaque handle for a sealed key blob.
static uint32_t internal_rotate_left_32(uint32_t value, uint8_t amount)
Rotate a 32-bit value left by amount bits (mod 32).
static uint32_t s_salt
Per-boot 32-bit salt used for handle obfuscation.
ra8_key_import_internal_t
Handle-obfuscation shift constants.
@ k_salt_reroll_rot
Salt reroll rotate amount.
@ k_handle_rotate_bits
Salt rotate amount before slot XOR.
static ra8_err_t internal_verify_cmac(const uint8_t *blob)
Verify the trailing AES-CMAC of a sealed key blob.
ra8_key_import_mask_t
32-bit handle/salt mixing masks and seeds.
@ k_salt_reroll_xor
Salt reroll mixing const.
@ k_handle_high_bit_mask
Forces a non-zero handle.
@ k_initial_salt
Boot salt seed.
static uint16_t s_slot_used
One bit per vault slot: 1 if currently allocated.
ra8_err_t priv_ra8_key_import_build_blob(const uint8_t *material, uint8_t *out_blob)
Build a sealed key blob from a raw 32-byte key (provisioning + test).
rotate_mask_t
5-bit rotate-amount mask (mod 32).
@ k_rotate_mask_5bit
Rotate mask 5bit.
ra8_err_t priv_ra8_key_import_resolve(uint32_t handle, uint16_t *out_slot)
Resolve a previously issued handle back to its vault slot.
static uint32_t internal_handle_for_slot(uint16_t slot)
Compute the opaque NS-side handle for a vault slot index.
ra8_err_t priv_ra8_key_import_reset(void)
Reset the import allocator and reroll the per-boot salt.
Secure-side sealed key import + opaque handle vending.
@ k_ra8_key_import_key_bytes
Key portion length.
@ k_ra8_key_import_mac_bytes
Trailing AES-CMAC tag length.
@ k_ra8_key_import_blob_bytes
32-byte key + 16-byte CMAC.
Secure-only symmetric key store.
ra8_err_t ra8_key_vault_store(uint16_t slot, const uint8_t *key)
Programme a 256-bit symmetric key into a vault slot.
@ k_ra8_key_vault_mac_key_bytes
Max key-authentication key.
@ k_ra8_key_vault_slots
Number of stored keys.
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.
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_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Secure-comparison primitives for the crypto / secure-boot paths.
void ra8_secure_memzero(void *ptr, size_t len)
Securely zero a buffer such that the write cannot be optimised away.
ra8_err_t priv_ra8_sec_cmac_compute(const uint8_t *key, uint16_t key_len, const uint8_t *msg, uint32_t msg_len, uint8_t *out_mac)
Compute the AES-CMAC tag of a message under a symmetric key.
ra8_err_t priv_ra8_sec_cmac_verify(const uint8_t *key, uint16_t key_len, const uint8_t *msg, uint32_t msg_len, const uint8_t *mac, uint16_t mac_len)
Verify an AES-CMAC tag against a message under a symmetric key.
Secure-side AES-CMAC seam (real PSA backend / in-tree reference).