Struct openpgp_card_rpgp::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, mpis: &[Mpi]) -> 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 KeyTrait for CardSlot<'_, '_>

source§

fn fingerprint(&self) -> Vec<u8>

source§

fn key_id(&self) -> KeyId

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

fn algorithm(&self) -> PublicKeyAlgorithm

source§

fn is_signing_key(&self) -> bool

source§

fn is_encryption_key(&self) -> bool

source§

impl PublicKeyTrait for CardSlot<'_, '_>

source§

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

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

fn encrypt<R: CryptoRng + Rng>( &self, rng: &mut R, plain: &[u8], ) -> Result<Vec<Mpi>>

Encrypt the given plain for this key.
source§

fn to_writer_old(&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§

impl SecretKeyTrait for CardSlot<'_, '_>

§

type PublicKey = PublicKey

§

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<Vec<Mpi>>
where F: FnOnce() -> String,

source§

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

source§

fn public_params(&self) -> &PublicParams

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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