• Home
Name Date Size #Lines LOC

..--

.github/03-May-2024-193178

examples/03-May-2024-9252

patches/03-May-2024-1612

scripts/03-May-2024-179115

src/03-May-2024-9,0197,062

.cargo_vcs_info.jsonD03-May-202494 66

.codecov.ymlD03-May-2024340 2621

.gitignoreD03-May-20248 21

.mdl-style.rbD03-May-2024763 195

.mdlrcD03-May-202447 11

.rustfmt.tomlD03-May-2024269 109

AUTHORSD03-May-2024288 77

Android.bpD03-May-2024806 3430

CHANGELOG.mdD03-May-20243.2 KiB6855

CONTRIBUTING.mdD03-May-20241.1 KiB2920

Cargo.lockD03-May-20242.6 KiB10794

Cargo.tomlD03-May-2024982 3128

Cargo.toml.origD03-May-2024507 1815

LICENSED03-May-202411.1 KiB203169

METADATAD03-May-2024359 2019

MODULE_LICENSE_APACHE2D03-May-20240

OWNERSD03-May-2024136 75

README.mdD03-May-20243.4 KiB7047

TEST_MAPPINGD03-May-2024247 1413

deny.tomlD03-May-2024717 3328

dependabot.ymlD03-May-2024276 106

README.md

1# COSET
2
3[![Docs](https://img.shields.io/badge/docs-rust-brightgreen?style=for-the-badge)](https://google.github.io/coset)
4[![CI Status](https://img.shields.io/github/workflow/status/google/coset/CI?color=blue&style=for-the-badge)](https://github.com/google/coset/actions?query=workflow%3ACI)
5[![codecov](https://img.shields.io/codecov/c/github/google/coset?style=for-the-badge)](https://codecov.io/gh/google/coset)
6
7This crate holds a set of Rust types for working with CBOR Object Signing and Encryption (COSE) objects, as defined in
8[RFC 8152](https://tools.ietf.org/html/rfc8152).  It builds on the core [CBOR](https://tools.ietf.org/html/rfc7049)
9parsing functionality from the [`ciborium` crate](https://docs.rs/ciborium).
10
11See [crate docs](https://google.github.io/coset/rust/coset/index.html), or the [signature
12example](examples/signature.rs) for documentation on how to use the code.
13
14**This repo is under construction** and so details of the API and the code may change without warning.
15
16## `no_std` Support
17
18This crate supports `no_std`, but uses the `alloc` crate.
19
20## Minimum Supported Rust Version
21
22MSRV is 1.56 (the main `ciborium` dependency is `edition="2021"`)
23
24## Integer Ranges
25
26CBOR supports integers in the range:
27
28```text
29[-18_446_744_073_709_551_616, -1] ∪ [0, 18_446_744_073_709_551_615]
30```
31
32which is [-2<sup>64</sup>, -1] ∪ [0, 2<sup>64</sup> - 1].
33
34This does not map onto a single Rust integer type, so different CBOR crates take different approaches.
35
36- The [`serde_cbor`](https://docs.rs/serde_cbor) crate uses a single `i128` integer type for all integer values, which
37  means that all CBOR integer values can be expressed, but there are also `i128` values that cannot be encoded in CBOR.
38  This also means that data size is larger.
39- The [`ciborium`](https://docs.rs/ciborium) also uses a single `i128` integer type internally, but wraps it in its own
40  [`Integer`](https://docs.rs/ciborium/latest/ciborium/value/struct.Integer.html) type and only implements `TryFrom`
41  (not `From`) for `i128` / `u128` conversions so that unrepresentable numbers can be rejected.
42- The [`sk-cbor`](https://docs.rs/sk-cbor) crate uses distinct types:
43    - positive numbers as u64, covering [0, 2<sup>64</sup> - 1]
44    - negative numbers as i64, covering [-2<sup>63</sup>, -1] (which means that some theoretically-valid large negative
45      values are not represented).
46
47This crate uses a single type to encompass both positive and negative values, but uses `i64` for that type to keep data
48sizes smaller.  This means that:
49
50- positive numbers in `i64` cover [0, 2<sup>63</sup> - 1]
51- negative numbers in `i64` cover [-2<sup>63</sup>, -1]
52
53and so there are large values &ndash; both positive and negative &ndash; which are not supported by this crate.
54
55## Working on the Code
56
57Local coding conventions are enforced by the [continuous integration jobs](.github/workflows) and include:
58
59- Build cleanly and pass all tests.
60- Free of [Clippy](https://github.com/rust-lang/rust-clippy) warnings.
61- Formatted with `rustfmt` using the local [rustfmt.toml](.rustfmt.toml) settings.
62- Compliance with local conventions:
63    - All `TODO` markers should be of form `TODO(#99)` and refer to an open GitHub issue.
64    - Calls to functions that can panic (`panic!`, `unwrap`, `expect`) should have a comment on the same line in the
65      form `// safe: reason` (or `/* safe: reason */`) to document the reason why panicking is acceptable.
66
67## Disclaimer
68
69This is not an officially supported Google product.
70