Use apdu-app instead of apdu-dispatch

This commit is contained in:
Robin Krahl
2024-10-17 23:15:14 +02:00
parent c5bddba53d
commit 21ddbf12a3
2 changed files with 12 additions and 14 deletions
+1 -2
View File
@@ -10,7 +10,7 @@ description = "Administrative Trussed app for SoloKeys Solo 2 security keys"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apdu-dispatch = "0.1"
apdu-app = "0.1"
cbor-smol = { version = "0.4.0", features = ["heapless-v0-7", "heapless-bytes-v0-3"] }
ctaphid-dispatch = "0.1"
delog = "0.1"
@@ -42,7 +42,6 @@ log-error = []
migration-tests = []
[patch.crates-io]
apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev = "915fc237103fcecc29d0f0b73391f19abf6576de" }
ctaphid-dispatch = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", rev = "57cb3317878a8593847595319aa03ef17c29ec5b" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "ebd27e49ca321089d01d8c9b169c4aeb58ceeeca" }
trussed = { git = "https://github.com/Nitrokey/trussed.git", tag = "v0.1.0-nitrokey.18" }
+11 -12
View File
@@ -1,6 +1,5 @@
use super::Client as TrussedClient;
use apdu_dispatch::iso7816::Status;
use apdu_dispatch::{app as apdu, command, dispatch::Interface, response, Command as ApduCommand};
use apdu_app::{CommandView, Interface, Status};
use cbor_smol::{cbor_deserialize, cbor_serialize_to};
use core::{convert::TryInto, marker::PhantomData, time::Duration};
use ctaphid_dispatch::app::{self as hid, Command as HidCommand, Message};
@@ -584,7 +583,7 @@ where
}
}
impl<T, R, S, C> apdu::App<{ command::SIZE }, { response::SIZE }> for App<T, R, S, C>
impl<T, R, S, C, const N: usize> apdu_app::App<N> for App<T, R, S, C>
where
T: TrussedClient,
R: Reboot,
@@ -594,9 +593,9 @@ where
fn select(
&mut self,
_interface: Interface,
_apdu: &ApduCommand,
_reply: &mut response::Data,
) -> apdu::Result {
_apdu: CommandView<'_>,
_reply: &mut apdu_app::Data<N>,
) -> apdu_app::Result {
Ok(())
}
@@ -604,15 +603,15 @@ where
fn call(
&mut self,
interface: apdu::Interface,
apdu: &ApduCommand,
reply: &mut response::Data,
) -> apdu::Result {
interface: Interface,
apdu: CommandView<'_>,
reply: &mut apdu_app::Data<N>,
) -> apdu_app::Result {
let instruction: u8 = apdu.instruction().into();
let command = Command::try_from(instruction)?;
// Reboot may only be called over USB
if command == Command::Reboot && interface != apdu::Interface::Contact {
if command == Command::Reboot && interface != Interface::Contact {
return Err(Status::ConditionsOfUseNotSatisfied);
}
@@ -622,7 +621,7 @@ where
if command == Command::Update || command == Command::Version {
self.exec(command, &[apdu.p1], reply)
} else {
self.exec(command, apdu.data().as_slice(), reply)
self.exec(command, apdu.data(), reply)
}
.map_err(From::from)
}