Move KeySet from card_do.rs to lib.rs
(It is not a DO, only a container to conveniently handle triples of DO)
This commit is contained in:
parent
6b3ae2cf62
commit
f5b31aac26
3 changed files with 36 additions and 36 deletions
|
@ -34,14 +34,14 @@ use openpgp_card::algorithm::{Algo, AlgoInfo, Curve};
|
||||||
use openpgp_card::card_do::{
|
use openpgp_card::card_do::{
|
||||||
ApplicationIdentifier, ApplicationRelatedData, CardholderRelatedData,
|
ApplicationIdentifier, ApplicationRelatedData, CardholderRelatedData,
|
||||||
ExtendedCapabilities, ExtendedLengthInfo, Features, Fingerprint,
|
ExtendedCapabilities, ExtendedLengthInfo, Features, Fingerprint,
|
||||||
HistoricalBytes, KeyGenerationTime, KeySet, PWStatusBytes,
|
HistoricalBytes, KeyGenerationTime, PWStatusBytes,
|
||||||
SecuritySupportTemplate, Sex,
|
SecuritySupportTemplate, Sex,
|
||||||
};
|
};
|
||||||
use openpgp_card::crypto_data::{
|
use openpgp_card::crypto_data::{
|
||||||
CardUploadableKey, Cryptogram, EccKey, EccType, Hash, PrivateKeyMaterial,
|
CardUploadableKey, Cryptogram, EccKey, EccType, Hash, PrivateKeyMaterial,
|
||||||
PublicKeyMaterial, RSAKey,
|
PublicKeyMaterial, RSAKey,
|
||||||
};
|
};
|
||||||
use openpgp_card::{CardApp, CardClientBox, Error, KeyType, Response};
|
use openpgp_card::{CardApp, CardClientBox, Error, KeySet, KeyType, Response};
|
||||||
|
|
||||||
use crate::signer::CardSigner;
|
use crate::signer::CardSigner;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::collections::HashSet;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use crate::{algorithm::Algo, tlv::Tlv, Error, KeyType};
|
use crate::{algorithm::Algo, tlv::Tlv, Error, KeySet, KeyType};
|
||||||
|
|
||||||
mod algo_attrs;
|
mod algo_attrs;
|
||||||
mod algo_info;
|
mod algo_info;
|
||||||
|
@ -334,39 +334,7 @@ impl PWStatusBytes {
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
pub struct Fingerprint([u8; 20]);
|
pub struct Fingerprint([u8; 20]);
|
||||||
|
|
||||||
/// A KeySet binds together a triple of information about each Key on a card
|
/// Helper fn for nom parsing
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
||||||
pub struct KeySet<T> {
|
|
||||||
signature: Option<T>,
|
|
||||||
decryption: Option<T>,
|
|
||||||
authentication: Option<T>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> From<(Option<T>, Option<T>, Option<T>)> for KeySet<T> {
|
|
||||||
fn from(tuple: (Option<T>, Option<T>, Option<T>)) -> Self {
|
|
||||||
Self {
|
|
||||||
signature: tuple.0,
|
|
||||||
decryption: tuple.1,
|
|
||||||
authentication: tuple.2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> KeySet<T> {
|
|
||||||
pub fn signature(&self) -> Option<&T> {
|
|
||||||
self.signature.as_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn decryption(&self) -> Option<&T> {
|
|
||||||
self.decryption.as_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn authentication(&self) -> Option<&T> {
|
|
||||||
self.authentication.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// nom parsing helper
|
|
||||||
pub(crate) fn complete<O>(
|
pub(crate) fn complete<O>(
|
||||||
result: nom::IResult<&[u8], O>,
|
result: nom::IResult<&[u8], O>,
|
||||||
) -> Result<O, anyhow::Error> {
|
) -> Result<O, anyhow::Error> {
|
||||||
|
|
|
@ -160,3 +160,35 @@ impl KeyType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A KeySet binds together a triple of information about each Key on a card
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct KeySet<T> {
|
||||||
|
signature: Option<T>,
|
||||||
|
decryption: Option<T>,
|
||||||
|
authentication: Option<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> From<(Option<T>, Option<T>, Option<T>)> for KeySet<T> {
|
||||||
|
fn from(tuple: (Option<T>, Option<T>, Option<T>)) -> Self {
|
||||||
|
Self {
|
||||||
|
signature: tuple.0,
|
||||||
|
decryption: tuple.1,
|
||||||
|
authentication: tuple.2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> KeySet<T> {
|
||||||
|
pub fn signature(&self) -> Option<&T> {
|
||||||
|
self.signature.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decryption(&self) -> Option<&T> {
|
||||||
|
self.decryption.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn authentication(&self) -> Option<&T> {
|
||||||
|
self.authentication.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue