mirror of
https://github.com/trussed-dev/piv-authenticator.git
synced 2026-06-20 04:16:15 -07:00
Add select command support and test
This commit is contained in:
+2
-1
@@ -69,7 +69,7 @@ where
|
||||
|
||||
pub fn select<const R: usize>(
|
||||
&mut self,
|
||||
_apdu: &iso7816::Command<C>,
|
||||
_aid: commands::Select<'_>,
|
||||
reply: &mut Data<R>,
|
||||
) -> Result {
|
||||
use piv_types::Algorithms::*;
|
||||
@@ -132,6 +132,7 @@ where
|
||||
Command::Verify(verify) => self.verify(verify),
|
||||
Command::ChangeReference(change_reference) => self.change_reference(change_reference),
|
||||
Command::GetData(container) => self.get_data(container, reply),
|
||||
Command::Select(aid) => self.select(aid, reply),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,11 @@
|
||||
VerifyDefaultApplicationPin(),
|
||||
VerifyDefaultGlobalPin(expected_status: FunctionNotSupported)
|
||||
]
|
||||
)
|
||||
),
|
||||
IoTest(
|
||||
name: "Select",
|
||||
cmd_resp: [
|
||||
Select
|
||||
]
|
||||
),
|
||||
]
|
||||
|
||||
@@ -206,6 +206,7 @@ enum IoCmd {
|
||||
#[serde(default)]
|
||||
expected_status: Status,
|
||||
},
|
||||
Select,
|
||||
}
|
||||
|
||||
const MATCH_EMPTY: OutputMatcher = OutputMatcher::Len(0);
|
||||
@@ -224,6 +225,7 @@ impl IoCmd {
|
||||
Self::VerifyDefaultGlobalPin { expected_status } => {
|
||||
Self::run_verify_default_global_pin(*expected_status, card)
|
||||
}
|
||||
Self::Select => Self::run_select(card),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +282,37 @@ impl IoCmd {
|
||||
card,
|
||||
)
|
||||
}
|
||||
|
||||
fn run_select(card: &mut setup::Piv) {
|
||||
let matcher = OutputMatcher::Bytes(Cow::Borrowed(&hex!(
|
||||
"
|
||||
61 63 // Card application property template
|
||||
4f 06 000010000100 // Application identifier
|
||||
50 0c 536f6c6f4b65797320504956 // Application label = b\"Solokeys PIV\"
|
||||
|
||||
// URL = b\"https://github.com/solokeys/piv-authenticator\"
|
||||
5f50 2d 68747470733a2f2f6769746875622e636f6d2f736f6c6f6b6579732f7069762d61757468656e74696361746f72
|
||||
|
||||
// Cryptographic Algorithm Identifier Template
|
||||
ac 12
|
||||
80 01 03 // TDES - ECB
|
||||
80 01 0c // AES256 - ECB
|
||||
80 01 11 // P-256
|
||||
80 01 e2 // Ed25519
|
||||
80 01 e3 // X25519
|
||||
06 01 00
|
||||
// Coexistent Tag Allocation Authority Template
|
||||
79 07
|
||||
4f 05 a000000308
|
||||
"
|
||||
)));
|
||||
Self::run_bytes(
|
||||
&hex!("00 A4 04 00 0C A000000308000010000100 00"),
|
||||
&matcher,
|
||||
Status::Success,
|
||||
card,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test_log::test]
|
||||
|
||||
Reference in New Issue
Block a user