Skip to content

Commit

Permalink
rust: bump hmac from 0.7.1 to 0.9.0 & sha2 from 0.8.2 to 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Sep 9, 2020
1 parent d6a891d commit 76ef16f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 28 deletions.
1 change: 1 addition & 0 deletions .changelog/3260.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rust: Update tiny-keccak, hmac, sha2 dependencies
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ updates:
# version, remove it from the ignore list.
- dependency-name: futures
- dependency-name: grpcio
- dependency-name: hmac
- dependency-name: intrusive-collections
- dependency-name: rustracing
- dependency-name: rustracing_jaeger
- dependency-name: serde
- dependency-name: serde_bytes
- dependency-name: serde_cbor
- dependency-name: sha2
- dependency-name: snow
30 changes: 12 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ tiny-keccak = { version = "2.0.2", features = ["sha3"] }
sp800-185 = "0.2.0"
zeroize = "1.1"
intrusive-collections = "0.8"
sha2 = "0.8.1"
hmac = "0.7.1"
sha2 = "0.9.1"
hmac = "0.9.0"
honggfuzz = "0.5.47"
arbitrary = { version = "0.4.1", features = ["derive"] }

Expand Down
4 changes: 2 additions & 2 deletions runtime/src/common/crypto/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl Hash {
pub fn digest_bytes_list(data: &[&[u8]]) -> Hash {
let mut ctx = Sha512Trunc256::new();
for datum in data {
ctx.input(datum);
ctx.update(datum);
}

let mut result = [0u8; 32];
result[..].copy_from_slice(ctx.result().as_ref());
result[..].copy_from_slice(ctx.finalize().as_ref());

Hash(result)
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/common/crypto/mrae/deoxysii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub use super::deoxysii_rust::{DeoxysII, KEY_SIZE, NONCE_SIZE, TAG_SIZE};

use super::{
hmac::{Hmac, Mac},
hmac::{Hmac, Mac, NewMac},
sha2::Sha512Trunc256,
x25519_dalek,
};
Expand All @@ -22,12 +22,12 @@ fn derive_symmetric_key(public: &[u8; 32], private: &[u8; 32]) -> [u8; KEY_SIZE]
let pmk = private.diffie_hellman(&public);

let mut kdf = Kdf::new_varkey(b"MRAE_Box_Deoxys-II-256-128").expect("Hmac::new_varkey");
kdf.input(pmk.as_bytes());
kdf.update(pmk.as_bytes());
drop(pmk);

let mut derived_key = [0u8; KEY_SIZE];
let digest = kdf.result();
derived_key.copy_from_slice(&digest.code().as_ref()[..KEY_SIZE]);
let digest = kdf.finalize();
derived_key.copy_from_slice(&digest.into_bytes()[..KEY_SIZE]);

derived_key
}
Expand Down

0 comments on commit 76ef16f

Please sign in to comment.