Skip to content

Commit 01a2653

Browse files
Update trussed to use new virtual store
1 parent cb30a2c commit 01a2653

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ ciborium = { version = "0.2.2" }
5454
ciborium-io = "0.2.2"
5555
cipher = "0.4.4"
5656
ctaphid = { version = "0.3.1", default-features = false }
57-
ctaphid-dispatch = "0.2"
57+
ctaphid-dispatch = "0.3"
5858
delog = { version = "0.1.6", features = ["std-log"] }
5959
env_logger = "0.11.0"
6060
hex-literal = "0.4.1"
6161
hmac = "0.12.1"
6262
interchange = "0.3.0"
6363
itertools = "0.14.0"
64-
littlefs2 = "0.5.0"
64+
littlefs2 = "0.6.0"
6565
log = "0.4.21"
6666
p256 = { version = "0.13.2", features = ["ecdh"] }
6767
rand = "0.8.4"
@@ -71,17 +71,17 @@ serde_test = "1.0.176"
7171
trussed = { version = "0.1", features = ["virt"] }
7272
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt", "fs-info"] }
7373
trussed-usbip = { version = "0.0.1", default-features = false, features = ["ctaphid"] }
74-
usbd-ctaphid = "0.2.0"
74+
usbd-ctaphid = "0.3.0"
7575
x509-parser = "0.16.0"
7676

7777
[package.metadata.docs.rs]
7878
features = ["dispatch"]
7979

8080
[patch.crates-io]
81-
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.19" }
82-
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
83-
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "1e1ca03a3a62ea9b802f4070ea4bce002eeb4bec" }
84-
trussed-usbip = { git = "https://github.com/trussed-dev/pc-usbip-runner.git", rev = "4fe4e4e287dac1d92fcd4f97e8926497bfa9d7a9" }
81+
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.20" }
82+
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "024e0eca5fb7dbd2457831f7c7bffe4341e08775" }
83+
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "7922d67e9637a87e5625aaff9e5111f0d4ec0346" }
84+
trussed-usbip = { git = "https://github.com/trussed-dev/pc-usbip-runner.git", rev = "504674453c9573a30aa2f155101df49eb2af1ba7" }
8585

8686
[profile.test]
8787
opt-level = 2

src/credential.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ mod test {
787787
key::{Kind, Secrecy},
788788
store::keystore::{ClientKeystore, Keystore as _},
789789
types::Location,
790-
virt::{self, Ram},
790+
virt::{self, StoreConfig},
791791
Platform as _,
792792
};
793793

@@ -960,7 +960,7 @@ mod test {
960960
);
961961
const SERIALIZED_CREDENTIAL: &[u8] = &hex!("A3000201A700A1626964684A6F686E20446F6501A16269644301020302187B03F404260582014301020306F4024C000000000000000000000000");
962962

963-
virt::with_platform(Ram::default(), |mut platform| {
963+
virt::with_platform(StoreConfig::ram(), |mut platform| {
964964
let kek = [0; 44];
965965
let client_id = path!("fido");
966966
let kek = {
@@ -1030,7 +1030,7 @@ mod test {
10301030

10311031
#[test]
10321032
fn credential_ids() {
1033-
trussed::virt::with_ram_client("fido", |mut client| {
1033+
trussed::virt::with_client(StoreConfig::ram(), "fido", |mut client| {
10341034
let kek = syscall!(client.generate_chacha8poly1305_key(Location::Internal)).key;
10351035
let nonce = ByteArray::new([0; 12]);
10361036
let data = credential_data();
@@ -1092,7 +1092,7 @@ mod test {
10921092
large_blob_key: Some(ByteArray::new([0xff; 32])),
10931093
third_party_payment: Some(true),
10941094
};
1095-
trussed::virt::with_ram_client("fido", |mut client| {
1095+
trussed::virt::with_client(StoreConfig::ram(), "fido", |mut client| {
10961096
let kek = syscall!(client.generate_chacha8poly1305_key(Location::Internal)).key;
10971097
let rp_id_hash = syscall!(client.hash_sha256(rp_id.as_ref()))
10981098
.hash

tests/virt/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{
44
borrow::Cow,
55
cell::RefCell,
66
fmt::{self, Debug, Formatter},
7-
ops::Deref as _,
87
sync::{
98
atomic::{AtomicBool, Ordering},
109
Arc, Once,
@@ -19,7 +18,7 @@ use ctaphid::{
1918
error::{RequestError, ResponseError},
2019
HidDevice, HidDeviceInfo,
2120
};
22-
use ctaphid_dispatch::{Channel, Dispatch, Requester};
21+
use ctaphid_dispatch::{Channel, Dispatch, Requester, DEFAULT_MESSAGE_SIZE};
2322
use fido_authenticator::{Authenticator, Config, Conforming};
2423
use littlefs2::{object_safe::DynFilesystem, path, path::PathBuf};
2524
use rand::{
@@ -30,7 +29,7 @@ use trussed::{
3029
backend::BackendId,
3130
platform::Platform as _,
3231
store::Store as _,
33-
virt::{self, Ram},
32+
virt::{self, StoreConfig},
3433
};
3534
use trussed_staging::virt::{BackendIds, Client, Dispatcher};
3635

@@ -199,10 +198,10 @@ impl HidDeviceInfo for DeviceInfo {
199198
}
200199
}
201200

202-
pub struct Device<'a>(RefCell<Pipe<'a>>);
201+
pub struct Device<'a>(RefCell<Pipe<'a, DEFAULT_MESSAGE_SIZE>>);
203202

204203
impl<'a> Device<'a> {
205-
fn new(requester: Requester<'a>) -> Self {
204+
fn new(requester: Requester<'a, DEFAULT_MESSAGE_SIZE>) -> Self {
206205
Self(RefCell::new(Pipe::new(requester)))
207206
}
208207
}
@@ -249,10 +248,10 @@ impl HidDevice for Device<'_> {
249248

250249
fn with_client<F, F2, T>(files: &[(PathBuf, Vec<u8>)], f: F, inspect_ifs: F2) -> T
251250
where
252-
F: FnOnce(Client<Ram>) -> T,
251+
F: FnOnce(Client) -> T,
253252
F2: FnOnce(&dyn DynFilesystem),
254253
{
255-
virt::with_platform(Ram::default(), |mut platform| {
254+
virt::with_platform(StoreConfig::ram(), |mut platform| {
256255
// virt always uses the same seed -- request some random bytes to reach a somewhat random
257256
// state
258257
let uniform = Uniform::from(0..64);
@@ -261,7 +260,8 @@ where
261260
platform.rng().next_u32();
262261
}
263262

264-
let ifs = platform.store().ifs();
263+
let store = platform.store();
264+
let ifs = store.ifs();
265265

266266
for (path, content) in files {
267267
if let Some(dir) = path.parent() {
@@ -280,7 +280,7 @@ where
280280
f,
281281
);
282282

283-
inspect_ifs(ifs.deref());
283+
inspect_ifs(ifs);
284284

285285
result
286286
})

tests/virt/pipe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ enum State {
9393
Sending((Response, MessageState)),
9494
}
9595

96-
pub struct Pipe<'a> {
96+
pub struct Pipe<'a, const N: usize> {
9797
queue: VecDeque<[u8; PACKET_SIZE]>,
9898
state: State,
99-
interchange: Requester<'a>,
99+
interchange: Requester<'a, N>,
100100
buffer: [u8; MESSAGE_SIZE],
101101
last_channel: u32,
102102
implements: u8,
@@ -106,8 +106,8 @@ pub struct Pipe<'a> {
106106
version: Version,
107107
}
108108

109-
impl<'a> Pipe<'a> {
110-
pub fn new(interchange: Requester<'a>) -> Self {
109+
impl<'a, const N: usize> Pipe<'a, N> {
110+
pub fn new(interchange: Requester<'a, N>) -> Self {
111111
Self {
112112
queue: Default::default(),
113113
state: State::Idle,

0 commit comments

Comments
 (0)