Struct CardSlot

Source
pub struct CardSlot<'cs, 't> { /* private fields */ }
Expand description

An individual OpenPGP card key slot, which can be used for private key operations.

Implementations§

Source§

impl<'cs, 't> CardSlot<'cs, 't>

Source

pub fn with_public_key( tx: &'cs mut Card<Transaction<'t>>, key_type: KeyType, public_key: PublicKey, touch_prompt: &'cs (dyn Fn() + Send + Sync), ) -> Result<Self, Error>

Set up a CardSigner for the card behind tx, using the key slot for key_type.

Initializes the CardSigner based on public key information obtained from public_key.

Source

pub fn init_from_card( tx: &'cs mut Card<Transaction<'t>>, key_type: KeyType, touch_prompt: &'cs (dyn Fn() + Send + Sync), ) -> Result<Self, Error>

Set up a CardSlot for the card behind tx, using the key slot for key_type.

Initializes the CardSigner based on public key information obtained from the card.

Source§

impl CardSlot<'_, '_>

Source

pub fn public_key(&self) -> &PublicKey

The OpenPGP public key material that corresponds to the key in this CardSlot

Source

pub fn key_type(&self) -> KeyType

The card slot that this CardSlot uses

Source

pub fn decrypt( &self, values: &PkeskBytes, ) -> Result<(Vec<u8>, SymmetricKeyAlgorithm)>

Source

pub fn decrypt_message(&self, message: &Message) -> Result<Message, Error>

Trait Implementations§

Source§

impl Debug for CardSlot<'_, '_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PublicKeyTrait for CardSlot<'_, '_>

Source§

fn version(&self) -> KeyVersion

Source§

fn fingerprint(&self) -> Fingerprint

Source§

fn key_id(&self) -> KeyId

Returns the Key ID of the associated primary key.
Source§

fn algorithm(&self) -> PublicKeyAlgorithm

Source§

fn created_at(&self) -> &DateTime<Utc>

Source§

fn expiration(&self) -> Option<u16>

Source§

fn verify_signature( &self, hash: HashAlgorithm, data: &[u8], sig: &SignatureBytes, ) -> Result<()>

Verify a signed message. Data will be hashed using hash, before verifying.
Source§

fn encrypt<R: CryptoRng + Rng>( &self, rng: R, plain: &[u8], typ: EskType, ) -> Result<PkeskBytes>

Encrypt the given plain for this key.
Source§

fn serialize_for_hashing(&self, writer: &mut impl Write) -> Result<()>

This is the data used for hashing in a signature. Only uses the public portion of the key.
Source§

fn public_params(&self) -> &PublicParams

Source§

fn is_signing_key(&self) -> bool

Source§

fn is_encryption_key(&self) -> bool

Source§

impl SecretKeyTrait for CardSlot<'_, '_>

Source§

type PublicKey = PublicKey

Source§

type Unlocked = CardSlot<'_, '_>

The type representing the unlocked version of this.
Source§

fn unlock<F, G, T>(&self, _pw: F, work: G) -> Result<T>
where F: FnOnce() -> String, G: FnOnce(&Self::Unlocked) -> Result<T>,

Unlock the raw data in the secret parameters.
Source§

fn create_signature<F>( &self, _key_pw: F, hash: HashAlgorithm, data: &[u8], ) -> Result<SignatureBytes>
where F: FnOnce() -> String,

Source§

fn public_key(&self) -> Self::PublicKey

Source§

fn hash_alg(&self) -> HashAlgorithm

The suggested hash algorithm to calculate the signature hash digest with, when using this key as a signer

Auto Trait Implementations§

§

impl<'cs, 't> !Freeze for CardSlot<'cs, 't>

§

impl<'cs, 't> !RefUnwindSafe for CardSlot<'cs, 't>

§

impl<'cs, 't> Send for CardSlot<'cs, 't>

§

impl<'cs, 't> Sync for CardSlot<'cs, 't>

§

impl<'cs, 't> Unpin for CardSlot<'cs, 't>

§

impl<'cs, 't> !UnwindSafe for CardSlot<'cs, 't>

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V