BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
CBOR.h File Reference

Declaration of CBOR CODEC wrappers and interfaces. More...

#include "bsl/BPSecLib_Public.h"
#include <qcbor/qcbor_encode.h>
#include <qcbor/qcbor_spiffy_decode.h>
+ Include dependency graph for CBOR.h:
+ This graph shows which files directly or indirectly include this file:

Macros

#define UsefulBuf_FROM_BSL_Data(obj)   ((UsefulBuf) { (obj).ptr, (obj).len })
 
#define UsefulBufC_FROM_BSL_Data(obj)   ((UsefulBufC) { (obj).ptr, (obj).len })
 

Typedefs

typedef int(* BSL_CBOR_Encode_f) (QCBOREncodeContext *enc, const void *obj)
 Callback to actually perform the encoding.
 
typedef int(* BSL_CBOR_Decode_f) (QCBORDecodeContext *dec, const void *obj)
 Callback to actually perform the decoding.
 

Functions

int BSL_CBOR_Encode_GetSize (size_t *needlen, BSL_CBOR_Encode_f func, const void *obj)
 Perform one-pass encoded size inspection.
 
int BSL_CBOR_Encode_Twopass (BSL_Data_t *buf, BSL_CBOR_Encode_f func, const void *obj)
 Perform two-pass size-fitted encoding.
 
int BSL_CBOR_Decode (const BSL_Data_t *buf, BSL_CBOR_Decode_f func, const void *obj)
 Perform size- and error-checked encoding.
 
int BSL_CBOR_Compare_Int64 (const int64_t *ltv, const int64_t *rtv)
 Sort integer values in CBOR canonical order per Section 4.2.1 of RFC 8949 [3].
 
int BSL_CBOR_EncodeEID (QCBOREncodeContext *enc, const BSL_HostEID_t *eid)
 Helper to encode EID values in a way that is optimized for two-pass encoder.
 

Detailed Description

Declaration of CBOR CODEC wrappers and interfaces.

Macro Definition Documentation

◆ UsefulBuf_FROM_BSL_Data

#define UsefulBuf_FROM_BSL_Data (   obj)    ((UsefulBuf) { (obj).ptr, (obj).len })

◆ UsefulBufC_FROM_BSL_Data

#define UsefulBufC_FROM_BSL_Data (   obj)    ((UsefulBufC) { (obj).ptr, (obj).len })

Typedef Documentation

◆ BSL_CBOR_Decode_f

typedef int(* BSL_CBOR_Decode_f) (QCBORDecodeContext *dec, const void *obj)

Callback to actually perform the decoding.

Parameters
encNon-null pointer to the decoder to use.
objPointer to the user data to decode into.

◆ BSL_CBOR_Encode_f

typedef int(* BSL_CBOR_Encode_f) (QCBOREncodeContext *enc, const void *obj)

Callback to actually perform the encoding.

Parameters
encNon-null pointer to the encoder to use.
objPointer to the user data to encode.
Returns
BSL_SUCCESS if successful.

Function Documentation

◆ BSL_CBOR_Compare_Int64()

int BSL_CBOR_Compare_Int64 ( const int64_t *  ltv,
const int64_t *  rtv 
)

Sort integer values in CBOR canonical order per Section 4.2.1 of RFC 8949 [3].

Matches the libc sort and M*LIB CMP signature.

References ASSERT_ARG_NONNULL.

◆ BSL_CBOR_Decode()

◆ BSL_CBOR_Encode_GetSize()

int BSL_CBOR_Encode_GetSize ( size_t *  needlen,
BSL_CBOR_Encode_f  func,
const void *  obj 
)

Perform one-pass encoded size inspection.

Parameters
[out]needlenPointer to the size output.
funcThe encoding function which takes the user data.
objPointer to the user data to encode.
Returns
BSL_SUCCESS if successful.

References ASSERT_ARG_NONNULL, BSL_ERR_ENCODING, BSL_LOG_DEBUG, BSL_LOG_ERR, and BSL_SUCCESS.

Referenced by bsl_mock_encode_eid().

◆ BSL_CBOR_Encode_Twopass()

◆ BSL_CBOR_EncodeEID()

int BSL_CBOR_EncodeEID ( QCBOREncodeContext *  enc,
const BSL_HostEID_t eid 
)