|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RSIP key-injection HAL implementation. More...
#include "ra8_rsip_key_injection.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_secure.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_rsip_key_inject_aes (uint8_t *installed_key_buf, const uint8_t *raw_key, ra8_rsip_aes_key_bits_t key_bits) |
| Wrap a raw AES key into the RSIP installed-key format. | |
| ra8_err_t | ra8_rsip_key_inject_rsa (uint8_t *installed_key_buf, const uint8_t *raw_modulus, const uint8_t *raw_exponent, ra8_rsip_rsa_size_t size) |
| Wrap a raw RSA key (modulus + exponent) into the installed-key format. | |
| ra8_err_t | ra8_rsip_key_inject_ecc (uint8_t *installed_key_buf, ra8_rsip_curve_t curve, const uint8_t *raw_priv_or_pub, bool is_private) |
| Wrap a raw ECC scalar (private or public) into the installed-key format. | |
| ra8_err_t | ra8_rsip_key_validate (const uint8_t *installed_key_buf, ra8_rsip_wrapped_key_type_t expected_type) |
| Validate that a wrapped-key blob has the expected structure and a matching trailing MAC. | |
Variables | |
| static const char * | s_tag = "RSIP_KI" |
| Logger tag for this TU. | |
RSIP key-injection HAL implementation.
Software-stub backend for the public API in libs/ra8_hal/inc/ra8_rsip_key_injection.h. Wrapped key blobs are laid out as [type | mgmt-info | payload | mac] and the MAC is computed with the same xorshift mixer ra8_sce_key_injection uses so the round-trip property is preserved across the inject -> protected-op pipeline. Round-tripping under unit tests is the only guarantee made; the wrapping is not cryptographically meaningful and a real backend will replace this entirely.
Definition in file ra8_rsip_key_injection.c.
|
nodiscard |
Wrap a raw AES key into the RSIP installed-key format.
Produces a self-describing blob the RSIP engine accepts as a "wrapped key": a leading type tag, the key-injection envelope, the AES key bytes, and a trailing MAC over the whole structure. The blob is the only artefact a caller may pass to ra8_rsip_protected_aes_init.
| [out] | installed_key_buf | Destination buffer; must be k_ra8_rsip_wrapped_max_total bytes. |
| [in] | raw_key | Raw AES key bytes (key_bits / 8). |
| [in] | key_bits | AES key width. |
| k_ra8_ok | Blob written. |
| k_ra8_err_null_ptr | installed_key_buf or raw_key was NULL. |
| k_ra8_err_invalid_arg | Unsupported key_bits. |
Definition at line 555 of file ra8_rsip_key_injection.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Wrap a raw ECC scalar (private or public) into the installed-key format.
For private keys the payload is the raw scalar bytes; for public keys the payload is X || Y (the uncompressed point coordinates). The byte counts come from curve.
| [out] | installed_key_buf | Destination buffer. |
| [in] | curve | Curve identifier. |
| [in] | raw_priv_or_pub | Raw scalar bytes; the buffer length is implied by curve. |
| [in] | is_private | true -> wrap a private scalar; false -> wrap a public point. |
| k_ra8_ok | Blob written. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Unsupported curve. |
Definition at line 577 of file ra8_rsip_key_injection.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Wrap a raw RSA key (modulus + exponent) into the installed-key format.
The payload layout is [modulus | 4-byte exponent]. Both private and public RSA blobs share this representation and are differentiated only by the leading type tag (private blobs use k_ra8_rsip_wrapped_type_rsa_priv).
| [out] | installed_key_buf | Destination (k_ra8_rsip_wrapped_max_total). |
| [in] | raw_modulus | Big-endian modulus bytes (size / 8 long). |
| [in] | raw_exponent | Big-endian exponent bytes (4 bytes for public e; truncated to 4 for the stub). |
| [in] | size | RSA modulus width. |
| k_ra8_ok | Blob written. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Unsupported size. |
Definition at line 565 of file ra8_rsip_key_injection.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Validate that a wrapped-key blob has the expected structure and a matching trailing MAC.
Parses the leading type tag, recomputes the MAC over [type | mgmt-info | payload] using the same xorshift mixer the inject path used, and returns k_ra8_ok only if it matches. Any single-byte tamper in the blob causes the recomputed MAC to diverge.
| [in] | installed_key_buf | Wrapped blob. |
| [in] | expected_type | Expected type tag. |
| k_ra8_ok | Blob is well-formed and MAC matches. |
| k_ra8_err_null_ptr | installed_key_buf was NULL. |
| k_ra8_err_invalid_arg | Type tag mismatched. |
| k_ra8_err_hw_error | Trailing MAC mismatched. |
Definition at line 589 of file ra8_rsip_key_injection.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_rsa_validate_wrapped(), ra8_rsip_protected_aes_init(), and ra8_rsip_protected_ecdsa_sign().
|
static |
Logger tag for this TU.
Definition at line 41 of file ra8_rsip_key_injection.c.