-
Notifications
You must be signed in to change notification settings - Fork 133
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
How to zeroize an Option<Z: ZeroizeOnDrop>
?
#819
Comments
Why do you want to call I think we should simply modify the |
In the case of That said, this is the second recent suggestion I'v seen to remove the |
Shouldn't it be handled by By the way, I think |
We're talking about the The It's not possible, nor does it make sense, to be able to use |
If I use struct Session {
current_keys: Keys,
new_keys: Option<Keys>,
}
impl Session {
fn switch_keys(&mut self) {
self.current_keys = new_keys.take().unwrap();
}
} with Another workaround would be making self.curr_keys = new_keys.unwrap().clone();
self.new_keys = None; // force the drop here but it would be nice to be able to just use |
@mkj there's nothing we can do there. Move semantics may make a copy in that case. It's a documented sharp edge of Making a copy and dropping the original value as you suggested will work around the issue. |
In cases like this users should use a wrapper around |
While that might make sense in some cases, that isn't necessarily a better option in all cases. |
Also The best we could do is deprecate the |
The However you won’t get the same benefits with a |
I have some ciphers stored as an
Option<Ctr32BE<Aes256>>
. I can't simply call.zeroize()
after.take()
because the cipher wrapper only implementsZeroizeOnDrop
, notZeroize
(for good reason, blank keys are dangerous).It seems like it should be fine for
Option<Z: ZeroizeOnDrop>
to implementZeroize
, but I can't add a blanket impl since there's already one forOption<Z: Zeroize>
. Any ideas how to proceed?I've tried a quick
TakeZeroize
trait adding a.take_zeroize()
method which works for my purpose, but it seems a bit too specific. mkj@074cec5The text was updated successfully, but these errors were encountered: