x25519: use manual impls instead of zeroize_derive - #776
Merged
Conversation
The types involved are all simple 1-tuple newtypes where zeroization only involves calling `zeroize` on the inner type, making all of the involved impls relatively trivial. Avoiding custom derive arguably improves auditability as you don't need to expand a proc macro to see the resulting code. It decreases the number of required dependencies in order for the `zeroize` feature to work, where some of those dependencies are incredibly heavy (particularly `syn`).
tarcieri
commented
Jul 7, 2025
Comment on lines
+119
to
+124
| impl Drop for EphemeralSecret { | ||
| fn drop(&mut self) { | ||
| #[cfg(feature = "zeroize")] | ||
| self.zeroize(); | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
The reason for gating the inner zeroize invocation on the feature as opposed to the whole Drop impl is so enabling the zeroize feature doesn't change the Drop bounds / presence of drop glue. There are some weird edge cases around this approach avoids.
Contributor
Author
|
Note: this is largely a workaround for the I think this upstream change should take care of the problem going forward, as well: RustCrypto/utils#1190 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The types involved are all simple 1-tuple newtypes where zeroization only involves calling
zeroizeon the inner type, making all of the involved impls relatively trivial.Avoiding custom derive arguably improves auditability as you don't need to expand a proc macro to see the resulting code. It decreases the number of required dependencies in order for the
zeroizefeature to work, where some of those dependencies are incredibly heavy (particularlysyn).