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

Migrate to coset and ciborium #94

Merged
merged 20 commits into from
Sep 23, 2024
Merged

Migrate to coset and ciborium #94

merged 20 commits into from
Sep 23, 2024

Conversation

radumarias
Copy link
Contributor

@radumarias radumarias commented Sep 7, 2024

Description

Integrate coset, having with MaybeTagged wrapper for CoseSign1 and CoseMac0 and Prepared* structs to build them. Also migrate to ciborium using serde integration.

Changes

  • Integrate coset crate.
  • Create module cose where we have sign1 and mac0 modules with their implementations.
  • MaybeTagged and wrap Cose objects in in.
  • PreparedCoseSign1 and PreparedCoseMac0 used to construct COSE objects.
  • Use iana::Algorithm.
  • Add CoseMac0 to DeviceAuth
  • Migrate to ciborium
  • Integrate CWT
  • Tests and docs.

Reviewers, please pay special attention to…

  • The way CoseSign1 and CoseMac0 is created and used along side with MaybeTagged.
  • Signature and tagging flow.
  • Serialization as tagged or not.
  • Proc macros

Reviewers, please pay special attention to…

  • The way CoseSign1 and CoseMac0 are created and used along side to MaybeTagged.
  • Serialization as tagged or not.
  • Signature and tagging flow.

Tested

Tested locally, running all tests.

Built with these targets:

aarch64-linux-android
armv7-linux-androideabi
i686-linux-android
wasm32-unknown-unknown
wasm32-wasi
x86_64-unknown-linux-gnu
i686-unknown-linux-gnu
x86_64-unknown-linux-musl
x86_64-pc-windows-gnu
i686-pc-windows-gnu
x86_64-apple-darwin
aarch64-apple-darwin

Checklist

  •  Integrate CoseSign1
  •  Expose verify method
  •  Integrate COSEMac0
  • Add COSEMac0 to DeviceAuth
  •  Integrate CWT
  • Migrate to ciborium
  • Add tests
  • Add docs

Copy link

@timothee-haudebourg timothee-haudebourg left a comment

Choose a reason for hiding this comment

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

Everything looks good to me except the CBOR Value type you introduced.

src/cbor.rs Outdated Show resolved Hide resolved
src/cbor.rs Outdated Show resolved Hide resolved
src/cbor.rs Outdated Show resolved Hide resolved
src/cose/serialized_as_cbor_value.rs Outdated Show resolved Hide resolved
Copy link

@timothee-haudebourg timothee-haudebourg left a comment

Choose a reason for hiding this comment

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

I'm still not convinced you need to define this wrapper around ciborium::Value, it seems to me you could use ciborium::Value directly. Maybe I missed an instance where it is necessary?

src/definitions/device_engagement/nfc_options.rs Outdated Show resolved Hide resolved
…s primitives

- Use actions-rs to setup Rust in CI so it works with act also locally
- Add CborValueKey as wrapper over ciborium::Value to impl Ord and PartialOrd to be used as Key in Map
…s primitives

- Use actions-rs to setup Rust in CI so it works with act also locally
- Add CborValueKey as wrapper over ciborium::Value to impl Ord and PartialOrd to be used as Key in Map
Copy link

@timothee-haudebourg timothee-haudebourg left a comment

Choose a reason for hiding this comment

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

This looks almost ready to be merged. My last issue will be with the roundtrip to Vec<u8> you make to serialize/deserialize values. You can use the functions provided by the ciborium library.

src/cbor.rs Outdated Show resolved Hide resolved
src/cbor.rs Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
macros/src/to_cbor.rs Outdated Show resolved Hide resolved
src/cbor.rs Outdated Show resolved Hide resolved
src/cbor.rs Outdated Show resolved Hide resolved
src/cose/mac0.rs Show resolved Hide resolved
src/definitions/device_engagement.rs Outdated Show resolved Hide resolved
src/definitions/device_engagement.rs Outdated Show resolved Hide resolved
src/definitions/device_key/cose_key.rs Outdated Show resolved Hide resolved
src/definitions/session.rs Show resolved Hide resolved
src/definitions/validity_info.rs Show resolved Hide resolved
radumarias and others added 3 commits September 18, 2024 16:49
…other changes

- use dtolnay/rust-toolchain@stable to setup Rus when running in act
- use Into where possible
Copy link
Contributor

@cobward cobward left a comment

Choose a reason for hiding this comment

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

One final change needed, otherwise looks good to me.

macros/src/to_cbor.rs Outdated Show resolved Hide resolved
@cobward cobward merged commit 72d8f61 into main Sep 23, 2024
1 check passed
@cobward cobward deleted the coset branch September 23, 2024 10:05
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.

3 participants