Update trussed-core to v0.2

This commit is contained in:
Robin Krahl
2026-03-23 12:48:06 +01:00
parent 488fffc989
commit c93a7b27b4
6 changed files with 56 additions and 45 deletions
+11
View File
@@ -6,6 +6,17 @@
- Replace `trussed-rsa-alloc` dependency with `trussed-rsa-types` for most use cases.
(Only the `virt` feature still requires `trussed-rsa-alloc`.)
- Update dependencies:
- `apdu-app` v0.2
- `cbor-smol` v0.5
- `flexiber` v0.2
- `heapless` v0.9
- `heapless-bytes` v0.5
- `iso7816` v0.2
- `trussed-chunked` v0.3
- `trussed-core` v0.2
- `trussed-hpke` v0.3
- `trussed-wrap-key-to-file` v0.3
## [v0.5.3][] (2025-07-31)
+14 -14
View File
@@ -12,7 +12,7 @@ name = "vpicc"
required-features = ["vpicc"]
[dependencies]
apdu-app = { version = "0.1", optional = true }
apdu-app = { version = "0.2", optional = true }
cbor-smol = { version = "0.5", features = ["heapless-bytes-v0-5"] }
delog = { version = "0.1.5", optional = true }
flexiber = { version = "0.2", features = ["derive", "heapless"] }
@@ -21,7 +21,7 @@ hex-literal = "0.3"
iso7816 = "0.2.0"
serde = { version = "1", default-features = false, features = ["derive"] }
trussed = { version = "0.1", default-features = false, features = ["aes256-cbc", "chacha8-poly1305", "crypto-client", "ed255", "filesystem-client", "p256", "p384", "shared-secret", "serde-extensions", "tdes", "x255"], optional = true }
trussed-auth = "0.4"
trussed-auth = "0.5"
trussed-auth-backend = { version = "0.1.0", optional = true }
untrusted = "0.9"
vpicc = { version = "0.1.0", optional = true }
@@ -29,13 +29,13 @@ log = "0.4"
heapless-bytes = "0.5.0"
subtle = { version = "2", default-features = false }
# TODO: only enable rsa features when needed
trussed-core = { version = "0.1.0-rc.1", features = ["aes256-cbc", "chacha8-poly1305", "crypto-client", "ed255", "filesystem-client", "p256", "p384", "rsa2048", "rsa3072", "rsa4096", "shared-secret", "tdes", "x255"] }
trussed-rsa-types = { version = "0.1", optional = true }
trussed-rsa-alloc = { version = "0.3", features = ["raw"], optional = true }
trussed-chunked = "0.2.0"
trussed-hpke = "0.2.0"
trussed-wrap-key-to-file = "0.2.0"
trussed-staging = { version = "0.3.2", features = ["chunked", "hpke", "wrap-key-to-file"], default-features = false, optional = true }
trussed-core = { version = "0.2", features = ["aes256-cbc", "chacha8-poly1305", "crypto-client", "ed255", "filesystem-client", "p256", "p384", "rsa2048", "rsa3072", "rsa4096", "shared-secret", "tdes", "x255"] }
trussed-rsa-types = { version = "0.2", optional = true }
trussed-rsa-alloc = { version = "0.4", features = ["raw"], optional = true }
trussed-chunked = "0.3.0"
trussed-hpke = "0.3.0"
trussed-wrap-key-to-file = "0.3.0"
trussed-staging = { version = "0.4", features = ["chunked", "hpke", "wrap-key-to-file"], default-features = false, optional = true }
littlefs2-core = "0.1.0"
cfg-if = "1.0.0"
@@ -52,7 +52,7 @@ des = "0.8"
aes = "0.8.2"
stoppable_thread = "0.2.1"
expectrl = "0.7.0"
iso7816 = { version = "0.1.2", features = ["std"] }
iso7816 = { version = "0.2", features = ["std"] }
# Examples
# usbip
@@ -83,10 +83,10 @@ log-error = []
dangerous-test-real-card = []
[patch.crates-io]
trussed = { git = "https://github.com/trussed-dev/trussed", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
trussed-rsa-alloc = { git = "https://github.com/trussed-dev/trussed-rsa-backend.git", tag = "v0.3.0" }
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "1e1ca03a3a62ea9b802f4070ea4bce002eeb4bec" }
trussed-auth-backend = { git = "https://github.com/trussed-dev/trussed-auth", tag = "v0.4.0" }
trussed = { git = "https://github.com/trussed-dev/trussed", rev = "0f8df68be879acdde1f8cf428c11e5d29692a47b" }
trussed-auth-backend = { git = "https://github.com/trussed-dev/trussed-auth", tag = "backend-v0.1.0" }
trussed-rsa-alloc = { git = "https://github.com/trussed-dev/trussed-rsa-backend.git", tag = "v0.4.0" }
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "v0.4.0" }
[profile.dev.package.rsa]
opt-level = 2
+10 -12
View File
@@ -460,7 +460,7 @@ impl Volatile {
client: &mut T,
) -> &'this mut PinVerified {
self.clear_pin_verified(client);
let pin = Bytes::try_from(&value.0).expect("Convertion of static array");
let pin = Bytes::from(&value.0);
let syscall_res = try_syscall!(client.get_pin_key(PinType::UserPin, pin));
let pin_key = match syscall_res {
Err(_err) => {
@@ -680,7 +680,7 @@ impl Persistent {
value: &Puk,
client: &mut T,
) -> Result<Option<KeyId>, Status> {
let puk = Bytes::try_from(&value.0).expect("Convertion of static array");
let puk = Bytes::from(&value.0);
try_syscall!(client.get_pin_key(PinType::Puk, puk))
.map(|r| r.result)
.map_err(|_err| {
@@ -695,8 +695,8 @@ impl Persistent {
new_value: &Pin,
client: &mut T,
) -> bool {
let old_pin = Bytes::try_from(&old_value.0).expect("Convertion of static array");
let new_pin = Bytes::try_from(&new_value.0).expect("Convertion of static array");
let old_pin = Bytes::from(&old_value.0);
let new_pin = Bytes::from(&new_value.0);
try_syscall!(client.change_pin(PinType::UserPin, old_pin, new_pin))
.map(|r| r.success)
.unwrap_or(false)
@@ -708,8 +708,8 @@ impl Persistent {
new_value: &Puk,
client: &mut T,
) -> bool {
let old_puk = Bytes::try_from(&old_value.0).expect("Convertion of static array");
let new_puk = Bytes::try_from(&new_value.0).expect("Convertion of static array");
let old_puk = Bytes::from(&old_value.0);
let new_puk = Bytes::from(&new_value.0);
try_syscall!(client.change_pin(PinType::Puk, old_puk, new_puk))
.map(|r| r.success)
.unwrap_or(false)
@@ -721,7 +721,7 @@ impl Persistent {
old_key: KeyId,
client: &mut T,
) -> Result<(), Status> {
let new_pin = Bytes::try_from(&new_pin.0).expect("Convertion of static array");
let new_pin = Bytes::from(&new_pin.0);
try_syscall!(client.set_pin_with_key(
PinType::UserPin,
new_pin,
@@ -740,7 +740,7 @@ impl Persistent {
new_puk: Puk,
client: &mut T,
) -> Result<(), Status> {
let new_puk = Bytes::try_from(&new_puk.0).expect("Convertion of static array");
let new_puk = Bytes::from(&new_puk.0);
try_syscall!(client.set_pin(PinType::Puk, new_puk, Some(Self::PUK_RETRIES_DEFAULT), true))
.map_err(|_err| {
error!("Failed to set puk");
@@ -858,8 +858,7 @@ impl Persistent {
}
fn init_pins<T: crate::Client>(client: &mut T, options: &crate::Options) -> Result<(), Status> {
let default_pin =
Bytes::try_from(&Self::DEFAULT_PIN.0).expect("Convertion of static array");
let default_pin = Bytes::from(&Self::DEFAULT_PIN.0);
try_syscall!(client.set_pin(
PinType::UserPin,
default_pin.clone(),
@@ -870,8 +869,7 @@ impl Persistent {
error!("Failed to set pin");
Status::UnspecifiedPersistentExecutionError
})?;
let default_puk =
Bytes::try_from(&Self::DEFAULT_PUK.0).expect("Convertion of static array");
let default_puk = Bytes::from(&Self::DEFAULT_PUK.0);
try_syscall!(client.set_pin(
PinType::Puk,
default_puk.clone(),
+14 -10
View File
@@ -213,23 +213,22 @@ pub mod dispatch {
use std::path::PathBuf;
use trussed::{
types::Bytes,
virt::{self, Client, Filesystem, Ram, StoreProvider},
virt::{self, Client, StorageConfig, StoreConfig},
};
/// Client type using a dispatcher with the backends required by opcard
pub type VirtClient<S> = Client<S, dispatch::Dispatch>;
pub type VirtClient<'a> = Client<'a, dispatch::Dispatch>;
/// Run a client using a provided store
pub fn with_client<S, R, F>(store: S, client_id: &str, f: F) -> R
pub fn with_client<R, F>(store: StoreConfig, client_id: &str, f: F) -> R
where
F: FnOnce(VirtClient<S>) -> R,
S: StoreProvider,
F: FnOnce(VirtClient<'_>) -> R,
{
#[allow(clippy::unwrap_used)]
virt::with_platform(store, |platform| {
platform.run_client_with_backends(
client_id,
dispatch::Dispatch::with_hw_key(Bytes::from_slice(b"some bytes").unwrap()),
dispatch::Dispatch::with_hw_key(Bytes::from(b"some bytes")),
dispatch::BACKENDS,
f,
)
@@ -240,17 +239,22 @@ where
/// using storage backed by a file
pub fn with_fs_client<P, R, F>(internal: P, client_id: &str, f: F) -> R
where
F: FnOnce(VirtClient<Filesystem>) -> R,
F: FnOnce(VirtClient<'_>) -> R,
P: Into<PathBuf>,
{
with_client(Filesystem::new(internal), client_id, f)
let store = StoreConfig {
internal: StorageConfig::filesystem(internal.into()),
external: StorageConfig::ram(),
volatile: StorageConfig::ram(),
};
with_client(store, client_id, f)
}
/// Run the backend with the extensions required by opcard
/// using a RAM file storage
pub fn with_ram_client<R, F>(client_id: &str, f: F) -> R
where
F: FnOnce(VirtClient<Ram>) -> R,
F: FnOnce(VirtClient<'_>) -> R,
{
with_client(Ram::default(), client_id, f)
with_client(StoreConfig::ram(), client_id, f)
}
+5 -6
View File
@@ -1,5 +1,4 @@
use iso7816::{command::FromSliceError, Command, Status};
use trussed::virt::Ram;
use crate::virt::VirtClient;
@@ -14,15 +13,15 @@ const RESPONSE_LEN: usize = 7609;
///
/// This struct provides a vpicc PIV smart card implementation that can be used with
/// `vpicc-rs` and [`vsmartcard`](https://frankmorgner.github.io/vsmartcard/) to emulate the card.
pub struct VpiccCard {
pub struct VpiccCard<'a> {
request_buffer: RequestBuffer<REQUEST_LEN>,
response_buffer: ResponseBuffer<RESPONSE_LEN>,
card: Authenticator<VirtClient<Ram>>,
card: Authenticator<VirtClient<'a>>,
}
impl VpiccCard {
impl<'a> VpiccCard<'a> {
/// Creates a new virtual smart card from the given card.
pub fn new(card: Authenticator<VirtClient<Ram>>) -> Self {
pub fn new(card: Authenticator<VirtClient<'a>>) -> Self {
Self {
request_buffer: Default::default(),
response_buffer: Default::default(),
@@ -46,7 +45,7 @@ impl VpiccCard {
}
}
impl vpicc::VSmartCard for VpiccCard {
impl vpicc::VSmartCard for VpiccCard<'_> {
fn power_on(&mut self) {}
fn power_off(&mut self) {
+2 -3
View File
@@ -12,13 +12,12 @@ use piv_authenticator::{
virt::{with_ram_client, VirtClient},
Authenticator, Options,
};
use trussed::virt::Ram;
pub type Piv = piv_authenticator::Authenticator<VirtClient<Ram>>;
pub type Piv<'a> = piv_authenticator::Authenticator<VirtClient<'a>>;
pub const WITHOUT_UUID: Options = Options::new();
pub fn piv<R>(options: Options, test: impl FnOnce(&mut Piv) -> R) -> R {
pub fn piv<R>(options: Options, test: impl FnOnce(&mut Piv<'_>) -> R) -> R {
with_ram_client("test", |client| {
let mut piv_app = Authenticator::new(client, options);
test(&mut piv_app)