Skip to content

Commit

Permalink
Merge pull request #32 from Nitrokey/fmt
Browse files Browse the repository at this point in the history
Run cargo fmt
  • Loading branch information
sosthene-nitrokey authored Feb 2, 2024
2 parents 419dd5c + 578071b commit 2583e09
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 257 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ entropy = "0.4.0"
once_cell = "1.13.0"
serde_test = "1"
# If this is not enabled, serde_test makes serde_cbor's compilation fail
serde_cbor = { feature = "0.11.2", features = ["std"] }
serde_cbor = { version = "0.11.2", features = ["std"] }
# Somehow, this is causing a regression.
# rand_core = { version = "0.5", features = ["getrandom"] }

Expand Down
6 changes: 1 addition & 5 deletions src/mechanisms/hmacblake2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ impl DeriveKey for super::HmacBlake2s {
if let Some(additional_data) = &request.additional_data {
mac.update(additional_data);
}
let derived_key: [u8; 32] = mac
.finalize()
.into_bytes()
.try_into()
.map_err(|_| Error::InternalError)?;
let derived_key: [u8; 32] = mac.finalize().into_bytes().into();
let key = keystore.store_key(
request.attributes.persistence,
key::Secrecy::Secret,
Expand Down
6 changes: 1 addition & 5 deletions src/mechanisms/hmacsha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ impl DeriveKey for super::HmacSha1 {
if let Some(additional_data) = &request.additional_data {
mac.update(additional_data);
}
let derived_key: [u8; 20] = mac
.finalize()
.into_bytes()
.try_into()
.map_err(|_| Error::InternalError)?;
let derived_key: [u8; 20] = mac.finalize().into_bytes().into();
let key_id = keystore.store_key(
request.attributes.persistence,
key::Secrecy::Secret,
Expand Down
6 changes: 1 addition & 5 deletions src/mechanisms/hmacsha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ impl DeriveKey for super::HmacSha256 {
if let Some(additional_data) = &request.additional_data {
mac.update(additional_data);
}
let derived_key: [u8; 32] = mac
.finalize()
.into_bytes()
.try_into()
.map_err(|_| Error::InternalError)?;
let derived_key: [u8; 32] = mac.finalize().into_bytes().into();
let key_id = keystore.store_key(
request.attributes.persistence,
key::Secrecy::Secret,
Expand Down
4 changes: 2 additions & 2 deletions src/mechanisms/hmacsha512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl DeriveKey for super::HmacSha512 {
if let Some(additional_data) = &request.additional_data {
mac.update(additional_data);
}
let mut derived_key = [0u8; 64];
derived_key.copy_from_slice(&mac.finalize().into_bytes()); //.try_into().map_err(|_| Error::InternalError)?;
let derived_key: [u8; 64] = mac.finalize().into_bytes().into();

let key = keystore.store_key(
request.attributes.persistence,
key::Secrecy::Secret,
Expand Down
Loading

0 comments on commit 2583e09

Please sign in to comment.