Skip to content

Commit

Permalink
Add CWT support (#9)
Browse files Browse the repository at this point in the history
* Scaffold initial CWT support

* Add initial serialization test from RFC 8392

* Add support for some registered claims and update test

* Update signing test to reflect RFC 8392 example

* Reorganize, rename, cleanup files

* Rename IANAClaim -> Claim

* Implement claims using traits

* Add support for fractional date strings

* Add deserialization tests

* Add define_claim macro to reduce boilerplate

* Add tests for other key types and roundtrip serialization

* Rename Key -> Label (adhere to rfc8152 and rest of repo)

* Add more detailed failure message in signing test

* Implement custom error for CWT

* Make ClaimsSet's inner BTreeMap actually private

* Apply suggestions from code review

Co-authored-by: Jacob <[email protected]>

* Address PR feedback: add units to NumericDate

* Revert "Rename Key -> Label (adhere to rfc8152 and rest of repo)"

This reverts commit 61c8e16.

* Re-add permissive ClaimsSet insert and retrieval functions

* Make macro private

* Remove roundtrip test

* Add and update docstrings for public functions

Update ClaimsSet docstrings

* Add remove_* methods for claims

* Reorganize files into one cwt module

* Add claims_set convenience setter+getter to CoseSign and builder

* Fix *_claim to return a claim struct

* Small fix to claims_set return type (to Option<Result> to match style

* First pass at to-from NumericDate helpers

* Implements date conversion using mul_to_int

* Add .DSSTORE to .gitignore

* Remove serde errors except for bytes and numericDate

* Remove commented out line

* Revert "Small fix to claims_set return type (to Option<Result> to match style"

This reverts commit 167db3b.

* Change return types from Option<Result> to Result<Option>

* Shorten claims_set return

* Implement TryFrom<Value> for NumericDate

* Add docstring + nits

* Reduce boilerplate in claims serialization

---------

Co-authored-by: Jacob <[email protected]>
  • Loading branch information
eelanagaraj and cobward authored Feb 6, 2024
1 parent 377c99b commit 4423492
Show file tree
Hide file tree
Showing 6 changed files with 743 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
.DS_Store
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ p384 = ["dep:p384"]

[dependencies]
async-signature = { version = "0.3.0", optional = true }
fmul-to-int = "1.0.0"
p256 = { version = "0.13.0", optional = true }
p384 = { version = "0.13.0", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11.9"
serde_cbor = { version = "0.11.2", features = ["tags"] }
signature = "2.0"
time = "0.3.32"
thiserror = "1.0"

[dev-dependencies]
Expand Down
Loading

0 comments on commit 4423492

Please sign in to comment.