This commit is contained in:
Nicolas Stalder
2021-06-05 22:44:59 +02:00
parent 52b9ec3cf4
commit 30d2ef148f
4 changed files with 92 additions and 51 deletions
-49
View File
@@ -194,55 +194,6 @@ impl TryFrom<Tag<'_>> for Container {
}
}
// pub mod container {
#[derive(Decodable, Encodable)]
#[tlv(application, number = "0x13")]
pub struct CardHolderUniqueIdentifier {
#[tlv(slice, simple = "0x30")]
fasc_n: [u8; 25],
#[tlv(slice, simple = "0x33")]
duns: [u8; 9],
#[tlv(slice, simple = "0x34")]
guid: [u8; 16],
#[tlv(slice, simple = "0x35")]
expiration_date: [u8; 8], // YYYYMMDD
#[tlv(slice, simple = "0x3E")]
issuer_asymmetric_signature: [u8; 1],
#[tlv(slice, simple = "0xFE")]
error_detection_code: [u8; 0],
}
#[derive(Decodable, Encodable)]
#[tlv(application, number = "0x1E")] // = 0x7E
pub struct DiscoveryObject {
#[tlv(slice, application, number = "0xF")]
piv_card_application_aid: [u8; 11], // tag: 0x4F, max bytes = 12,
#[tlv(slice, application, number = "0x2f")]
pin_usage_policy: [u8; 2], // tag: 0x5F2F, max bytes = 2,
}
// // '5FC1 02' (351B)
// DataObjects::CardHolderUniqueIdentifier => {
// // pivy: https://git.io/JfzBo
// // https://www.idmanagement.gov/wp-content/uploads/sites/1171/uploads/TIG_SCEPACS_v2.3.pdf
// let mut der = Der::<consts::U1024>::default();
// der.nested(0x53, |der| {
// // der.raw_tlv(0x30, FASC_N)?; // pivy: 26B, TIG: 25B
// der.raw_tlv(0x30, &[0x99, 0x99])?; // 9999 = non-federal; pivy: 26B, TIG: 25B
// // der.raw_tlv(0x34, DUNS)?; // ? - pivy skips
// der.raw_tlv(0x34, GUID)?; // 16B type 1,2,4 UUID
// // der.raw_tlv(0x35, EXPIRATION_DATE)?; // [u8; 8], YYYYMMDD
// der.raw_tlv(0x35, b"22220101")?; // [u8; 8], YYYYMMDD
// // der.raw_tlv(0x36, CARDHOLDER_UUID)?; // 16B, like GUID
// // der.raw_tlv(0x3E, SIGNATURE)?; // ? - pivy only checks for non-zero entry
// der.raw_tlv(0x3E, b" ")?; // ? - pivy only checks for non-zero entry
// Ok(())
// }).unwrap();
// Ok(der.to_bytes())
// }
// #[derive(Clone, Copy, PartialEq)]
// pub struct CertInfo {
+10 -2
View File
@@ -11,13 +11,13 @@ pub mod commands;
pub use commands::Command;
pub mod constants;
pub mod container;
#[cfg(feature = "apdu-dispatch")]
mod dispatch;
pub mod state;
pub mod derp;
pub mod piv_types;
pub use piv_types::{Pin, Puk};
#[cfg(feature = "apdu-dispatch")]
mod apdu_dispatch;
use core::convert::TryInto;
@@ -931,6 +931,14 @@ where
// todo!("biometric information template"),
}
// '5FC1 07' (351B)
Container::CardCapabilityContainer => {
piv_types::CardCapabilityContainer::default()
.encode_to_heapless_vec(reply)
.unwrap();
info_now!("returning CCC {}", hex_str!(reply));
}
// '5FC1 02' (351B)
Container::CardHolderUniqueIdentifier => {
let guid = self.state.persistent(&mut self.trussed).guid();
+82
View File
@@ -252,6 +252,23 @@ pub struct CardHolderUniqueIdentifier<'l> {
error_detection_code: [u8; 0],
}
// #[derive(Decodable, Encodable)]
// #[tlv(application, number = "0x13")]
// pub struct CardHolderUniqueIdentifier {
// #[tlv(slice, simple = "0x30")]
// fasc_n: [u8; 25],
// // #[tlv(slice, simple = "0x33")]
// // duns: [u8; 9],
// #[tlv(slice, simple = "0x34")]
// guid: [u8; 16],
// #[tlv(slice, simple = "0x35")]
// expiration_date: [u8; 8], // YYYYMMDD
// #[tlv(slice, simple = "0x3E")]
// issuer_asymmetric_signature: [u8; 1],
// #[tlv(slice, simple = "0xFE")]
// error_detection_code: [u8; 0],
// }
impl Default for CardHolderUniqueIdentifier<'static> {
fn default() -> Self {
Self {
@@ -274,3 +291,68 @@ impl CardHolderUniqueIdentifier<'_> {
modified_self
}
}
#[derive(Clone, Copy, Encodable, Eq, PartialEq)]
#[tlv(application, number = "0x13")]
pub struct CardCapabilityContainer {
#[tlv(slice, simple = "0xF0")]
card_identifier: [u8; 0],
#[tlv(slice, simple = "0xF1")]
capability_container_version: [u8; 0],
#[tlv(slice, simple = "0xF2")]
capability_container_grammar: [u8; 0],
#[tlv(slice, simple = "0xF3")]
application_card_url: [u8; 0],
#[tlv(slice, simple = "0xF4")]
pkcs_15: [u8; 0],
#[tlv(slice, simple = "0xF5")]
/// This is the only one that needs
/// to be filled, namely with 0x10
registered_data_model_number: [u8; 1],
#[tlv(slice, simple = "0xF6")]
access_control_rule_table: [u8; 0],
#[tlv(slice, simple = "0xF7")]
card_apdus: [u8; 0],
#[tlv(slice, simple = "0xFA")]
redirection_tag: [u8; 0],
#[tlv(slice, simple = "0xFB")]
capability_tuples: [u8; 0],
#[tlv(slice, simple = "0xFC")]
status_tuples: [u8; 0],
#[tlv(slice, simple = "0xFD")]
next_ccc: [u8; 0],
#[tlv(slice, simple = "0xFE")]
error_detection_code: [u8; 0],
}
impl Default for CardCapabilityContainer {
fn default() -> Self {
Self {
card_identifier: [],
capability_container_version: [],
capability_container_grammar: [],
application_card_url: [],
pkcs_15: [],
registered_data_model_number: [0x10],
access_control_rule_table: [],
card_apdus: [],
redirection_tag: [],
capability_tuples: [],
status_tuples: [],
next_ccc: [],
error_detection_code: [],
}
}
}
#[derive(Clone, Copy, Encodable, Eq, PartialEq)]
#[tlv(application, number = "0x13")]
pub struct DiscoveryObject {
#[tlv(slice, application, number = "0xF")]
piv_card_application_aid: [u8; 11], // tag: 0x4F, max bytes = 12,
#[tlv(slice, application, number = "0x2f")]
pin_usage_policy: [u8; 2], // tag: 0x5F2F, max bytes = 2,
}