pub struct Card<S>where
    S: State,{ /* private fields */ }
Expand description

Representation of an OpenPGP card.

A card transitions between States by starting a transaction (that groups together a number of operations into an atomic sequence) and via PIN presentation.

Depending on the State of the card, and the access privileges that are associated with that state, different operations can be performed. In many cases, client software will want to transition between states while performing one activity for the user.

Implementations§

source§

impl Card<Open>

source

pub fn transaction(&mut self) -> Result<Card<Transaction<'_>>, Error>

source

pub fn into_card(self) -> Box<dyn CardBackend + Send + Sync>

Get the internal CardBackend.

This is useful to perform operations on the card with a different crate, e.g. yubikey-management.

source§

impl<'a> Card<Transaction<'a>>

source

pub fn new(opt: OpenPgpTransaction<'a>) -> Result<Self, Error>

Do not use!

FIXME: this interface is currently used in card-functionality, for testing. It will be removed.

source

pub fn reload_ard(&mut self) -> Result<(), Error>

Replace cached “application related data” in this instance of Open with the current data on the card.

This is needed e.g. after importing or generating keys on a card, to see these changes reflected in self.ard.

source

pub fn feature_pinpad_verify(&mut self) -> bool

source

pub fn feature_pinpad_modify(&mut self) -> bool

source

pub fn verify_user(&mut self, pin: &[u8]) -> Result<(), Error>

source

pub fn verify_user_pinpad( &mut self, pinpad_prompt: &dyn Fn() ) -> Result<(), Error>

source

pub fn verify_user_for_signing(&mut self, pin: &[u8]) -> Result<(), Error>

source

pub fn verify_user_for_signing_pinpad( &mut self, pinpad_prompt: &dyn Fn() ) -> Result<(), Error>

source

pub fn verify_admin(&mut self, pin: &[u8]) -> Result<(), Error>

source

pub fn verify_admin_pinpad( &mut self, pinpad_prompt: &dyn Fn() ) -> Result<(), Error>

source

pub fn check_user_verified(&mut self) -> Result<(), Error>

Ask the card if the user password has been successfully verified.

NOTE: on some cards this functionality seems broken.

source

pub fn check_admin_verified(&mut self) -> Result<(), Error>

Ask the card if the admin password has been successfully verified.

NOTE: on some cards this functionality seems broken.

source

pub fn change_user_pin(&mut self, old: &[u8], new: &[u8]) -> Result<(), Error>

source

pub fn change_user_pin_pinpad( &mut self, pinpad_prompt: &dyn Fn() ) -> Result<(), Error>

source

pub fn reset_user_pin(&mut self, rst: &[u8], new: &[u8]) -> Result<(), Error>

source

pub fn change_admin_pin(&mut self, old: &[u8], new: &[u8]) -> Result<(), Error>

source

pub fn change_admin_pin_pinpad( &mut self, pinpad_prompt: &dyn Fn() ) -> Result<(), Error>

source

pub fn user_card<'b>(&'b mut self) -> Option<Card<User<'a, 'b>>>

Get a view of the card authenticated for “User” commands.

source

pub fn signing_card<'b>(&'b mut self) -> Option<Card<Sign<'a, 'b>>>

Get a view of the card authenticated for Signing.

source

pub fn admin_card<'b>(&'b mut self) -> Option<Card<Admin<'a, 'b>>>

Get a view of the card authenticated for “Admin” commands.

source

pub fn application_identifier(&self) -> Result<ApplicationIdentifier, Error>

source

pub fn historical_bytes(&self) -> Result<HistoricalBytes, Error>

source

pub fn extended_length_information( &self ) -> Result<Option<ExtendedLengthInfo>, Error>

source

pub fn extended_capabilities(&self) -> Result<ExtendedCapabilities, Error>

source

pub fn algorithm_attributes(&self, key_type: KeyType) -> Result<Algo, Error>

source

pub fn pw_status_bytes(&self) -> Result<PWStatusBytes, Error>

PW status Bytes

source

pub fn fingerprints(&self) -> Result<KeySet<Fingerprint>, Error>

source

pub fn ca_fingerprints(&self) -> Result<[Option<Fingerprint>; 3], Error>

source

pub fn key_generation_times(&self) -> Result<KeySet<KeyGenerationTime>, Error>

source

pub fn key_information(&self) -> Result<Option<KeyInformation>, Error>

source

pub fn uif_signing(&self) -> Result<Option<UIF>, Error>

source

pub fn uif_decryption(&self) -> Result<Option<UIF>, Error>

source

pub fn uif_authentication(&self) -> Result<Option<UIF>, Error>

source

pub fn uif_attestation(&self) -> Result<Option<UIF>, Error>

source

pub fn login_data(&mut self) -> Result<String, Error>

source

pub fn url(&mut self) -> Result<String, Error>

Get “hardholder” URL from the card.

“The URL should contain a link to a set of public keys in OpenPGP format, related to the card.”

source

pub fn cardholder_name(&mut self) -> Result<Option<String>, Error>

Get cardholder name as a String (this also normalizes the “<” and “<<” filler chars)

source

pub fn security_support_template( &mut self ) -> Result<SecuritySupportTemplate, Error>

source

pub fn select_data( &mut self, num: u8, tag: &[u8], yk_workaround: bool ) -> Result<(), Error>

SELECT DATA (“select a DO in the current template”).

source

pub fn cardholder_certificate(&mut self) -> Result<Vec<u8>, Error>

Get cardholder certificate.

Call select_data() before calling this fn to select a particular certificate (if the card supports multiple certificates).

source

pub fn next_cardholder_certificate(&mut self) -> Result<Vec<u8>, Error>

“GET NEXT DATA” for the DO cardholder certificate.

Cardholder certificate data for multiple slots can be read from the card by first calling cardholder_certificate(), followed by up to two calls to next_cardholder_certificate().

source

pub fn algorithm_information(&mut self) -> Result<Option<AlgoInfo>, Error>

source

pub fn manage_security_environment( &mut self, for_operation: KeyType, key_ref: KeyType ) -> Result<(), Error>

“MANAGE SECURITY ENVIRONMENT” Make key_ref usable for the operation normally done by the key designated by for_operation

source

pub fn attestation_certificate(&mut self) -> Result<Vec<u8>, Error>

Get “Attestation Certificate (Yubico)”

source

pub fn attestation_key_fingerprint( &mut self ) -> Result<Option<Fingerprint>, Error>

source

pub fn attestation_key_algorithm_attributes( &mut self ) -> Result<Option<Algo>, Error>

source

pub fn attestation_key_generation_time( &mut self ) -> Result<Option<KeyGenerationTime>, Error>

source

pub fn firmware_version(&mut self) -> Result<Vec<u8>, Error>

Firmware Version, YubiKey specific (?)

source

pub fn set_identity(&mut self, id: u8) -> Result<(), Error>

Set “identity”, Nitrokey Start specific (possible values: 0, 1, 2). https://docs.nitrokey.com/start/windows/multiple-identities.html

A Nitrokey Start can present as 3 different virtual OpenPGP cards. This command enables one of those virtual cards.

Each virtual card identity behaves like a separate, independent OpenPGP card.

source

pub fn public_key_material( &mut self, key_type: KeyType ) -> Result<PublicKeyMaterial, Error>

source

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

Delete all state on this OpenPGP card

source

pub fn public_key(&mut self, kt: KeyType) -> Result<Option<PublicKey>, Error>

Get PublicKey representation for a key slot on the card

source§

impl<'app, 'open> Card<User<'app, 'open>>

source

pub fn decryptor( &mut self, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> Result<CardDecryptor<'_, 'app>, Error>

source

pub fn decryptor_from_public( &mut self, pubkey: PublicKey, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> CardDecryptor<'_, 'app>

source

pub fn authenticator( &mut self, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> Result<CardSigner<'_, 'app>, Error>

source

pub fn authenticator_from_public( &mut self, pubkey: PublicKey, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> CardSigner<'_, 'app>

source§

impl<'app, 'open> Card<Sign<'app, 'open>>

source

pub fn signer( &mut self, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> Result<CardSigner<'_, 'app>, Error>

source

pub fn signer_from_public( &mut self, pubkey: PublicKey, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> CardSigner<'_, 'app>

source

pub fn generate_attestation( &mut self, key_type: KeyType, touch_prompt: &'open (dyn Fn() + Send + Sync) ) -> Result<(), Error>

Generate Attestation (Yubico)

source§

impl<'app, 'open> Card<Admin<'app, 'open>>

source

pub fn as_open(&mut self) -> &mut Card<Transaction<'app>>

source§

impl Card<Admin<'_, '_>>

source

pub fn set_name(&mut self, name: &str) -> Result<(), Error>

source

pub fn set_lang(&mut self, lang: &[Lang]) -> Result<(), Error>

source

pub fn set_sex(&mut self, sex: Sex) -> Result<(), Error>

source

pub fn set_login_data(&mut self, login_data: &str) -> Result<(), Error>

source

pub fn set_url(&mut self, url: &str) -> Result<(), Error>

Set “hardholder” URL on the card.

“The URL should contain a link to a set of public keys in OpenPGP format, related to the card.”

source

pub fn set_uif( &mut self, key: KeyType, policy: TouchPolicy ) -> Result<(), Error>

source

pub fn set_resetting_code(&mut self, pin: &[u8]) -> Result<(), Error>

source

pub fn set_pso_enc_dec_key(&mut self, key: &[u8]) -> Result<(), Error>

source

pub fn reset_user_pin(&mut self, new: &[u8]) -> Result<(), Error>

source

pub fn upload_key( &mut self, vka: ValidErasedKeyAmalgamation<'_, SecretParts>, key_type: KeyType, password: Option<String> ) -> Result<(), Error>

Upload a ValidErasedKeyAmalgamation to the card as a specific KeyType.

(The caller needs to make sure that vka is suitable as key_type)

source

pub fn generate_key_simple( &mut self, key_type: KeyType, algo: Option<AlgoSimple> ) -> Result<(PublicKeyMaterial, KeyGenerationTime), Error>

Trait Implementations§

source§

impl<B> From<B> for Card<Open>where B: Into<Box<dyn CardBackend + Send + Sync>>,

source§

fn from(backend: B) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Card<S>where S: RefUnwindSafe,

§

impl<S> Send for Card<S>where S: Send,

§

impl<S> Sync for Card<S>where S: Sync,

§

impl<S> Unpin for Card<S>where S: Unpin,

§

impl<S> UnwindSafe for Card<S>where S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V