-
Notifications
You must be signed in to change notification settings - Fork 96
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
Make sure secret keys are always inside a ClearOnDrop
.
#89
Comments
Just a thought: There is an MIT-licensed secrets crate that does clear on drop: impl<T> Drop for Sec<T> {
fn drop(&mut self) {
if !thread::panicking() {
debug_assert_eq!(0, self.refs.get());
debug_assert_eq!(Prot::NoAccess, self.prot.get());
}
unsafe { sodium::free(self.ptr) }
}
} It promises a lot more:
It might be worth examining that crate. Maybe we could use it, fix some bugs, send fixes upstream? If the design does not hold up though, at least going over this list and ensuring everything that's listed there is true for our implementation can't hurt, I guess. The only caveat I see is a dependency on NaCl, which has an excellent reputation but it still something we would require at link time. |
Also, it doesn't seem to have the restriction that pub struct SecretKey(Secret(Fr)) We should ideally do the same for |
I don't think that the Also, the dalek cryptography crate designers chose to use What do you (@afck, @mbr) think about adding the extra From what I have read, I think that |
After thinking about it, I don't think that the compiler is smart enough to elide a call to a C function. So elision of the memory clearing code may not be a problem with |
Yes, I imagine that won't be optimized away, but I agree that the sodium dependency is annoying. Maybe Anyway, I don't have a strong opinion regarding |
I did not understand yet why we are not using an "established" crate that protects memory, I assume it was due to the libsodium dependency? Or was it just not generic enough? I would think that disabling swap is fairly important for keys. There's also the tradeoff between implementing @DrPeterVanNostrand: If you think these are valid concerns, feel free to reopen the issue. Sorry! |
I agree Marc, At some point we should use something like https://github.com/quininer/seckey. |
Reopening issue for lack of
|
Overwriting the memory containing a secret key (#57) can still easily be forgotten: e.g.
SecretKey::new
returns a key outside of aClearOnDrop
.Maybe the current
SecretKey
should be turned into a privateSecretKeyInner
, and put aClearOnDrop<Box<SecretKeyInner>>
inside the newSecretKey
, so that outside of thecrypto
module there's no way to circumvent it anymore?The text was updated successfully, but these errors were encountered: