ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_psa_crypto_internal.h File Reference

Module-private definitions shared across the ra8_psa_crypto TUs. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_err.h"
#include "ra8_psa_crypto.h"
#include "psa/crypto.h"
Include dependency graph for ra8_psa_crypto_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_psa_key_handle
 Forward declaration of the static-pool slot type. More...

Enumerations

enum  ra8_psa_internal_const_t : uint16_t {
  k_ra8_psa_sha256_block_bytes = 64U ,
  k_ra8_psa_sha256_state_words = 8U ,
  k_ra8_psa_sha256_schedule_len = 64U ,
  k_ra8_psa_sha256_init_words = 16U ,
  k_ra8_psa_sha256_pad_buf_len = 128U ,
  k_ra8_psa_sha256_pad_threshold = 56U ,
  k_ra8_psa_fake_scratch_bytes = 256U ,
  k_ra8_psa_word_bits = 32U ,
  k_ra8_psa_byte_bits = 8U ,
  k_ra8_psa_bytes_per_word = 4U ,
  k_ra8_psa_pad_marker = 0x80U ,
  k_ra8_psa_length_field_bytes = 8U ,
  k_ra8_psa_shift_b3 = 24U ,
  k_ra8_psa_shift_b2 = 16U ,
  k_ra8_psa_shift_b1 = 8U ,
  k_ra8_psa_rot_s0_a = 7U ,
  k_ra8_psa_rot_s0_b = 18U ,
  k_ra8_psa_shr_s0 = 3U ,
  k_ra8_psa_rot_s1_a = 17U ,
  k_ra8_psa_rot_s1_b = 19U ,
  k_ra8_psa_shr_s1 = 10U ,
  k_ra8_psa_rot_e_a = 6U ,
  k_ra8_psa_rot_e_b = 11U ,
  k_ra8_psa_rot_e_c = 25U ,
  k_ra8_psa_rot_a_a = 2U ,
  k_ra8_psa_rot_a_b = 13U ,
  k_ra8_psa_rot_a_c = 22U ,
  k_ra8_psa_w_back_15 = 15U ,
  k_ra8_psa_w_back_2 = 2U ,
  k_ra8_psa_w_back_16 = 16U ,
  k_ra8_psa_w_back_7 = 7U ,
  k_ra8_psa_state_idx_a = 0U ,
  k_ra8_psa_state_idx_b = 1U ,
  k_ra8_psa_state_idx_c = 2U ,
  k_ra8_psa_state_idx_d = 3U ,
  k_ra8_psa_state_idx_e = 4U ,
  k_ra8_psa_state_idx_f = 5U ,
  k_ra8_psa_state_idx_g = 6U ,
  k_ra8_psa_state_idx_h = 7U
}
 Internal numeric constants used by the crypto facade. More...
enum  ra8_psa_xs32_const_t : uint32_t {
  k_xs32_seed = 0xACE1ACE1U ,
  k_xs32_byte_m = 0xFFU
}
 xorshift32 off-target RNG constants (Marsaglia 2003). More...
enum  ra8_psa_xs32_shift_t : uint8_t {
  k_xs32_shl_a = 13U ,
  k_xs32_shr_b = 17U ,
  k_xs32_shl_c = 5U
}
 xorshift32 shift amounts (Marsaglia 2003 Table 1 row "y[13,17,5]"). More...
enum  ra8_psa_sha256_iv_t : uint32_t {
  k_ra8_psa_sha256_h0 = 0x6a09e667U ,
  k_ra8_psa_sha256_h1 = 0xbb67ae85U ,
  k_ra8_psa_sha256_h2 = 0x3c6ef372U ,
  k_ra8_psa_sha256_h3 = 0xa54ff53aU ,
  k_ra8_psa_sha256_h4 = 0x510e527fU ,
  k_ra8_psa_sha256_h5 = 0x9b05688cU ,
  k_ra8_psa_sha256_h6 = 0x1f83d9abU ,
  k_ra8_psa_sha256_h7 = 0x5be0cd19U
}
 SHA-256 initial hash values H0..H7 (FIPS 180-4 Sec 5.3.3). More...

Detailed Description

Module-private definitions shared across the ra8_psa_crypto TUs.

Tag
[Ring 4 / PAL] {World: NS}

The ra8_psa_crypto facade is split across two translation units: ra8_psa_crypto.c (public API + key-handle pool) and ra8_psa_crypto_fake.c (off-target SHA-256 / AEAD stand-ins). This private header holds the definitions both TUs need:

  • The concrete struct ra8_psa_key_handle slot layout (the public header only forward-declares it).
  • The internal typed-enum numeric constants (no magic numbers) used by the SHA-256 reference path, the AEAD fake, and the xorshift32 RNG.
  • extern declarations for the fake helpers that are defined in ra8_psa_crypto_fake.c but called from the public API in ra8_psa_crypto.c.

This header is internal to the library; consumers include the public ra8_psa_crypto.h only.

Since
0.1.0

Definition in file ra8_psa_crypto_internal.h.

Enumeration Type Documentation

◆ ra8_psa_internal_const_t

enum ra8_psa_internal_const_t : uint16_t

Internal numeric constants used by the crypto facade.

Centralizes all sizes, byte offsets, and bit counts referenced by the SHA-256 reference implementation and AEAD fake paths so that no magic numbers leak into the source.

Enumerator
k_ra8_psa_sha256_block_bytes 

SHA-256 message block size.

k_ra8_psa_sha256_state_words 

SHA-256 working state words.

k_ra8_psa_sha256_schedule_len 

Length of message schedule W[].

k_ra8_psa_sha256_init_words 

Initial copy from block to W[].

k_ra8_psa_sha256_pad_buf_len 

Two-block padding scratch.

k_ra8_psa_sha256_pad_threshold 

If remaining < this, one tail block.

k_ra8_psa_fake_scratch_bytes 

AEAD fake scratch buffer size.

k_ra8_psa_word_bits 

Word width in bits.

k_ra8_psa_byte_bits 

Bits per byte.

k_ra8_psa_bytes_per_word 

Bytes packed per 32-bit word.

k_ra8_psa_pad_marker 

SHA-256 padding sentinel byte.

k_ra8_psa_length_field_bytes 

64-bit big-endian length tail.

k_ra8_psa_shift_b3 

Shift for big-endian byte 3.

k_ra8_psa_shift_b2 

Shift for big-endian byte 2.

k_ra8_psa_shift_b1 

Shift for big-endian byte 1.

k_ra8_psa_rot_s0_a 

sigma0(W[i-15]) rot a.

k_ra8_psa_rot_s0_b 

sigma0(W[i-15]) rot b.

k_ra8_psa_shr_s0 

sigma0(W[i-15]) shr.

k_ra8_psa_rot_s1_a 

sigma1(W[i-2]) rot a.

k_ra8_psa_rot_s1_b 

sigma1(W[i-2]) rot b.

k_ra8_psa_shr_s1 

sigma1(W[i-2]) shr.

k_ra8_psa_rot_e_a 

Sigma1(e) rot a.

k_ra8_psa_rot_e_b 

Sigma1(e) rot b.

k_ra8_psa_rot_e_c 

Sigma1(e) rot c.

k_ra8_psa_rot_a_a 

Sigma0(a) rot a.

k_ra8_psa_rot_a_b 

Sigma0(a) rot b.

k_ra8_psa_rot_a_c 

Sigma0(a) rot c.

k_ra8_psa_w_back_15 

Schedule offset W[i-15].

k_ra8_psa_w_back_2 

Schedule offset W[i-2].

k_ra8_psa_w_back_16 

Schedule offset W[i-16].

k_ra8_psa_w_back_7 

Schedule offset W[i-7].

k_ra8_psa_state_idx_a 

SHA-256 working register a slot.

k_ra8_psa_state_idx_b 

SHA-256 working register b slot.

k_ra8_psa_state_idx_c 

SHA-256 working register c slot.

k_ra8_psa_state_idx_d 

SHA-256 working register d slot.

k_ra8_psa_state_idx_e 

SHA-256 working register e slot.

k_ra8_psa_state_idx_f 

SHA-256 working register f slot.

k_ra8_psa_state_idx_g 

SHA-256 working register g slot.

k_ra8_psa_state_idx_h 

SHA-256 working register h slot.

Definition at line 61 of file ra8_psa_crypto_internal.h.

◆ ra8_psa_sha256_iv_t

enum ra8_psa_sha256_iv_t : uint32_t

SHA-256 initial hash values H0..H7 (FIPS 180-4 Sec 5.3.3).

Enumerator
k_ra8_psa_sha256_h0 

RA8 PSA sha256 h0.

k_ra8_psa_sha256_h1 

RA8 PSA sha256 h1.

k_ra8_psa_sha256_h2 

RA8 PSA sha256 h2.

k_ra8_psa_sha256_h3 

RA8 PSA sha256 h3.

k_ra8_psa_sha256_h4 

RA8 PSA sha256 h4.

k_ra8_psa_sha256_h5 

RA8 PSA sha256 h5.

k_ra8_psa_sha256_h6 

RA8 PSA sha256 h6.

k_ra8_psa_sha256_h7 

RA8 PSA sha256 h7.

Definition at line 126 of file ra8_psa_crypto_internal.h.

◆ ra8_psa_xs32_const_t

enum ra8_psa_xs32_const_t : uint32_t

xorshift32 off-target RNG constants (Marsaglia 2003).

Enumerator
k_xs32_seed 

Default seed.

k_xs32_byte_m 

Mask isolating the low byte of state.

Definition at line 107 of file ra8_psa_crypto_internal.h.

◆ ra8_psa_xs32_shift_t

enum ra8_psa_xs32_shift_t : uint8_t

xorshift32 shift amounts (Marsaglia 2003 Table 1 row "y[13,17,5]").

Enumerator
k_xs32_shl_a 

First left shift.

k_xs32_shr_b 

Right shift.

k_xs32_shl_c 

Second left shift.

Definition at line 116 of file ra8_psa_crypto_internal.h.