diff --git a/src/lib.rs b/src/lib.rs index 2c0c6af..26d9824 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,7 +69,7 @@ where pub fn select( &mut self, - _apdu: &iso7816::Command, + _aid: commands::Select<'_>, reply: &mut Data, ) -> 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!(), } } diff --git a/tests/command_response.ron b/tests/command_response.ron index 5bf2d6d..bcee492 100644 --- a/tests/command_response.ron +++ b/tests/command_response.ron @@ -8,5 +8,11 @@ VerifyDefaultApplicationPin(), VerifyDefaultGlobalPin(expected_status: FunctionNotSupported) ] - ) + ), + IoTest( + name: "Select", + cmd_resp: [ + Select + ] + ), ] diff --git a/tests/command_response.rs b/tests/command_response.rs index bc1f7b7..15d49f9 100644 --- a/tests/command_response.rs +++ b/tests/command_response.rs @@ -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]