Giter VIP home page Giter VIP logo

coset's Introduction

COSET

Docs CI Status codecov

This crate holds a set of Rust types for working with CBOR Object Signing and Encryption (COSE) objects, as defined in RFC 8152. It builds on the core CBOR parsing functionality from the ciborium crate.

See crate docs, or the signature example for documentation on how to use the code.

This repo is under construction and so details of the API and the code may change without warning.

Features

The std feature of the crate enables an implementation of std::error::Error for CoseError.

no_std Support

This crate supports no_std (when the std feature is not set, which is the default), but uses the alloc crate.

Minimum Supported Rust Version

MSRV is 1.56 (the main ciborium dependency is edition="2021")

Integer Ranges

CBOR supports integers in the range:

[-18_446_744_073_709_551_616, -1] ∪ [0, 18_446_744_073_709_551_615]

which is [-264, -1] ∪ [0, 264 - 1].

This does not map onto a single Rust integer type, so different CBOR crates take different approaches.

  • The serde_cbor crate uses a single i128 integer type for all integer values, which means that all CBOR integer values can be expressed, but there are also i128 values that cannot be encoded in CBOR. This also means that data size is larger.
  • The ciborium also uses a single i128 integer type internally, but wraps it in its own Integer type and only implements TryFrom (not From) for i128 / u128 conversions so that unrepresentable numbers can be rejected.
  • The sk-cbor crate uses distinct types:
    • positive numbers as u64, covering [0, 264 - 1]
    • negative numbers as i64, covering [-263, -1] (which means that some theoretically-valid large negative values are not represented).

This crate uses a single type to encompass both positive and negative values, but uses i64 for that type to keep data sizes smaller. This means that:

  • positive numbers in i64 cover [0, 263 - 1]
  • negative numbers in i64 cover [-263, -1]

and so there are large values – both positive and negative – which are not supported by this crate.

Working on the Code

Local coding conventions are enforced by the continuous integration jobs and include:

  • Build cleanly and pass all tests.
  • Free of Clippy warnings.
  • Formatted with rustfmt using the local rustfmt.toml settings.
  • Compliance with local conventions:
    • All TODO markers should be of form TODO(#99) and refer to an open GitHub issue.
    • Calls to functions that can panic (panic!, unwrap, expect) should have a comment on the same line in the form // safe: reason (or /* safe: reason */) to document the reason why panicking is acceptable.

Disclaimer

This is not an officially supported Google product.

coset's People

Contributors

alanstokes avatar ciphergoth avatar daviddrysdale avatar dependabot[bot] avatar falko17 avatar scouten-adobe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.