You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: README.md
+19-14Lines changed: 19 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
[](https://github.com/fxamacker/cbor/releases)
2
2
3
3
# 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.
__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.
13
13
14
14
__Why this CBOR library?__ It doesn't crash and it has well-balanced qualities: small, fast, reliable and easy.
15
15
@@ -32,7 +32,7 @@ Version 1.x has:
32
32
33
33
*__Stable API__ – won't make breaking API changes.
34
34
*__Stable requirements__ – will always support Go v1.12.
*__Passed fuzzing__ – v1.3.3 passed 250+ million execs in coverage-guided fuzzing.
36
36
37
37
Each commit passes hundreds of unit tests. Each release also passes fuzz tests. See [Fuzzing and Code Coverage](#fuzzing-and-code-coverage).
38
38
@@ -42,11 +42,11 @@ Recent activity:
42
42
*[x][Release v1.3](https://github.com/fxamacker/cbor/releases) -- faster encoding and decoding.
43
43
*[x][Release v1.3](https://github.com/fxamacker/cbor/releases) -- add struct to/from CBOR array (`toarray` struct tag) for more compact data.
44
44
*[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.
47
47
48
48
## 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.
50
50
51
51
This library is designed to be:
52
52
@@ -65,15 +65,19 @@ All releases prioritize reliability to avoid crashes on decoding malformed CBOR
65
65
66
66
## Comparisons
67
67
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.
69
69
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.
71
71
72
-

__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.

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.
The resource intensive `codec.CborHandle` initialization (in the other library) was placed outside the benchmark loop to make sure their library wasn't penalized.
79
83
@@ -84,6 +88,7 @@ Additional comparisons may be added here from time to time.
84
88
## Features
85
89
86
90
* Idiomatic API like `encoding/json`.
91
+
* Support 3 encoding modes: default (unsorted), Canonical, CTAP2Canonical
87
92
* Support "cbor" and "json" keys in Go's struct tags. If both are specified, then "cbor" is used.
88
93
* Encode using smallest CBOR integer sizes for more compact data serialization.
89
94
* Decode slices, maps, and structs in-place.
@@ -98,7 +103,7 @@ Additional comparisons may be added here from time to time.
98
103
* v1.2 -- User-defined types can have custom CBOR encoding and decoding by implementing `cbor.Marshaler` and `cbor.Unmarshaler` interfaces.
99
104
* v1.3 -- add struct to/from CBOR array (`toarray` struct tag) for more compact data
100
105
* 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.
102
107
103
108
## Fuzzing and Code Coverage
104
109
@@ -129,10 +134,10 @@ Encoding has 3 modes:
129
134
130
135
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.
131
136
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).
133
138
134
139
## 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)).
0 commit comments