Skip to content

Commit ab563e3

Browse files
x448fxamacker
authored andcommitted
Update README for fxamacker/cbor v1.3.3 (#65)
Also update and simplify CBOR speed and size comparison charts. Mention CBOR safety (resource exhaustion attacks.) Fuzzing is at 267+ million execs and will continue running until 1+ billion execs or v2.0 is released, whichever is sooner. Closes #64
1 parent bb1c06a commit ab563e3

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[![CBOR Library in Go/Golang](https://user-images.githubusercontent.com/57072051/69258148-c874b580-0b81-11ea-982d-e44b21f3a0fe.png)](https://github.com/fxamacker/cbor/releases)
22

33
# CBOR library in Go
4-
This library encodes and decodes CBOR. It's been fuzz tested since v0.1 and fast since v1.3.
4+
This library is a generic CBOR encoder and decoder. It's been fuzz tested since v0.1 and fast since v1.3.
55

66
[![Build Status](https://travis-ci.com/fxamacker/cbor.svg?branch=master)](https://travis-ci.com/fxamacker/cbor)
77
[![codecov](https://codecov.io/gh/fxamacker/cbor/branch/master/graph/badge.svg?v=4)](https://codecov.io/gh/fxamacker/cbor)
88
[![Go Report Card](https://goreportcard.com/badge/github.com/fxamacker/cbor)](https://goreportcard.com/report/github.com/fxamacker/cbor)
99
[![Release](https://img.shields.io/github/release/fxamacker/cbor.svg?style=flat-square)](https://github.com/fxamacker/cbor/releases)
1010
[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/fxamacker/cbor/master/LICENSE)
1111

12-
__What is CBOR__? [CBOR](CBOR.md) ([RFC 7049](https://tools.ietf.org/html/rfc7049)) is a binary data format inspired by JSON and MessagePack. CBOR is used in [IETF](https://www.ietf.org) Internet Standards such as COSE ([RFC 8152](https://tools.ietf.org/html/rfc8152)) and CWT ([RFC 8392 CBOR Web Token](https://tools.ietf.org/html/rfc8392)). WebAuthn also uses CBOR.
12+
__What is CBOR__? [CBOR](CBOR.md) ([RFC 7049](https://tools.ietf.org/html/rfc7049)) is a binary data format inspired by JSON and MessagePack. CBOR is used in [IETF](https://www.ietf.org) Internet Standards such as COSE ([RFC 8152](https://tools.ietf.org/html/rfc8152)) and CWT ([RFC 8392 CBOR Web Token](https://tools.ietf.org/html/rfc8392)). Even WebAuthn uses CBOR.
1313

1414
__Why this CBOR library?__ It doesn't crash and it has well-balanced qualities: small, fast, reliable and easy.
1515

@@ -32,7 +32,7 @@ Version 1.x has:
3232

3333
* __Stable API__ – won't make breaking API changes.
3434
* __Stable requirements__ – will always support Go v1.12.
35-
* __Passed fuzzing__ – v1.3.2 passed 4+ billion execs in coverage-guided fuzzing.
35+
* __Passed fuzzing__ – v1.3.3 passed 250+ million execs in coverage-guided fuzzing.
3636

3737
Each commit passes hundreds of unit tests. Each release also passes fuzz tests. See [Fuzzing and Code Coverage](#fuzzing-and-code-coverage).
3838

@@ -42,11 +42,11 @@ Recent activity:
4242
* [x] [Release v1.3](https://github.com/fxamacker/cbor/releases) -- faster encoding and decoding.
4343
* [x] [Release v1.3](https://github.com/fxamacker/cbor/releases) -- add struct to/from CBOR array (`toarray` struct tag) for more compact data.
4444
* [x] [Release v1.3](https://github.com/fxamacker/cbor/releases) -- add struct to/from CBOR map with int keys (`keyasint` struct tag). Simplifies using COSE, etc.
45-
* [x] [Release v1.3.2](https://github.com/fxamacker/cbor/releases) -- (latest) prevent potential problems by adding checks after well-formedness.
46-
* [ ] [Milestone v1.4](https://github.com/fxamacker/cbor/milestone/3) -- 🎈 add support for CBOR tags (major type 6.)
45+
* [x] [Release v1.3.3](https://github.com/fxamacker/cbor/releases) -- (latest) prevent potential problems by adding validation checks and unit tests.
46+
* [ ] [Milestone v2.0](https://github.com/fxamacker/cbor/milestone/3) -- (in progress) add support for CBOR tags (major type 6) and more encoding modes.
4747

4848
## Design Goals
49-
This CBOR library was created for my [WebAuthn (FIDO2) server library](https://github.com/fxamacker/webauthn), because existing CBOR libraries didn't meet certain criteria. This library became a good fit for many other projects.
49+
This library is designed to be a generic CBOR encoder and decoder. It was initially created for my [WebAuthn (FIDO2) server library](https://github.com/fxamacker/webauthn), because existing CBOR libraries (in Go) didn't meet certain criteria in 2019.
5050

5151
This library is designed to be:
5252

@@ -65,15 +65,19 @@ All releases prioritize reliability to avoid crashes on decoding malformed CBOR
6565

6666
## Comparisons
6767

68-
Program size and speed comparisons are between this new library and the most popular codec. This library prioritizes reliability so the speed comparison was a nice surprise.
68+
Safety, program size, and speed comparisons are between this newer library and the most popular library. The other library is a feature-rich codec for multiple data formats and had over 1,000 stars on github before this library was created.
6969

70-
__This library makes compiled programs smaller__. Programs like senmlCat can be 4 MB smaller by switching to this library. Programs using more complex CBOR data types can be 9.2 MB smaller.
70+
__This library is safer__. Tiny malicious CBOR messages have a harder time succeeding in resource exhaustion attacks.
7171

72-
![alt text](https://user-images.githubusercontent.com/57072051/69993581-b98eeb00-1511-11ea-98da-46d14ad0fdd0.png "CBOR library and program size comparison chart")
72+
![alt text](https://user-images.githubusercontent.com/57072051/70479896-f889e700-1aa3-11ea-8135-c51cfb8508e2.png "CBOR library safety comparison")
7373

74-
__This library is faster__ for encoding and decoding CBOR Web Token (CWT claims). WebAuthn has more impressive speed advantages but its CBOR data (on servers) is used during registration (not login). So CWT speed matters more.
74+
__This library is smaller__. Programs like senmlCat can be 4 MB smaller by switching to this library. Programs using more complex CBOR data types can be 9.2 MB smaller.
7575

76-
![alt text](https://user-images.githubusercontent.com/57072051/69992105-9c0c5200-150e-11ea-9888-9c50a0f41de2.png "CBOR library speed comparison chart")
76+
![alt text](https://user-images.githubusercontent.com/57072051/70470674-316c9080-1a91-11ea-930f-3d221ced0973.png "CBOR library and program size comparison chart")
77+
78+
__This library is faster__ for encoding and decoding CBOR Web Token (CWT claims). However, speed is only one factor and it can vary depending on data types and sizes.
79+
80+
![alt text](https://user-images.githubusercontent.com/57072051/70470717-4812e780-1a91-11ea-964d-be82996d90b3.png "CBOR library speed comparison chart")
7781

7882
The resource intensive `codec.CborHandle` initialization (in the other library) was placed outside the benchmark loop to make sure their library wasn't penalized.
7983

@@ -84,6 +88,7 @@ Additional comparisons may be added here from time to time.
8488
## Features
8589

8690
* Idiomatic API like `encoding/json`.
91+
* Support 3 encoding modes: default (unsorted), Canonical, CTAP2Canonical
8792
* Support "cbor" and "json" keys in Go's struct tags. If both are specified, then "cbor" is used.
8893
* Encode using smallest CBOR integer sizes for more compact data serialization.
8994
* Decode slices, maps, and structs in-place.
@@ -98,7 +103,7 @@ Additional comparisons may be added here from time to time.
98103
* v1.2 -- User-defined types can have custom CBOR encoding and decoding by implementing `cbor.Marshaler` and `cbor.Unmarshaler` interfaces.
99104
* v1.3 -- add struct to/from CBOR array (`toarray` struct tag) for more compact data
100105
* v1.3 -- add struct to/from CBOR map with int keys (`keyasint` struct tag). Simplifies using COSE, etc.
101-
* [Milestone v1.4](https://github.com/fxamacker/cbor/milestone/3) -- 🎈 add support for CBOR tags (major type 6.)
106+
* [Milestone v2.0](https://github.com/fxamacker/cbor/milestone/3) -- add support for CBOR tags (major type 6) and more encoding modes.
102107

103108
## Fuzzing and Code Coverage
104109

@@ -129,10 +134,10 @@ Encoding has 3 modes:
129134

130135
CTAP2 Canonical CBOR encoding is used by [CTAP](https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html) and [WebAuthn](https://www.w3.org/TR/webauthn/) in [FIDO2](https://fidoalliance.org/fido2/) framework.
131136

132-
All three encoding modes in this library use smallest form of CBOR integer that preserves data. A new encoding mode will be added to do the same for floating point numbers in [milestone v1.4](https://github.com/fxamacker/cbor/milestone/3).
137+
All three encoding modes in this library use smallest form of CBOR integer that preserves data. A new encoding mode will be added to do the same for floating point numbers in [milestone v2.0](https://github.com/fxamacker/cbor/milestone/3).
133138

134139
## Limitations
135-
🎈 CBOR tags (type 6) is being added in the next release ([milestone v1.4](https://github.com/fxamacker/cbor/milestone/3)).
140+
🎈 CBOR tags (type 6) is being added in the next release ([milestone v2.0](https://github.com/fxamacker/cbor/milestone/3)).
136141

137142
Current limitations:
138143

0 commit comments

Comments
 (0)