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.
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
crypto: fix edge case in authenticated encryption #22828
crypto: fix edge case in authenticated encryption #22828
Changes from 1 commit
57c0dbe
520717b
994d6b7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is there currently a difference between these two states? Sorry for asking questions, but I’m not sure I’m fully qualified to review this…
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.
Yes, you can use GCM (e.g.
aes-128-gcm
) without specifying the authentication tag length, then the state will bekAuthTagUnknown
, but other modes such as CCM (aes-128-ccm
) and OCB (aes-128-ocb
) require the length of the authentication tag in advance (via theauthTagLength
option), so the cipher will start in the statekAuthTagLengthKnown
. Once the user callssetAuthTag
, the state becomeskAuthTagKnown
, which implies that the length is known as well.(Never apologize for asking questions. 😉)
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.
Thank you! Is there any difference in how we treat those states after they have been entered?
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.
Technically, we do. But:
If
auth_tag_state_
is eitherkAuthTagUnknown
orkAuthTagLengthKnown
, thenauth_tag_state_ == kAuthTagUnknown
iffauth_tag_len_ == kNoAuthTagLength
. So you are right, we could totally drop the second state! (Or removekNoAuthTagLength
.)