diff --git a/src/commands.rs b/src/commands.rs index 5fbbec6..e3d71ac 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -55,7 +55,7 @@ pub enum Command<'l> { GeneralAuthenticate(GeneralAuthenticate), /// Store a data object / container. PutData(PutData), - GenerateAsymmetric(GenerateAsymmetric), + GenerateAsymmetric(GenerateAsymmetricKeyReference), /* Yubico commands */ YkExtension(YubicoPivExtension), @@ -252,22 +252,6 @@ impl TryFrom<&[u8]> for PutData { } } -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct GenerateAsymmetricArguments<'l> { - pub key_reference: GenerateAsymmetricKeyReference, - pub data: &'l [u8], -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum GenerateAsymmetric {} - -impl TryFrom> for GenerateAsymmetric { - type Error = Status; - fn try_from(_arguments: GenerateAsymmetricArguments<'_>) -> Result { - todo!(); - } -} - impl<'l, const C: usize> TryFrom<&'l iso7816::Command> for Command<'l> { type Error = Status; /// The first layer of unraveling the iso7816::Command onion. @@ -340,13 +324,7 @@ impl<'l, const C: usize> TryFrom<&'l iso7816::Command> for Command<'l> { } (0x00, Instruction::GenerateAsymmetricKeyPair, 0x00, p2) => { - let key_reference = GenerateAsymmetricKeyReference::try_from(p2)?; - Self::GenerateAsymmetric(GenerateAsymmetric::try_from( - GenerateAsymmetricArguments { - key_reference, - data, - }, - )?) + Self::GenerateAsymmetric(GenerateAsymmetricKeyReference::try_from(p2)?) } // (0x00, 0x01, 0x10, 0x00) (0x00, Instruction::Unknown(0x01), 0x00, 0x00) => { diff --git a/src/lib.rs b/src/lib.rs index 7f2ce0c..ce506df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -319,22 +319,13 @@ where pub fn generate_asymmetric_keypair( &mut self, - command: &iso7816::Command, + data: &[u8], reply: &mut Data, ) -> Result { if !self.state.runtime.app_security_status.management_verified { return Err(Status::SecurityStatusNotSatisfied); } - if command.p1 != 0x00 { - return Err(Status::IncorrectP1OrP2Parameter); - } - - if command.p2 != 0x9a { - // TODO: make more general - return Err(Status::FunctionNotSupported); - } - // example: 00 47 00 9A 0B // AC 09 // # P256 @@ -357,7 +348,7 @@ where // } // TODO: iterate on this, don't expect tags.. - let input = derp::Input::from(command.data()); + let input = derp::Input::from(data); // let (mechanism, parameter) = input.read_all(derp::Error::Read, |input| { let (mechanism, _pin_policy, _touch_policy) = input .read_all(derp::Error::Read, |input| { @@ -454,11 +445,8 @@ where Ok(()) } - pub fn put_data(&mut self, command: &iso7816::Command) -> Result { + pub fn put_data(&mut self, data: &[u8]) -> Result { info!("PutData"); - if command.p1 != 0x3f || command.p2 != 0xff { - return Err(Status::IncorrectP1OrP2Parameter); - } // if !self.state.runtime.app_security_status.management_verified { // return Err(Status::SecurityStatusNotSatisfied); @@ -474,7 +462,7 @@ where // 88 1A 89 18 AA 81 D5 48 A5 EC 26 01 60 BA 06 F6 EC 3B B6 05 00 2E B6 3D 4B 28 7F 86 // - let input = derp::Input::from(command.data()); + let input = derp::Input::from(data); let (data_object, data) = input .read_all(derp::Error::Read, |input| { let data_object = derp::expect_tag_and_get_value(input, 0x5c)?;