update ring to 0.14 (#10262)

* cargo upgrade hyper-rustls --all

* cargo upgrade parity-crypto --all

* update Cargo.lock

* propagate NonZeroU32

* use NonZeroU32::new_unchecked for crypto::KEY_ITERATIONS

* update Cargo.lock

* replace unsafe code with lazy_static
This commit is contained in:
Andronik Ordian
2019-02-06 19:53:34 +03:00
committed by Niklas Adolfsson
parent 8ab6d89810
commit a3e39c9858
29 changed files with 256 additions and 180 deletions

View File

@@ -17,6 +17,7 @@
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;
@@ -143,6 +144,8 @@ 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 cmd = if self.args.flag_version {
Cmd::Version
@@ -199,7 +202,7 @@ impl Configuration {
} else if self.args.cmd_account {
let account_cmd = if self.args.cmd_account_new {
let new_acc = NewAccount {
iterations: self.args.arg_keys_iterations,
iterations: keys_iterations,
path: dirs.keys,
spec: spec,
password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
@@ -233,7 +236,7 @@ impl Configuration {
Cmd::Account(account_cmd)
} else if self.args.cmd_wallet {
let presale_cmd = ImportWallet {
iterations: self.args.arg_keys_iterations,
iterations: keys_iterations,
path: dirs.keys,
spec: spec,
wallet_path: self.args.arg_wallet_import_path.clone().unwrap(),
@@ -528,8 +531,10 @@ 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: self.args.arg_keys_iterations,
iterations: 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(),
@@ -1212,6 +1217,10 @@ mod tests {
use super::*;
lazy_static! {
static ref ITERATIONS: NonZeroU32 = NonZeroU32::new(10240).expect("10240 > 0; qed");
}
#[derive(Debug, PartialEq)]
struct TestPasswordReader(&'static str);
@@ -1233,7 +1242,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: 10240,
iterations: *ITERATIONS,
path: Directories::default().keys,
password_file: None,
spec: SpecType::default(),
@@ -1268,7 +1277,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: 10240,
iterations: *ITERATIONS,
path: Directories::default().keys,
wallet_path: "my_wallet.json".into(),
password_file: Some("pwd".into()),