Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
constant-time mac comparison
  • Loading branch information
rphmeier committed Mar 15, 2018
commit 81e9b23e9a29021a6d083b587be3c593269589f7
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions polkadot/keystore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rand = "0.4"
serde_json = "1.0"
serde = "1.0"
serde_derive = "1.0"
subtle = "0.5"

[dev-dependencies]
tempdir = "0.3"
3 changes: 2 additions & 1 deletion polkadot/keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Keystore (and session key management) for polkadot.

extern crate ethcrypto as crypto;
extern crate subtle;
extern crate ed25519;
extern crate rand;
extern crate serde_json;
Expand Down Expand Up @@ -109,7 +110,7 @@ impl EncryptedKey {

let mac = crypto::derive_mac(&derived_right_bits, &self.ciphertext).keccak256();

if mac != self.mac {
if subtle::slices_equal(&mac[..], &self.mac[..]) != 1 {
return Err(ErrorKind::InvalidPassword.into());
}

Expand Down