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

Use cbor-x instead of cbor-js for CBOR encoding/decoding #34

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

cyraxx
Copy link
Contributor

@cyraxx cyraxx commented Jul 26, 2024

Switch to newer, well maintained library cbor-x that includes proper tagging support.

It's pretty straightforward. Only two adjustments were necessary:

  • src/cose/SigStructure.ts shows an example of CBOR encoding – it needs a special flag to properly encode Uint8Array to the format we need.
  • src/jumbf/CBORBox.ts needs to deal with the fact that cbor-x returns a special Tag object when encountering CBOR tags it doesn't natively understand.

@cyraxx cyraxx requested a review from UlrichEckhardt July 26, 2024 10:45
@@ -33,7 +33,6 @@
"devDependencies": {
"@eslint/js": "^9.7.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@types/cbor-js": "^0.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. :)

this.content = cbor.decode(BinaryHelper.toArrayBuffer(buf));
this.content = cbor.decode(buf);

// Ignore unknown CBOR tags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really unknown: Some of the JPEGs have data with tag #18 here, which is COSE_Sign1 according to this list off assigned CBOR tags. I'll add this link in the typed-binary branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, unknown as in „unknown by cbor-x“. The COSE data is supposed to be tagged according to the COSE RFC.

@cyraxx cyraxx merged commit b0b3d08 into main Jul 27, 2024
3 checks passed
@cyraxx cyraxx deleted the feature/cbor-x branch July 27, 2024 19:25
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.

2 participants