diff --git a/Cargo.toml b/Cargo.toml index b5aa712..5107c66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,14 +12,17 @@ description = "Administrative Trussed app for SoloKeys Solo 2 security keys" [dependencies] apdu-app = "0.1" cbor-smol = { version = "0.5.0", features = ["heapless-v0-7", "heapless-bytes-v0-3"] } -ctaphid-dispatch = "0.1" +ctaphid-app = "0.1.0-rc.1" delog = "0.1" +heapless = "0.7" +heapless-bytes = "0.3" iso7816 = "0.1" littlefs2 = { version = "0.5", optional = true } littlefs2-core = { version = "0.1", features = ["heapless-bytes03"] } serde = { version = "1.0.180", default-features = false } strum_macros = "0.25.2" -trussed = "0.1" +trussed = { version = "0.1", default-features = false } +trussed-core = { version = "0.1.0-rc.1", features = ["crypto-client", "filesystem-client", "management-client", "ui-client"] } embedded-hal = { version = "0.2.7", optional = true } hex-literal = "0.4.1" @@ -43,7 +46,6 @@ log-error = [] migration-tests = ["dep:littlefs2"] [patch.crates-io] -ctaphid-dispatch = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", rev = "57cb3317878a8593847595319aa03ef17c29ec5b" } -trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "046478b7a4f6e2315acf9112d98308379c2e3eee" } -trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "manage-v0.1.0" } -trussed-se050-manage = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", tag = "se050-manage-v0.1.0" } +trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" } +trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "9355f700831c1a278c334f76382fbf98d82aedcd" } +trussed-se050-manage = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", rev = "a0bb4b92bffb2dc119fcc0cc47259ea7ed59d8a4" } diff --git a/src/admin.rs b/src/admin.rs index 85b3580..6ceccf8 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -2,14 +2,14 @@ use super::Client as TrussedClient; 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}; -use ctaphid_dispatch::command::VendorCommand; +use ctaphid_app::{self as hid, Command as HidCommand, VendorCommand}; +use heapless::Vec; +use heapless_bytes::Bytes; #[cfg(feature = "factory-reset")] use littlefs2_core::PathBuf; use serde::Deserialize; -use trussed::store::Store; -use trussed::try_syscall; -use trussed::{interrupt::InterruptFlag, store::filestore::Filestore, syscall, types::Vec}; +use trussed::store::{filestore::Filestore, Store}; +use trussed_core::{syscall, try_syscall, InterruptFlag}; use crate::config::{self, Config, ConfigError}; use crate::migrations::Migrator; @@ -531,7 +531,7 @@ where } } -impl hid::App<'static> for App +impl hid::App<'static, N> for App where T: TrussedClient, R: Reboot, @@ -554,9 +554,9 @@ where fn call( &mut self, command: HidCommand, - input_data: &Message, - response: &mut Message, - ) -> hid::AppResult { + input_data: &[u8], + response: &mut Bytes, + ) -> Result<(), hid::Error> { let (command, input) = if command == HidCommand::Vendor(ADMIN) { // new mode: first input byte specifies the actual command let (command, input) = input_data.split_first().ok_or(Error::InvalidLength)?; @@ -564,7 +564,7 @@ where (command, input) } else { // old mode: directly use vendor commands + wink - (Command::try_from(command)?, input_data.as_slice()) + (Command::try_from(command)?, input_data) }; self.exec(command, input, response).map_err(From::from) } diff --git a/src/config.rs b/src/config.rs index 0bb70c5..3df212c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,14 +5,15 @@ use core::{ }; use cbor_smol::{cbor_deserialize, cbor_serialize_to}; +use heapless::Vec; use littlefs2_core::{path, Path}; use serde::{de::DeserializeOwned, Serialize}; use strum_macros::FromRepr; -use trussed::{ - store::filestore::Filestore, +use trussed::store::filestore::Filestore; +use trussed_core::{ try_syscall, - types::{Location, Message, Vec}, - Client, + types::{Location, Message}, + FilesystemClient, }; #[derive(Debug)] @@ -312,7 +313,7 @@ pub fn save_filestore( Ok(()) } -pub fn save(client: &mut T, config: &C) -> Result<(), ConfigError> { +pub fn save(client: &mut T, config: &C) -> Result<(), ConfigError> { if config == &Default::default() { if exists(client, LOCATION, FILENAME)? { try_syscall!(client.remove_file(LOCATION, FILENAME.into())) @@ -327,7 +328,11 @@ pub fn save(client: &mut T, config: &C) -> Result<(), Conf Ok(()) } -fn exists(client: &mut T, location: Location, path: &Path) -> Result { +fn exists( + client: &mut T, + location: Location, + path: &Path, +) -> Result { try_syscall!(client.entry_metadata(location, path.into())) .map(|r| r.metadata.is_some()) .map_err(|_| ConfigError::ReadFailed) diff --git a/src/lib.rs b/src/lib.rs index 97a34fd..04d897e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,8 @@ //! It directly implements the APDU and CTAPHID dispatch App interfaces. #![no_std] +use trussed_core::{CryptoClient, FilesystemClient, ManagementClient, UiClient}; + #[macro_use] extern crate delog; generate_macros!(); @@ -24,11 +26,26 @@ use trussed_manage::ManageClient; use trussed_se050_manage::Se050ManageClient; #[cfg(not(feature = "se050"))] -pub trait Client: trussed::Client + ManageClient {} +pub trait Client: + CryptoClient + FilesystemClient + ManagementClient + UiClient + ManageClient +{ +} #[cfg(not(feature = "se050"))] -impl Client for C {} +impl Client for C {} #[cfg(feature = "se050")] -pub trait Client: trussed::Client + Se050ManageClient + ManageClient {} +pub trait Client: + CryptoClient + FilesystemClient + ManagementClient + UiClient + Se050ManageClient + ManageClient +{ +} #[cfg(feature = "se050")] -impl Client for C {} +impl< + C: CryptoClient + + FilesystemClient + + ManagementClient + + UiClient + + Se050ManageClient + + ManageClient, + > Client for C +{ +}