Skip to content

Commit 88950e0

Browse files
Update to trussed-v0.2.0-rc.1
1 parent faeb596 commit 88950e0

6 files changed

Lines changed: 39 additions & 34 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@ trussed-core = { version = "0.2", features = ["serde-extensions"] }
1717

1818
[patch.crates-io]
1919
trussed-auth = { path = "extension" }
20-
21-
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "0b65280d69be541b8771f7756139826332c7d674" }
22-
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", rev = "46f0c4fd9110b7ab68468c8070a5aa290e9654c7" }
23-
apdu-app = { git = "https://github.com/trussed-dev/apdu-dispatch.git", branch = "release" }

backend/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
## Unreleased
1313

14-
-
14+
- Update to `trussed` v0.2.0-rc.1
1515

1616
## [0.1.0][] - 2026-03-23
1717

backend/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repository.workspace = true
1414
serde.workspace = true
1515
trussed-core.workspace = true
1616

17+
cbor-smol = { version = "0.5", features = ["heapless-bytes-v0-5"] }
1718
chacha20poly1305 = { version = "0.10.1", default-features = false, features = ["reduced-round"] }
1819
hkdf = "0.12.3"
1920
hmac = "0.12.1"
@@ -22,14 +23,15 @@ rand_core = "0.6.4"
2223
serde-byte-array = "0.1.2"
2324
sha2 = { version = "0.10.6", default-features = false }
2425
subtle = { version = "2.4.1", default-features = false }
25-
trussed = { version = "0.1.0", default-features = false, features = ["crypto-client", "filesystem-client", "hmac-sha256", "serde-extensions"] }
26+
trussed = { version = "=0.2.0-rc.1", default-features = false, features = ["crypto-client", "filesystem-client", "hmac-sha256", "serde-extensions"] }
2627
trussed-auth = "0.5"
2728

2829
[dev-dependencies]
29-
admin-app = { version = "0.1.0", features = ["migration-tests"] }
30+
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.22", features = ["migration-tests"] }
31+
heapless-bytes = "0.5"
3032
hex-literal = "0.4.1"
3133
quickcheck = { version = "1.0.3", default-features = false }
3234
rand_core = { version = "0.6.4", default-features = false, features = ["getrandom"] }
3335
serde_cbor = { version = "0.11.2", features = ["std"] }
3436
serde_test = "1.0.176"
35-
trussed = { version = "0.1.0", default-features = false, features = ["crypto-client", "filesystem-client", "hmac-sha256", "serde-extensions", "virt"] }
37+
trussed = { version = "=0.2.0-rc.1", default-features = false, features = ["crypto-client", "filesystem-client", "hmac-sha256", "serde-extensions", "virt"] }

backend/src/data.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ use core::ops::Deref;
55

66
use chacha20poly1305::ChaCha8Poly1305;
77
use hmac::{Hmac, Mac};
8-
use littlefs2_core::path;
8+
use littlefs2_core::{path, Path};
9+
use rand_core::{CryptoRng, RngCore};
910
use serde::{Deserialize, Serialize};
1011
use serde_byte_array::ByteArray;
1112
use sha2::{Digest as _, Sha256};
1213
use subtle::ConstantTimeEq as _;
13-
use trussed::{
14-
platform::{CryptoRng, RngCore},
15-
store::filestore::Filestore,
16-
types::{Location, Path},
17-
Bytes,
18-
};
14+
use trussed::store::Filestore;
15+
use trussed_core::types::{Bytes, Location};
1916

2017
use super::Error;
2118
use trussed_auth::{Pin, PinId, MAX_PIN_LENGTH};
@@ -223,14 +220,14 @@ impl PinData {
223220
.read::<SIZE>(&path, location)
224221
.map_err(|_| Error::ReadFailed)?;
225222
let mut data: Self =
226-
trussed::cbor_deserialize(&data).map_err(|_| Error::DeserializationFailed)?;
223+
cbor_smol::cbor_deserialize(&data).map_err(|_| Error::DeserializationFailed)?;
227224
data.id = id;
228225
Ok(data)
229226
}
230227

231228
pub fn save<S: Filestore>(&self, fs: &mut S, location: Location) -> Result<(), Error> {
232-
let data = trussed::cbor_serialize_bytes::<_, SIZE>(self)
233-
.map_err(|_| Error::SerializationFailed)?;
229+
let mut data: Bytes<SIZE> = Bytes::new();
230+
cbor_smol::cbor_serialize_to(self, &mut data).map_err(|_| Error::SerializationFailed)?;
234231
fs.write(&self.id.path(), location, &data)
235232
.map_err(|_| Error::WriteFailed)
236233
}
@@ -520,7 +517,7 @@ pub(crate) fn get_app_salt<S: Filestore, R: CryptoRng + RngCore>(
520517
pub(crate) fn delete_app_salt<S: Filestore>(
521518
fs: &mut S,
522519
location: Location,
523-
) -> Result<(), trussed::Error> {
520+
) -> Result<(), trussed_core::Error> {
524521
if fs.exists(APP_SALT_PATH, location) {
525522
fs.remove_file(APP_SALT_PATH, location)
526523
} else {
@@ -573,7 +570,8 @@ mod tests {
573570
salt: [u8::MAX; SALT_LEN].into(),
574571
data: KeyOrHash::Hash([u8::MAX; HASH_LEN].into()),
575572
};
576-
let serialized = trussed::cbor_serialize_bytes::<_, 1024>(&data).unwrap();
573+
let mut serialized: Bytes<1024> = Bytes::new();
574+
cbor_smol::cbor_serialize_to(&data, &mut serialized).unwrap();
577575
assert!(serialized.len() <= SIZE);
578576
}
579577

@@ -582,7 +580,8 @@ mod tests {
582580
fn test_salt_size() {
583581
// We allow one byte overhead for byte array serialization
584582
let salt = Salt::from([u8::MAX; SALT_LEN]);
585-
let serialized = trussed::cbor_serialize_bytes::<_, 1024>(&salt).unwrap();
583+
let mut serialized: Bytes<1024> = Bytes::new();
584+
cbor_smol::cbor_serialize_to(&salt, &mut serialized).unwrap();
586585
assert!(serialized.len() <= SALT_LEN + 1, "{}", serialized.len());
587586
}
588587

backend/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ use rand_core::{CryptoRng, RngCore};
3131
use sha2::Sha256;
3232
use trussed::{
3333
backend::Backend,
34-
error::Result,
3534
key::{Kind, Secrecy},
3635
platform::Platform,
3736
serde_extensions::ExtensionImpl,
38-
service::{ClientFilestore, Keystore, ServiceResources},
39-
store::{filestore::Filestore, Store},
40-
types::{CoreContext, Location},
41-
Bytes,
37+
service::ServiceResources,
38+
store::{ClientFilestore, Filestore, Keystore, Store},
39+
types::CoreContext,
4240
};
4341
use trussed_auth::{reply, AuthExtension, AuthReply, AuthRequest};
42+
use trussed_core::{
43+
types::{Bytes, Location},
44+
Result,
45+
};
4446

4547
use data::{delete_app_salt, expand_app_key, get_app_salt, Key, PinData, Salt, KEY_LEN, SALT_LEN};
4648

@@ -248,7 +250,7 @@ impl AuthBackend {
248250
}
249251

250252
Ok(fs
251-
.read_dir_first(path!(""), location, &trussed::api::NotBefore::None)?
253+
.read_dir_first(path!(""), location, &trussed_core::types::NotBefore::None)?
252254
.is_some())
253255
}
254256
}
@@ -440,7 +442,7 @@ enum Error {
440442
BadPinType,
441443
}
442444

443-
impl From<Error> for trussed::error::Error {
445+
impl From<Error> for trussed_core::Error {
444446
fn from(error: Error) -> Self {
445447
match error {
446448
Error::NotFound => Self::NoSuchKey,

backend/tests/backend.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33

44
mod dispatch {
55
use trussed::{
6-
api::{reply, request, Reply, Request},
76
backend::{Backend as _, BackendId},
8-
error::Error,
97
platform::Platform,
108
serde_extensions::{ExtensionDispatch, ExtensionId, ExtensionImpl as _},
119
service::ServiceResources,
12-
types::{Bytes, Context, Location},
10+
types::Context,
1311
};
1412
use trussed_auth::AuthExtension;
1513
use trussed_auth_backend::{AuthBackend, AuthContext, MAX_HW_KEY_LEN};
14+
use trussed_core::{
15+
api::{reply, request, Reply, Request},
16+
types::{Bytes, Location},
17+
Error,
18+
};
1619

1720
pub const BACKENDS: &[BackendId<Backend>] =
1821
&[BackendId::Custom(Backend::Auth), BackendId::Core];
@@ -134,13 +137,16 @@ use littlefs2_core::path;
134137
use rand_core::{OsRng, RngCore as _};
135138
use trussed::{
136139
backend::BackendId,
137-
client::{FilesystemClient, HmacSha256},
138-
syscall, try_syscall,
139-
types::{Bytes, Location, Message, PathBuf},
140140
virt::{self, StoreConfig},
141141
};
142142
use trussed_auth::{AuthClient as _, PinId};
143143
use trussed_auth_backend::MAX_HW_KEY_LEN;
144+
use trussed_core::{
145+
mechanisms::HmacSha256,
146+
syscall, try_syscall,
147+
types::{Bytes, Location, Message, PathBuf},
148+
FilesystemClient,
149+
};
144150

145151
use dispatch::{Backend, Dispatch, BACKENDS};
146152

0 commit comments

Comments
 (0)