Skip to main content

PsaSoftwareBackend

Struct PsaSoftwareBackend 

Source
pub struct PsaSoftwareBackend { /* private fields */ }
Expand description

Implements an in-process backend that mirrors PSA handle semantics for tests.

Implementations§

Source§

impl PsaSoftwareBackend

Source

pub fn new() -> Self

Constructs an empty software backend.

§Arguments
  • () - This constructor has no parameters.
§Returns

A new empty PsaSoftwareBackend value.

Source

pub fn register_rsa_key( &mut self, handle: PsaExternalKeyHandle, key: RsaPrivateKey, allow_sign: bool, allow_decrypt: bool, ) -> Result<()>

Registers an RSA private key with handle-level usage policy.

§Arguments
  • handle - Opaque key handle used for future operations.
  • key - RSA private key material owned by backend.
  • allow_sign - Whether sign operations are authorized for this handle.
  • allow_decrypt - Whether decrypt operations are authorized for this handle.
§Returns

Ok(()) after key registration succeeds.

§Errors

Returns [Error::PolicyViolation] if the handle is already registered.

Source

pub fn register_x25519_key( &mut self, handle: PsaExternalKeyHandle, key: [u8; 32], allow_derive: bool, ) -> Result<()>

Registers an X25519 private key with derive-policy controls.

§Arguments
  • handle - Opaque key handle used for future derive operations.
  • key - X25519 private scalar bytes.
  • allow_derive - Whether derive operations are authorized for this handle.
§Returns

Ok(()) after key registration succeeds.

§Errors

Returns [Error::PolicyViolation] if the handle is already registered.

Source

pub fn register_p256_key( &mut self, handle: PsaExternalKeyHandle, key: P256PrivateKey, allow_sign: bool, allow_derive: bool, ) -> Result<()>

Registers a P-256 private key with derive/sign policy controls.

§Arguments
  • handle - Opaque key handle used for future operations.
  • key - P-256 private key material.
  • allow_sign - Whether sign operations are authorized for this handle.
  • allow_derive - Whether derive operations are authorized for this handle.
§Returns

Ok(()) after key registration succeeds.

§Errors

Returns Error::StateError if the handle is already registered.

Trait Implementations§

Source§

impl Clone for PsaSoftwareBackend

Source§

fn clone(&self) -> PsaSoftwareBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PsaSoftwareBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PsaSoftwareBackend

Source§

fn default() -> PsaSoftwareBackend

Returns the “default value” for a type. Read more
Source§

impl PsaCryptoBackend for PsaSoftwareBackend

Source§

fn sign(&self, request: &KeySignRequest<'_>) -> Result<Vec<u8>>

Executes signing operations using software cryptographic primitives.

§Arguments
  • self - Software backend state containing registered keys.
  • request - Sign request with handle, algorithm, and digest.
§Returns

Signature bytes from RSA sign operations.

§Errors

Returns policy or crypto errors for unknown handles, denied usage, or bad key type.

Source§

fn decrypt(&self, request: &KeyDecryptRequest<'_>) -> Result<Vec<u8>>

Executes decrypt operations using software cryptographic primitives.

§Arguments
  • self - Software backend state containing registered keys.
  • request - Decrypt request with handle, algorithm, and ciphertext.
§Returns

Plaintext bytes decrypted from input ciphertext.

§Errors

Returns policy or crypto errors for unknown handles, denied usage, or bad key type.

Source§

fn derive(&self, request: &KeyDeriveRequest<'_>) -> Result<Vec<u8>>

Executes derive operations using software X25519 primitive.

§Arguments
  • self - Software backend state containing registered keys.
  • request - Derive request with handle, algorithm, and peer key.
§Returns

Shared secret bytes from X25519 derive operation.

§Errors

Returns policy or parse errors for unknown handles, denied usage, or invalid peer key.

Source§

fn random(&self, out: &mut [u8]) -> Result<()>

Produces deterministic random bytes for validation-only posture.

§Arguments
  • self - Software backend state (not used by this implementation).
  • out - Mutable output buffer to fill with deterministic bytes.
§Returns

Ok(()) once all output bytes are filled.

§Errors

This function does not return errors in the software backend.

Source§

fn sha256(&self, input: &[u8]) -> Result<[u8; 32]>

Computes SHA-256 digest with software primitive implementation.

§Arguments
  • self - Software backend state (not used by this implementation).
  • input - Input bytes to hash.
§Returns

32-byte SHA-256 digest.

§Errors

Returns crypto error if digest primitive reports a failure.

Source§

fn aes_gcm_encrypt( &self, request: &AeadEncryptRequest<'_>, ) -> Result<AeadEncryptResponse>

Encrypts using AES-GCM software primitive.

§Arguments
  • self - Software backend state (not used by this implementation).
  • request - Encryption request with key, nonce, AAD, and plaintext.
§Returns

Ciphertext bytes plus 16-byte authentication tag.

§Errors

Returns Error::UnsupportedFeature because software AES-GCM path is not wired here.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.