mirror of
https://github.com/trussed-dev/trussed-auth.git
synced 2026-06-20 04:16:21 -07:00
Update littlefs2 to v0.5.0
This commit is contained in:
+3
-5
@@ -20,7 +20,7 @@ serde-byte-array = "0.1.2"
|
||||
sha2 = { version = "0.10.6", default-features = false }
|
||||
subtle = { version = "2.4.1", default-features = false }
|
||||
trussed = { version = "0.1.0", features = ["serde-extensions"] }
|
||||
littlefs2 = "0.4.0"
|
||||
littlefs2-core = "0.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = { version = "1.0.3", default-features = false }
|
||||
@@ -32,10 +32,8 @@ serde_cbor = { version = "0.11.2", features = ["std"] }
|
||||
hex-literal = "0.4.1"
|
||||
|
||||
[patch.crates-io]
|
||||
littlefs2 = { git = "https://github.com/sosthene-nitrokey/littlefs2.git", rev = "2b45a7559ff44260c6dd693e4cb61f54ae5efc53" }
|
||||
trussed = { git = "https://github.com/Nitrokey/trussed.git", tag = "v0.1.0-nitrokey.19" }
|
||||
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "046478b7a4f6e2315acf9112d98308379c2e3eee" }
|
||||
trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "manage-v0.1.0" }
|
||||
apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev = "915fc237103fcecc29d0f0b73391f19abf6576de" }
|
||||
ctaphid-dispatch = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", rev = "57cb3317878a8593847595319aa03ef17c29ec5b" }
|
||||
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.12" }
|
||||
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.18" }
|
||||
cbor-smol = { git = "https://github.com/Nitrokey/cbor-smol.git", tag = "v0.4.0-nitrokey.2" }
|
||||
|
||||
+1
-4
@@ -6,10 +6,7 @@ mod data;
|
||||
use core::fmt;
|
||||
|
||||
use hkdf::Hkdf;
|
||||
use littlefs2::{
|
||||
path,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use littlefs2_core::{path, Path, PathBuf};
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
use sha2::Sha256;
|
||||
use trussed::{
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ use core::ops::Deref;
|
||||
|
||||
use chacha20poly1305::ChaCha8Poly1305;
|
||||
use hmac::{Hmac, Mac};
|
||||
use littlefs2::path;
|
||||
use littlefs2_core::path;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_byte_array::ByteArray;
|
||||
use sha2::{Digest as _, Sha256};
|
||||
|
||||
+6
-6
@@ -67,10 +67,7 @@ pub mod migrate;
|
||||
|
||||
use core::str::FromStr;
|
||||
|
||||
use littlefs2::{
|
||||
path,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use littlefs2_core::{path, Path, PathBuf};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use trussed::{config::MAX_SHORT_DATA_LENGTH, types::Bytes};
|
||||
|
||||
@@ -129,7 +126,9 @@ impl PinId {
|
||||
path[0..4].copy_from_slice(b"pin.");
|
||||
path[4..].copy_from_slice(&self.hex());
|
||||
|
||||
PathBuf::from(&path)
|
||||
// path has only ASCII characters and is not too long
|
||||
#[allow(clippy::unwrap_used)]
|
||||
PathBuf::try_from(&path).ok().unwrap()
|
||||
}
|
||||
|
||||
/// Get the hex representation of the PIN id
|
||||
@@ -182,7 +181,8 @@ mod tests {
|
||||
for i in 0..=u8::MAX {
|
||||
assert_eq!(Ok(PinId(i)), PinId::from_path(PinId(i).path().as_ref()));
|
||||
let actual = PinId(i).path();
|
||||
let expected = PathBuf::from(format!("pin.{i:02x}").as_str());
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let expected = PathBuf::try_from(format!("pin.{i:02x}").as_str()).unwrap();
|
||||
println!("id: {i}, actual: {actual}, expected: {expected}");
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
+5
-9
@@ -7,7 +7,7 @@
|
||||
|
||||
use core::iter::once;
|
||||
|
||||
use littlefs2::{io::Error, object_safe::DynFilesystem, path, path::Path};
|
||||
use littlefs2_core::{path, DynFilesystem, Error, Path};
|
||||
|
||||
fn migrate_single(fs: &dyn DynFilesystem, path: &Path) -> Result<(), Error> {
|
||||
let path = path.join(path!("backend-auth"));
|
||||
@@ -22,7 +22,7 @@ fn migrate_single(fs: &dyn DynFilesystem, path: &Path) -> Result<(), Error> {
|
||||
});
|
||||
match dir_res {
|
||||
Ok(()) => fs.remove_dir(&path_dat),
|
||||
Err(Error::NoSuchEntry) => Ok(()),
|
||||
Err(Error::NO_SUCH_ENTRY) => Ok(()),
|
||||
Err(_) => dir_res,
|
||||
}
|
||||
}
|
||||
@@ -34,16 +34,12 @@ fn migrate_single(fs: &dyn DynFilesystem, path: &Path) -> Result<(), Error> {
|
||||
/// Migrate does not itself keep track of whether the migration was performed
|
||||
///
|
||||
/// ```rust
|
||||
///# use littlefs2::{fs::Filesystem, const_ram_storage, path};
|
||||
///# use trussed::types::{LfsResult, LfsStorage};
|
||||
///# use littlefs2_core::{DynFilesystem, Error, path};
|
||||
///# use trussed_auth::migrate::migrate_remove_dat;
|
||||
///# const_ram_storage!(Storage, 4096);
|
||||
///# let mut storage = Storage::new();
|
||||
///# Filesystem::format(&mut storage);
|
||||
///# Filesystem::mount_and_then(&mut storage, |fs| {
|
||||
///# fn test(fs: &dyn DynFilesystem) -> Result<(), Error> {
|
||||
/// migrate_remove_dat(fs, &[path!("secrets"), path!("opcard")])?;
|
||||
///# Ok(())
|
||||
///# }).unwrap();
|
||||
///# }
|
||||
/// ```
|
||||
pub fn migrate_remove_dat(fs: &dyn DynFilesystem, apps: &[&Path]) -> Result<(), Error> {
|
||||
for p in once(&path!("/")).chain(apps) {
|
||||
|
||||
+9
-6
@@ -126,6 +126,7 @@ mod dispatch {
|
||||
}
|
||||
}
|
||||
|
||||
use littlefs2_core::path;
|
||||
use rand_core::{OsRng, RngCore as _};
|
||||
use trussed::{
|
||||
backend::BackendId,
|
||||
@@ -651,9 +652,10 @@ fn delete_all_pins() {
|
||||
assert!(reply.has_pin);
|
||||
let reply = syscall!(client.has_pin(Pin::Admin));
|
||||
assert!(reply.has_pin);
|
||||
assert!(try_syscall!(
|
||||
client.read_file(Location::Internal, PathBuf::from("/backend-auth/pin.00"))
|
||||
)
|
||||
assert!(try_syscall!(client.read_file(
|
||||
Location::Internal,
|
||||
PathBuf::from(path!("/backend-auth/pin.00"))
|
||||
))
|
||||
.is_err());
|
||||
|
||||
syscall!(client.reset_app_keys());
|
||||
@@ -740,9 +742,10 @@ fn reset_auth_data() {
|
||||
assert!(reply.has_pin);
|
||||
let reply = syscall!(client.has_pin(Pin::Admin));
|
||||
assert!(reply.has_pin);
|
||||
assert!(try_syscall!(
|
||||
client.read_file(Location::Internal, PathBuf::from("/backend-auth/pin.00"))
|
||||
)
|
||||
assert!(try_syscall!(client.read_file(
|
||||
Location::Internal,
|
||||
PathBuf::from(path!("/backend-auth/pin.00"))
|
||||
))
|
||||
.is_err());
|
||||
|
||||
syscall!(client.reset_auth_data());
|
||||
|
||||
Reference in New Issue
Block a user