-
Notifications
You must be signed in to change notification settings - Fork 136
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
Zeroize: Discrepency between [Z; N]
, `[Z]
, Vec<Z>
, Box<[Z]>
#899
Comments
Maybe one day we could use specialization for these kinds of stuff |
That stated reason for the slice impl is very important. It's what permits the sort of optimizations we're exploring in #841 without specialization. It's deliberately inconsistent with the owned types in that regard, and also if you wanted to use the optimized implementation to zero the others, you can always obtain a slice. |
Could you expand on that? |
...to permit vectorized optimizations, as you already identified |
Wouldn't we also want to do vectorized optimizations for the owned variants? |
Maybe |
As I just mentioned, if you want to take advantage of that optimization for the owned variants in the case the type is Likewise, if you have a mut slice you want to zero for a type which is Without specialization I don't think you can do much better than this. Also |
My main concern with that is that at least I usually use this crate via either the derive macros or the derive macro combined with |
We can potentially change the derive macro to support calling some sort of mutable slice accessor like Other than that I'm not sure there's a solution other than specialization. (also note we haven't landed any optimized implementation yet, so you're not missing anything) |
I opened #901 to track custom derive support for Otherwise this is working as intended, and probably won't be revisited until specialization is stable. |
Right now
[Z]
only implementsZeroize
ifZ: DefaultIsZeroes
[0].While
Vec<Z>
[1],Box<[Z]>
[2], and even[Z; N]
[3] all implementZeroize
ifZ: Zeroize
.The justification for
impl<Z: DefaultIsZeros> Zeroize for [Z]
is given here:utils/zeroize/src/lib.rs
Lines 455 to 457 in 017165f
To me it feels like they should all behave ~the same with regard to zeroing
[0] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-%5BZ%5D
[1] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-Vec%3CZ%3E
[2] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-Box%3C%5BZ%5D%3E
[3] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-%5BZ;+N%5D
The text was updated successfully, but these errors were encountered: