Skip to content
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

Implement Zeroize for [MaybeUninit<Z>] #793

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

elichai
Copy link
Contributor

@elichai elichai commented Jul 8, 2021

Implementing Zeroize for [MaybeUninit<Z>] is very helpful IMHO, because it allows to zeroize any custom heap allocated objects by just constructing a slice of MaybeUninit(as some of the buffer might not be initialized) and calling zeroize() on it.

I also changed the Vec implementation to zero out the full capacity and not just the uninitialized part, because I don't see any difference between the initialized and the unintialized, if the data in the buffer is secret then we should make sure we zero out all of the buffer.

The downside is that if the Vec contains a primitive(say Vec<u8>) then we'll zero the used space twice, so I can see arguments against it (currently the only time I can think this will matter is in Vecs with another indirection, like Vec<Box<Z>> or Vec<&Z>, and then is there a point in zeroing out those pointers?)

So if people disagree on the 2nd commit I can drop it and leave only the first commit.

@codecov-commenter
Copy link

Codecov Report

Merging #793 (a939587) into main (86b87a3) will increase coverage by 0.14%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #793      +/-   ##
==========================================
+ Coverage   55.43%   55.58%   +0.14%     
==========================================
  Files          76       76              
  Lines        2785     2794       +9     
==========================================
+ Hits         1544     1553       +9     
  Misses       1241     1241              
Impacted Files Coverage Δ
zeroize/src/lib.rs 84.04% <86.66%> (+1.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86b87a3...a939587. Read the comment docs.

@elichai elichai force-pushed the maybeuninit branch 2 times, most recently from 16f6d70 to e380358 Compare July 19, 2021 09:30
@elichai
Copy link
Contributor Author

elichai commented Jul 19, 2021

Fixed the CI fail

@tony-iqlusion tony-iqlusion merged commit 9e199ec into iqlusioninc:main Jul 19, 2021
@tony-iqlusion
Copy link
Member

Thank you!

@elichai elichai deleted the maybeuninit branch July 20, 2021 08:32
@tony-iqlusion tony-iqlusion mentioned this pull request Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants