From c14c496210d625b815cf613bda161410a93bf18d Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 14 Oct 2024 17:57:33 +0200 Subject: [PATCH] Update littlefs2 to v0.5.0 --- Cargo.lock | 183 +++++++++++++++++++---------------------- Cargo.toml | 19 ++--- examples/usbip/main.rs | 64 +++++++++----- src/lib/commands.rs | 3 +- src/lib/rk_files.rs | 7 +- src/lib/state.rs | 5 +- src/lib/wcstate.rs | 5 +- 7 files changed, 147 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 584833d..5438347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,15 +5,15 @@ version = 3 [[package]] name = "admin-app" version = "0.1.0" -source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.16#21ddbf12a3a5f60916c4a47e1bf3e49ce5cf03cd" +source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.18#599d205e47a7430dfed1c37263fa565597b6597f" dependencies = [ "apdu-app", - "cbor-smol 0.4.1", + "cbor-smol", "ctaphid-dispatch", "delog", "hex-literal", "iso7816", - "littlefs2", + "littlefs2-core", "serde", "strum_macros", "trussed", @@ -94,21 +94,22 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bindgen" -version = "0.56.0" +version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", - "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", + "syn 2.0.52", ] [[package]] @@ -119,9 +120,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -165,17 +166,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "cbor-smol" -version = "0.4.1" -source = "git+https://github.com/trussed-dev/cbor-smol.git?rev=d499e527f1214b2998b844720f0d41a9d05be7e1#d499e527f1214b2998b844720f0d41a9d05be7e1" -dependencies = [ - "delog", - "heapless", - "heapless-bytes", - "serde", -] - [[package]] name = "cbor-smol" version = "0.5.0" @@ -183,6 +173,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087b31faa4ad4ba21c9bd0209204eef424dae6424195aafc7242006b69fc8d" dependencies = [ "delog", + "heapless", + "heapless-bytes", "serde", ] @@ -194,9 +186,9 @@ checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" [[package]] name = "cexpr" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ "nom", ] @@ -365,43 +357,14 @@ dependencies = [ "subtle", ] -[[package]] -name = "cstr_core" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956" -dependencies = [ - "cty", - "memchr", -] - -[[package]] -name = "ctap-types" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4fa005ff525537460e1fd70a1ff4f417ae4a6ed14887f3e4720221e20f7562" -dependencies = [ - "bitflags 1.3.2", - "cbor-smol 0.4.1", - "cosey", - "delog", - "heapless", - "heapless-bytes", - "interchange 0.2.2", - "iso7816", - "serde", - "serde-indexed", - "serde_repr", -] - [[package]] name = "ctap-types" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209c174878bcb580b4383484a09dd416c3e1e00fe01c813da57fb9248402de56" +checksum = "e1beeb5a05e42c7cbfb788ce3e9fd6ce7d0aa214893b5ca6cd38d09ac9afe722" dependencies = [ "bitflags 1.3.2", - "cbor-smol 0.4.1", + "cbor-smol", "cosey", "delog", "heapless", @@ -421,7 +384,7 @@ dependencies = [ "delog", "heapless", "heapless-bytes", - "interchange 0.3.0", + "interchange", "ref-swap", "trussed", ] @@ -524,6 +487,12 @@ dependencies = [ "signature 2.2.0", ] +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + [[package]] name = "elliptic-curve" version = "0.10.4" @@ -584,16 +553,17 @@ dependencies = [ [[package]] name = "fido-authenticator" version = "0.1.1" -source = "git+https://github.com/Nitrokey/fido-authenticator.git?tag=v0.1.1-nitrokey.21#629a75f189a3db930070fb19753a9d347afea38d" +source = "git+https://github.com/Nitrokey/fido-authenticator.git?tag=v0.1.1-nitrokey.23#5b6ae97b5f92962b545a1af1bf5b69fee66bca0a" dependencies = [ "apdu-app", - "cbor-smol 0.4.1", + "cbor-smol", "cosey", - "ctap-types 0.3.1", + "ctap-types", "ctaphid-dispatch", "delog", "heapless", "iso7816", + "littlefs2-core", "serde", "serde-indexed", "serde_bytes", @@ -784,12 +754,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "interchange" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310d743c23f798f10d5ba2f77fdd3eff06aaf2d8f8b9d78beba7fb1167f4ccbf" - [[package]] name = "interchange" version = "0.3.0" @@ -809,6 +773,15 @@ dependencies = [ "heapless", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -848,28 +821,36 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "littlefs2" -version = "0.4.0" -source = "git+https://github.com/sosthene-nitrokey/littlefs2.git?rev=2b45a7559ff44260c6dd693e4cb61f54ae5efc53#2b45a7559ff44260c6dd693e4cb61f54ae5efc53" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6857dedc8aba748ea287177abe2bdfb3bb43464c3003f93cdc0a72e1e542b60f" dependencies = [ - "bitflags 1.3.2", - "cstr_core", - "cty", "delog", "generic-array", "heapless", + "littlefs2-core", "littlefs2-sys", +] + +[[package]] +name = "littlefs2-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250ec1e3017a4540932dc8b33daca325cb6195cded097e1addd9111d9ea2c48f" +dependencies = [ + "bitflags 2.6.0", + "heapless-bytes", "serde", ] [[package]] name = "littlefs2-sys" -version = "0.1.7" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c25e4f545f6ca5415c6325066260e764674d7893dcf0017a52a2ef456ba915f5" +checksum = "5e9a93267fadc37e91758279342f2055b6c03b1187ec7a6b1419c3710172466e" dependencies = [ "bindgen", "cc", - "cty", ] [[package]] @@ -916,6 +897,12 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "nb" version = "0.1.3" @@ -933,12 +920,12 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "nom" -version = "5.1.3" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", - "version_check", + "minimal-lexical", ] [[package]] @@ -1092,12 +1079,6 @@ dependencies = [ "cty", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1471,9 +1452,9 @@ dependencies = [ [[package]] name = "shlex" -version = "0.1.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signature" @@ -1680,12 +1661,12 @@ dependencies = [ [[package]] name = "trussed" version = "0.1.0" -source = "git+https://github.com/trussed-dev/trussed.git?rev=b548d379dcbd67d29453d94847b7bc33ae92e673#b548d379dcbd67d29453d94847b7bc33ae92e673" +source = "git+https://github.com/trussed-dev/trussed.git?rev=046478b7a4f6e2315acf9112d98308379c2e3eee#046478b7a4f6e2315acf9112d98308379c2e3eee" dependencies = [ "aes", - "bitflags 2.4.2", + "bitflags 2.6.0", "cbc", - "cbor-smol 0.4.1", + "cbor-smol", "cfg-if", "chacha20", "chacha20poly1305", @@ -1699,8 +1680,9 @@ dependencies = [ "heapless-bytes", "hex-literal", "hmac 0.12.1", - "interchange 0.3.0", + "interchange", "littlefs2", + "littlefs2-core", "nb 1.1.0", "p256-cortex-m4", "postcard", @@ -1716,12 +1698,13 @@ dependencies = [ [[package]] name = "trussed-auth" -version = "0.2.2" -source = "git+https://github.com/trussed-dev/trussed-auth?rev=62235294bd63977bbb88eb01e7ac44b8010eb450#62235294bd63977bbb88eb01e7ac44b8010eb450" +version = "0.3.0" +source = "git+https://github.com/trussed-dev/trussed-auth?rev=c030b82ad3441f337af09afe3a69e8a6da5785ea#c030b82ad3441f337af09afe3a69e8a6da5785ea" dependencies = [ "chacha20poly1305", "hkdf", "hmac 0.12.1", + "littlefs2-core", "rand_core", "serde", "serde-byte-array", @@ -1784,14 +1767,16 @@ dependencies = [ [[package]] name = "trussed-staging" -version = "0.3.0" -source = "git+https://github.com/trussed-dev/trussed-staging.git?tag=v0.3.1#72b082002e0869facfc11bf8d76a1272c7ddf4ee" +version = "0.3.2" +source = "git+https://github.com/trussed-dev/trussed-staging.git?rev=53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069#53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069" dependencies = [ "chacha20poly1305", "delog", + "digest 0.10.7", "hkdf", - "littlefs2", + "littlefs2-core", "rand_core", + "salty", "serde", "serde-byte-array", "sha2 0.10.8", @@ -1805,10 +1790,10 @@ dependencies = [ [[package]] name = "trussed-usbip" version = "0.0.1" -source = "git+https://github.com/Nitrokey/pc-usbip-runner?tag=v0.0.1-nitrokey.1#e78883847fb01ac93179074ff29e13a0d470775b" +source = "git+https://github.com/Nitrokey/pc-usbip-runner?tag=v0.0.1-nitrokey.5#8d36e78e932b52ae62639bd3fb10ec5c0bae4aed" dependencies = [ "ctaphid-dispatch", - "interchange 0.3.0", + "interchange", "log", "trussed", "usb-device", @@ -1853,15 +1838,14 @@ checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" [[package]] name = "usbd-ctaphid" version = "0.1.0" -source = "git+https://github.com/Nitrokey/usbd-ctaphid?tag=v0.1.0-nitrokey.1#e9cbf904f548979685c4c06d75479b75e3695160" +source = "git+https://github.com/trussed-dev/usbd-ctaphid.git?rev=dcff9009c3cd1ef9e5b09f8f307aca998fc9a8c8#dcff9009c3cd1ef9e5b09f8f307aca998fc9a8c8" dependencies = [ - "ctap-types 0.1.2", "ctaphid-dispatch", "delog", "embedded-time", "heapless", "heapless-bytes", - "interchange 0.3.0", + "interchange", "ref-swap", "serde", "trussed", @@ -1903,10 +1887,10 @@ version = "0.8.0" dependencies = [ "admin-app", "apdu-app", - "cbor-smol 0.5.0", + "cbor-smol", "clap", "clap-num", - "ctap-types 0.3.1", + "ctap-types", "ctaphid-dispatch", "delog", "fido-authenticator", @@ -1915,6 +1899,7 @@ dependencies = [ "heapless-bytes", "hmac 0.12.1", "iso7816", + "littlefs2-core", "pretty_env_logger", "serde", "serde-indexed", diff --git a/Cargo.toml b/Cargo.toml index b4cfa23..36e1874 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ delog = { version = "0.1.6", features = ["std-log"] } cbor-smol = "0.5.0" heapless-bytes = { version = "0.3.0" } heapless = "0.7" +littlefs2-core = "0.1" serde = { version = "1.0", default-features = false } serde-indexed = "0.1.0" serde_bytes = { version = "0.11.10", default-features = false, features=["alloc"] } @@ -50,7 +51,7 @@ admin-app = { version = "0.1", features = ["log-all"] } # extensions trussed-rsa-alloc = { version = "0.2.0", features = ["virt"] } -trussed-auth = "0.2.2" +trussed-auth = "0.3" [features] @@ -100,24 +101,22 @@ ctaphid-dispatch = { git = "https://github.com/Nitrokey/ctaphid-dispatch", tag = #apdu-dispatch = { git = "https://github.com/Nitrokey/apdu-dispatch.git", branch="sz-multiple-apps" } # forked -admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.16" } -fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.21" } -cbor-smol = { git = "https://github.com/trussed-dev/cbor-smol.git", rev = "d499e527f1214b2998b844720f0d41a9d05be7e1" } +admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.18" } +fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.23" } # unreleased upstream changes -littlefs2 = { git = "https://github.com/sosthene-nitrokey/littlefs2.git", rev = "2b45a7559ff44260c6dd693e4cb61f54ae5efc53" } -trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "b548d379dcbd67d29453d94847b7bc33ae92e673" } -usbd-ctaphid = { git = "https://github.com/Nitrokey/usbd-ctaphid", tag = "v0.1.0-nitrokey.1" } +trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "046478b7a4f6e2315acf9112d98308379c2e3eee" } +usbd-ctaphid = { git = "https://github.com/trussed-dev/usbd-ctaphid.git", rev = "dcff9009c3cd1ef9e5b09f8f307aca998fc9a8c8" } # unreleased crates trussed-fs-info = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "fs-info-v0.1.0" } -trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth", rev = "62235294bd63977bbb88eb01e7ac44b8010eb450" } +trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth", rev = "c030b82ad3441f337af09afe3a69e8a6da5785ea" } trussed-chunked = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "chunked-v0.1.0" } trussed-hkdf = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "hkdf-v0.2.0" } trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "manage-v0.1.0" } trussed-rsa-alloc = { git = "https://github.com/trussed-dev/trussed-rsa-backend.git", tag = "v0.2.0" } -trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "v0.3.1" } -trussed-usbip = { git = "https://github.com/Nitrokey/pc-usbip-runner", tag = "v0.0.1-nitrokey.1" } +trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069" } +trussed-usbip = { git = "https://github.com/Nitrokey/pc-usbip-runner", tag = "v0.0.1-nitrokey.5" } # Local development #trussed = { path = "../trussed" } diff --git a/examples/usbip/main.rs b/examples/usbip/main.rs index 6395c82..8b53926 100644 --- a/examples/usbip/main.rs +++ b/examples/usbip/main.rs @@ -23,7 +23,7 @@ mod dispatch { service::ServiceResources, types::{Bytes, Context}, }; - use trussed_auth::{AuthBackend, AuthContext, AuthExtension, MAX_HW_KEY_LEN}; + use trussed_auth::{AuthBackend, AuthContext, AuthExtension, FilesystemLayout, MAX_HW_KEY_LEN}; use crate::LOCATION_FOR_SIMULATION; #[cfg(feature = "rsa")] @@ -96,7 +96,7 @@ mod dispatch { impl Dispatch { pub fn new() -> Self { Self { - auth: AuthBackend::new(LOCATION_FOR_SIMULATION), + auth: AuthBackend::new(LOCATION_FOR_SIMULATION, FilesystemLayout::V0), staging: StagingBackend::new(), hmacsha256p256: webcrypt::hmacsha256p256::Backend::new(), } @@ -104,7 +104,11 @@ mod dispatch { pub fn with_hw_key(hw_key: Bytes) -> Self { Self { - auth: AuthBackend::with_hw_key(LOCATION_FOR_SIMULATION, hw_key), + auth: AuthBackend::with_hw_key( + LOCATION_FOR_SIMULATION, + hw_key, + FilesystemLayout::V0, + ), staging: StagingBackend::new(), hmacsha256p256: webcrypt::hmacsha256p256::Backend::new(), } @@ -247,22 +251,25 @@ use apdu_dispatch::command::SIZE as ApduCommandSize; use admin_app::StatusBytes; use clap::Parser; use clap_num::maybe_hex; +use littlefs2_core::path; use trussed::backend::BackendId; +use trussed::client::ClientBuilder; use trussed::platform::{consent, reboot, ui}; +use trussed::virt::StoreProvider; +use trussed_usbip::Syscall; use trussed::types::Location; -use trussed::{virt, ClientImplementation, Platform}; -use trussed_usbip::ClientBuilder; +use trussed::{ + virt::{self}, + ClientImplementation, Platform, Service, +}; use usbd_ctaphid::constants::MESSAGE_SIZE; use webcrypt::{debug, info, try_debug, try_info, try_warn, warn}; use webcrypt::{Options, PeekingBypass}; pub type FidoConfig = fido_authenticator::Config; -pub type VirtClient = ClientImplementation< - trussed_usbip::Service, - dispatch::Dispatch, ->; +pub type VirtClient = ClientImplementation; /// USP/IP based virtualization of the Nitrokey 3 / Solo2 device. #[derive(Parser, Debug)] @@ -473,11 +480,20 @@ struct Apps { const MAX_RESIDENT_CREDENTIAL_COUNT: u32 = 50; -impl trussed_usbip::Apps<'static, VirtClient, dispatch::Dispatch> for Apps { +impl trussed_usbip::Apps<'static, S, dispatch::Dispatch> for Apps { type Data = (); - fn new>(builder: &B, _data: ()) -> Self { + fn new( + service: &mut Service, dispatch::Dispatch>, + syscall: Syscall, + _data: (), + ) -> Self { + let client = ClientBuilder::new(path!("fido")) + .backends(&[BackendId::Core]) + .prepare(service) + .expect("failed to build client") + .build(syscall.clone()); let fido = fido_authenticator::Authenticator::new( - builder.build("fido", &[BackendId::Core]), + client, fido_authenticator::Conforming {}, fido_authenticator::Config { max_msg_size: MESSAGE_SIZE, @@ -487,18 +503,22 @@ impl trussed_usbip::Apps<'static, VirtClient, dispatch::Dispatch> for Apps { nfc_transport: false, }, ); + + let client = ClientBuilder::new(path!("admin")) + .backends(&[BackendId::Core]) + .prepare(service) + .expect("failed to build client") + .build(syscall.clone()); let data = AdminData::new(Variant::Usbip); - let admin = admin_app::App::with_default_config( - builder.build("admin", &[BackendId::Core]), - [0; 16], - 0, - "", - data, - &[], - ); + let admin = admin_app::App::with_default_config(client, [0; 16], 0, "", data, &[]); + let client = ClientBuilder::new(path!("webcrypt")) + .backends(dispatch::BACKENDS) + .prepare(service) + .expect("failed to build client") + .build(syscall); let webcrypt = webcrypt::Webcrypt::new_with_options( - builder.build("webcrypt", dispatch::BACKENDS), + client, Options::new(Location::External, *b"1234", 10000), ); @@ -563,7 +583,7 @@ fn store_file(platform: &impl Platform, host_file: &Path, device_file: &str) { trussed::store::store( platform.store(), LOCATION_FOR_SIMULATION, - &trussed::types::PathBuf::from(device_file), + &trussed::types::PathBuf::try_from(device_file).unwrap(), &data, ) .expect("failed to store file"); diff --git a/src/lib/commands.rs b/src/lib/commands.rs index 1823d9e..e41dd4a 100644 --- a/src/lib/commands.rs +++ b/src/lib/commands.rs @@ -1,5 +1,6 @@ use cbor_smol::cbor_deserialize; use heapless::Vec; +use littlefs2_core::path; use heapless_bytes::{Bytes, Bytes32}; use trussed::api::reply::Encrypt; @@ -1017,7 +1018,7 @@ where syscall!(w.trussed.delete_all(w.options.location)); syscall!(w .trussed - .remove_dir_all(w.options.location, PathBuf::from("wcrk"),)); + .remove_dir_all(w.options.location, PathBuf::from(path!("wcrk")),)); #[cfg(feature = "transparent-encryption")] { diff --git a/src/lib/rk_files.rs b/src/lib/rk_files.rs index ba84f0e..2c71144 100644 --- a/src/lib/rk_files.rs +++ b/src/lib/rk_files.rs @@ -4,6 +4,7 @@ // Imported from the https://github.com/solokeys/fido-authenticator/ project use heapless_bytes::Bytes; +use littlefs2_core::path; use trussed::types::PathBuf; #[inline(never)] @@ -22,8 +23,8 @@ pub fn rp_rk_dir(rp_id_hash: &Bytes<32>) -> PathBuf { let mut hex = [b'0'; 16]; format_hex(&rp_id_hash[..8], &mut hex); - let mut dir = PathBuf::from(b"wcrk"); - dir.push(&PathBuf::from(&hex)); + let mut dir = PathBuf::from(path!("wcrk")); + dir.push(&PathBuf::try_from(&hex).unwrap()); dir } @@ -34,7 +35,7 @@ pub fn rk_path(rp_id_hash: &Bytes<32>, credential_id_hash: &Bytes<32>) -> PathBu let mut hex = [0u8; 16]; format_hex(&credential_id_hash[..8], &mut hex); - path.push(&PathBuf::from(&hex)); + path.push(&PathBuf::try_from(&hex).unwrap()); path } diff --git a/src/lib/state.rs b/src/lib/state.rs index 6b88602..b59e392 100644 --- a/src/lib/state.rs +++ b/src/lib/state.rs @@ -6,7 +6,8 @@ // TODO Consider importing PersistentState from fido-authenticator directly if needed use ctap_types::Error; -use trussed::types::PathBuf; +use littlefs2_core::path; +use trussed::types::{Path, PathBuf}; use trussed::{ client, syscall, try_syscall, @@ -51,7 +52,7 @@ impl PersistentState { } impl PersistentState { - const FILENAME: &'static [u8] = b"persistent-state.cbor"; + const FILENAME: &'static Path = path!("persistent-state.cbor"); #[inline(never)] pub fn load( diff --git a/src/lib/wcstate.rs b/src/lib/wcstate.rs index e776272..051277d 100644 --- a/src/lib/wcstate.rs +++ b/src/lib/wcstate.rs @@ -1,9 +1,10 @@ #![allow(non_camel_case_types)] use heapless_bytes::{Bytes, Bytes32}; +use littlefs2_core::path; use trussed::{ client, syscall, try_syscall, - types::{KeyId, Location}, + types::{KeyId, Location, Path}, }; // use std::borrow::Borrow; @@ -204,7 +205,7 @@ impl WebcryptSession { } } -const STATE_FILE_PATH: &[u8; 10] = b"wcrk/state"; +const STATE_FILE_PATH: &Path = path!("wcrk/state"); impl WebcryptState { #[inline(never)]