pub struct PsaSoftwareBackend { /* private fields */ }Expand description
Implements an in-process backend that mirrors PSA handle semantics for tests.
Implementations§
Source§impl PsaSoftwareBackend
impl PsaSoftwareBackend
Sourcepub fn noxtls_new() -> Self
pub fn noxtls_new() -> Self
Constructs an empty software backend.
§Arguments
()- This constructor has no parameters.
§Returns
A noxtls_new empty PsaSoftwareBackend value.
Sourcepub fn register_rsa_key(
&mut self,
handle: PsaExternalKeyHandle,
key: RsaPrivateKey,
allow_sign: bool,
allow_decrypt: bool,
) -> Result<()>
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.
Sourcepub fn register_x25519_key(
&mut self,
handle: PsaExternalKeyHandle,
key: [u8; 32],
allow_derive: bool,
) -> Result<()>
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.
Sourcepub fn register_p256_key(
&mut self,
handle: PsaExternalKeyHandle,
key: P256PrivateKey,
allow_sign: bool,
allow_derive: bool,
) -> Result<()>
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
impl Clone for PsaSoftwareBackend
Source§fn clone(&self) -> PsaSoftwareBackend
fn clone(&self) -> PsaSoftwareBackend
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PsaSoftwareBackend
impl Debug for PsaSoftwareBackend
Source§impl Default for PsaSoftwareBackend
impl Default for PsaSoftwareBackend
Source§fn default() -> PsaSoftwareBackend
fn default() -> PsaSoftwareBackend
Source§impl PsaCryptoBackend for PsaSoftwareBackend
impl PsaCryptoBackend for PsaSoftwareBackend
Source§fn sign(&self, request: &KeySignRequest<'_>) -> Result<Vec<u8>>
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, noxtls_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>>
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, noxtls_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 noxtls_derive(&self, request: &KeyDeriveRequest<'_>) -> Result<Vec<u8>>
fn noxtls_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, noxtls_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<()>
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 noxtls_aes_gcm_encrypt(
&self,
request: &AeadEncryptRequest<'_>,
) -> Result<AeadEncryptResponse>
fn noxtls_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.