1*2e6f5bf1SYuichi Sugiyama 2*2e6f5bf1SYuichi Sugiyama 3*2e6f5bf1SYuichi Sugiyama**QCBOR** is a powerful, commercial-quality CBOR encoder-decoder that 4*2e6f5bf1SYuichi Sugiyamaimplements these RFCs: 5*2e6f5bf1SYuichi Sugiyama 6*2e6f5bf1SYuichi Sugiyama* [RFC8949](https://tools.ietf.org/html/rfc8949) The CBOR Standard. (Nearly everything 7*2e6f5bf1SYuichi Sugiyamaexcept sorting of encoded maps) 8*2e6f5bf1SYuichi Sugiyama* [RFC7049](https://tools.ietf.org/html/rfc7049) The previous CBOR standard. 9*2e6f5bf1SYuichi SugiyamaReplaced by RFC 8949. 10*2e6f5bf1SYuichi Sugiyama* [RFC8742](https://tools.ietf.org/html/rfc8742) CBOR Sequences 11*2e6f5bf1SYuichi Sugiyama* [RFC8943](https://tools.ietf.org/html/rfc8943) CBOR Dates 12*2e6f5bf1SYuichi Sugiyama 13*2e6f5bf1SYuichi Sugiyama## QCBOR Characteristics 14*2e6f5bf1SYuichi Sugiyama 15*2e6f5bf1SYuichi Sugiyama**Implemented in C with minimal dependency** – Dependent only 16*2e6f5bf1SYuichi Sugiyama on C99, <stdint.h>, <stddef.h>, <stdbool.h> and <string.h> making 17*2e6f5bf1SYuichi Sugiyama it highly portable. <math.h> and <fenv.h> are used too, but their 18*2e6f5bf1SYuichi Sugiyama use can disabled. No #ifdefs or compiler options need to be set for 19*2e6f5bf1SYuichi Sugiyama QCBOR to run correctly. 20*2e6f5bf1SYuichi Sugiyama 21*2e6f5bf1SYuichi Sugiyama**Focused on C / native data representation** – Careful conversion of 22*2e6f5bf1SYuichi Sugiyama CBOR data types in to C data types, handling over and 23*2e6f5bf1SYuichi Sugiyama underflow, strict typing and such so the caller doesn't have to 24*2e6f5bf1SYuichi Sugiyama worry so much about this and so code using QCBOR passes static 25*2e6f5bf1SYuichi Sugiyama analyzers easier. Simpler code because there is no support for 26*2e6f5bf1SYuichi Sugiyama encoding/decoding to/from JSON, pretty printing, diagnostic 27*2e6f5bf1SYuichi Sugiyama notation... Only encoding from native C representations and decoding 28*2e6f5bf1SYuichi Sugiyama to native C representations is supported. 29*2e6f5bf1SYuichi Sugiyama 30*2e6f5bf1SYuichi Sugiyama**Small simple memory model** – Malloc is not needed. The encode 31*2e6f5bf1SYuichi Sugiyama context is 176 bytes, decode context is 312 bytes and the 32*2e6f5bf1SYuichi Sugiyama description of decoded data item is 56 bytes. Stack use is light and 33*2e6f5bf1SYuichi Sugiyama there is no recursion. The caller supplies the memory to hold the 34*2e6f5bf1SYuichi Sugiyama encoded CBOR and encode/decode contexts so caller has full control 35*2e6f5bf1SYuichi Sugiyama of memory usage making it good for embedded implementations that 36*2e6f5bf1SYuichi Sugiyama have to run in small fixed memory. 37*2e6f5bf1SYuichi Sugiyama 38*2e6f5bf1SYuichi Sugiyama**Easy decoding of maps** – The "spiffy decode" functions allow 39*2e6f5bf1SYuichi Sugiyama fetching map items directly by label. Detection of duplicate map 40*2e6f5bf1SYuichi Sugiyama items is automatically performed. This makes decoding of complex 41*2e6f5bf1SYuichi Sugiyama protocols much simpler, say when compared to TinyCBOR. 42*2e6f5bf1SYuichi Sugiyama 43*2e6f5bf1SYuichi Sugiyama**Supports most of RFC 8949** – With some size limits, all data types 44*2e6f5bf1SYuichi Sugiyama and formats in the specification are supported. Map sorting is main 45*2e6f5bf1SYuichi Sugiyama CBOR feature that is not supported. The same decoding API supports 46*2e6f5bf1SYuichi Sugiyama both definite and indefinite-length map and array decoding. Decoding 47*2e6f5bf1SYuichi Sugiyama indefinite length strings is supported but requires a string 48*2e6f5bf1SYuichi Sugiyama allocator be set up. Encoding of indefinite length strings is 49*2e6f5bf1SYuichi Sugiyama planned, but not yet supported. 50*2e6f5bf1SYuichi Sugiyama 51*2e6f5bf1SYuichi Sugiyama**Extensible and general** – Provides a way to handle data types that 52*2e6f5bf1SYuichi Sugiyama are not directly supported. 53*2e6f5bf1SYuichi Sugiyama 54*2e6f5bf1SYuichi Sugiyama**Secure coding style** – Uses a construct called UsefulBuf as a 55*2e6f5bf1SYuichi Sugiyama discipline for very safe coding and handling of binary data. 56*2e6f5bf1SYuichi Sugiyama 57*2e6f5bf1SYuichi Sugiyama**Small code size** – In the smallest configuration the object 58*2e6f5bf1SYuichi Sugiyama code is less than 4KB on 64-bit x86 CPUs. The design is such that 59*2e6f5bf1SYuichi Sugiyama object code for QCBOR APIs not used is not referenced. 60*2e6f5bf1SYuichi Sugiyama 61*2e6f5bf1SYuichi Sugiyama**Clear documented public interface** – The public interface is 62*2e6f5bf1SYuichi Sugiyama separated from the implementation. It can be put to use without 63*2e6f5bf1SYuichi Sugiyama reading the source. 64*2e6f5bf1SYuichi Sugiyama 65*2e6f5bf1SYuichi Sugiyama**Comprehensive test suite** – Easy to verify on a new platform or OS 66*2e6f5bf1SYuichi Sugiyama with the test suite. The test suite dependencies are minimal and the 67*2e6f5bf1SYuichi Sugiyama same as the library's. 68*2e6f5bf1SYuichi Sugiyama 69*2e6f5bf1SYuichi Sugiyama## Spiffy Decode 70*2e6f5bf1SYuichi Sugiyama 71*2e6f5bf1SYuichi SugiyamaThese are functions to decode particular data types. They are an 72*2e6f5bf1SYuichi Sugiyamaalternative to and built on top of QCBORDecode_GetNext(). They do type 73*2e6f5bf1SYuichi Sugiyamachecking and in some cases sophisticated type conversion. 74*2e6f5bf1SYuichi Sugiyama 75*2e6f5bf1SYuichi SugiyamaSpiffy decode supports easier map and array decoding. A map can be 76*2e6f5bf1SYuichi Sugiyamadescended into with QCBORDecode_EnterMap(). When a map has been 77*2e6f5bf1SYuichi Sugiyamaentered, members can be retrieved by label. Detection of duplicate 78*2e6f5bf1SYuichi Sugiyamamap labels, an error, is automatically performed. 79*2e6f5bf1SYuichi Sugiyama 80*2e6f5bf1SYuichi SugiyamaAn internal error state is maintained. This simplifies the decode 81*2e6f5bf1SYuichi Sugiyamaimplementation as an error check is only needed at the end of the 82*2e6f5bf1SYuichi Sugiyamadecode, rather than on every function. 83*2e6f5bf1SYuichi Sugiyama 84*2e6f5bf1SYuichi SugiyamaAn outcome is that decoding implementations are simple and involve 85*2e6f5bf1SYuichi Sugiyamamany fewer lines of code. They also tend to parallel the encoding 86*2e6f5bf1SYuichi Sugiyamaimplementations as seen in the following example. 87*2e6f5bf1SYuichi Sugiyama 88*2e6f5bf1SYuichi Sugiyama /* Encode */ 89*2e6f5bf1SYuichi Sugiyama QCBOREncode_Init(&EncodeCtx, Buffer); 90*2e6f5bf1SYuichi Sugiyama QCBOREncode_OpenMap(&EncodeCtx); 91*2e6f5bf1SYuichi Sugiyama QCBOREncode_AddTextToMap(&EncodeCtx, "Manufacturer", pE->Manufacturer); 92*2e6f5bf1SYuichi Sugiyama QCBOREncode_AddInt64ToMap(&EncodeCtx, "Displacement", pE->uDisplacement); 93*2e6f5bf1SYuichi Sugiyama QCBOREncode_AddInt64ToMap(&EncodeCtx, "Horsepower", pE->uHorsePower); 94*2e6f5bf1SYuichi Sugiyama QCBOREncode_CloseMap(&EncodeCtx); 95*2e6f5bf1SYuichi Sugiyama uErr = QCBOREncode_Finish(&EncodeCtx, &EncodedEngine); 96*2e6f5bf1SYuichi Sugiyama 97*2e6f5bf1SYuichi Sugiyama /* Decode */ 98*2e6f5bf1SYuichi Sugiyama QCBORDecode_Init(&DecodeCtx, EncodedEngine, QCBOR_DECODE_MODE_NORMAL); 99*2e6f5bf1SYuichi Sugiyama QCBORDecode_EnterMap(&DecodeCtx); 100*2e6f5bf1SYuichi Sugiyama QCBORDecode_GetTextStringInMapSZ(&DecodeCtx, "Manufacturer", &(pE->Manufacturer)); 101*2e6f5bf1SYuichi Sugiyama QCBORDecode_GetInt64InMapSZ(&DecodeCtx, "Displacement", &(pE->uDisplacement)); 102*2e6f5bf1SYuichi Sugiyama QCBORDecode_GetInt64InMapSZ(&DecodeCtx, "Horsepower", &(pE->uHorsePower)); 103*2e6f5bf1SYuichi Sugiyama QCBORDecode_ExitMap(&DecodeCtx); 104*2e6f5bf1SYuichi Sugiyama uErr = QCBORDecode_Finish(&DecodeCtx); 105*2e6f5bf1SYuichi Sugiyama 106*2e6f5bf1SYuichi SugiyamaThe spiffy decode functions will handle definite and indefinite length 107*2e6f5bf1SYuichi Sugiyamamaps and arrays without the caller having to do anything. This 108*2e6f5bf1SYuichi Sugiyamaincludes mixed definite and indefinte maps and arrays. (Some work 109*2e6f5bf1SYuichi Sugiyamaremains to support map searching with indefinite length strings.) 110*2e6f5bf1SYuichi Sugiyama 111*2e6f5bf1SYuichi Sugiyama## Comparison to TinyCBOR 112*2e6f5bf1SYuichi Sugiyama 113*2e6f5bf1SYuichi SugiyamaTinyCBOR is a popular widely used implementation. Like QCBOR, 114*2e6f5bf1SYuichi Sugiyamait is a solid, well-maintained commercial quality implementation. This 115*2e6f5bf1SYuichi Sugiyamasection is for folks trying to understand the difference in 116*2e6f5bf1SYuichi Sugiyamathe approach between QCBOR and TinyCBOR. 117*2e6f5bf1SYuichi Sugiyama 118*2e6f5bf1SYuichi SugiyamaTinyCBOR's API is more minimalist and closer to the CBOR 119*2e6f5bf1SYuichi Sugiyamaencoding mechanics than QCBOR's. QCBOR's API is at a somewhat higher 120*2e6f5bf1SYuichi Sugiyamalevel of abstraction. 121*2e6f5bf1SYuichi Sugiyama 122*2e6f5bf1SYuichi SugiyamaQCBOR really does implement just about everything described in 123*2e6f5bf1SYuichi SugiyamaRFC 8949. The main part missing is sorting of maps when encoding. 124*2e6f5bf1SYuichi SugiyamaTinyCBOR implements a smaller part of the standard. 125*2e6f5bf1SYuichi Sugiyama 126*2e6f5bf1SYuichi SugiyamaNo detailed code size comparison has been made, but in a spot check 127*2e6f5bf1SYuichi Sugiyamathat encodes and decodes a single integer shows QCBOR about 25% 128*2e6f5bf1SYuichi Sugiyamalarger. QCBOR encoding is actually smaller, but QCBOR decoding is 129*2e6f5bf1SYuichi Sugiyamalarger. This includes the code to call the library, which is about the 130*2e6f5bf1SYuichi Sugiyamasame for both libraries, and the code linked from the libraries. QCBOR 131*2e6f5bf1SYuichi Sugiyamais a bit more powerful, so you get value for the extra code brought 132*2e6f5bf1SYuichi Sugiyamain, especially when decoding more complex protocols. 133*2e6f5bf1SYuichi Sugiyama 134*2e6f5bf1SYuichi SugiyamaQCBOR tracks encoding and decoding errors internally so the caller 135*2e6f5bf1SYuichi Sugiyamadoesn't have to check the return code of every call to an encode or 136*2e6f5bf1SYuichi Sugiyamadecode function. In many cases the error check is only needed as the 137*2e6f5bf1SYuichi Sugiyamalast step or an encode or decode. TinyCBOR requires an error check on 138*2e6f5bf1SYuichi Sugiyamaeach call. 139*2e6f5bf1SYuichi Sugiyama 140*2e6f5bf1SYuichi SugiyamaQCBOR provides a substantial feature that allows searching for data 141*2e6f5bf1SYuichi Sugiyamaitems in a map by label. It works for integer and text string labels 142*2e6f5bf1SYuichi Sugiyama(and at some point byte-string labels). This includes detection of 143*2e6f5bf1SYuichi Sugiyamaitems with duplicate labels. This makes the code for decoding CBOR 144*2e6f5bf1SYuichi Sugiyamasimpler, similar to the encoding code and easier to read. TinyCBOR 145*2e6f5bf1SYuichi Sugiyamasupports search by string, but no integer, nor duplicate detection. 146*2e6f5bf1SYuichi Sugiyama 147*2e6f5bf1SYuichi SugiyamaQCBOR provides explicit support many of the registered CBOR tags. For 148*2e6f5bf1SYuichi Sugiyamaexample, QCBOR supports big numbers and decimal fractions including 149*2e6f5bf1SYuichi Sugiyamatheir conversion to floats, uint64_t and such. 150*2e6f5bf1SYuichi Sugiyama 151*2e6f5bf1SYuichi SugiyamaGenerally, QCBOR supports safe conversion of most CBOR number formats 152*2e6f5bf1SYuichi Sugiyamainto number formats supported in C. For example, a data item can be 153*2e6f5bf1SYuichi Sugiyamafetched and converted to a C uint64_t whether the input CBOR is an 154*2e6f5bf1SYuichi Sugiyamaunsigned 64-bit integer, signed 64-bit integer, floating-point number, 155*2e6f5bf1SYuichi Sugiyamabig number, decimal fraction or a big float. The conversion is 156*2e6f5bf1SYuichi Sugiyamaperformed with full proper error detection of overflow and underflow. 157*2e6f5bf1SYuichi Sugiyama 158*2e6f5bf1SYuichi SugiyamaQCBOR has a special feature for decoding byte-string wrapped CBOR. It 159*2e6f5bf1SYuichi Sugiyamatreats this similar to entering an array with one item. This is 160*2e6f5bf1SYuichi Sugiyamaparticularly use for CBOR protocols like COSE that make use of 161*2e6f5bf1SYuichi Sugiyamabyte-string wrapping. The implementation of these protocols is 162*2e6f5bf1SYuichi Sugiyamasimpler and uses less memory. 163*2e6f5bf1SYuichi Sugiyama 164*2e6f5bf1SYuichi SugiyamaQCBOR's test suite is written in the same portable C that QCBOR is 165*2e6f5bf1SYuichi Sugiyamawhere TinyCBOR requires Qt for its test. QCBOR's test suite is 166*2e6f5bf1SYuichi Sugiyamadesigned to be able to run on small embedded devices the same as 167*2e6f5bf1SYuichi SugiyamaQCBOR. 168*2e6f5bf1SYuichi Sugiyama 169*2e6f5bf1SYuichi Sugiyama## Code Status 170*2e6f5bf1SYuichi Sugiyama 171*2e6f5bf1SYuichi SugiyamaThe official current release is version 1.4.1 Changes over the last few 172*2e6f5bf1SYuichi Sugiyamayears have been only minor bug fixes, minor feature additions and 173*2e6f5bf1SYuichi Sugiyamadocumentation improvements. QCBOR 1.x is highly stable. 174*2e6f5bf1SYuichi Sugiyama 175*2e6f5bf1SYuichi SugiyamaWork on some larger feature additions is ongoing in "dev" branch. 176*2e6f5bf1SYuichi SugiyamaThis includes more explicit support for preferred serialization and 177*2e6f5bf1SYuichi SugiyamaCDE (CBOR Deterministic Encoding). It will eventually be release as 178*2e6f5bf1SYuichi SugiyamaQCBOR 2.x. 179*2e6f5bf1SYuichi Sugiyama 180*2e6f5bf1SYuichi SugiyamaQCBOR was originally developed by Qualcomm. It was [open sourced 181*2e6f5bf1SYuichi Sugiyamathrough CAF](https://source.codeaurora.org/quic/QCBOR/QCBOR/) with a 182*2e6f5bf1SYuichi Sugiyamapermissive Linux license, September 2018 (thanks Qualcomm!). 183*2e6f5bf1SYuichi Sugiyama 184*2e6f5bf1SYuichi Sugiyama## Building 185*2e6f5bf1SYuichi Sugiyama 186*2e6f5bf1SYuichi SugiyamaThere is a simple makefile for the UNIX style command line binary that 187*2e6f5bf1SYuichi Sugiyamacompiles everything to run the tests. CMake is also available, please read 188*2e6f5bf1SYuichi Sugiyamathe "Building with CMake" section for more information. 189*2e6f5bf1SYuichi Sugiyama 190*2e6f5bf1SYuichi SugiyamaThese eleven files, the contents of the src and inc directories, make 191*2e6f5bf1SYuichi Sugiyamaup the entire implementation. 192*2e6f5bf1SYuichi Sugiyama 193*2e6f5bf1SYuichi Sugiyama* inc 194*2e6f5bf1SYuichi Sugiyama * UsefulBuf.h 195*2e6f5bf1SYuichi Sugiyama * qcbor_private.h 196*2e6f5bf1SYuichi Sugiyama * qcbor_common.h 197*2e6f5bf1SYuichi Sugiyama * qcbor_encode.h 198*2e6f5bf1SYuichi Sugiyama * qcbor_decode.h 199*2e6f5bf1SYuichi Sugiyama * qcbor_spiffy_decode.h 200*2e6f5bf1SYuichi Sugiyama* src 201*2e6f5bf1SYuichi Sugiyama * UsefulBuf.c 202*2e6f5bf1SYuichi Sugiyama * qcbor_encode.c 203*2e6f5bf1SYuichi Sugiyama * qcbor_decode.c 204*2e6f5bf1SYuichi Sugiyama * ieee754.h 205*2e6f5bf1SYuichi Sugiyama * ieee754.c 206*2e6f5bf1SYuichi Sugiyama 207*2e6f5bf1SYuichi SugiyamaFor most use cases you should just be able to add them to your 208*2e6f5bf1SYuichi Sugiyamaproject. Hopefully the easy portability of this implementation makes 209*2e6f5bf1SYuichi Sugiyamathis work straight away, whatever your development environment is. 210*2e6f5bf1SYuichi Sugiyama 211*2e6f5bf1SYuichi SugiyamaThe test directory includes the tests that are nearly as portable as 212*2e6f5bf1SYuichi Sugiyamathe main implementation. If your development environment doesn't 213*2e6f5bf1SYuichi Sugiyamasupport UNIX style command line and make, you should be able to make a 214*2e6f5bf1SYuichi Sugiyamasimple project and add the test files to it. Then just call 215*2e6f5bf1SYuichi SugiyamaRunTests() to invoke them all. 216*2e6f5bf1SYuichi Sugiyama 217*2e6f5bf1SYuichi SugiyamaWhile this code will run fine without configuration, there are several 218*2e6f5bf1SYuichi SugiyamaC pre processor macros that can be #defined in order to: 219*2e6f5bf1SYuichi Sugiyama 220*2e6f5bf1SYuichi Sugiyama * use a more efficient implementation 221*2e6f5bf1SYuichi Sugiyama * to reduce code size 222*2e6f5bf1SYuichi Sugiyama * to improve performance (a little) 223*2e6f5bf1SYuichi Sugiyama * remove features to reduce code size 224*2e6f5bf1SYuichi Sugiyama 225*2e6f5bf1SYuichi SugiyamaSee the comment sections on "Configuration" in inc/UsefulBuf.h and 226*2e6f5bf1SYuichi Sugiyamathe pre processor defines that start with QCBOR_DISABLE_XXX. 227*2e6f5bf1SYuichi Sugiyama 228*2e6f5bf1SYuichi Sugiyama### Building with CMake 229*2e6f5bf1SYuichi Sugiyama 230*2e6f5bf1SYuichi SugiyamaCMake can also be used to build QCBOR and the test application. Having the root 231*2e6f5bf1SYuichi Sugiyama`CMakeLists.txt` file, QCBOR can be easily integrated with your project's 232*2e6f5bf1SYuichi Sugiyamaexisting CMake environment. The result of the build process is a static library, 233*2e6f5bf1SYuichi Sugiyamato build a shared library instead you must add the 234*2e6f5bf1SYuichi Sugiyama`-DBUILD_SHARED_LIBS=ON` option at the CMake configuration step. 235*2e6f5bf1SYuichi SugiyamaThe tests can be built into a simple command line application to run them as it 236*2e6f5bf1SYuichi Sugiyamawas mentioned before; or it can be built as a library to be integrated with your 237*2e6f5bf1SYuichi Sugiyamadevelopment environment. 238*2e6f5bf1SYuichi SugiyamaThe `BUILD_QCBOR_TEST` CMake option can be used for building the tests, it can 239*2e6f5bf1SYuichi Sugiyamahave three values: `APP`, `LIB` or `OFF` (default, test are not included in the 240*2e6f5bf1SYuichi Sugiyamabuild). 241*2e6f5bf1SYuichi Sugiyama 242*2e6f5bf1SYuichi SugiyamaBuilding the QCBOR library: 243*2e6f5bf1SYuichi Sugiyama 244*2e6f5bf1SYuichi Sugiyama```bash 245*2e6f5bf1SYuichi Sugiyamacd <QCBOR_base_folder> 246*2e6f5bf1SYuichi Sugiyama# Configuring the project and generating a native build system 247*2e6f5bf1SYuichi Sugiyamacmake -S . -B <build_folder> 248*2e6f5bf1SYuichi Sugiyama# Building the project 249*2e6f5bf1SYuichi Sugiyamacmake --build <build_folder> 250*2e6f5bf1SYuichi Sugiyama``` 251*2e6f5bf1SYuichi Sugiyama 252*2e6f5bf1SYuichi SugiyamaBuilding and running the QCBOR test app: 253*2e6f5bf1SYuichi Sugiyama```bash 254*2e6f5bf1SYuichi Sugiyamacd <QCBOR_base_folder> 255*2e6f5bf1SYuichi Sugiyama# Configuring the project and generating a native build system 256*2e6f5bf1SYuichi Sugiyamacmake -S . -B <build_folder> -DBUILD_QCBOR_TEST=APP 257*2e6f5bf1SYuichi Sugiyama# Building the project 258*2e6f5bf1SYuichi Sugiyamacmake --build <build_folder> 259*2e6f5bf1SYuichi Sugiyama# Running the test app 260*2e6f5bf1SYuichi Sugiyama.<build_folder>/test/qcbortest 261*2e6f5bf1SYuichi Sugiyama``` 262*2e6f5bf1SYuichi Sugiyama 263*2e6f5bf1SYuichi SugiyamaTo enable all the compiler warnings that are used in the QCBOR release process 264*2e6f5bf1SYuichi Sugiyamayou can use the `BUILD_QCBOR_WARN` option at the CMake configuration step: 265*2e6f5bf1SYuichi Sugiyama```bash 266*2e6f5bf1SYuichi Sugiyamacmake -S . -B <build_folder> -DBUILD_QCBOR_WARN=ON 267*2e6f5bf1SYuichi Sugiyama``` 268*2e6f5bf1SYuichi Sugiyama 269*2e6f5bf1SYuichi Sugiyama### Floating Point Support & Configuration 270*2e6f5bf1SYuichi Sugiyama 271*2e6f5bf1SYuichi SugiyamaBy default, all QCBOR floating-point features are enabled: 272*2e6f5bf1SYuichi Sugiyama 273*2e6f5bf1SYuichi Sugiyama* Encoding and decoding of basic float types, single and double-precision 274*2e6f5bf1SYuichi Sugiyama* Encoding and decoding of half-precision with conversion to/from single 275*2e6f5bf1SYuichi Sugiyama and double-precision 276*2e6f5bf1SYuichi Sugiyama* Preferred serialization of floating-point 277*2e6f5bf1SYuichi Sugiyama* Floating point dates 278*2e6f5bf1SYuichi Sugiyama* Methods that can convert big numbers, decimal fractions and other numbers 279*2e6f5bf1SYuichi Sugiyama to/from floating-point 280*2e6f5bf1SYuichi Sugiyama 281*2e6f5bf1SYuichi SugiyamaIf full floating-point is not needed, the following #defines can be 282*2e6f5bf1SYuichi Sugiyamaused to reduce object code size and dependency. 283*2e6f5bf1SYuichi Sugiyama 284*2e6f5bf1SYuichi SugiyamaSee discussion in qcbor_encode.h for other details. 285*2e6f5bf1SYuichi Sugiyama 286*2e6f5bf1SYuichi Sugiyama#### #define QCBOR_DISABLE_FLOAT_HW_USE 287*2e6f5bf1SYuichi Sugiyama 288*2e6f5bf1SYuichi SugiyamaThis removes dependency on: 289*2e6f5bf1SYuichi Sugiyama 290*2e6f5bf1SYuichi Sugiyama* Floating-point hardware and floating-point instructions 291*2e6f5bf1SYuichi Sugiyama* `<math.h>` and `<fenv.h>` 292*2e6f5bf1SYuichi Sugiyama* The math library (libm, -lm) 293*2e6f5bf1SYuichi Sugiyama 294*2e6f5bf1SYuichi SugiyamaFor most limited environments, this removes enough floating-point 295*2e6f5bf1SYuichi Sugiyamadependencies to be able to compile and run QCBOR. 296*2e6f5bf1SYuichi Sugiyama 297*2e6f5bf1SYuichi SugiyamaNote that this does not remove use of the types double and float from 298*2e6f5bf1SYuichi SugiyamaQCBOR, but it limits QCBOR's use of them to converting the encoded 299*2e6f5bf1SYuichi Sugiyamabyte stream to them and copying them. Converting and copying them 300*2e6f5bf1SYuichi Sugiyamausually don't require any hardware, libraries or includes. The C 301*2e6f5bf1SYuichi Sugiyamacompiler takes care of it on its own. 302*2e6f5bf1SYuichi Sugiyama 303*2e6f5bf1SYuichi SugiyamaQCBOR uses its own implementation of half-precision float-pointing 304*2e6f5bf1SYuichi Sugiyamathat doesn't depend on math libraries. It uses masks and shifts 305*2e6f5bf1SYuichi Sugiyamainstead. Thus, even with this define, half-precision encoding and 306*2e6f5bf1SYuichi Sugiyamadecoding works. 307*2e6f5bf1SYuichi Sugiyama 308*2e6f5bf1SYuichi SugiyamaWhen this is defined, the QCBOR functionality lost is minimal and only 309*2e6f5bf1SYuichi Sugiyamafor decoding: 310*2e6f5bf1SYuichi Sugiyama 311*2e6f5bf1SYuichi Sugiyama* Decoding floating-point format dates are not handled 312*2e6f5bf1SYuichi Sugiyama* There is no conversion between floats and integers when decoding. For 313*2e6f5bf1SYuichi Sugiyama example, QCBORDecode_GetUInt64ConvertAll() will be unable to convert 314*2e6f5bf1SYuichi Sugiyama to and from float-point. 315*2e6f5bf1SYuichi Sugiyama* Floats will be unconverted to double when decoding. 316*2e6f5bf1SYuichi Sugiyama 317*2e6f5bf1SYuichi SugiyamaNo interfaces are disabled or removed with this define. If input that 318*2e6f5bf1SYuichi Sugiyamarequires floating-point conversion or functions are called that 319*2e6f5bf1SYuichi Sugiyamarequest floating-point conversion, an error code like 320*2e6f5bf1SYuichi Sugiyama`QCBOR_ERR_HW_FLOAT_DISABLED` will be returned. 321*2e6f5bf1SYuichi Sugiyama 322*2e6f5bf1SYuichi SugiyamaThis saves only a small amount of object code. The primary purpose for 323*2e6f5bf1SYuichi Sugiyamadefining this is to remove dependency on floating point hardware and 324*2e6f5bf1SYuichi Sugiyamalibraries. 325*2e6f5bf1SYuichi Sugiyama 326*2e6f5bf1SYuichi Sugiyama#### #define QCBOR_DISABLE_PREFERRED_FLOAT 327*2e6f5bf1SYuichi Sugiyama 328*2e6f5bf1SYuichi SugiyamaThis eliminates support for half-precision 329*2e6f5bf1SYuichi Sugiyamaand CBOR preferred serialization by disabling 330*2e6f5bf1SYuichi SugiyamaQCBOR's shift and mask based implementation of 331*2e6f5bf1SYuichi Sugiyamahalf-precision floating-point. 332*2e6f5bf1SYuichi Sugiyama 333*2e6f5bf1SYuichi SugiyamaWith this defined, single and double-precision floating-point 334*2e6f5bf1SYuichi Sugiyamanumbers can still be encoded and decoded. Conversion 335*2e6f5bf1SYuichi Sugiyamaof floating-point to and from integers, big numbers and 336*2e6f5bf1SYuichi Sugiyamasuch is also supported. Floating-point dates are still 337*2e6f5bf1SYuichi Sugiyamasupported. 338*2e6f5bf1SYuichi Sugiyama 339*2e6f5bf1SYuichi SugiyamaThe primary reason to define this is to save object code. 340*2e6f5bf1SYuichi SugiyamaRoughly 900 bytes are saved, though about half of this 341*2e6f5bf1SYuichi Sugiyamacan be saved just by not calling any functions that 342*2e6f5bf1SYuichi Sugiyamaencode floating-point numbers. 343*2e6f5bf1SYuichi Sugiyama 344*2e6f5bf1SYuichi Sugiyama#### #define USEFULBUF_DISABLE_ALL_FLOAT 345*2e6f5bf1SYuichi Sugiyama 346*2e6f5bf1SYuichi SugiyamaThis eliminates floating point support completely (along with related function 347*2e6f5bf1SYuichi Sugiyamaheaders). This is useful if the compiler options deny the usage of floating 348*2e6f5bf1SYuichi Sugiyamapoint operations completely, and the usage soft floating point ABI is not 349*2e6f5bf1SYuichi Sugiyamapossible. 350*2e6f5bf1SYuichi Sugiyama 351*2e6f5bf1SYuichi Sugiyama#### Compiler options 352*2e6f5bf1SYuichi Sugiyama 353*2e6f5bf1SYuichi SugiyamaCompilers support a number of options that control 354*2e6f5bf1SYuichi Sugiyamawhich float-point related code is generated. For example, 355*2e6f5bf1SYuichi Sugiyamait is usually possible to give options to the compiler to avoid all 356*2e6f5bf1SYuichi Sugiyamafloating-point hardware and instructions, to use software 357*2e6f5bf1SYuichi Sugiyamaand replacement libraries instead. These are usually 358*2e6f5bf1SYuichi Sugiyamabigger and slower, but these options may still be useful 359*2e6f5bf1SYuichi Sugiyamain getting QCBOR to run in some environments in 360*2e6f5bf1SYuichi Sugiyamacombination with `QCBOR_DISABLE_FLOAT_HW_USE`. 361*2e6f5bf1SYuichi SugiyamaIn particular, `-mfloat-abi=soft`, disables use of 362*2e6f5bf1SYuichi Sugiyama hardware instructions for the float and double 363*2e6f5bf1SYuichi Sugiyama types in C for some architectures. 364*2e6f5bf1SYuichi Sugiyama 365*2e6f5bf1SYuichi Sugiyama#### CMake options 366*2e6f5bf1SYuichi Sugiyama 367*2e6f5bf1SYuichi SugiyamaIf you are using CMake, it can also be used to configure the floating-point 368*2e6f5bf1SYuichi Sugiyamasupport. These options can be enabled by adding them to the CMake configuration 369*2e6f5bf1SYuichi Sugiyamastep and setting their value to 'ON' (True). The following table shows the 370*2e6f5bf1SYuichi Sugiyamaavailable options and the associated #defines. 371*2e6f5bf1SYuichi Sugiyama 372*2e6f5bf1SYuichi Sugiyama | CMake option | #define | 373*2e6f5bf1SYuichi Sugiyama |-----------------------------------|-------------------------------| 374*2e6f5bf1SYuichi Sugiyama | QCBOR_OPT_DISABLE_FLOAT_HW_USE | QCBOR_DISABLE_FLOAT_HW_USE | 375*2e6f5bf1SYuichi Sugiyama | QCBOR_OPT_DISABLE_FLOAT_PREFERRED | QCBOR_DISABLE_PREFERRED_FLOAT | 376*2e6f5bf1SYuichi Sugiyama | QCBOR_OPT_DISABLE_FLOAT_ALL | USEFULBUF_DISABLE_ALL_FLOAT | 377*2e6f5bf1SYuichi Sugiyama 378*2e6f5bf1SYuichi Sugiyama## Code Size 379*2e6f5bf1SYuichi Sugiyama 380*2e6f5bf1SYuichi SugiyamaThese are approximate sizes on a 64-bit x86 CPU with the -Os optimization. 381*2e6f5bf1SYuichi SugiyamaAll QCBOR_DISABLE_XXX are set and compiler stack frame checking is disabled 382*2e6f5bf1SYuichi Sugiyamafor smallest but not for largest. Smallest is the library functions for a 383*2e6f5bf1SYuichi Sugiyamaprotocol with strings, integers, arrays, maps and Booleans, but not floats 384*2e6f5bf1SYuichi Sugiyamaand standard tag types. 385*2e6f5bf1SYuichi Sugiyama 386*2e6f5bf1SYuichi Sugiyama | | smallest | largest | 387*2e6f5bf1SYuichi Sugiyama |---------------|----------|---------| 388*2e6f5bf1SYuichi Sugiyama | encode only | 850 | 2200 | 389*2e6f5bf1SYuichi Sugiyama | decode only | 1550 | 13300 | 390*2e6f5bf1SYuichi Sugiyama | combined | 2500 | 15500 | 391*2e6f5bf1SYuichi Sugiyama 392*2e6f5bf1SYuichi Sugiyama From the table above, one can see that the amount of code pulled in 393*2e6f5bf1SYuichi Sugiyama from the QCBOR library varies a lot, ranging from 1KB to 15KB. The 394*2e6f5bf1SYuichi Sugiyama main factor is the number of QCBOR functions called and 395*2e6f5bf1SYuichi Sugiyama which ones they are. QCBOR minimizes internal 396*2e6f5bf1SYuichi Sugiyama interdependency so only code necessary for the called functions is 397*2e6f5bf1SYuichi Sugiyama brought in. 398*2e6f5bf1SYuichi Sugiyama 399*2e6f5bf1SYuichi Sugiyama Encoding is simpler and smaller. An encode-only implementation may 400*2e6f5bf1SYuichi Sugiyama bring in only 1KB of code. 401*2e6f5bf1SYuichi Sugiyama 402*2e6f5bf1SYuichi Sugiyama Encoding of floating-point brings in a little more code as does 403*2e6f5bf1SYuichi Sugiyama encoding of tagged types and encoding of bstr wrapping. 404*2e6f5bf1SYuichi Sugiyama 405*2e6f5bf1SYuichi Sugiyama Basic decoding using QCBORDecode_GetNext() brings in 3KB. 406*2e6f5bf1SYuichi Sugiyama 407*2e6f5bf1SYuichi Sugiyama Use of the supplied MemPool by calling QCBORDecode_SetMemPool() to 408*2e6f5bf1SYuichi Sugiyama setup to decode indefinite-length strings adds 0.5KB. 409*2e6f5bf1SYuichi Sugiyama 410*2e6f5bf1SYuichi Sugiyama Basic use of spiffy decode to brings in about 3KB. Using more spiffy 411*2e6f5bf1SYuichi Sugiyama decode functions, such as those for tagged types bstr wrapping brings 412*2e6f5bf1SYuichi Sugiyama in more code. 413*2e6f5bf1SYuichi Sugiyama 414*2e6f5bf1SYuichi Sugiyama Finally, use of all of the integer conversion functions will bring in 415*2e6f5bf1SYuichi Sugiyama about 5KB, though you can use the simpler ones like 416*2e6f5bf1SYuichi Sugiyama QCBORDecode_GetInt64() without bringing in very much code. 417*2e6f5bf1SYuichi Sugiyama 418*2e6f5bf1SYuichi Sugiyama In addition to using fewer QCBOR functions, the following are some 419*2e6f5bf1SYuichi Sugiyama ways to make the code smaller. 420*2e6f5bf1SYuichi Sugiyama 421*2e6f5bf1SYuichi Sugiyama The gcc compiler output is usually smaller than llvm because stack 422*2e6f5bf1SYuichi Sugiyama guards are off by default (be sure you actually have gcc and not llvm 423*2e6f5bf1SYuichi Sugiyama installed to be invoked by the gcc command). You can also turn off 424*2e6f5bf1SYuichi Sugiyama stack gaurds with llvm. It is safe to turn off stack gaurds with this 425*2e6f5bf1SYuichi Sugiyama code because Usefulbuf provides similar defenses and this code was 426*2e6f5bf1SYuichi Sugiyama carefully written to be defensive. 427*2e6f5bf1SYuichi Sugiyama 428*2e6f5bf1SYuichi Sugiyama If QCBOR is installed as a shared library, then of course only one 429*2e6f5bf1SYuichi Sugiyama copy of the code is in memory no matter how many applications use it. 430*2e6f5bf1SYuichi Sugiyama 431*2e6f5bf1SYuichi Sugiyama### Disabling Features 432*2e6f5bf1SYuichi Sugiyama 433*2e6f5bf1SYuichi SugiyamaHere's the list of all features that can be disabled to save object 434*2e6f5bf1SYuichi Sugiyamacode. The amount saved is an approximation. 435*2e6f5bf1SYuichi Sugiyama 436*2e6f5bf1SYuichi Sugiyama | #define | Saves | 437*2e6f5bf1SYuichi Sugiyama | ----------------------------------------| ------| 438*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_ENCODE_USAGE_GUARDS | 150 | 439*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS | 400 | 440*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS | 200 | 441*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_UNCOMMON_TAGS | 100 | 442*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_EXP_AND_MANTISSA | 400 | 443*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_PREFERRED_FLOAT | 900 | 444*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_FLOAT_HW_USE | 50 | 445*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_TAGS | 400 | 446*2e6f5bf1SYuichi Sugiyama | QCBOR_DISABLE_NON_INTEGER_LABELS | 140 | 447*2e6f5bf1SYuichi Sugiyama | USEFULBUF_DISABLE_ALL_FLOAT | 950 | 448*2e6f5bf1SYuichi Sugiyama 449*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_ENCODE_USAGE_GUARDS affects encoding only. It doesn't 450*2e6f5bf1SYuichi Sugiyamadisable any encoding features, just some error checking. Disable it 451*2e6f5bf1SYuichi Sugiyamawhen you are confident that an encoding implementation is complete and 452*2e6f5bf1SYuichi Sugiyamacorrect. 453*2e6f5bf1SYuichi Sugiyama 454*2e6f5bf1SYuichi SugiyamaIndefinite lengths are a feature of CBOR that makes encoding simpler 455*2e6f5bf1SYuichi Sugiyamaand the decoding more complex. They allow the encoder to not have to 456*2e6f5bf1SYuichi Sugiyamaknow the length of a string, map or array when they start encoding 457*2e6f5bf1SYuichi Sugiyamait. Their main use is when encoding has to be done on a very 458*2e6f5bf1SYuichi Sugiyamaconstrained device. Conversely when decoding on a very constrained 459*2e6f5bf1SYuichi Sugiyamadevice, it is good to prohibit use of indefinite lengths so the 460*2e6f5bf1SYuichi Sugiyamadecoder can be smaller. 461*2e6f5bf1SYuichi Sugiyama 462*2e6f5bf1SYuichi SugiyamaThe QCBOR decode API processes both definite and indefinite lengths 463*2e6f5bf1SYuichi Sugiyamawith the same API, except to decode indefinite-length strings a 464*2e6f5bf1SYuichi Sugiyamastorage allocator must be configured. 465*2e6f5bf1SYuichi Sugiyama 466*2e6f5bf1SYuichi SugiyamaTo reduce the size of the decoder define 467*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS particularly if you are not 468*2e6f5bf1SYuichi Sugiyamaconfiguring a storage allocator. 469*2e6f5bf1SYuichi Sugiyama 470*2e6f5bf1SYuichi SugiyamaFurther reduction can be by defining 471*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS which will result in an error 472*2e6f5bf1SYuichi Sugiyamawhen an indefinite-length map or array arrives for decoding. 473*2e6f5bf1SYuichi Sugiyama 474*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_UNCOMMON_TAGS disables the decoding of explicit tags for 475*2e6f5bf1SYuichi Sugiyamabase 64, regex, UUID and MIME data. This just disables the automatic 476*2e6f5bf1SYuichi Sugiyamarecognition of these from a major type 6 tag. 477*2e6f5bf1SYuichi Sugiyama 478*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_EXP_AND_MANTISSA disables the decoding of decimal 479*2e6f5bf1SYuichi Sugiyamafractions and big floats. 480*2e6f5bf1SYuichi Sugiyama 481*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_TAGS disables all decoding of CBOR tags. If the input has 482*2e6f5bf1SYuichi Sugiyamaa single tag, the error is unrecoverable so it is suitable only for protocols that 483*2e6f5bf1SYuichi Sugiyamahave no tags. "Borrowed" tag content formats (e.g. an epoch-based date 484*2e6f5bf1SYuichi Sugiyamawithout the tag number), can still be processed. 485*2e6f5bf1SYuichi Sugiyama 486*2e6f5bf1SYuichi SugiyamaQCBOR_DISABLE_NON_INTEGER_LABELS causes any label that doesn't 487*2e6f5bf1SYuichi Sugiyamafit in an int64_t to result in a QCBOR_ERR_MAP_LABEL_TYPE error. 488*2e6f5bf1SYuichi SugiyamaThis also disables QCBOR_DECODE_MODE_MAP_AS_ARRAY and 489*2e6f5bf1SYuichi SugiyamaQCBOR_DECODE_MODE_MAP_STRINGS_ONLY. It is fairly common for CBOR-based 490*2e6f5bf1SYuichi Sugiyamaprotocols to use only small integers as labels. 491*2e6f5bf1SYuichi Sugiyama 492*2e6f5bf1SYuichi SugiyamaSee the discussion above on floating-point. 493*2e6f5bf1SYuichi Sugiyama 494*2e6f5bf1SYuichi Sugiyama ### Size of spiffy decode 495*2e6f5bf1SYuichi Sugiyama 496*2e6f5bf1SYuichi Sugiyama When creating a decode implementation, there is a choice of whether 497*2e6f5bf1SYuichi Sugiyama or not to use spiffy decode features or to just use 498*2e6f5bf1SYuichi Sugiyama QCBORDecode_GetNext(). 499*2e6f5bf1SYuichi Sugiyama 500*2e6f5bf1SYuichi Sugiyama The implementation using spiffy decode will be simpler resulting in 501*2e6f5bf1SYuichi Sugiyama the calling code being smaller, but the amount of code brought in 502*2e6f5bf1SYuichi Sugiyama from the QCBOR library will be larger. Basic use of spiffy decode 503*2e6f5bf1SYuichi Sugiyama brings in about 2KB of object code. If object code size is not a 504*2e6f5bf1SYuichi Sugiyama concern, then it is probably better to use spiffy decode because it 505*2e6f5bf1SYuichi Sugiyama is less work, there is less complexity and less testing to worry 506*2e6f5bf1SYuichi Sugiyama about. 507*2e6f5bf1SYuichi Sugiyama 508*2e6f5bf1SYuichi Sugiyama If code size is a concern, then use of QCBORDecode_GetNext() will 509*2e6f5bf1SYuichi Sugiyama probably result in smaller overall code size for simpler CBOR 510*2e6f5bf1SYuichi Sugiyama protocols. However, if the CBOR protocol is complex then use of 511*2e6f5bf1SYuichi Sugiyama spiffy decode may reduce overall code size. An example of a complex 512*2e6f5bf1SYuichi Sugiyama protocol is one that involves decoding a lot of maps or maps that 513*2e6f5bf1SYuichi Sugiyama have many data items in them. The overall code may be smaller 514*2e6f5bf1SYuichi Sugiyama because the general purpose spiffy decode map processor is the one 515*2e6f5bf1SYuichi Sugiyama used for all the maps. 516*2e6f5bf1SYuichi Sugiyama 517*2e6f5bf1SYuichi Sugiyama 518*2e6f5bf1SYuichi Sugiyama## Other Software Using QCBOR 519*2e6f5bf1SYuichi Sugiyama 520*2e6f5bf1SYuichi Sugiyama* [t_cose](https://github.com/laurencelundblade/t_cose) implements enough of 521*2e6f5bf1SYuichi Sugiyama[COSE, RFC 8152](https://tools.ietf.org/html/rfc8152) to support 522*2e6f5bf1SYuichi Sugiyama[CBOR Web Token (CWT)](https://tools.ietf.org/html/rfc8392) and 523*2e6f5bf1SYuichi Sugiyama[Entity Attestation Token (EAT)](https://tools.ietf.org/html/draft-ietf-rats-eat-06). 524*2e6f5bf1SYuichi SugiyamaSpecifically it supports signing and verification of the COSE_Sign1 message. 525*2e6f5bf1SYuichi Sugiyama 526*2e6f5bf1SYuichi Sugiyama* [ctoken](https://github.com/laurencelundblade/ctoken) is an implementation of 527*2e6f5bf1SYuichi SugiyamaEAT and CWT. 528*2e6f5bf1SYuichi Sugiyama 529*2e6f5bf1SYuichi Sugiyama## Credits 530*2e6f5bf1SYuichi Sugiyama* Ganesh Kanike for porting to QSEE 531*2e6f5bf1SYuichi Sugiyama* Mark Bapst for sponsorship and release as open source by Qualcomm 532*2e6f5bf1SYuichi Sugiyama* Sachin Sharma for release through CAF 533*2e6f5bf1SYuichi Sugiyama* Tamas Ban for porting to TF-M and 32-bit ARM 534*2e6f5bf1SYuichi Sugiyama* Michael Eckel for Makefile improvements 535*2e6f5bf1SYuichi Sugiyama* Jan Jongboom for indefinite length encoding 536*2e6f5bf1SYuichi Sugiyama* Peter Uiterwijk for error strings and other 537*2e6f5bf1SYuichi Sugiyama* Michael Richarson for CI set up and fixing some compiler warnings 538*2e6f5bf1SYuichi Sugiyama* Máté Tóth-Pál for float-point disabling and other 539*2e6f5bf1SYuichi Sugiyama* Dave Thaler for portability to Windows 540*2e6f5bf1SYuichi Sugiyama 541*2e6f5bf1SYuichi Sugiyama## Copyright and License 542*2e6f5bf1SYuichi Sugiyama 543*2e6f5bf1SYuichi SugiyamaQCBOR is available under what is essentially the 3-Clause BSD License. 544*2e6f5bf1SYuichi Sugiyama 545*2e6f5bf1SYuichi SugiyamaFiles created inside Qualcomm and open-sourced through CAF (The Code 546*2e6f5bf1SYuichi SugiyamaAurora Forum) have a slightly modified 3-Clause BSD License. The 547*2e6f5bf1SYuichi Sugiyamamodification additionally disclaims NON-INFRINGEMENT. 548*2e6f5bf1SYuichi Sugiyama 549*2e6f5bf1SYuichi SugiyamaFiles created after release to CAF use the standard 3-Clause BSD 550*2e6f5bf1SYuichi SugiyamaLicense with no modification. These files have the SPDX license 551*2e6f5bf1SYuichi Sugiyamaidentifier, "SPDX-License-Identifier: BSD-3-Clause" in them. 552*2e6f5bf1SYuichi Sugiyama 553*2e6f5bf1SYuichi Sugiyama### BSD-3-Clause license 554*2e6f5bf1SYuichi Sugiyama 555*2e6f5bf1SYuichi Sugiyama* Redistributions of source code must retain the above copyright 556*2e6f5bf1SYuichi Sugiyamanotice, this list of conditions and the following disclaimer. 557*2e6f5bf1SYuichi Sugiyama 558*2e6f5bf1SYuichi Sugiyama* Redistributions in binary form must reproduce the above copyright 559*2e6f5bf1SYuichi Sugiyamanotice, this list of conditions and the following disclaimer in the 560*2e6f5bf1SYuichi Sugiyamadocumentation and/or other materials provided with the distribution. 561*2e6f5bf1SYuichi Sugiyama 562*2e6f5bf1SYuichi Sugiyama* Neither the name of the copyright holder nor the names of its 563*2e6f5bf1SYuichi Sugiyamacontributors may be used to endorse or promote products derived from 564*2e6f5bf1SYuichi Sugiyamathis software without specific prior written permission. 565*2e6f5bf1SYuichi Sugiyama 566*2e6f5bf1SYuichi SugiyamaTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 567*2e6f5bf1SYuichi Sugiyama"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 568*2e6f5bf1SYuichi SugiyamaLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 569*2e6f5bf1SYuichi SugiyamaA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 570*2e6f5bf1SYuichi SugiyamaHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 571*2e6f5bf1SYuichi SugiyamaSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 572*2e6f5bf1SYuichi SugiyamaLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 573*2e6f5bf1SYuichi SugiyamaDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 574*2e6f5bf1SYuichi SugiyamaTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 575*2e6f5bf1SYuichi Sugiyama(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 576*2e6f5bf1SYuichi SugiyamaOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 577*2e6f5bf1SYuichi Sugiyama 578*2e6f5bf1SYuichi Sugiyama### Copyright for this README 579*2e6f5bf1SYuichi Sugiyama 580*2e6f5bf1SYuichi SugiyamaCopyright (c) 2018-2024, Laurence Lundblade. All rights reserved. 581*2e6f5bf1SYuichi SugiyamaCopyright (c) 2021-2023, Arm Limited. All rights reserved. 582