Upgrade to parity-crypto 0.4 (#10650)

* [whisper] Move needed aes_gcm crypto in-crate

In the latest `parity-crypto` release (upcoming 0.4), the aes GCM features were removed (done to remove the dependency on `ring`).
This PR adds the bare minimum crypto needed for Whisper directly to the crate itself and as those were the only features needed from `parity-crypto`, removes the dependency on that crate altogether.

* Upgrade to parity-crypto 0.4

Reverts using NonZeroU32 (introduced [here](b347599cf7)).

* Check for 0 in `args.arg_keys_iteration`

* Use beta.4

* parity-crypto 0.4.0 is released
This commit is contained in:
David
2019-05-28 07:50:10 +02:00
committed by Wei Tang
parent 9bbf8b6c0f
commit 9584faee55
24 changed files with 317 additions and 136 deletions

View File

@@ -17,7 +17,6 @@
use std::time::Duration;
use std::io::Read;
use std::net::SocketAddr;
use std::num::NonZeroU32;
use std::path::PathBuf;
use std::collections::{HashSet, BTreeMap};
use std::iter::FromIterator;
@@ -144,8 +143,11 @@ impl Configuration {
let ipfs_conf = self.ipfs_config();
let secretstore_conf = self.secretstore_config()?;
let format = self.format()?;
let keys_iterations = NonZeroU32::new(self.args.arg_keys_iterations)
.ok_or_else(|| "--keys-iterations must be non-zero")?;
let key_iterations = self.args.arg_keys_iterations;
if key_iterations == 0 {
return Err("--key-iterations must be non-zero".into());
}
let cmd = if self.args.flag_version {
Cmd::Version
@@ -202,7 +204,7 @@ impl Configuration {
} else if self.args.cmd_account {
let account_cmd = if self.args.cmd_account_new {
let new_acc = NewAccount {
iterations: keys_iterations,
iterations: key_iterations,
path: dirs.keys,
spec: spec,
password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
@@ -236,7 +238,7 @@ impl Configuration {
Cmd::Account(account_cmd)
} else if self.args.cmd_wallet {
let presale_cmd = ImportWallet {
iterations: keys_iterations,
iterations: key_iterations,
path: dirs.keys,
spec: spec,
wallet_path: self.args.arg_wallet_import_path.clone().unwrap(),
@@ -532,10 +534,8 @@ impl Configuration {
}
fn accounts_config(&self) -> Result<AccountsConfig, String> {
let keys_iterations = NonZeroU32::new(self.args.arg_keys_iterations)
.ok_or_else(|| "--keys-iterations must be non-zero")?;
let cfg = AccountsConfig {
iterations: keys_iterations,
iterations: self.args.arg_keys_iterations,
refresh_time: self.args.arg_accounts_refresh,
testnet: self.args.flag_testnet,
password_files: self.args.arg_password.iter().map(|s| replace_home(&self.directories().base, s)).collect(),
@@ -1216,10 +1216,6 @@ mod tests {
use super::*;
lazy_static! {
static ref ITERATIONS: NonZeroU32 = NonZeroU32::new(10240).expect("10240 > 0; qed");
}
#[derive(Debug, PartialEq)]
struct TestPasswordReader(&'static str);
@@ -1241,7 +1237,7 @@ mod tests {
let args = vec!["parity", "account", "new"];
let conf = parse(&args);
assert_eq!(conf.into_command().unwrap().cmd, Cmd::Account(AccountCmd::New(NewAccount {
iterations: *ITERATIONS,
iterations: 10240,
path: Directories::default().keys,
password_file: None,
spec: SpecType::default(),
@@ -1276,7 +1272,7 @@ mod tests {
let args = vec!["parity", "wallet", "import", "my_wallet.json", "--password", "pwd"];
let conf = parse(&args);
assert_eq!(conf.into_command().unwrap().cmd, Cmd::ImportPresaleWallet(ImportWallet {
iterations: *ITERATIONS,
iterations: 10240,
path: Directories::default().keys,
wallet_path: "my_wallet.json".into(),
password_file: Some("pwd".into()),