Skip to main content

PsaProvider

Struct PsaProvider 

Source
pub struct PsaProvider<B> { /* private fields */ }
Expand description

Adapts a concrete backend into a stable PSA provider API.

Implementations§

Source§

impl<B> PsaProvider<B>

Source

pub fn new(backend: B) -> Self

Constructs a provider from a concrete backend implementation.

§Arguments
  • backend - Backend implementation used by provider operations.
§Returns

A new PsaProvider owning the backend.

Source§

impl<B: PsaCryptoBackend> PsaProvider<B>

Source

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

Dispatches signing requests to the configured backend.

§Arguments
  • self - Provider dispatching to backend.
  • request - Signing request to execute.
§Returns

Signature bytes produced by backend.

§Errors

Returns backend-provided Error on failures.

Source

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

Dispatches decrypt requests with uniform decrypt failure posture.

§Arguments
  • self - Provider dispatching to backend.
  • request - Decrypt request to execute.
§Returns

Plaintext bytes returned by backend.

§Errors

Returns Error::CryptoFailure for decrypt failures to avoid oracle leakage.

Source

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

Dispatches derive requests to the configured backend.

§Arguments
  • self - Provider dispatching to backend.
  • request - Derive request to execute.
§Returns

Shared secret bytes produced by backend.

§Errors

Returns backend-provided Error on failures.

Source

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

Fills output bytes with backend-provided random data.

§Arguments
  • self - Provider dispatching to backend.
  • out - Mutable output buffer to fill.
§Returns

Ok(()) when random output was written to the caller buffer.

§Errors

Returns backend-provided Error when random generation fails.

Source

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

Computes SHA-256 using backend digest implementation.

§Arguments
  • self - Provider dispatching to backend.
  • input - Bytes to hash.
§Returns

32-byte SHA-256 digest bytes.

§Errors

Returns backend-provided Error on hashing failures.

Source

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

Encrypts plaintext with backend AES-GCM implementation.

§Arguments
  • self - Provider dispatching to backend.
  • request - AES-GCM request with key/nonce/aad/plaintext.
§Returns

Ciphertext bytes plus a 16-byte authentication tag.

§Errors

Returns backend-provided Error when encryption fails.

Trait Implementations§

Source§

impl<B: Clone> Clone for PsaProvider<B>

Source§

fn clone(&self) -> PsaProvider<B>

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<B: Debug> Debug for PsaProvider<B>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B> Freeze for PsaProvider<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for PsaProvider<B>
where B: RefUnwindSafe,

§

impl<B> Send for PsaProvider<B>
where B: Send,

§

impl<B> Sync for PsaProvider<B>
where B: Sync,

§

impl<B> Unpin for PsaProvider<B>
where B: Unpin,

§

impl<B> UnsafeUnpin for PsaProvider<B>
where B: UnsafeUnpin,

§

impl<B> UnwindSafe for PsaProvider<B>
where B: UnwindSafe,

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.