-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
It looks like @twittner signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
self.sstore.remove_account(&self.sstore.account_ref(&address)?, &password)?; | ||
Ok(()) | ||
} | ||
|
||
/// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given. | ||
pub fn change_password(&self, address: &Address, password: String, new_password: String) -> Result<(), Error> { | ||
pub fn change_password(&self, address: &Address, password: Password, new_password: Password) -> Result<(), Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out-of-scope for this PR:
Why not pass-by_ref
here?
self.sstore.change_password(&self.sstore.account_ref(address)?, &password, &new_password) | ||
} | ||
|
||
/// Exports an account for given address. | ||
pub fn export_account(&self, address: &Address, password: String) -> Result<KeyFile, Error> { | ||
pub fn export_account(&self, address: &Address, password: Password) -> Result<KeyFile, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out-of-scope for this PR:
Why not pass-by_ref
here?
self.sstore.export_account(&self.sstore.account_ref(address)?, &password) | ||
} | ||
|
||
/// Helper method used for unlocking accounts. | ||
fn unlock_account(&self, address: Address, password: String, unlock: Unlock) -> Result<(), Error> { | ||
fn unlock_account(&self, address: Address, password: Password, unlock: Unlock) -> Result<(), Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out-of-scope for this PR:
Why not pass-by_ref
here?
ethkey/src/password.rs
Outdated
let p = vec.as_mut_ptr(); | ||
for i in 0..n { | ||
unsafe { | ||
ptr::write_volatile(p.offset(i as isize), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be worth to add a comment and explaining why write_volatile
is used here. i.e., to actually make sure that passwords
are erased and not LLVM performs some magic optimization!
Also consider to simply the code to:
let ptr = unsafe { s.as_mut_vec() };
for byte in ptr {
unsafe { ptr::write_volatile(byte, 0) }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but document why volatile
writes are used to erase the passwords in the memory!
Needs 2nd review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ethkey/src/password.rs
Outdated
|
||
use std::ptr; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we provide a custom Debug
that prints a static Password(******)
? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good improvement. I wonder if we should accompany this with std::mem::drop(password)
calls in the appropriate places as well?
Minor grumble: indentation in a few places look off: https://github.com/paritytech/parity/pull/8920/files#diff-d3979a57cbb0a0d1504cc1f5bab2d007R36 and https://github.com/paritytech/parity/pull/8920/files#diff-4d8151f665cbc6bf2a9fe83d64a61b64R35
ethkey/src/password.rs
Outdated
impl Drop for Password { | ||
fn drop(&mut self) { | ||
unsafe { | ||
for byte_ref in self.0.as_mut_vec() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace indentation spaces with tabs.
util/mem/src/lib.rs
Outdated
ptr::write_volatile(p.offset(i as isize), 0) | ||
unsafe { | ||
for byte_ref in self.mem.as_mut() { | ||
ptr::write_volatile(byte_ref, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs :)
Explicit Also in context of this |
@niklasad1 makes sense, especially considering that |
@niklasad1 I think what @dvdplm meant was to use |
…rp_sync_on_light_client * 'master' of https://github.com/paritytech/parity: parity: omit redundant last imported block number in light sync informant (openethereum#8962) Disable hardware-wallets on platforms that don't support `libusb` (openethereum#8464) Bump error-chain and quick_error versions (openethereum#8972) EVM benchmark utilities (openethereum#8944) parity: hide legacy options from cli --help (openethereum#8967) scripts: fix docker build tag on latest using master (openethereum#8952) Add type for passwords. (openethereum#8920)
No description provided.