Add type for passwords. (#8920)

* Add type for passwords.

* Fix test.

* Simplify `Drop` impls of `Password` and `Memzero`.

* Spaces to tabs.

* Custom `Drop` impl for `Password`.
This commit is contained in:
Toralf Wittner
2018-06-22 15:09:15 +02:00
committed by David
parent c473ab97c7
commit 41348dead4
61 changed files with 550 additions and 457 deletions

View File

@@ -20,6 +20,7 @@ use ethkey::{KeyPair, Public, Signature, Error as EthKeyError, sign, public_to_a
use ethcore::account_provider::AccountProvider;
use ethereum_types::{H256, Address};
use traits::NodeKeyPair;
use ethkey::Password;
pub struct PlainNodeKeyPair {
key_pair: KeyPair,
@@ -29,7 +30,7 @@ pub struct KeyStoreNodeKeyPair {
account_provider: Arc<AccountProvider>,
address: Address,
public: Public,
password: String,
password: Password,
}
impl PlainNodeKeyPair {
@@ -61,7 +62,7 @@ impl NodeKeyPair for PlainNodeKeyPair {
}
impl KeyStoreNodeKeyPair {
pub fn new(account_provider: Arc<AccountProvider>, address: Address, password: String) -> Result<Self, EthKeyError> {
pub fn new(account_provider: Arc<AccountProvider>, address: Address, password: Password) -> Result<Self, EthKeyError> {
let public = account_provider.account_public(address.clone(), &password).map_err(|e| EthKeyError::Custom(format!("{}", e)))?;
Ok(KeyStoreNodeKeyPair {
account_provider: account_provider,