Memory reduction (#54)

* Reduce memory usage for determining encoding size.

Some devices don't have the memory to spare to use an 8K buffer to
determine the size of buffer that is needed for encoding.

* Enable limiting decoders

* Add COSE_ERR_UNSUPPORTED_COSE_TYPE

* Adapt tests for decoders not configured

* Setup to build individuals

Setup to do indivual COSE elements.  We are going to assume that if individuals build and all build then all combinations are going to build

* Pass NULL to cn_cbor_encoder_write to get the size.

* Conditional compilation based on INCLUDE_* defines

* Revert "Adapt tests for decoders not configured"

This reverts commit a66f0a7568beecec7e78275c4fa9e1bc92e328f1.

* Add missing compile checks in sign corner cases

* Fix cmake check for excluding sign0

* Fix unintentional whitespace differences
20 files changed
tree: 5abae652be29b9857e35da59ce39c3eb2927adf6
  1. cmake/
  2. dumper/
  3. src/
  4. test/
  5. .appveyor.yml
  6. .gitignore
  7. .travis.yml
  8. build.sh
  9. CMakeLists.txt
  10. Coverity_Model.c
  11. Doxyfile.in
  12. LICENSE
  13. README.md
README.md

COSE-C Implementation Build Status Coverage Status Coverity Status

This project is a C implementation of the IETF CBOR Encoded Message Syntax (COSE). There are currently two versions of the COSE document that can be read. The most current work in progress draft can be found on github in the cose-wg/cose-spec project. The IETF also keeps a copy of the spec in the COSE WG.

The project is using the CN-CBOR project to provide an implementation of the Concise Binary Object Representation or CBOR.

The project is using OpenSSL for the cryptographic primitives.

Contributing

Go ahead, file issues, make pull requests.

Building

The project is setup to build using CMake. The way that the CMake files are setup, it requires that version 3.0 or higher is used.

The project requires the use of cn-cbor(https://github.com/cabo/cn-cbor) in order to build. The CMake configuration files will automatically pull down the correct version when run.

Memory Model

The memory model used in this library is a mess. This is in large part because the memory model of cn-cbor is still poorly understood.

There are three different memory models that can be used with cn-cbor and cose-c, at this time only one of them is going to produce good results for long running systems.

The cn-cbor project was built with a specific memory model, but did not limit itself to that memory model when writing the code. It was originally designed for working on small devices that use a block allocator with sub-allocations done from that allocated block. This allows for all of the items allocated in that large block to be freed in a single operation when everything is done.

  • Build without USE_CONTEXT: This model uses standard calloc/free and suffers from the cn-cbor memory model problems.

  • Build with USE_CONTEXT and pass in NULL: This model is equivalent to the previous configuration.

  • Build with USE_CONTEXT and pass in a block allocator: This model works, but requires that you provide the allocator.