Repository navigation
fix: use a zero-length bstr for an empty protected header in the structures - #132
Open
Executioner1939 wants to merge 1 commit into
Open
Executioner1939 wants to merge 1 commit into
Executioner1939 wants to merge 1 commit into
Conversation
…ctures RFC 9052 section 3 lets a sender encode an empty protected header as a bstr holding an empty map (41a0), and says recipients MUST accept it. Sections 4.4, 5.3 and 6.3 build Sig_structure, Enc_structure and MAC_structure with a zero-length bstr when there are no protected attributes. coset used the received bytes instead, so the COSE WG's sign1-tests/sign-pass-01 vector did not verify. The structures now use a zero-length bstr for an empty header, and the received bytes otherwise. Re-serializing a message still gives back the bytes as received. The existing non-canonical tests move to non-empty headers, which still use the received bytes.
This branch has not been deployed
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.
Fixes #131.
RFC 9052 §3 lets a sender encode an empty protected header as
h'A0', and recipients MUST accept it. §4.4, §5.3 and §6.3 say "If there are no protected attributes, a zero-length byte string is used" in the three structures. coset used the received bytes, so the WG'ssign-pass-01vector didn't verify. Sig_structure, MAC_structure and Enc_structure now useh''for an empty header and the received bytes otherwise. Re-serializing still gives back the bytes as received.I added four tests, one of them
sign-pass-01itself. They fail onmainand pass with the change. All 135 lib tests pass, and fmt and clippy report nothing new.The six
*_noncanonicaltests used41a0and checked that it was signed as received, which is what this changes. I moved them to non-empty headers (a reordered map, or a non-minimal integer), where the received bytes are still used.