Rename Features -> ExCapFeatures
This commit is contained in:
parent
48803eb454
commit
ad929598ce
4 changed files with 25 additions and 25 deletions
|
@ -33,7 +33,7 @@ use sequoia_openpgp as openpgp;
|
|||
use openpgp_card::algorithm::{Algo, AlgoInfo, Curve};
|
||||
use openpgp_card::card_do::{
|
||||
ApplicationIdentifier, ApplicationRelatedData, CardholderRelatedData,
|
||||
ExtendedCapabilities, ExtendedLengthInfo, Features, Fingerprint,
|
||||
ExCapFeatures, ExtendedCapabilities, ExtendedLengthInfo, Fingerprint,
|
||||
HistoricalBytes, KeyGenerationTime, PWStatusBytes,
|
||||
SecuritySupportTemplate, Sex,
|
||||
};
|
||||
|
@ -697,7 +697,7 @@ impl CardBase {
|
|||
// The DO "Algorithm Information" (Tag FA) shall be present if
|
||||
// Algorithm attributes can be changed
|
||||
let ec = self.get_extended_capabilities()?;
|
||||
if !ec.features().contains(&Features::AlgoAttrsChangeable) {
|
||||
if !ec.features().contains(&ExCapFeatures::AlgoAttrsChangeable) {
|
||||
// Algorithm attributes can not be changed,
|
||||
// list_supported_algo is not supported
|
||||
return Ok(None);
|
||||
|
|
|
@ -236,7 +236,7 @@ pub struct CardServiceData {
|
|||
/// 4.4.3.7 Extended Capabilities
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct ExtendedCapabilities {
|
||||
features: HashSet<Features>,
|
||||
features: HashSet<ExCapFeatures>,
|
||||
sm_algo: u8,
|
||||
max_len_challenge: u16,
|
||||
max_len_cardholder_cert: u16,
|
||||
|
@ -247,7 +247,7 @@ pub struct ExtendedCapabilities {
|
|||
|
||||
/// Features (first byte of Extended Capabilities, see 4.4.3.7)
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub enum Features {
|
||||
pub enum ExCapFeatures {
|
||||
SecureMessaging,
|
||||
GetChallenge,
|
||||
KeyImport,
|
||||
|
|
|
@ -8,36 +8,36 @@ use nom::{combinator, number::complete as number, sequence};
|
|||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use crate::card_do::{complete, ExtendedCapabilities, Features};
|
||||
use crate::card_do::{complete, ExCapFeatures, ExtendedCapabilities};
|
||||
use crate::Error;
|
||||
|
||||
fn features(input: &[u8]) -> nom::IResult<&[u8], HashSet<Features>> {
|
||||
fn features(input: &[u8]) -> nom::IResult<&[u8], HashSet<ExCapFeatures>> {
|
||||
combinator::map(number::u8, |b| {
|
||||
let mut f = HashSet::new();
|
||||
|
||||
if b & 0x80 != 0 {
|
||||
f.insert(Features::SecureMessaging);
|
||||
f.insert(ExCapFeatures::SecureMessaging);
|
||||
}
|
||||
if b & 0x40 != 0 {
|
||||
f.insert(Features::GetChallenge);
|
||||
f.insert(ExCapFeatures::GetChallenge);
|
||||
}
|
||||
if b & 0x20 != 0 {
|
||||
f.insert(Features::KeyImport);
|
||||
f.insert(ExCapFeatures::KeyImport);
|
||||
}
|
||||
if b & 0x10 != 0 {
|
||||
f.insert(Features::PwStatusChange);
|
||||
f.insert(ExCapFeatures::PwStatusChange);
|
||||
}
|
||||
if b & 0x08 != 0 {
|
||||
f.insert(Features::PrivateUseDOs);
|
||||
f.insert(ExCapFeatures::PrivateUseDOs);
|
||||
}
|
||||
if b & 0x04 != 0 {
|
||||
f.insert(Features::AlgoAttrsChangeable);
|
||||
f.insert(ExCapFeatures::AlgoAttrsChangeable);
|
||||
}
|
||||
if b & 0x02 != 0 {
|
||||
f.insert(Features::Aes);
|
||||
f.insert(ExCapFeatures::Aes);
|
||||
}
|
||||
if b & 0x01 != 0 {
|
||||
f.insert(Features::KdfDo);
|
||||
f.insert(ExCapFeatures::KdfDo);
|
||||
}
|
||||
|
||||
f
|
||||
|
@ -46,7 +46,7 @@ fn features(input: &[u8]) -> nom::IResult<&[u8], HashSet<Features>> {
|
|||
|
||||
fn parse(
|
||||
input: &[u8],
|
||||
) -> nom::IResult<&[u8], (HashSet<Features>, u8, u16, u16, u16, u8, u8)> {
|
||||
) -> nom::IResult<&[u8], (HashSet<ExCapFeatures>, u8, u16, u16, u16, u8, u8)> {
|
||||
nom::combinator::all_consuming(sequence::tuple((
|
||||
features,
|
||||
number::u8,
|
||||
|
@ -59,7 +59,7 @@ fn parse(
|
|||
}
|
||||
|
||||
impl ExtendedCapabilities {
|
||||
pub fn features(&self) -> HashSet<Features> {
|
||||
pub fn features(&self) -> HashSet<ExCapFeatures> {
|
||||
self.features.clone()
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl TryFrom<&[u8]> for ExtendedCapabilities {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::card_do::extended_cap::{ExtendedCapabilities, Features};
|
||||
use crate::card_do::extended_cap::{ExCapFeatures, ExtendedCapabilities};
|
||||
use hex_literal::hex;
|
||||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
|
@ -103,12 +103,12 @@ mod test {
|
|||
ec,
|
||||
ExtendedCapabilities {
|
||||
features: HashSet::from_iter(vec![
|
||||
Features::GetChallenge,
|
||||
Features::KeyImport,
|
||||
Features::PwStatusChange,
|
||||
Features::PrivateUseDOs,
|
||||
Features::AlgoAttrsChangeable,
|
||||
Features::KdfDo
|
||||
ExCapFeatures::GetChallenge,
|
||||
ExCapFeatures::KeyImport,
|
||||
ExCapFeatures::PwStatusChange,
|
||||
ExCapFeatures::PrivateUseDOs,
|
||||
ExCapFeatures::AlgoAttrsChangeable,
|
||||
ExCapFeatures::KdfDo
|
||||
]),
|
||||
sm_algo: 0x0,
|
||||
max_len_challenge: 0xbfe,
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::apdu::command::Command;
|
|||
use crate::apdu::commands;
|
||||
use crate::card_app::CardApp;
|
||||
use crate::card_do::{
|
||||
ApplicationRelatedData, Features, Fingerprint, KeyGenerationTime,
|
||||
ApplicationRelatedData, ExCapFeatures, Fingerprint, KeyGenerationTime,
|
||||
};
|
||||
use crate::crypto_data::{
|
||||
CardUploadableKey, EccKey, EccPub, PrivateKeyMaterial, PublicKeyMaterial,
|
||||
|
@ -198,7 +198,7 @@ pub(crate) fn key_import(
|
|||
if ard
|
||||
.get_extended_capabilities()?
|
||||
.features()
|
||||
.contains(&Features::AlgoAttrsChangeable)
|
||||
.contains(&ExCapFeatures::AlgoAttrsChangeable)
|
||||
{
|
||||
card_app.set_algorithm_attributes(key_type, &algo)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue