Skip to content

Commit

Permalink
Update deps. (#102)
Browse files Browse the repository at this point in the history
* Update deps.

* Fix code.

* fmt
  • Loading branch information
tomusdrw committed May 30, 2023
1 parent 443754a commit f49c0b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version = "0.9.0"
zeroize = "1.0.0"
rand = "0.8.0"
rustc-hex = "2.0.1"
secp256k1 = { version = "0.26", optional = true, features = ["recovery"] }
secp256k1 = { version = "0.27", optional = true, features = ["recovery"] }
serde = { version = "1.0", features = ["derive"]}

# Libraries for for pure-rust crypto
Expand Down
7 changes: 4 additions & 3 deletions ethsign-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ description = "Pure Rust drop-in replacement for the `parity-crypto` crate"
license = "GPL-3.0"

[dependencies]
pbkdf2 = { version = "0.11.0", features = [ "parallel" ], default-features = false }
scrypt = "0.10"
pbkdf2 = { version = "0.12.1", features = [ "parallel" ], default-features = false }
scrypt = "0.11"
sha2 = "0.10.1"
hmac = "0.12.0"
aes = { version = "0.7.5", features = [ "ctr" ], default-features = false }
aes = { version = "0.8.0", default-features = false }
ctr = { version = "0.9.2" }
tiny-keccak = { version = "2.0.0", features = [ "keccak" ] }

[dev-dependencies]
Expand Down
7 changes: 3 additions & 4 deletions ethsign-crypto/src/aes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! AES symmetric encryption

use aes::{
cipher::{generic_array::GenericArray, FromBlockCipher, NewBlockCipher, StreamCipher},
Aes128, Aes128Ctr,
cipher::{generic_array::GenericArray, KeyIvInit, StreamCipher},
Aes128,
};
use std::fmt;

Expand Down Expand Up @@ -44,8 +44,7 @@ pub fn encrypt_128_ctr(k: &[u8], iv: &[u8], plain: &[u8], dest: &mut [u8]) -> Re

dest.copy_from_slice(plain);

let cipher = Aes128::new(&key);
let mut cipher_ctr = Aes128Ctr::from_block_cipher(cipher, &nonce);
let mut cipher_ctr = ctr::Ctr128BE::<Aes128>::new(&key, &nonce);
cipher_ctr.apply_keystream(dest);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion ethsign-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<T: AsRef<[u8]>> Keccak256<[u8; 32]> for T {

pub fn derive_key_iterations(password: &[u8], salt: &[u8], c: u32) -> (Vec<u8>, Vec<u8>) {
let mut derived_key = [0u8; KEY_LENGTH];
pbkdf2::<Hmac<Sha256>>(password, salt, c, &mut derived_key);
pbkdf2::<Hmac<Sha256>>(password, salt, c, &mut derived_key).expect("Length is valid; qed");
let derived_right_bits = &derived_key[0..KEY_LENGTH_AES];
let derived_left_bits = &derived_key[KEY_LENGTH_AES..KEY_LENGTH];
(derived_right_bits.to_vec(), derived_left_bits.to_vec())
Expand Down
2 changes: 1 addition & 1 deletion ethsign-crypto/src/scrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{KEY_LENGTH, KEY_LENGTH_AES};
pub fn derive_key(pass: &[u8], salt: &[u8], n: u32, p: u32, r: u32) -> Result<(Vec<u8>, Vec<u8>), ScryptError> {
let log_n = (32 - n.leading_zeros() - 1) as u8;
let mut derived_key = vec![0u8; KEY_LENGTH];
let scrypt_params = scrypt::Params::new(log_n, r, p)?;
let scrypt_params = scrypt::Params::new(log_n, r, p, KEY_LENGTH)?;
scrypt::scrypt(pass, salt, &scrypt_params, &mut derived_key).expect("derived_key is long enough; qed");
let derived_right_bits = &derived_key[0..KEY_LENGTH_AES];
let derived_left_bits = &derived_key[KEY_LENGTH_AES..KEY_LENGTH];
Expand Down

0 comments on commit f49c0b0

Please sign in to comment.