-
Notifications
You must be signed in to change notification settings - Fork 239
Implement ZeroizeOnDrop for the output of buffer_ct_variable
#2353
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
Open
kayabaNerve
wants to merge
1
commit into
RustCrypto:master
Choose a base branch
from
kayabaNerve:zod
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unnecessary complication. Why can't you simply copy what is done in
buffer_fixed!?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the
cfg(feature = "zeroize")local todigestand not in the generated code which assumes the caller will have a feature of the same name. In all my work, I don't havezeroizeas optional and don't define such a feature, so I'd not have such codegen applied despite explicitly wanting it as shown by enablingdigest/zeroize. The fact the other macro exhibited that pattern would be a hygiene issue and bug in it, AFAIK.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces inconsistency across macros and makes the macros API even more complicated and confusing than it's already is.
No, it's intentional. The macro is a helper to define a buffered struct, so the generated code should work with features defined by the downstream crate. If it does not define
zeroizecrate feature for some reason, then it should not implementZeroizeOnDropusing the macro and instead do it with an explicitimpl.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually believe this makes the macro API more complicated, as the user-facing API is identical. The only change is when
digest/zeroize, it'll also deriveZeroizeOnDrop.If I have to update this macro to be unhygienic and impose undocumented requirements on the caller's declared features (assumed to have the exact same presence and name as seen within RustCrypto) to get it merged, I'm fine doing so because I honestly can't be arsed to care, but please confirm if that's a prerequisite for this PR getting merged. Right now, I'm unclear if this is still a discussion or if I am being told this is a hard blocker, sorry.
I'm unsure if this is anything more than a footgun. Specifically, the
digest/zeroizefeature means thatzeroizeis a dependency and already present in-tree. I have no idea why, whenzeroizeis present,digestwouldn't derive traits fromzeroize. If the goal is a caller who's using these macros but can opt-in/out of these features, then this macro should have an explicit variant withZeroizeOnDrop/a way to exclude traits/shouldn't generateZeroizeOnDropat all IMO. This would imply I should PR this trait implementation directly toblake2, though I assume such a PR will then be kicked back as it should be part of the macro.Also, manually unconditionally implementing
ZeroizeOnDropsomewhat conflicts with a macro which conditionally implements it. I don't believe it'd ever actually come up, as it'd only be realized if that feature was added and enabled, but it truly seems like a poor solution to me.