-
Notifications
You must be signed in to change notification settings - Fork 130
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
Why DefaultIsZeroes
requires Copy
?
#1062
Comments
A
For your example: impl Zeroize for SecretKey {
fn zeroize(&mut self) {
self.0.zeroize();
}
} Though you'd likely be better zeroizing in a drop handler for such a use case, to avoid use-after-zeroize problems: impl Drop for SecretKey {
fn drop(&mut self) {
self.0.zeroize();
}
}
impl ZeroizeOnDrop for SecretKey {} |
Thanks for the detailed answer!
If this can't be used because |
There's no safe way to zeroize a foreign type. #1045 added a |
Thanks for the explanation 👍 |
utils/zeroize/src/lib.rs
Line 283 in 216d2b8
What is recommended approach to implement
Zeroize
for non-copy-types? Consider some library has non-copy type:And in user code we have wrapper around that which we would like to zeroize on drop:
One approach would be to implement
Default
forMyKey
and addimpl DefaultIsZeroes for MyKey {}
soMyKey
will implementZeroize
, but it is not possible because ofCopy
constraint onDefaultIsZeroes
The text was updated successfully, but these errors were encountered: