More cleanup

This commit is contained in:
Nicolas Stalder
2021-06-05 19:52:16 +02:00
parent 4127b7687a
commit 32757ada31
3 changed files with 40 additions and 29 deletions
-1
View File
@@ -30,7 +30,6 @@ rand_core = { version = "0.5.1", features = ["getrandom"] }
[features]
default = []
applet = ["apdu-dispatch"]
strict-pin = []
log-all = []
+37
View File
@@ -0,0 +1,37 @@
use crate::{Authenticator, constants::PIV_AID, Result};
use apdu_dispatch::{
app::{Aid, App},
command::Size as CommandSize,
Command,
response::{Data, Size as ResponseSize},
};
use trussed::client;
impl<T> Aid for Authenticator<CommandSize, T> {
fn aid(&self) -> &'static [u8] {
&PIV_AID
}
fn right_truncated_length(&self) -> usize {
11
}
}
#[cfg(feature = "apdu-dispatch")]
impl<T> App<CommandSize, ResponseSize> for Authenticator<CommandSize, T>
where
T: client::Client + client::Ed255 + client::Tdes
{
fn select(&mut self, apdu: &Command, reply: &mut Data) -> Result {
self.select(apdu, reply)
}
fn deselect(&mut self) { self.deselect() }
fn call(&mut self, _: iso7816::Interface, apdu: &Command, reply: &mut Data) -> Result {
self.respond(apdu, reply)
}
}
+3 -28
View File
@@ -16,6 +16,9 @@ pub mod derp;
pub mod piv_types;
pub use piv_types::{Pin, Puk};
#[cfg(feature = "apdu-dispatch")]
mod apdu_dispatch;
use core::convert::TryInto;
use flexiber::EncodableHeapless;
@@ -1069,31 +1072,3 @@ where
}
#[cfg(feature = "apdu-dispatch")]
impl<T> apdu_dispatch::app::Aid for Authenticator<apdu_dispatch::command::Size, T> {
fn aid(&self) -> &'static [u8] {
&constants::PIV_AID
}
fn right_truncated_length(&self) -> usize {
11
}
}
#[cfg(feature = "apdu-dispatch")]
impl<T> apdu_dispatch::app::App<apdu_dispatch::command::Size, apdu_dispatch::response::Size> for Authenticator<apdu_dispatch::command::Size, T>
where
T: client::Client + client::Ed255 + client::Tdes
{
fn select(&mut self, apdu: &apdu_dispatch::Command, reply: &mut apdu_dispatch::response::Data) -> Result {
self.select(apdu, reply)
}
fn deselect(&mut self) { self.deselect() }
fn call(&mut self, _: iso7816::Interface, apdu: &apdu_dispatch::Command, reply: &mut apdu_dispatch::response::Data) -> Result {
self.respond(apdu, reply)
}
}