Skip to main content

MockOpenpgpCardBackend

Struct MockOpenpgpCardBackend 

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

In-memory mock backend (no hardware). Testing only.

Implementations§

Source§

impl MockOpenpgpCardBackend

Source

pub fn new(card_id: impl Into<String>) -> Self

Construct a new mock backend.

Trait Implementations§

Source§

impl OpenpgpCardBackend for MockOpenpgpCardBackend

Source§

fn card_id(&self) -> Result<CardId, CardError>

Get the card identifier.
Source§

fn generate_keypair( &mut self, slot: OpenpgpSlot, algorithm: &str, ) -> Result<Vec<u8>, CardError>

Generate a new keypair in the given slot. Returns the public key bytes.
Source§

fn import_keypair( &mut self, _slot: OpenpgpSlot, _private_key: &[u8], ) -> Result<(), CardError>

Import a keypair into the given slot (rare; usually generated in-card).
Source§

fn public_key(&self, slot: OpenpgpSlot) -> Result<Vec<u8>, CardError>

Get the public key from a slot.
Source§

fn sign(&self, digest: &[u8]) -> Result<Vec<u8>, CardError>

Sign data using the SIG slot.
Source§

fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CardError>

Decrypt data using the DEC slot.
Source§

fn verify_pin(&self, _pin: &str) -> Result<(), CardError>

Verify the user PIN.
Source§

fn verify_admin_pin(&self, _admin_pin: &str) -> Result<(), CardError>

Verify the admin PIN.
Source§

fn factory_reset(&mut self) -> Result<(), CardError>

Reset the card (wipes all keys; requires admin or special procedure).

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> 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, 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.