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§
Sourcefn generate_keypair(
&mut self,
slot: OpenpgpSlot,
algorithm: &str,
) -> Result<Vec<u8>, CardError>
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.
Sourcefn import_keypair(
&mut self,
slot: OpenpgpSlot,
private_key: &[u8],
) -> Result<(), CardError>
fn import_keypair( &mut self, slot: OpenpgpSlot, private_key: &[u8], ) -> Result<(), CardError>
Import a keypair into the given slot (rare; usually generated in-card).
Sourcefn public_key(&self, slot: OpenpgpSlot) -> Result<Vec<u8>, CardError>
fn public_key(&self, slot: OpenpgpSlot) -> Result<Vec<u8>, CardError>
Get the public key from a slot.
Sourcefn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CardError>
fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CardError>
Decrypt data using the DEC slot.
Sourcefn factory_reset(&mut self) -> Result<(), CardError>
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".