Skip to content

fix: use a zero-length bstr for an empty protected header in the structures - #132

Open
Executioner1939 wants to merge 1 commit into
google:mainfrom
Executioner1939:fix/empty-protected-structure
Open

Executioner1939 wants to merge 1 commit into
google:mainfrom
Executioner1939:fix/empty-protected-structure

Conversation

@Executioner1939

Copy link
Copy Markdown

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's sign-pass-01 vector didn't verify. Sig_structure, MAC_structure and Enc_structure now use h'' 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-01 itself. They fail on main and pass with the change. All 135 lib tests pass, and fmt and clippy report nothing new.

The six *_noncanonical tests used 41a0 and 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.

…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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant