Skip to content
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

Ignore more unknown keys in cose deserialization #22

Closed
wants to merge 3 commits into from

Conversation

robin-nitrokey
Copy link
Member

Using cbor-smol’s new deserialize_any implementation, we can now iterate
over all keys and values in the input map and ignore all unknown keys,
as required by the spec.

Built on top of #8 using trussed-dev/cbor-smol#6.

This patch introduces the RawPublicKey helper type that takes care of
serialization and deserialization of the key type.  The *PublicKey
structs now only need to check if all required fields are present and
have the correct value.  It also adds extensive tests to make sure that
serialization and deserialization work correctly.
The algorithm field is optional, see RFC 8152 § 7:

   COSE_Key = {
       1 => tstr / int,          ; kty
       ? 2 => bstr,              ; kid
       ? 3 => tstr / int,        ; alg
       ? 4 => [+ (tstr / int) ], ; key_ops
       ? 5 => bstr,              ; Base IV
       * label => values
   }

   alg:  This parameter is used to restrict the algorithm that is used
      with the key.  If this parameter is present in the key structure,
      the application MUST verify that this algorithm matches the
      algorithm for which the key is being used.
Using cbor-smol’s new deserialize_any implementation, we can now iterate
over all keys and values in the input map and ignore all unknown keys,
as required by the spec.
@robin-nitrokey
Copy link
Member Author

The COSE implementation has been moved to the cosey crate. This issue is now tracked there:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant