Skip to content

Commit

Permalink
Use serde-indexed to save space
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Feb 13, 2024
1 parent 4b8191f commit 34abe7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ hmac = "0.12.1"
rand_core = "0.6.4"
serde = { version = "1", default-features = false }
serde-byte-array = "0.1.2"
serde-indexed = "0.1.0"
sha2 = { version = "0.10.6", default-features = false }
subtle = { version = "2.4.1", default-features = false }
trussed = { version = "0.1.0", features = ["serde-extensions"] }
Expand All @@ -27,5 +28,7 @@ rand_core = { version = "0.6.4", default-features = false, features = ["getrando
trussed = { version = "0.1.0", features = ["serde-extensions", "virt"] }

[patch.crates-io]
littlefs2 = { git = "https://github.com/Nitrokey/littlefs2", tag = "v0.3.2-nitrokey-2" }
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "df720980888e3e0d5487250bd14a28db02a5f13b" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2", rev = "ebd27e49ca321089d01d8c9b169c4aeb58ceeeca" }
trussed = { git = "https://github.com/Nitrokey/trussed.git", tag = "v0.1.0-nitrokey.17" }
serde-indexed = { git = "https://github.com/nitrokey/serde-indexed.git", rev = "37ba220526961fb8ba067d3fa18ee620337bb73b" }
cbor-smol = { git = "https://github.com/sosthene-nitrokey/cbor-smol.git", rev = "327f723d53263d4ac1da368660de4fe4aa8ebef8" }
5 changes: 3 additions & 2 deletions src/backend/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,20 @@ pub(crate) type Key = ByteArray<KEY_LEN>;
/// to_presistent_storage(salt, wrapped_key);
/// }
/// ````
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, serde_indexed::SerializeIndexed)]
struct WrappedKeyData {
wrapped_key: Key,
tag: ChaChaTag,
}

// No need for using SerializeIndexed, cbor_smol already does it for enums
#[derive(Debug, Deserialize, Serialize)]
enum KeyOrHash {
Key(WrappedKeyData),
Hash(Hash),
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, serde_indexed::SerializeIndexed)]
pub(crate) struct PinData {
#[serde(skip)]
id: PinId,
Expand Down

0 comments on commit 34abe7d

Please sign in to comment.