-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box secret memory #400
Box secret memory #400
Conversation
This reverts commit 2bc0b2a.
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.
fmt should make travis happy |
Reading https://doc.rust-lang.org/src/alloc/boxed.rs.html#1074-1097, I'm actually not sure if |
Yes indeed, let's remove it. |
LGTM. Just needs a second approval. |
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 % TryFrom
stuff
@@ -232,7 +238,7 @@ impl TryFrom<&[u8]> for Secret { | |||
if b.len() != SECP256K1_SECRET_KEY_SIZE { |
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.
Both TryFrom
implementations can't really guarantee that the source slice is zeroized, there is no way to inform the user that it should be.
Not a security expert, but perhaps it's worth to get rid of these in favour of some more explicit methods which would allow you to add extra security notes.
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 am more having an issue with the From implementation, try_from
never zeroized the input, but yes we do not have any related doc.
I will be in favor of replacing those from
and try_from
implementation with specific functions, but then it would be a breaking PR, so I am thinking this PR could be parity-crypto 6.2 and another one could be a 7.0 with a more significant work for library users.
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.
Actually that is not such a big change, maybe doing it now and releasing breaking 0.7.0 would be better, I will do it.
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.
Sounds good to me!
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 am a big fan of deprecation warnings, so people get a hint on how to migrate directly from the build - that could be applied to the TryFrom
impl while exposing a more explicit API already
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.
Could try 6.2 with dep warning indeed.
Why does it need to be boxed? Stack memory can be zeroed in |
We would need to pin memory to avoid mem copy which does not looks trivial to me (I need to check again but it would mean following a &'a H256 since H256 is not Deref), box was more straightforward. |
In 8ddd0da I am putting the 'from' 'try_from' function as deprecated, following this I switched usage in the crate and I fear there is a possible performance regression in ec_math_utils du to zeroize. Edit : also it includes codes from @tomusdrw rustweb3 for zeroing secp secret key memory |
It depends on what kind of release you want to slate and what kind of implications a deprecations has in code that uses it? |
Co-authored-by: Andronik Ordian <write@reusable.software>
Lastest commit I did switch back some of the previous api by simply take advantage of #[inline(always)]. |
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Andronik Ordian <write@reusable.software>
Put `Secret` memory on heap.
This pr box memory for
Secret
.