Skip to main content

OpenpgpCardBackend

Trait OpenpgpCardBackend 

Source
pub trait OpenpgpCardBackend {
    // Required methods
    fn card_id(&self) -> Result<CardId, CardError>;
    fn generate_keypair(
        &mut self,
        slot: OpenpgpSlot,
        algorithm: &str,
    ) -> Result<Vec<u8>, CardError>;
    fn import_keypair(
        &mut self,
        slot: OpenpgpSlot,
        private_key: &[u8],
    ) -> Result<(), CardError>;
    fn public_key(&self, slot: OpenpgpSlot) -> Result<Vec<u8>, CardError>;
    fn sign(&self, digest: &[u8]) -> Result<Vec<u8>, CardError>;
    fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CardError>;
    fn verify_pin(&self, pin: &str) -> Result<(), CardError>;
    fn verify_admin_pin(&self, admin_pin: &str) -> Result<(), CardError>;
    fn factory_reset(&mut self) -> Result<(), CardError>;
}
Expand description

Backend trait for talking to OpenPGP cards.

Not Send + Sync because some backends (e.g. rnp) hold raw FFI handles that librnp does not mark thread-safe.

Required Methods§

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§