Giter Club home page Giter Club logo

libcose's Introduction

libcose

build

Libcose is a C library aiming to implement the full COSE standard. Libcose is aimed at constrained devices without dynamic memory allocation, libcose will never call malloc related calls by itself. However it does require a simple block array allocator for cbor management.

Libcose implements modern ed25519 based signatures for signing. ECDSA based signing and verification is implemented using Mbed TLS. RSA will probably be skipped.

There is online documentation available.

Dependencies:

Building

To build a shared library from libcose:

make lib

Default libcose will try to link against libsodium for the crypto. Since versions after v0.3.x libcose depends on tinycbor instead of cn-cbor.

Testing

libcose is supplied with a test suite covering most cases. Testing requires CUnit as test framework and tinycbor as additional CBOR library. Running al tests is done with:

make test

Contributing

Open an issue, PR, the usual. Builds must pass before merging. Currently Travis tests the full test suite. In addition Travis also runs clang-tidy to check for simple style and code mistakes.

Limitations

Due to time constraints, for now only signing is implemented. Contributions for encryption and authentication is of course welcome.

As libcose is aimed at constrained devices a number of configurables are compile time defined. This includes the number of headers and the number signatures that are allowed in a single signature structure.

libcose's People

Contributors

bergzand avatar chrysn avatar fjmolinas avatar kaspar030 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libcose's Issues

gh-pages out of date

Readme.md advices to check https://bergzand.github.io/libcose/ for documentation which seems out of data to me

Dependencies:

    [cn-cbor](https://github.com/cabo/cn-cbor)
    Either [TweetNaCl](https://tweetnacl.cr.yp.to/) or [libsodium](https://github.com/jedisct1/libsodium) as crypto library
    A memory block allocator (can be malloc/calloc based)

vs

Dependencies:

    [NanoCBOR](https://github.com/bergzand/NanoCBOR)
    Either [HACL-C](https://github.com/mitls/hacl-c), [libsodium](https://github.com/jedisct1/libsodium) or [mbed TLS](https://tls.mbed.org/) as crypto library

Behavior changes through tinyDTLS

The changes of eclipse/tinydtls#34 altered the output of the cryptographic reference AES-CCM operations.

I'll yet have to dig down where things go wrong exactly, but chances are libcose should just use the more modern dtls_decrypt_params API rather than the compatibility dtls_decrypt which tinydtls offers.

Missing C++ guards

Please add standard C++ guards to include files so that they are linkable from C++ code.

Finalize migration to tinycbor

With the iterative design of tinycbor, some refactoring can be done to make libcose eat a bit less memory. All of this implies a large API change.

Headers as linked list

Enables unlimited number of headers for a cose structure and demands only a minimum amount of memory when decoding.

Signers as linked list

Same as above but for signers of a sign/sign1 structure. Verification of a sign structure could be done by iterating over the signers and calling the verify function with a pointer to that specific signer.

Recipients as linked list

Same as above. Decryption in a similar way as the signer verification. It is more complex when the recipient structure is multilayered.

TODO:

  • linked list headers
  • Linked list signers
  • Linked list recipients

AEAD: Add AES-CCM

libcose looks like a good tool to get OSCORE running on RIOT, but seems to currently lack AES-CCM -- and AES-CCM-16-64-128 (COSE number 10) is the default algorithm there.

Would there be any obstacles to adding it?

mbedtls writes ECDSA signatures in ASN1

It seems (from code inspection while digging through what safe buffer sizes for signature buffers are and whether *siglen can be predetermined; I'm not at the point of using it yet) that the mbedtls ECDSA implementation uses ASN.1 encoding for signatures where COSE expects its own fixed-length encoding.

Code path:

  • cose_crypto_sign_ecdsa at src/crypt/mbedtls.c calls mbedtls_ecdsa_write_signature
  • mbedtls_ecdsa_write_signature at library/ecdsa.c calls (via mbedtls_ecdsa_write_signature_restartable) ecdsa_signature_to_asn1 into sig[*siglen]
  • ecdsa_signature_to_asn1 does ASN.1 encoding

while https://tools.ietf.org/html/rfc8152#section-8.1 says:

Using the function defined in [RFC8017], the signature is:
Signature = I2OSP(R, n) | I2OSP(S, n)
where n = ceiling(key_length / 8)

As mbedtls is the only ECDSA implementation in libcose, it wouldn't run against common test vectors. Has this been tested against any external COSE implementation yet?

Add direct KDFs

For use with OSCORE, it would be convenient to have COSE's direct key KDFs available (basically, a way to use the tables from COSE's table16).

Are there any plans to add support for that, would you accept PRs to that effect, or do you have concrete ideas on interface requirements for those?

Apache 2.0/MIT/BSD/CC Licensing

libcose is currently under the LGPL 2.1 license which unfortunately restricts use in systems that utilize static linking, such as microcontrollers. As this library is well suited for the microcontroller use case, I believe adoption would be greatly improved by moving to a less restrictive license.

For my application using the Espressif ESP32 microcontroller, my team and I are prepared to make the necessary additions to the ESP-IDF for inclusion of libcose into the upstream repo as a PR. The only hurdle is that Espressif will only accept code with an Apache 2.0 or compatible license.

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.