ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_psa_crypto.h
Go to the documentation of this file.
1
62
63#pragma once
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69#include <stddef.h>
70#include <stdint.h>
71
72#include "ra8_err.h"
73
74/* =============================================================================
75 * Limits
76 * =============================================================================
77 */
78
127
128/* =============================================================================
129 * Algorithm + key-type tags
130 * =============================================================================
131 */
132
152
165
184
185/* =============================================================================
186 * Opaque key handle
187 * =============================================================================
188 */
189
199struct ra8_psa_key_handle;
200
212
234
235/* =============================================================================
236 * Public API
237 * =============================================================================
238 */
239
282
306
356 const ra8_psa_key_attr_t* attr,
357 const uint8_t* data,
358 size_t data_len);
359
387
423 const uint8_t* input,
424 size_t input_len,
425 uint8_t* out,
426 size_t out_cap,
427 size_t* out_len);
428
469 ra8_psa_alg_t alg,
470 const uint8_t* hash,
471 size_t hash_len,
472 uint8_t* sig,
473 size_t sig_cap,
474 size_t* sig_len);
475
513 ra8_psa_alg_t alg,
514 const uint8_t* hash,
515 size_t hash_len,
516 const uint8_t* sig,
517 size_t sig_len);
518
565 ra8_psa_alg_t alg,
566 const uint8_t* nonce,
567 size_t nonce_len,
568 const uint8_t* aad,
569 size_t aad_len,
570 const uint8_t* plain,
571 size_t plain_len,
572 uint8_t* out,
573 size_t out_cap,
574 size_t* out_len);
575
620 ra8_psa_alg_t alg,
621 const uint8_t* nonce,
622 size_t nonce_len,
623 const uint8_t* aad,
624 size_t aad_len,
625 const uint8_t* cipher,
626 size_t cipher_len,
627 uint8_t* out,
628 size_t out_cap,
629 size_t* out_len);
630
667[[nodiscard]] ra8_err_t ra8_psa_crypto_random(uint8_t* out, size_t out_len);
668
669#ifdef __cplusplus
670}
671#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_psa_key_usage_t
Bitmask of allowed operations on an imported key.
@ k_ra8_psa_usage_encrypt
Allow ra8_psa_aead_encrypt.
@ k_ra8_psa_usage_derive
Allow KDF-style derivation (future).
@ k_ra8_psa_usage_verify
Allow ra8_psa_verify_hash.
@ k_ra8_psa_usage_none
No usage allowed (placeholder).
@ k_ra8_psa_usage_decrypt
Allow ra8_psa_aead_decrypt.
@ k_ra8_psa_usage_sign
Allow ra8_psa_sign_hash.
ra8_err_t ra8_psa_hash_compute(ra8_psa_alg_t alg, const uint8_t *input, size_t input_len, uint8_t *out, size_t out_cap, size_t *out_len)
Compute a one-shot SHA-256 digest.
ra8_err_t ra8_psa_key_destroy(ra8_psa_key_t handle)
Destroy a previously-imported key.
ra8_err_t ra8_psa_aead_decrypt(ra8_psa_key_t handle, ra8_psa_alg_t alg, const uint8_t *nonce, size_t nonce_len, const uint8_t *aad, size_t aad_len, const uint8_t *cipher, size_t cipher_len, uint8_t *out, size_t out_cap, size_t *out_len)
Decrypt + verify-tag an AES-GCM buffer.
ra8_err_t ra8_psa_crypto_init(void)
One-shot facade initialisation.
ra8_err_t ra8_psa_key_import(ra8_psa_key_t *out_handle, const ra8_psa_key_attr_t *attr, const uint8_t *data, size_t data_len)
Import a raw-byte key into the static pool.
struct ra8_psa_key_handle * ra8_psa_key_t
Opaque PSA key handle (typed pointer into the static pool).
ra8_err_t ra8_psa_verify_hash(ra8_psa_key_t handle, ra8_psa_alg_t alg, const uint8_t *hash, size_t hash_len, const uint8_t *sig, size_t sig_len)
Verify an ECDSA signature over a pre-computed hash.
ra8_err_t ra8_psa_sign_hash(ra8_psa_key_t handle, ra8_psa_alg_t alg, const uint8_t *hash, size_t hash_len, uint8_t *sig, size_t sig_cap, size_t *sig_len)
Sign a pre-computed hash with a private ECDSA key.
ra8_psa_key_type_t
Project-local enum mirroring the PSA key-type families we care about.
@ k_ra8_psa_key_type_ecc_p256_pub
ECDSA P-256 public key (uncompressed).
@ k_ra8_psa_key_type_raw
Raw octet string (HKDF input).
@ k_ra8_psa_key_type_aes
Symmetric AES key.
@ k_ra8_psa_key_type_hmac
HMAC key (any hash).
@ k_ra8_psa_key_type_ecc_p256_priv
ECDSA P-256 private key.
ra8_err_t ra8_psa_crypto_random(uint8_t *out, size_t out_len)
Fill out[0..out_len-1] with cryptographically secure bytes.
ra8_err_t ra8_psa_crypto_deinit(void)
Symmetric tear-down for ra8_psa_crypto_init.
ra8_psa_alg_t
Algorithm selector passed to sign / verify / AEAD operations.
@ k_ra8_psa_alg_none
Sentinel for "unset".
@ k_ra8_psa_alg_ecdsa_sha_256
ECDSA over SHA-256 (FIPS 186-4).
@ k_ra8_psa_alg_aes_gcm
AES-GCM AEAD (NIST SP 800-38D).
@ k_ra8_psa_alg_sha_256
SHA-256 hash (FIPS 180-4).
ra8_psa_limits_t
Static-pool sizing constants for the PSA Crypto facade.
@ k_ra8_psa_max_keys
Maximum simultaneous key handles handed out by the pool.
@ k_ra8_psa_gcm_tag_len
AES-GCM authentication tag length (16 octets).
@ k_ra8_psa_max_key_bytes
Maximum imported raw-key length in bytes (P-384 + AES-256).
@ k_ra8_psa_sha256_len
SHA-256 digest length (RFC 6234, Section 4.1).
@ k_ra8_psa_gcm_nonce_len
AES-GCM nonce length used by ra8_psa_aead_* (NIST SP 800-38D).
@ k_ra8_psa_max_sig_bytes
Maximum ECDSA signature length we ever emit (P-384 raw r||s).
ra8_err_t ra8_psa_aead_encrypt(ra8_psa_key_t handle, ra8_psa_alg_t alg, const uint8_t *nonce, size_t nonce_len, const uint8_t *aad, size_t aad_len, const uint8_t *plain, size_t plain_len, uint8_t *out, size_t out_cap, size_t *out_len)
Encrypt + authenticate a buffer with AES-GCM.
Attributes describing a key being imported.
ra8_psa_alg_t alg
Algorithm the key is permitted to drive.
ra8_psa_key_type_t type
Key type family (AES, ECDSA priv, ...).
ra8_psa_key_usage_t usage
Allowed operations on this key.
Forward declaration of the static-pool slot type.