|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RSIP-E50D RSA sign / verify / encrypt / decrypt path. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_rsip.h"#include "ra8_rsip_asym_internal.h"#include "ra8_rsip_internal.h"#include "ra8_rsip_regs.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_rsip_rsa_sign (const ra8_rsip_key_handle_t *key, ra8_rsip_rsa_size_t size, const uint8_t *digest, uint32_t digest_len, uint8_t *signature) |
| RSA sign a digest with a wrapped private key. | |
| ra8_err_t | ra8_rsip_rsa_verify (const ra8_rsip_key_handle_t *key, ra8_rsip_rsa_size_t size, const uint8_t *digest, uint32_t digest_len, const uint8_t *signature) |
| RSA verify a signature against a digest using a wrapped pubkey. | |
| ra8_err_t | ra8_rsip_rsa_encrypt (const ra8_rsip_key_handle_t *key, ra8_rsip_rsa_size_t size, ra8_rsip_rsa_pad_t pad, const uint8_t *plaintext, uint32_t plaintext_len, uint8_t *ciphertext) |
| RSA public-key encrypt a short message (RSAES-OAEP / PKCS1). | |
| ra8_err_t | ra8_rsip_rsa_decrypt (const ra8_rsip_key_handle_t *key, ra8_rsip_rsa_size_t size, ra8_rsip_rsa_pad_t pad, const uint8_t *ciphertext, uint8_t *plaintext, uint32_t plaintext_cap, uint32_t *recovered_len) |
| RSA private-key decrypt a ciphertext (RSAES-OAEP / PKCS1). | |
Variables | |
| static const char * | s_tag = "RSIP" |
| Logger tag used by every ra8_log_* call in this TU. | |
RSIP-E50D RSA sign / verify / encrypt / decrypt path.
RSA slice of the RA8D2 RSIP-E50D asymmetric HAL driver, split out of ra8_rsip_asym.c to keep every translation unit under the file-size budget. Exposes:
All four entry points are FAIL-CLOSED in production: HUM Ch 52 documents no asymmetric command-register map for the RSIP-E50D, so the off-target-only command path is gated behind the stub-crypto guard and a production build returns k_ra8_err_not_supported (issues #214 + #187).
The byte-lane streaming primitives internal_asym_push / internal_asym_pull are defined in ra8_rsip_asym.c and shared with the ECDSA / ECDH / EdDSA code there; their declarations live in ra8_rsip_asym_internal.h. The remaining cross-TU primitives (priv_load_handle, priv_complete) are declared in ra8_rsip_internal.h. The RSIP engine exposes no documented asymmetric register interface (HUM Ch 52 is a feature overview, p 3302-3307), so the fake command path here is a modelled fiction, not a real hardware sequence.
Definition in file ra8_rsip_rsa.c.
|
nodiscard |
RSA private-key decrypt a ciphertext (RSAES-OAEP / PKCS1).
Drives the RSIP asymmetric engine's private-decrypt opcode (k_ra8_rsip_asym_op_rsa_decrypt): the modulus-width ciphertext is raised to the private exponent and the pad padding is removed inside the secure boundary, leaving the recovered message. The recovered length (shorter than the modulus for OAEP / PKCS1) is reported through recovered_len.
| [in] | key | Wrapped RSA private-key handle. |
| [in] | size | RSA modulus selector (1024 / 2048 / 3072 / 4096). |
| [in] | pad | Padding scheme (OAEP or PKCS1). |
| [in] | ciphertext | Ciphertext to decrypt (modulus / 8 bytes); never NULL. |
| [out] | plaintext | Recovered-message buffer; never NULL. |
| [in] | plaintext_cap | Capacity of plaintext in bytes. |
| [out] | recovered_len | Receives the recovered-message length; never NULL. |
| k_ra8_ok | Message recovered. |
| k_ra8_err_not_supported | Production build fail-closed; no RSIP backend, use tf-psa-crypto. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Bad size / pad, or recovered message exceeds plaintext_cap. |
| k_ra8_err_hw_timeout | Engine never signalled DONE. |
| k_ra8_err_hw_error | Padding check failed (corrupt ciphertext). |
Definition at line 408 of file ra8_rsip_rsa.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
RSA public-key encrypt a short message (RSAES-OAEP / PKCS1).
Drives the RSIP asymmetric engine's public-encrypt opcode (k_ra8_rsip_asym_op_rsa_encrypt) so RSA-OAEP key transport works: the plaintext (typically a wrapped content-encryption key) is padded per pad and raised to the public exponent, yielding a modulus-width ciphertext. The engine performs the padding inside the secure boundary; the caller supplies only the raw message bytes.
| [in] | key | Wrapped RSA public-key handle. |
| [in] | size | RSA modulus selector (1024 / 2048 / 3072 / 4096). |
| [in] | pad | Padding scheme (OAEP or PKCS1). |
| [in] | plaintext | Message to encrypt; never NULL. |
| [in] | plaintext_len | Message length in bytes; 1 .. modulus / 8. |
| [out] | ciphertext | Output ciphertext (modulus / 8 bytes); never NULL. |
| k_ra8_ok | Ciphertext produced. |
| k_ra8_err_not_supported | Production build fail-closed; no RSIP backend, use tf-psa-crypto. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Bad size / pad, or plaintext_len out of range. |
| k_ra8_err_hw_timeout | Engine never signalled DONE. |
| k_ra8_err_hw_error | Message too long for the padding scheme. |
Definition at line 392 of file ra8_rsip_rsa.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
RSA sign a digest with a wrapped private key.
| [in] | key | Wrapped RSA private-key handle. |
| [in] | size | RSA modulus selector (1024 / 2048 / 3072 / 4096). |
| [in] | digest | Pre-computed message digest. |
| [in] | digest_len | Digest length in bytes. |
| [out] | signature | Output signature (modulus / 8 bytes). |
| k_ra8_ok | Signature produced. |
| k_ra8_err_not_supported | Production build fail-closed; no RSIP backend, use tf-psa-crypto. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Bad size. |
| k_ra8_err_hw_timeout | Engine never signalled DONE. |
Definition at line 364 of file ra8_rsip_rsa.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_rsip_protected_rsa_decrypt().
|
nodiscard |
RSA verify a signature against a digest using a wrapped pubkey.
| [in] | key | Wrapped RSA public-key handle. |
| [in] | size | RSA modulus selector. |
| [in] | digest | Pre-computed message digest. |
| [in] | digest_len | Digest length. |
| [in] | signature | Signature (modulus / 8 bytes). |
| k_ra8_ok | Signature valid. |
| k_ra8_err_not_supported | Production build fail-closed; no RSIP backend, use tf-psa-crypto. |
| k_ra8_err_null_ptr | Any pointer was NULL. |
| k_ra8_err_invalid_arg | Bad size. |
| k_ra8_err_hw_timeout | Engine never signalled DONE. |
| k_ra8_err_hw_error | Signature did not verify. |
Definition at line 378 of file ra8_rsip_rsa.c.
References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.
|
static |
Logger tag used by every ra8_log_* call in this TU.
Kept short ("RSIP") so it fits in the fixed-width log prefix without truncation. Each RSIP translation unit keeps its own private copy.
Definition at line 57 of file ra8_rsip_rsa.c.