-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add util/mem
to zero out memory on drop.
#8356
Conversation
It looks like @twittner signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
ethkey/src/secret.rs
Outdated
} | ||
} | ||
|
||
impl AsMut<[u8]> for H256Mut { |
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.
Is lack of this impl
the only reason you created H256Mut
? I see no reason why it shouldn't be added to paritytech/primitives. Please make a pr with this change to that repo :)
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.
Yes, will do.
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.
TBH I don't see if it fits primitives. All primitives we have are immutable, do we want to have both mutable and immutable ones there? IMHO makes the library unnecessary bloated.
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.
There is already DerefMut
in primitives though.
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.
Ah, ok. I thought we want to introduce H256Mut
struct into that repo. If it's only about adding missing AsMut
trait implementation then it's all good!
|
||
/// Wrapper to zero out memory when dropped. | ||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct Memzero<T: AsMut<[u8]>> { |
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.
Why not replace the content in place and just require that T: Default
?
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 don't understand. Could you explain this a more fully please?
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.
Nvm, actually it's better with AsMut
if we have all the supported structs.
whisper/src/rpc/crypto.rs
Outdated
|
||
for topic in topics { | ||
buf.extend(&*(topic ^ key)); | ||
} | ||
|
||
let _ = Memzero::from(key.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.
doesn't that just copy the value of key
into some other place in the stack and then zero that?
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.
Yes, thanks.
No description provided.