Skip to content

Commit 8562ad1

Browse files
Update to healpess v0.9
1 parent ab6ad84 commit 8562ad1

File tree

7 files changed

+55
-42
lines changed

7 files changed

+55
-42
lines changed

Cargo.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,23 @@ repository = "https://github.com/trussed-dev/trussed-auth"
1313

1414
[workspace.dependencies]
1515
serde = { version = "1", default-features = false }
16-
trussed-core = { version = "0.1.0-rc.1", features = ["serde-extensions"] }
16+
trussed-core = { version = "0.1.0", features = ["serde-extensions"] }
1717

1818
[patch.crates-io]
1919
trussed-auth = { path = "extension" }
2020

21-
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
22-
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.19" }
21+
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "e6bb61a716a3575b3e5d9869a0e1bb1740fe9969" }
22+
trussed-core = { git = "https://github.com/trussed-dev/trussed.git", rev = "e6bb61a716a3575b3e5d9869a0e1bb1740fe9969" }
23+
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", rev = "2b3f758016afbc56535d8a65f98a067d5a2d843e" }
24+
heapless-bytes = { git = "https://github.com/trussed-dev/heapless-bytes.git", rev = "038106af58d65dfd34d5e9b6379191bfc842530b" }
25+
cosey = { git = "https://github.com/trussed-dev/cosey.git", branch = "heapless-bytes-0.5" }
26+
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", branch = "update-heapless" }
27+
littlefs2-core = { git = "https://github.com/trussed-dev/littlefs2.git", branch = "update-heapless" }
28+
littlefs2-sys = { git = "https://github.com/trussed-dev/littlefs2-sys", rev = "v0.3.1-nitrokey.1" }
29+
flexiber = { git = "https://github.com/trussed-dev/flexiber.git", branch = "heapless-090" }
30+
iso7816 = { git = "https://github.com/trussed-dev/iso7816.git", branch = "heapless-09" }
31+
# cbor-smol = { git = "https://github.com/trussed-dev/cbor-smol.git", branch = "heapless-0.9" }
32+
cbor-smol = { git = "https://github.com/trussed-dev/cbor-smol.git", branch = "heapless-0.9" }
33+
ctaphid-app = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", branch = "heapless-0.9" }
34+
apdu-app = { git = "https://github.com/trussed-dev/apdu-dispatch.git", branch = "heapless-09" }
35+
trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", branch = "heapless-09" }

backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ quickcheck = { version = "1.0.3", default-features = false }
3232
rand_core = { version = "0.6.4", default-features = false, features = ["getrandom"] }
3333
serde_cbor = { version = "0.11.2", features = ["std"] }
3434
serde_test = "1.0.176"
35-
trussed = { version = "0.1.0", default-features = false, features = ["clients-1", "crypto-client", "filesystem-client", "hmac-sha256", "serde-extensions", "virt"] }
35+
trussed = { version = "0.1.0", default-features = false, features = ["hmac-sha256", "serde-extensions", "virt"] }

backend/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ fn create_app_salt<S: Filestore, R: CryptoRng + RngCore>(
543543
fn load_app_salt<S: Filestore>(fs: &mut S, location: Location) -> Result<Salt, Error> {
544544
fs.read(APP_SALT_PATH, location)
545545
.map_err(|_| Error::ReadFailed)
546-
.and_then(|b: Bytes<SALT_LEN>| (**b).try_into().map_err(|_| Error::ReadFailed))
546+
.and_then(|b: Bytes<SALT_LEN>| (*b).try_into().map_err(|_| Error::ReadFailed))
547547
}
548548

549549
pub fn expand_app_key(salt: &Salt, application_key: &Key, info: &[u8]) -> Key {

backend/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl AuthBackend {
163163
.or(Err(Error::WriteFailed))
164164
.and(Ok(salt))
165165
})
166-
.and_then(|b| (**b).try_into().or(Err(Error::ReadFailed)))
166+
.and_then(|b| (*b).try_into().or(Err(Error::ReadFailed)))
167167
}
168168

169169
fn extract<R: CryptoRng + RngCore>(
@@ -172,7 +172,7 @@ impl AuthBackend {
172172
ikm: Option<Bytes<MAX_HW_KEY_LEN>>,
173173
rng: &mut R,
174174
) -> Result<&Hkdf<Sha256>, Error> {
175-
let ikm: &[u8] = ikm.as_deref().map(|i| &**i).unwrap_or(&[]);
175+
let ikm: &[u8] = ikm.as_deref().map(|i| &*i).unwrap_or(&[]);
176176
let salt = self.get_global_salt(global_fs, rng)?;
177177
let kdf = Hkdf::new(Some(&*salt), ikm);
178178
self.hw_key = HardwareKey::Extracted(kdf);

backend/tests/backend.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ fn random_pin() -> trussed_auth::Pin {
214214
#[test]
215215
fn basic() {
216216
run(BACKENDS, |client| {
217-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
218-
let pin2 = Bytes::from_slice(b"123456").unwrap();
217+
let pin1 = Bytes::try_from(b"12345678").unwrap();
218+
let pin2 = Bytes::try_from(b"123456").unwrap();
219219

220220
let reply = syscall!(client.has_pin(Pin::User));
221221
assert!(!reply.has_pin);
@@ -258,8 +258,8 @@ fn basic() {
258258
#[test]
259259
fn basic_wrapped() {
260260
run(BACKENDS, |client| {
261-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
262-
let pin2 = Bytes::from_slice(b"123456").unwrap();
261+
let pin1 = Bytes::try_from(b"12345678").unwrap();
262+
let pin2 = Bytes::try_from(b"123456").unwrap();
263263

264264
let reply = syscall!(client.has_pin(Pin::User));
265265
assert!(!reply.has_pin);
@@ -303,10 +303,10 @@ fn basic_wrapped() {
303303
fn hw_key_wrapped() {
304304
run_with_hw_key(
305305
BACKENDS,
306-
Bytes::from_slice(b"Some HW ikm").unwrap(),
306+
Bytes::try_from(b"Some HW ikm").unwrap(),
307307
|client| {
308-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
309-
let pin2 = Bytes::from_slice(b"123456").unwrap();
308+
let pin1 = Bytes::try_from(b"12345678").unwrap();
309+
let pin2 = Bytes::try_from(b"123456").unwrap();
310310

311311
let reply = syscall!(client.has_pin(Pin::User));
312312
assert!(!reply.has_pin);
@@ -350,8 +350,8 @@ fn hw_key_wrapped() {
350350
#[test]
351351
fn missing_hw_key() {
352352
run_with_missing_hw_key(BACKENDS, |client| {
353-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
354-
let pin2 = Bytes::from_slice(b"123456").unwrap();
353+
let pin1 = Bytes::try_from(b"12345678").unwrap();
354+
let pin2 = Bytes::try_from(b"123456").unwrap();
355355

356356
let reply = syscall!(client.has_pin(Pin::User));
357357
assert!(!reply.has_pin);
@@ -400,10 +400,10 @@ fn missing_hw_key() {
400400
fn pin_key() {
401401
run_with_hw_key(
402402
BACKENDS,
403-
Bytes::from_slice(b"Some HW ikm").unwrap(),
403+
Bytes::try_from(b"Some HW ikm").unwrap(),
404404
|client| {
405-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
406-
let pin2 = Bytes::from_slice(b"123456").unwrap();
405+
let pin1 = Bytes::try_from(b"12345678").unwrap();
406+
let pin2 = Bytes::try_from(b"123456").unwrap();
407407

408408
syscall!(client.set_pin(Pin::User, pin1.clone(), Some(3), true));
409409
assert!(syscall!(client.get_pin_key(Pin::User, pin2.clone()))
@@ -448,11 +448,11 @@ fn pin_key() {
448448
fn reset_pin_key() {
449449
run_with_hw_key(
450450
BACKENDS,
451-
Bytes::from_slice(b"Some HW ikm").unwrap(),
451+
Bytes::try_from(b"Some HW ikm").unwrap(),
452452
|client| {
453-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
454-
let pin2 = Bytes::from_slice(b"123456").unwrap();
455-
let pin3 = Bytes::from_slice(b"1234567890").unwrap();
453+
let pin1 = Bytes::try_from(b"12345678").unwrap();
454+
let pin2 = Bytes::try_from(b"123456").unwrap();
455+
let pin3 = Bytes::try_from(b"1234567890").unwrap();
456456

457457
syscall!(client.set_pin(Pin::User, pin1.clone(), Some(3), true));
458458
assert!(syscall!(client.get_pin_key(Pin::User, pin2.clone()))
@@ -499,8 +499,8 @@ fn reset_pin_key() {
499499
#[test]
500500
fn blocked_pin() {
501501
run(BACKENDS, |client| {
502-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
503-
let pin2 = Bytes::from_slice(b"123456").unwrap();
502+
let pin1 = Bytes::try_from(b"12345678").unwrap();
503+
let pin2 = Bytes::try_from(b"123456").unwrap();
504504

505505
syscall!(client.set_pin(Pin::User, pin1.clone(), Some(3), false));
506506

@@ -520,8 +520,8 @@ fn blocked_pin() {
520520
#[test]
521521
fn set_blocked_pin() {
522522
run(BACKENDS, |client| {
523-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
524-
let pin2 = Bytes::from_slice(b"123456").unwrap();
523+
let pin1 = Bytes::try_from(b"12345678").unwrap();
524+
let pin2 = Bytes::try_from(b"123456").unwrap();
525525

526526
syscall!(client.set_pin(Pin::User, pin1.clone(), Some(1), false));
527527
let reply = syscall!(client.check_pin(Pin::User, pin1.clone()));
@@ -541,7 +541,7 @@ fn set_blocked_pin() {
541541
fn empty_pin() {
542542
run(BACKENDS, |client| {
543543
let pin1 = Bytes::new();
544-
let pin2 = Bytes::from_slice(b"123456").unwrap();
544+
let pin2 = Bytes::try_from(b"123456").unwrap();
545545

546546
syscall!(client.set_pin(Pin::User, pin1.clone(), None, false));
547547
let reply = syscall!(client.has_pin(Pin::User));
@@ -577,9 +577,9 @@ fn max_pin_length() {
577577
#[test]
578578
fn pin_retries() {
579579
run(BACKENDS, |client| {
580-
let pin1 = Bytes::from_slice(b"12345678").unwrap();
581-
let pin2 = Bytes::from_slice(b"123456").unwrap();
582-
let pin3 = Bytes::from_slice(b"654321").unwrap();
580+
let pin1 = Bytes::try_from(b"12345678").unwrap();
581+
let pin2 = Bytes::try_from(b"123456").unwrap();
582+
let pin3 = Bytes::try_from(b"654321").unwrap();
583583

584584
syscall!(client.set_pin(Pin::User, pin1.clone(), Some(3), false));
585585
syscall!(client.set_pin(Pin::Admin, pin2.clone(), Some(5), false));
@@ -627,7 +627,7 @@ fn pin_retries() {
627627
#[test]
628628
fn delete_pin() {
629629
run(BACKENDS, |client| {
630-
let pin = Bytes::from_slice(b"123456").unwrap();
630+
let pin = Bytes::try_from(b"123456").unwrap();
631631

632632
syscall!(client.set_pin(Pin::User, pin.clone(), None, false));
633633
let reply = syscall!(client.has_pin(Pin::User));
@@ -647,8 +647,8 @@ fn delete_pin() {
647647
#[test]
648648
fn delete_all_pins() {
649649
run(BACKENDS, |client| {
650-
let pin1 = Bytes::from_slice(b"123456").unwrap();
651-
let pin2 = Bytes::from_slice(b"12345678").unwrap();
650+
let pin1 = Bytes::try_from(b"123456").unwrap();
651+
let pin2 = Bytes::try_from(b"12345678").unwrap();
652652

653653
syscall!(client.set_pin(Pin::User, pin1.clone(), None, false));
654654
syscall!(client.set_pin(Pin::Admin, pin2.clone(), None, false));
@@ -686,8 +686,8 @@ fn delete_all_pins() {
686686
#[test]
687687
fn reset_application_key() {
688688
run(BACKENDS, |client| {
689-
let info1 = Message::from_slice(b"test1").unwrap();
690-
let info2 = Message::from_slice(b"test2").unwrap();
689+
let info1 = Message::try_from(b"test1").unwrap();
690+
let info2 = Message::try_from(b"test2").unwrap();
691691
let app_key1 = syscall!(client.get_application_key(info1.clone())).key;
692692
let app_key2 = syscall!(client.get_application_key(info2)).key;
693693
let mac1 = syscall!(client.sign_hmacsha256(app_key1, b"Some data")).signature;
@@ -722,8 +722,8 @@ fn reset_application_key() {
722722
fn reset_auth_data() {
723723
run(BACKENDS, |client| {
724724
/* ------- APP KEYS ------- */
725-
let info1 = Message::from_slice(b"test1").unwrap();
726-
let info2 = Message::from_slice(b"test2").unwrap();
725+
let info1 = Message::try_from(b"test1").unwrap();
726+
let info2 = Message::try_from(b"test2").unwrap();
727727
let app_key1 = syscall!(client.get_application_key(info1.clone())).key;
728728
let app_key2 = syscall!(client.get_application_key(info2)).key;
729729
let mac1 = syscall!(client.sign_hmacsha256(app_key1, b"Some data")).signature;
@@ -737,8 +737,8 @@ fn reset_auth_data() {
737737
assert_eq!(mac1, mac1_again);
738738

739739
/* ------- PINS ------- */
740-
let pin1 = Bytes::from_slice(b"123456").unwrap();
741-
let pin2 = Bytes::from_slice(b"12345678").unwrap();
740+
let pin1 = Bytes::try_from(b"123456").unwrap();
741+
let pin2 = Bytes::try_from(b"12345678").unwrap();
742742

743743
syscall!(client.set_pin(Pin::User, pin1.clone(), None, false));
744744
syscall!(client.set_pin(Pin::Admin, pin2.clone(), None, false));

extension/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ serde.workspace = true
1515
trussed-core.workspace = true
1616

1717
[dev-dependencies]
18-
heapless-bytes = "0.3"
18+
heapless-bytes = "0.5"

extension/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
//! // PIN is set but not provided
4848
//! return false;
4949
//! };
50-
//! let Ok(pin) = Bytes::from_slice(pin) else {
50+
//! let Ok(pin) = Bytes::try_from(pin) else {
5151
//! // provided PIN is too long
5252
//! return false;
5353
//! };

0 commit comments

Comments
 (0)