diff --git a/Cargo.lock b/Cargo.lock index a7b2ded0..b1de7e3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "admin-app" version = "0.1.0" -source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.17#f66f5263db2d4ff36e7a288288cce6b81b3741ed" +source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.18#599d205e47a7430dfed1c37263fa565597b6597f" dependencies = [ "apdu-app", "cbor-smol", @@ -13,7 +13,7 @@ dependencies = [ "delog", "hex-literal 0.4.1", "iso7816", - "littlefs2", + "littlefs2-core", "serde", "strum_macros", "trussed", @@ -179,7 +179,7 @@ dependencies = [ "heapless-bytes", "hex", "if_chain", - "littlefs2", + "littlefs2-core", "ndef-app", "opcard", "piv-authenticator", @@ -854,16 +854,6 @@ dependencies = [ "typenum", ] -[[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 = "csv" version = "1.3.0" @@ -1098,6 +1088,7 @@ dependencies = [ "delog", "embedded-hal", "interchange", + "littlefs2-core", "littlefs2-sys", "lpc55-hal", "lpc55-pac", @@ -1137,7 +1128,7 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encrypted_container" version = "0.1.0" -source = "git+https://github.com/Nitrokey/trussed-secrets-app?rev=afbf6b8a2f92b5693bfee483dade2608c633b51c#afbf6b8a2f92b5693bfee483dade2608c633b51c" +source = "git+https://github.com/Nitrokey/trussed-secrets-app?rev=fae41aabe63fa674042b3d217d734955f1f2aac2#fae41aabe63fa674042b3d217d734955f1f2aac2" dependencies = [ "cbor-smol", "delog", @@ -1189,7 +1180,7 @@ dependencies = [ [[package]] name = "fido-authenticator" version = "0.1.1" -source = "git+https://github.com/Nitrokey/fido-authenticator.git?tag=v0.1.1-nitrokey.22#28e0b059985b22a71f7d7cae093a184fa6d0e1d5" +source = "git+https://github.com/Nitrokey/fido-authenticator.git?tag=v0.1.1-nitrokey.23#5b6ae97b5f92962b545a1af1bf5b69fee66bca0a" dependencies = [ "apdu-app", "cbor-smol", @@ -1199,6 +1190,7 @@ dependencies = [ "delog", "heapless", "iso7816", + "littlefs2-core", "serde", "serde-indexed", "serde_bytes", @@ -1757,27 +1749,36 @@ checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" [[package]] name = "littlefs2" -version = "0.4.0" -source = "git+https://github.com/trussed-dev/littlefs2.git?rev=960e57d9fc0d209308c8e15dc26252bbe1ff6ba8#960e57d9fc0d209308c8e15dc26252bbe1ff6ba8" +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" -source = "git+https://github.com/trussed-dev/littlefs2-sys.git?rev=39626c0dbc2f6c38b74889a5bf9d5a200614f121#39626c0dbc2f6c38b74889a5bf9d5a200614f121" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9a93267fadc37e91758279342f2055b6c03b1187ec7a6b1419c3710172466e" dependencies = [ "bindgen", "cc", - "cty", ] [[package]] @@ -1811,9 +1812,9 @@ dependencies = [ [[package]] name = "lpc55-hal" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e9bba980b3a2de5813c8db696806c59bdb5f57956c8137ebe1e10b2e988a53" +checksum = "c0434f9766e2521d8f550550f6c894e9bcf1503d0994d64feafa32981946203d" dependencies = [ "block-buffer 0.9.0", "cipher 0.3.0", @@ -2110,7 +2111,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "opcard" version = "1.4.1" -source = "git+https://github.com/Nitrokey/opcard-rs?rev=79e22c3f379c312a4b1bbe24e6b2da847219b367#79e22c3f379c312a4b1bbe24e6b2da847219b367" +source = "git+https://github.com/Nitrokey/opcard-rs?rev=1a0d5bf623af114e2adfc8ac89f7b0418ec49349#1a0d5bf623af114e2adfc8ac89f7b0418ec49349" dependencies = [ "admin-app", "apdu-app", @@ -2121,6 +2122,7 @@ dependencies = [ "heapless-bytes", "hex-literal 0.4.1", "iso7816", + "littlefs2-core", "log", "serde", "serde_repr", @@ -2219,7 +2221,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piv-authenticator" version = "0.3.8" -source = "git+https://github.com/Nitrokey/piv-authenticator.git?rev=586e8821b381f04b74038578ccce01ffc79023e6#586e8821b381f04b74038578ccce01ffc79023e6" +source = "git+https://github.com/Nitrokey/piv-authenticator.git?rev=84ebc022ebacbd1b1964f38f6173010a2fd514f8#84ebc022ebacbd1b1964f38f6173010a2fd514f8" dependencies = [ "apdu-app", "cfg-if", @@ -2229,7 +2231,7 @@ dependencies = [ "heapless-bytes", "hex-literal 0.3.4", "iso7816", - "littlefs2", + "littlefs2-core", "log", "serde", "subtle", @@ -2618,9 +2620,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "se05x" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c532692f81ed21aaab0c629927a6eb9a172ba968310d4409672a615951d9140" +checksum = "f3ad92298f6eb2377e187610511550737cf2434cb36b177cdc1bd468abb44533" dependencies = [ "aes", "bitflags 2.6.0", @@ -2655,7 +2657,7 @@ dependencies = [ [[package]] name = "secrets-app" version = "0.13.0" -source = "git+https://github.com/Nitrokey/trussed-secrets-app?rev=afbf6b8a2f92b5693bfee483dade2608c633b51c#afbf6b8a2f92b5693bfee483dade2608c633b51c" +source = "git+https://github.com/Nitrokey/trussed-secrets-app?rev=fae41aabe63fa674042b3d217d734955f1f2aac2#fae41aabe63fa674042b3d217d734955f1f2aac2" dependencies = [ "apdu-app", "bitflags 2.6.0", @@ -2669,6 +2671,7 @@ dependencies = [ "heapless-bytes", "hex-literal 0.3.4", "iso7816", + "littlefs2-core", "serde", "trussed", "trussed-auth", @@ -3174,7 +3177,7 @@ dependencies = [ [[package]] name = "trussed" version = "0.1.0" -source = "git+https://github.com/nitrokey/trussed.git?tag=v0.1.0-nitrokey.22#be5fa72073f1a974f9b3e63c00275cf982e03fd0" +source = "git+https://github.com/nitrokey/trussed.git?tag=v0.1.0-nitrokey.23#92dd7f010e61ba17895d7844ea31b8f288e308b8" dependencies = [ "aes", "bitflags 2.6.0", @@ -3195,6 +3198,7 @@ dependencies = [ "hmac", "interchange", "littlefs2", + "littlefs2-core", "nb 1.1.0", "p256-cortex-m4", "postcard 0.7.3", @@ -3211,12 +3215,12 @@ dependencies = [ [[package]] name = "trussed-auth" version = "0.3.0" -source = "git+https://github.com/trussed-dev/trussed-auth?rev=947ffe6cff426ccbbbb2d0f689437f427665919e#947ffe6cff426ccbbbb2d0f689437f427665919e" +source = "git+https://github.com/trussed-dev/trussed-auth?rev=c030b82ad3441f337af09afe3a69e8a6da5785ea#c030b82ad3441f337af09afe3a69e8a6da5785ea" dependencies = [ "chacha20poly1305", "hkdf", "hmac", - "littlefs2", + "littlefs2-core", "rand_core", "serde", "serde-byte-array", @@ -3290,7 +3294,7 @@ dependencies = [ [[package]] name = "trussed-se050-backend" version = "0.3.6" -source = "git+https://github.com/Nitrokey/trussed-se050-backend.git?rev=09e3f601976224f1fd3487b8e1f72e205c2093c3#09e3f601976224f1fd3487b8e1f72e205c2093c3" +source = "git+https://github.com/Nitrokey/trussed-se050-backend.git?rev=f4ff60b8aa0f322a424613165f66ed9112c7a94f#f4ff60b8aa0f322a424613165f66ed9112c7a94f" dependencies = [ "admin-app", "bitflags 2.6.0", @@ -3304,7 +3308,7 @@ dependencies = [ "hkdf", "hmac", "iso7816", - "littlefs2", + "littlefs2-core", "p256", "p256-cortex-m4", "postcard 0.7.3", @@ -3336,7 +3340,7 @@ dependencies = [ [[package]] name = "trussed-staging" version = "0.3.2" -source = "git+https://github.com/trussed-dev/trussed-staging.git?tag=v0.3.2#7c99973187eb9ae2c1e410b5996169ccf2690efa" +source = "git+https://github.com/trussed-dev/trussed-staging.git?rev=53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069#53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069" dependencies = [ "aead", "chacha20poly1305", @@ -3344,7 +3348,7 @@ dependencies = [ "digest 0.10.7", "hex-literal 0.4.1", "hkdf", - "littlefs2", + "littlefs2-core", "rand_core", "salty", "serde", @@ -3386,18 +3390,18 @@ dependencies = [ [[package]] name = "typed-builder" -version = "0.18.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77739c880e00693faef3d65ea3aad725f196da38b22fdc7ea6ded6e1ce4d3add" +checksum = "7e14ed59dc8b7b26cacb2a92bad2e8b1f098806063898ab42a3bd121d7d45e75" dependencies = [ "typed-builder-macro", ] [[package]] name = "typed-builder-macro" -version = "0.18.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f718dfaf347dcb5b983bfc87608144b0bad87970aebcbea5ce44d2a30c08e63" +checksum = "560b82d656506509d43abe30e0ba64c56b1953ab3d4fe7ba5902747a7a3cedd5" dependencies = [ "proc-macro2", "quote", @@ -3680,7 +3684,7 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "webcrypt" version = "0.8.0" -source = "git+https://github.com/nitrokey/nitrokey-websmartcard-rust?rev=2ceed58651387ee468c791bcca3f2ee2d2470a2d#2ceed58651387ee468c791bcca3f2ee2d2470a2d" +source = "git+https://github.com/nitrokey/nitrokey-websmartcard-rust?tag=v0.8.0-rc10#c14c496210d625b815cf613bda161410a93bf18d" dependencies = [ "apdu-app", "cbor-smol", @@ -3692,6 +3696,7 @@ dependencies = [ "heapless-bytes", "hmac", "iso7816", + "littlefs2-core", "serde", "serde-indexed", "serde_bytes", diff --git a/Cargo.toml b/Cargo.toml index 6c8ac970..af4a1f22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,40 +17,33 @@ version = "1.7.2" memory-regions = { path = "components/memory-regions" } # forked -admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.17" } -fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.22" } -trussed = { git = "https://github.com/nitrokey/trussed.git", tag = "v0.1.0-nitrokey.22" } +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" } +trussed = { git = "https://github.com/nitrokey/trussed.git", tag = "v0.1.0-nitrokey.23" } # unreleased upstream changes ctaphid-dispatch = { git = "https://github.com/Nitrokey/ctaphid-dispatch.git", tag = "v0.1.1-nitrokey.3" } -littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "960e57d9fc0d209308c8e15dc26252bbe1ff6ba8" } -littlefs2-sys = { git = "https://github.com/trussed-dev/littlefs2-sys.git", rev = "39626c0dbc2f6c38b74889a5bf9d5a200614f121" } usbd-ctaphid = { git = "https://github.com/trussed-dev/usbd-ctaphid.git", rev = "dcff9009c3cd1ef9e5b09f8f307aca998fc9a8c8" } usbd-ccid = { git = "https://github.com/Nitrokey/usbd-ccid", tag = "v0.2.0-nitrokey.1" } p256-cortex-m4 = { git = "https://github.com/ycrypto/p256-cortex-m4.git", rev = "cdb31e12594b4dc1f045b860a885fdc94d96aee2" } # unreleased crates -# secrets-app = { git = "https://github.com/Nitrokey/trussed-secrets-app", tag = "v0.13.0" } -secrets-app = { git = "https://github.com/Nitrokey/trussed-secrets-app", rev = "afbf6b8a2f92b5693bfee483dade2608c633b51c" } -# webcrypt = { git = "https://github.com/nitrokey/nitrokey-websmartcard-rust", tag = "v0.8.0-rc9" } -webcrypt = { git = "https://github.com/nitrokey/nitrokey-websmartcard-rust", rev = "2ceed58651387ee468c791bcca3f2ee2d2470a2d" } -# opcard = { git = "https://github.com/Nitrokey/opcard-rs", tag = "v1.5.0" } -opcard = { git = "https://github.com/Nitrokey/opcard-rs", rev = "79e22c3f379c312a4b1bbe24e6b2da847219b367" } -# piv-authenticator = { git = "https://github.com/Nitrokey/piv-authenticator.git", tag = "v0.3.7" } -piv-authenticator = { git = "https://github.com/Nitrokey/piv-authenticator.git", rev = "586e8821b381f04b74038578ccce01ffc79023e6" } +secrets-app = { git = "https://github.com/Nitrokey/trussed-secrets-app", rev = "fae41aabe63fa674042b3d217d734955f1f2aac2" } +webcrypt = { git = "https://github.com/nitrokey/nitrokey-websmartcard-rust", tag = "v0.8.0-rc10" } +opcard = { git = "https://github.com/Nitrokey/opcard-rs", rev = "1a0d5bf623af114e2adfc8ac89f7b0418ec49349" } +piv-authenticator = { git = "https://github.com/Nitrokey/piv-authenticator.git", rev = "84ebc022ebacbd1b1964f38f6173010a2fd514f8" } trussed-fs-info = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "fs-info-v0.1.0" } trussed-chunked = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "chunked-v0.1.0" } trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "manage-v0.1.0" } trussed-wrap-key-to-file = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "wrap-key-to-file-v0.1.0" } -trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "v0.3.2" } -trussed-hpke = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "hpke-v0.1.0" } -trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth", rev = "947ffe6cff426ccbbbb2d0f689437f427665919e" } +trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "53eba84d2cd0bcacc3a7096d4b7a2490dcf6f069" } +trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth", rev = "c030b82ad3441f337af09afe3a69e8a6da5785ea" } trussed-hkdf = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "hkdf-v0.2.0" } +trussed-hpke = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "hpke-v0.1.0" } trussed-rsa-alloc = { git = "https://github.com/trussed-dev/trussed-rsa-backend.git", tag = "v0.2.1" } trussed-usbip = { git = "https://github.com/Nitrokey/pc-usbip-runner.git", tag = "v0.0.1-nitrokey.5" } trussed-se050-manage = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", tag = "se050-manage-v0.1.0" } -# trussed-se050-backend = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", tag = "v0.3.6" } -trussed-se050-backend = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", rev = "09e3f601976224f1fd3487b8e1f72e205c2093c3" } +trussed-se050-backend = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", rev = "f4ff60b8aa0f322a424613165f66ed9112c7a94f" } [profile.release] codegen-units = 1 diff --git a/components/apps/Cargo.toml b/components/apps/Cargo.toml index 3bae72ed..114c3e60 100644 --- a/components/apps/Cargo.toml +++ b/components/apps/Cargo.toml @@ -18,7 +18,7 @@ trussed-usbip = { version = "0.0.1", default-features = false, features = ["ctap usbd-ctaphid = { version = "0.1", optional = true } utils = { path = "../utils" } if_chain = "1.0.2" -littlefs2 = "0.4" +littlefs2-core = "0.1" # Backends trussed-auth = { version = "0.3.0", optional = true } diff --git a/components/apps/src/dispatch.rs b/components/apps/src/dispatch.rs index 022a6389..0b62d83e 100644 --- a/components/apps/src/dispatch.rs +++ b/components/apps/src/dispatch.rs @@ -12,7 +12,7 @@ use trussed::{ #[cfg(feature = "backend-auth")] use trussed::types::Location; -use littlefs2::{path, path::Path}; +use littlefs2_core::{path, Path}; use if_chain::if_chain; use trussed::{ @@ -88,7 +88,7 @@ fn should_preserve_file(file: &Path) -> bool { let mut components = file.iter(); if_chain! { - if components.next() == Some("/".into()); + if components.next().as_deref() == Some(path!("/")); if components.next().is_some(); if let Some(intermediary) = components.next(); if DIRS.contains(&&*intermediary); diff --git a/components/apps/src/lib.rs b/components/apps/src/lib.rs index 4c4e12f0..d75eb52e 100644 --- a/components/apps/src/lib.rs +++ b/components/apps/src/lib.rs @@ -12,8 +12,7 @@ use ctaphid_dispatch::app::App as CtaphidApp; #[cfg(feature = "se050")] use embedded_hal::blocking::delay::DelayUs; use heapless::Vec; -#[cfg(any(feature = "factory-reset", feature = "se050"))] -use littlefs2::path; +use littlefs2_core::path; #[cfg(feature = "factory-reset")] use admin_app::ResetConfigResult; @@ -416,7 +415,7 @@ impl Apps { trussed_service: &mut Service>, mut make_client: impl FnMut( &mut Service>, - &'static str, + &'static Path, &'static [BackendId], Option<&'static InterruptFlag>, ) -> Client, @@ -492,7 +491,7 @@ impl Apps { trussed_service: &mut Service>, make_client: impl FnOnce( &mut Service>, - &'static str, + &'static Path, &'static [BackendId], Option<&'static InterruptFlag>, ) -> Client, @@ -762,12 +761,12 @@ trait App: Sized { type Config; /// the desired client ID - const CLIENT_ID: &'static str; + const CLIENT_ID: &'static Path; fn new( runner: &R, make_client: impl FnOnce( - &'static str, + &'static Path, &'static [BackendId], Option<&'static InterruptFlag>, ) -> Client, @@ -781,7 +780,7 @@ trait App: Sized { fn client( runner: &R, make_client: impl FnOnce( - &'static str, + &'static Path, &'static [BackendId], Option<&'static InterruptFlag>, ) -> Client, @@ -906,10 +905,10 @@ impl AdminData { } } -const ADMIN_APP_CLIENT_ID: &str = "admin"; +const ADMIN_APP_CLIENT_ID: &Path = path!("admin"); impl App for AdminApp { - const CLIENT_ID: &'static str = ADMIN_APP_CLIENT_ID; + const CLIENT_ID: &'static Path = ADMIN_APP_CLIENT_ID; type Data = AdminData; type Config = (); @@ -944,7 +943,7 @@ pub struct FidoData { #[cfg(feature = "fido-authenticator")] impl App for FidoApp { - const CLIENT_ID: &'static str = "fido"; + const CLIENT_ID: &'static Path = path!("fido"); type Data = FidoData; type Config = FidoConfig; @@ -987,7 +986,7 @@ impl App for FidoApp { #[cfg(feature = "webcrypt")] impl App for WebcryptApp { - const CLIENT_ID: &'static str = "webcrypt"; + const CLIENT_ID: &'static Path = path!("webcrypt"); type Data = (); type Config = (); @@ -1017,7 +1016,7 @@ impl App for WebcryptApp { #[cfg(feature = "secrets-app")] impl App for SecretsApp { - const CLIENT_ID: &'static str = "secrets"; + const CLIENT_ID: &'static Path = path!("secrets"); type Data = (); type Config = (); @@ -1050,7 +1049,7 @@ static OPCARD_RESET_SIGNAL: ResetSignalAllocation = ResetSignalAllocation::new() #[cfg(feature = "opcard")] impl App for OpcardApp { - const CLIENT_ID: &'static str = "opcard"; + const CLIENT_ID: &'static Path = path!("opcard"); type Data = (); type Config = OpcardConfig; @@ -1120,7 +1119,7 @@ impl App for OpcardApp { #[cfg(feature = "piv-authenticator")] impl App for PivApp { - const CLIENT_ID: &'static str = "piv"; + const CLIENT_ID: &'static Path = path!("piv"); type Data = (); type Config = (); @@ -1157,7 +1156,7 @@ pub struct ProvisionerData { #[cfg(feature = "provisioner-app")] impl App for ProvisionerApp { - const CLIENT_ID: &'static str = "attn"; + const CLIENT_ID: &'static Path = path!("attn"); type Data = ProvisionerData; type Config = (); diff --git a/components/apps/src/migrations.rs b/components/apps/src/migrations.rs index 9b5da450..78899de7 100644 --- a/components/apps/src/migrations.rs +++ b/components/apps/src/migrations.rs @@ -1,7 +1,7 @@ #![allow(unused)] use admin_app::migrations::Migrator; -use littlefs2::path; +use littlefs2_core::path; pub(crate) const MIGRATION_VERSION_SPACE_EFFICIENCY: u32 = 1; diff --git a/components/boards/Cargo.toml b/components/boards/Cargo.toml index 09cc8958..198b458a 100644 --- a/components/boards/Cargo.toml +++ b/components/boards/Cargo.toml @@ -15,7 +15,7 @@ embedded-hal = "0.2.3" embedded-time = "0.12" generic-array = "0.14" interchange = "0.3" -littlefs2 = { version = "0.4", features = ["c-stubs"] } +littlefs2 = { version = "0.5", features = ["c-stubs"] } memory-regions = { path = "../memory-regions" } nb = "1" nfc-device = { path = "../nfc-device" } @@ -30,7 +30,7 @@ usbd-ctaphid = "0.1" utils = { path = "../utils" } # soc-lpc55 -lpc55-hal = { version = "0.3", features = ["littlefs"], optional = true } +lpc55-hal = { version = "0.4", features = ["littlefs"], optional = true } lpc55-pac = { version = "0.4", optional = true } systick-monotonic = { version = "1.0.0", optional = true } @@ -50,14 +50,14 @@ cortex-m-semihosting = { version = "0.3.5", optional = true } rtt-target = { version = "0.3", features = ["cortex-m"], optional = true } # se050 -se05x = { version = "0.1.1", optional = true } +se05x = { version = "0.1.7", optional = true } [features] board-nk3am = ["soc-nrf52", "lfs-backup"] board-nk3xn = ["soc-lpc55", "fm11nc08"] board-nkpk = ["board-nk3am"] -soc-lpc55 = ["lpc55-hal", "lpc55-pac", "se05x?/lpc55", "systick-monotonic"] +soc-lpc55 = ["lpc55-hal", "lpc55-pac", "se05x?/lpc55-v0.4", "systick-monotonic"] soc-nrf52 = ["embedded-storage", "nrf52840-hal", "nrf52840-pac", "se05x?/nrf"] log-all = [] diff --git a/components/boards/src/flash.rs b/components/boards/src/flash.rs index 2bc6650d..bd26f9fd 100644 --- a/components/boards/src/flash.rs +++ b/components/boards/src/flash.rs @@ -46,7 +46,7 @@ where return Ok(0); }*/ if buf.len() > FLASH_PROPERTIES.size || off > FLASH_PROPERTIES.size - buf.len() { - return Err(Error::Unknown(0x6578_7046)); + return Err(Error::IO); } let mut flash = self.s25flash.borrow_mut(); let r = flash.read(off as u32, buf); @@ -62,9 +62,7 @@ where for chunk in data.chunks(CHUNK_SIZE) { let buf = &mut buf[..chunk.len()]; buf.copy_from_slice(chunk); - flash - .write_bytes(off, buf) - .map_err(|_| Error::Unknown(0x6565_6565))?; + flash.write_bytes(off, buf).map_err(|_| Error::IO)?; off += CHUNK_SIZE as u32; } Ok(data.len()) @@ -73,7 +71,7 @@ where fn erase(&mut self, off: usize, len: usize) -> Result { trace!("EFe {:x} {:x}", off, len); if len > FLASH_PROPERTIES.size || off > FLASH_PROPERTIES.size - len { - return Err(Error::Unknown(0x6578_7046)); + return Err(Error::IO); } let result = self .s25flash @@ -93,7 +91,7 @@ where { match r { Ok(()) => Ok(len), - Err(_) => Err(Error::Unknown(0x6565_6565)), + Err(_) => Err(Error::IO), } } diff --git a/components/boards/src/nk3am/migrations/ftl_journal/ifs_flash_old.rs b/components/boards/src/nk3am/migrations/ftl_journal/ifs_flash_old.rs index 7e073e27..b57b3ec3 100644 --- a/components/boards/src/nk3am/migrations/ftl_journal/ifs_flash_old.rs +++ b/components/boards/src/nk3am/migrations/ftl_journal/ifs_flash_old.rs @@ -78,8 +78,7 @@ fn nvmc_to_lfs_return( r: Result<(), nrf52840_hal::nvmc::NvmcError>, len: usize, ) -> Result { - r.map(|_| len) - .map_err(|_| littlefs2::io::Error::Unknown(0x4e56_4d43)) // 'NVMC' + r.map(|_| len).map_err(|_| littlefs2::io::Error::IO) // 'NVMC' } impl FlashStorage { diff --git a/components/boards/src/nk3xn/prince.rs b/components/boards/src/nk3xn/prince.rs index e5eab61a..e14efe99 100644 --- a/components/boards/src/nk3xn/prince.rs +++ b/components/boards/src/nk3xn/prince.rs @@ -108,7 +108,7 @@ impl Storage for InternalFilesystem { let ret = self.prince.write_encrypted(|prince| { with_enabled(prince, || self.flash_gordon.write(FS_START + off, data)) }); - ret.map(|_| data.len()).map_err(|_| Error::Io) + ret.map(|_| data.len()).map_err(|_| Error::IO) } fn erase(&mut self, off: usize, len: usize) -> Result { @@ -118,7 +118,7 @@ impl Storage for InternalFilesystem { for i in 0..pages { self.flash_gordon .erase_page(first_page + i) - .map_err(|_| Error::Io)?; + .map_err(|_| Error::IO)?; } Ok(BLOCK_SIZE * pages) } diff --git a/components/boards/src/soc/nrf52/flash.rs b/components/boards/src/soc/nrf52/flash.rs index a1ad9bee..18b3b2bf 100644 --- a/components/boards/src/soc/nrf52/flash.rs +++ b/components/boards/src/soc/nrf52/flash.rs @@ -269,8 +269,7 @@ fn nvmc_to_lfs_return( r: Result<(), nrf52840_hal::nvmc::NvmcError>, len: usize, ) -> Result { - r.map(|_| len) - .map_err(|_| littlefs2::io::Error::Unknown(0x4e56_4d43)) // 'NVMC' + r.map(|_| len).map_err(|_| littlefs2::io::Error::IO) // 'NVMC' } impl FlashStorage { diff --git a/components/boards/src/store.rs b/components/boards/src/store.rs index 7c2f20e0..e8c01b21 100644 --- a/components/boards/src/store.rs +++ b/components/boards/src/store.rs @@ -267,7 +267,7 @@ fn init_efs( ) -> LfsResult> { if !Filesystem::is_mountable(efs_storage) { let fmt_ext = Filesystem::format(efs_storage); - if simulated_efs && fmt_ext == Err(littlefs2::io::Error::NoSpace) { + if simulated_efs && fmt_ext == Err(littlefs2::io::Error::NO_SPACE) { info_now!("Formatting simulated EFS failed as expected"); } else { error_now!("EFS Mount Error, Reformat {:?}", fmt_ext); diff --git a/components/lfs-backup/Cargo.toml b/components/lfs-backup/Cargo.toml index 9ae06f27..30f82277 100644 --- a/components/lfs-backup/Cargo.toml +++ b/components/lfs-backup/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] -littlefs2 = "0.4.0" +littlefs2 = "0.5.0" generic-array = "0.14.6" heapless-bytes = "0.3.0" diff --git a/components/lfs-backup/src/lfs_backup.rs b/components/lfs-backup/src/lfs_backup.rs index 6b68ffdc..a0f73330 100644 --- a/components/lfs-backup/src/lfs_backup.rs +++ b/components/lfs-backup/src/lfs_backup.rs @@ -1,7 +1,10 @@ use littlefs2::consts::PATH_MAX; -use littlefs2::fs::{Attribute, DirEntry, Filesystem}; +use littlefs2::fs::{DirEntry, Filesystem}; -use littlefs2::path::{Path, PathBuf}; +use littlefs2::{ + path, + path::{Path, PathBuf}, +}; use serde::{Deserialize, Serialize}; @@ -167,7 +170,7 @@ pub trait BackupBackend { &mut self, fs: &Filesystem, ) -> Result<(usize, usize)> { - let root_dir = PathBuf::from("/"); + let root_dir = PathBuf::from(path!("/")); let mut path_stack: Vec = Vec::new(); path_stack @@ -197,11 +200,15 @@ pub trait BackupBackend { // move index "pointer" to next item current.idx += 1; + let mut buffer = UserAttribute::new(); + buffer.resize_to_capacity(); let attr = fs - .attribute(entry.path(), USER_ATTRIBUTE_NUMBER)? - .map(|v| UserAttribute::from_slice(v.data())) - .transpose() - .map_err(|_| FSBackupError::UserAttributeErr)?; + .attribute(entry.path(), USER_ATTRIBUTE_NUMBER, &mut buffer)? + .map(|v| v.data().len()) + .map(|n| { + buffer.truncate(n); + buffer + }); if entry.file_type().is_dir() { d_cnt += 1; @@ -267,9 +274,7 @@ pub trait BackupBackend { fs.create_dir(path)?; if let Some(user_attr) = v.attr { - let mut attr = Attribute::new(USER_ATTRIBUTE_NUMBER); - attr.set_data(user_attr.as_slice()); - fs.set_attribute(path, &attr)? + fs.set_attribute(path, USER_ATTRIBUTE_NUMBER, &user_attr)? }; } else { f_cnt += 1; @@ -277,9 +282,7 @@ pub trait BackupBackend { fs.write(path, content.as_slice())?; if let Some(user_attr) = v.attr { - let mut attr = Attribute::new(USER_ATTRIBUTE_NUMBER); - attr.set_data(user_attr.as_slice()); - fs.set_attribute(path, &attr)?; + fs.set_attribute(path, USER_ATTRIBUTE_NUMBER, &user_attr)?; }; } } diff --git a/components/provisioner-app/Cargo.toml b/components/provisioner-app/Cargo.toml index d9241993..f961de27 100644 --- a/components/provisioner-app/Cargo.toml +++ b/components/provisioner-app/Cargo.toml @@ -13,7 +13,7 @@ delog = "0.1" heapless = "0.7" heapless-bytes = "0.3" iso7816 = "0.1" -littlefs2 = "0.4.0" +littlefs2 = "0.5.0" salty = { version = "0.3", features = ["cose"] } trussed = "0.1" p256-cortex-m4 = "0.1.0-alpha.6" diff --git a/components/provisioner-app/src/lib.rs b/components/provisioner-app/src/lib.rs index 124ce763..7856d3c7 100644 --- a/components/provisioner-app/src/lib.rs +++ b/components/provisioner-app/src/lib.rs @@ -19,7 +19,10 @@ generate_macros!(); use core::convert::TryFrom; use heapless::Vec; -use littlefs2::path::PathBuf; +use littlefs2::{ + path, + path::{Path, PathBuf}, +}; use trussed::{ client, key::{Flags, Key, Kind as KeyKind}, @@ -92,15 +95,15 @@ pub enum Error { type Uuid = [u8; 16]; -const FILENAME_T1_PUBLIC: &[u8] = b"/attn/pub/00"; +const FILENAME_T1_PUBLIC: &Path = path!("/attn/pub/00"); -const FILENAME_P256_SECRET: &[u8] = b"/attn/sec/01"; -const FILENAME_ED255_SECRET: &[u8] = b"/attn/sec/02"; -const FILENAME_X255_SECRET: &[u8] = b"/attn/sec/03"; +const FILENAME_P256_SECRET: &Path = path!("/attn/sec/01"); +const FILENAME_ED255_SECRET: &Path = path!("/attn/sec/02"); +const FILENAME_X255_SECRET: &Path = path!("/attn/sec/03"); -const FILENAME_P256_CERT: &[u8] = b"/attn/x5c/01"; -const FILENAME_ED255_CERT: &[u8] = b"/attn/x5c/02"; -const FILENAME_X255_CERT: &[u8] = b"/attn/x5c/03"; +const FILENAME_P256_CERT: &Path = path!("/attn/x5c/01"); +const FILENAME_ED255_CERT: &Path = path!("/attn/x5c/02"); +const FILENAME_X255_CERT: &Path = path!("/attn/x5c/03"); enum SelectedBuffer { Filename, @@ -180,7 +183,7 @@ where Instruction::WriteFile => { if self.buffer_file_contents.is_empty() || self.buffer_filename.is_empty() { Err(Error::IncorrectDataParameter) - } else { + } else if let Ok(buffer_path) = PathBuf::try_from(self.buffer_filename.as_slice()) { // self.buffer_filename.push(0); let _filename = unsafe { core::str::from_utf8_unchecked(self.buffer_filename.as_slice()) }; @@ -194,7 +197,7 @@ where let res = store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(self.buffer_filename.as_slice()), + &buffer_path, &self.buffer_file_contents, ); self.buffer_file_contents.clear(); @@ -206,6 +209,8 @@ where info!("wrote file"); Ok(()) } + } else { + Err(Error::IncorrectDataParameter) } } Instruction::GenerateP256Key => { @@ -239,14 +244,11 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_P256_SECRET), + FILENAME_P256_SECRET, &serialized_bytes, ) .map_err(|_| Error::NotEnoughMemory)?; - info!( - "stored to {}", - core::str::from_utf8(FILENAME_P256_SECRET).unwrap() - ); + info!("stored to {}", FILENAME_P256_SECRET.as_str()); reply .extend_from_slice(&keypair.public.to_untagged_bytes()) @@ -272,7 +274,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_ED255_SECRET), + FILENAME_ED255_SECRET, &serialized_bytes, ) .map_err(|_| Error::NotEnoughMemory)?; @@ -301,7 +303,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_X255_SECRET), + FILENAME_X255_SECRET, &serialized_bytes, ) .map_err(|_| Error::NotEnoughMemory)?; @@ -313,8 +315,7 @@ where Ok(()) } Instruction::SaveP256AttestationCertificate => { - let secret_path = PathBuf::from(FILENAME_P256_SECRET); - if !secret_path.exists(self.store.ifs()) || data.len() < 100 { + if !self.store.ifs().exists(FILENAME_P256_SECRET) || data.len() < 100 { // Assuming certs will always be >100 bytes Err(Error::IncorrectDataParameter) } else { @@ -322,7 +323,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_P256_CERT), + FILENAME_P256_CERT, data, ) .map_err(|_| Error::NotEnoughMemory)?; @@ -330,8 +331,7 @@ where } } Instruction::SaveEd255AttestationCertificate => { - let secret_path = PathBuf::from(FILENAME_ED255_SECRET); - if !secret_path.exists(self.store.ifs()) || data.len() < 100 { + if !self.store.ifs().exists(FILENAME_ED255_SECRET) || data.len() < 100 { // Assuming certs will always be >100 bytes Err(Error::IncorrectDataParameter) } else { @@ -339,7 +339,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_ED255_CERT), + FILENAME_ED255_CERT, data, ) .map_err(|_| Error::NotEnoughMemory)?; @@ -347,8 +347,7 @@ where } } Instruction::SaveX255AttestationCertificate => { - let secret_path = PathBuf::from(FILENAME_X255_SECRET); - if !secret_path.exists(self.store.ifs()) || data.len() < 100 { + if !self.store.ifs().exists(FILENAME_X255_SECRET) || data.len() < 100 { // Assuming certs will always be >100 bytes Err(Error::IncorrectDataParameter) } else { @@ -356,7 +355,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_X255_CERT), + FILENAME_X255_CERT, data, ) .map_err(|_| Error::NotEnoughMemory)?; @@ -379,7 +378,7 @@ where store::store( self.store, trussed::types::Location::Internal, - &PathBuf::from(FILENAME_T1_PUBLIC), + FILENAME_T1_PUBLIC, &serialized_key, ) .map_err(|_| Error::NotEnoughMemory) diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index 8220dc3d..fd26d0b9 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] delog = "0.1" -littlefs2 = { version = "0.4", optional = true } +littlefs2 = { version = "0.5", optional = true } # build chrono = { version = "0.4.31", default-features = false, features = ["clock"], optional = true } diff --git a/components/utils/src/storage.rs b/components/utils/src/storage.rs index 2063a00b..21b2ceab 100644 --- a/components/utils/src/storage.rs +++ b/components/utils/src/storage.rs @@ -38,7 +38,7 @@ impl Storage for RamStorage { fn write(&mut self, off: usize, data: &[u8]) -> Result { if off + data.len() > SIZE { - return Err(Error::NoSpace); + return Err(Error::NO_SPACE); } let write_size: usize = Self::WRITE_SIZE; debug_assert!(off % write_size == 0); diff --git a/runners/embedded/Cargo.toml b/runners/embedded/Cargo.toml index 5ff43108..04947fef 100644 --- a/runners/embedded/Cargo.toml +++ b/runners/embedded/Cargo.toml @@ -17,6 +17,7 @@ cortex-m = { version = "0.7", features = ["critical-section-single-core"]} cortex-m-rt = "0.6.15" cortex-m-rtic = "1.0" embedded-hal = "0.2.3" +littlefs2-core = "0.1" nfc-device = { path = "../../components/nfc-device" } utils = { path = "../../components/utils", features = ["storage"] } @@ -36,7 +37,7 @@ nrf52840-hal = { version = "0.15.1", optional = true } nrf52840-pac = { version = "0.11", optional = true } ### LPC55 specific dependencies -lpc55-hal = { version = "0.3.1", features = ["littlefs"], optional = true } +lpc55-hal = { version = "0.4", features = ["littlefs"], optional = true } lpc55-pac = { version = "0.4", optional = true } nb = { version = "1", optional = true } systick-monotonic = { version = "1.0.0", optional = true } @@ -45,7 +46,7 @@ systick-monotonic = { version = "1.0.0", optional = true } alloc-cortex-m = { version = "0.4.3", optional = true } # littlefs2-sys for intrinsics feature -littlefs2-sys = { version = "0.1.7", optional = true } +littlefs2-sys = { version = "0.2", optional = true } [build-dependencies] cargo-lock = "7" diff --git a/runners/embedded/src/nk3xn/init.rs b/runners/embedded/src/nk3xn/init.rs index 41ec7d36..6e8f5de1 100644 --- a/runners/embedded/src/nk3xn/init.rs +++ b/runners/embedded/src/nk3xn/init.rs @@ -57,11 +57,12 @@ use hal::{ Pin, }; use interchange::Channel; +use littlefs2_core::path; use lpc55_hal as hal; #[cfg(any(feature = "log-info", feature = "log-all"))] use lpc55_hal::drivers::timer::Elapsed as _; use nfc_device::Iso14443; -use trussed::types::{Location, PathBuf}; +use trussed::types::Location; use utils::OptionalStorage; use crate::{VERSION, VERSION_STRING}; @@ -754,7 +755,7 @@ impl Stage6 { let res = trussed::store::store( self.store, Location::Internal, - &PathBuf::from("fido/x5c/00"), + path!("fido/x5c/00"), include_bytes!("../../data/fido-cert.der"), ); if res.is_err() { diff --git a/runners/usbip/Cargo.toml b/runners/usbip/Cargo.toml index 0fa5da02..4ffab7e1 100644 --- a/runners/usbip/Cargo.toml +++ b/runners/usbip/Cargo.toml @@ -10,7 +10,7 @@ clap = { version = "4.0.0", features = ["cargo", "derive"] } clap-num = "1.0.0" delog = { version = "0.1.6", features = ["std-log"] } dialoguer = { version = "0.10.4", default-features = false } -littlefs2 = { version = "0.4" } +littlefs2 = { version = "0.5" } log = { version = "0.4.14", default-features = false } pretty_env_logger = "0.5.0" rand_core = { version = "0.6.4", features = ["getrandom"] } diff --git a/runners/usbip/src/store.rs b/runners/usbip/src/store.rs index b3c7fd77..744087e2 100644 --- a/runners/usbip/src/store.rs +++ b/runners/usbip/src/store.rs @@ -101,7 +101,7 @@ impl LfsStorage for FilesystemStorage { fn write(&mut self, offset: usize, data: &[u8]) -> LfsResult { if offset + data.len() > Self::BLOCK_COUNT * Self::BLOCK_SIZE { - return Err(littlefs2::io::Error::NoSpace); + return Err(littlefs2::io::Error::NO_SPACE); } let mut file = OpenOptions::new().write(true).open(&self.path).unwrap(); file.seek(SeekFrom::Start(offset as _)).unwrap(); @@ -113,7 +113,7 @@ impl LfsStorage for FilesystemStorage { fn erase(&mut self, offset: usize, len: usize) -> LfsResult { if offset + len > Self::BLOCK_COUNT * Self::BLOCK_SIZE { - return Err(littlefs2::io::Error::NoSpace); + return Err(littlefs2::io::Error::NO_SPACE); } let mut file = OpenOptions::new().write(true).open(&self.path).unwrap(); file.seek(SeekFrom::Start(offset as _)).unwrap();