From 390a0f61043e2dee9c3f814a6145fde4d7db716c Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 2 Mar 2023 17:58:37 +0100 Subject: [PATCH 1/2] Update serde-byte-array --- Cargo.toml | 2 +- src/backend/data.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d03d0ec..3a29443 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ description = "Authentication extension and backend for Trussed" [dependencies] serde = { version = "1", default-features = false } -serde-byte-array = "0.1.0" +serde-byte-array = "0.1.2" sha2 = { version = "0.10.6", default-features = false } subtle = { version = "2.4.1", default-features = false } trussed = { git = "https://github.com/trussed-dev/trussed", rev = "1c55b3b2dd6a9e1cfc55758635baf0d0bbf387d1", features = ["serde-extensions"] } diff --git a/src/backend/data.rs b/src/backend/data.rs index c574fb8..1b9947c 100644 --- a/src/backend/data.rs +++ b/src/backend/data.rs @@ -113,8 +113,8 @@ impl<'a> PinDataMut<'a> { return false; } let success = hash(self.id, pin, &self.salt) - .as_ref() - .ct_eq(self.hash.as_ref()) + .as_slice() + .ct_eq(self.hash.as_slice()) .into(); if let Some(retries) = &mut self.data.retries { if success { @@ -173,7 +173,7 @@ fn hash(id: PinId, pin: &Pin, salt: &Salt) -> Hash { digest.update([u8::from(id)]); digest.update([pin_len(pin)]); digest.update(pin); - digest.update(salt.as_ref()); + digest.update(salt); Hash::new(digest.finalize().into()) } From d01a95cc5704f2fe37bb4fcef3bab913331af2c4 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 2 Mar 2023 17:59:50 +0100 Subject: [PATCH 2/2] Flatten backend directory To save blocks in the filesystem, flatten the directory hierarchy by changing the backend directory from backend/auth to backend-auth. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f25d2da..57e0f1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ pub const MAX_PIN_LENGTH: usize = MAX_SHORT_DATA_LENGTH; /// A PIN. pub type Pin = Bytes; -const PIN_PATH: &str = "backend/auth/pin"; +const PIN_PATH: &str = "backend-auth/pin"; /// The ID of a PIN within the namespace of a client. ///