|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
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. | |
Declaration of CBOR CODEC wrappers and interfaces.
| #define UsefulBuf_FROM_BSL_Data | ( | obj | ) | ((UsefulBuf) { (obj).ptr, (obj).len }) |
| #define UsefulBufC_FROM_BSL_Data | ( | obj | ) | ((UsefulBufC) { (obj).ptr, (obj).len }) |
| typedef int(* BSL_CBOR_Decode_f) (QCBORDecodeContext *dec, const void *obj) |
Callback to actually perform the decoding.
| enc | Non-null pointer to the decoder to use. |
| obj | Pointer to the user data to decode into. |
| typedef int(* BSL_CBOR_Encode_f) (QCBOREncodeContext *enc, const void *obj) |
Callback to actually perform the encoding.
| enc | Non-null pointer to the encoder to use. |
| obj | Pointer to the user data to encode. |
| 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.
| int BSL_CBOR_Decode | ( | const BSL_Data_t * | buf, |
| BSL_CBOR_Decode_f | func, | ||
| const void * | obj | ||
| ) |
Perform size- and error-checked encoding.
| [in] | buf | The populated buffer to read from. |
| func | The decoding function which takes the user data. | |
| obj | Pointer to the user data to encode. |
References ASSERT_ARG_NONNULL, BSL_ERR_DECODING, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, BSL_Data_t::len, BSL_Data_t::ptr, and UsefulBufC_FROM_BSL_Data.
Referenced by BSL_API_QuerySecurity(), BSL_ExecAnyVerifierAcceptor_Pre(), BSLX_CoseMsg_Headers_CheckCrit(), BSLX_CoseSc_Encrypt0_VerifyAccept(), BSLX_CoseSc_Encrypt_VerifyAccept(), BSLX_CoseSc_GetAndValidateAadScope(), BSLX_CoseSc_GetAndValidateAddlHeaders(), BSLX_CoseSc_GetOptions(), BSLX_CoseSc_Mac0_VerifyAccept(), BSLX_CoseSc_Mac_VerifyAccept(), LLVMFuzzerTestOneInput(), mock_bpa_ctr_decode(), mock_bpa_key_registry_init_cosekey(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example6_BCB_Source(), TEST_CASE(), test_CCSDS_Example_Mac_Source(), and TestASBDecodeEncodeClosure().
| int BSL_CBOR_Encode_GetSize | ( | size_t * | needlen, |
| BSL_CBOR_Encode_f | func, | ||
| const void * | obj | ||
| ) |
Perform one-pass encoded size inspection.
| [out] | needlen | Pointer to the size output. |
| func | The encoding function which takes the user data. | |
| obj | Pointer to the user data to encode. |
References ASSERT_ARG_NONNULL, BSL_ERR_ENCODING, BSL_LOG_DEBUG, BSL_LOG_ERR, and BSL_SUCCESS.
Referenced by bsl_mock_encode_eid().
| int BSL_CBOR_Encode_Twopass | ( | BSL_Data_t * | buf, |
| BSL_CBOR_Encode_f | func, | ||
| const void * | obj | ||
| ) |
Perform two-pass size-fitted encoding.
| [out] | buf | The already-initialized buffer to resize and write into. |
| func | The encoding function which takes the user data. | |
| obj | Pointer to the user data to encode. |
References ASSERT_ARG_NONNULL, BSL_Data_Resize(), BSL_ERR_ENCODING, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_PLAINTEXT_PTR, BSL_SUCCESS, BSL_Data_t::len, BSL_Data_t::ptr, and UsefulBuf_FROM_BSL_Data.
Referenced by bsl_mock_encode_eid(), BSLP_PolicyOptions_SC3(), BSLX_CoseMsg_Headers_DerivePhdr(), BSLX_CoseSc_AddAadScope(), BSLX_CoseSc_Encrypt0_Source(), BSLX_CoseSc_Encrypt_Source(), BSLX_CoseSc_ExternalAad_Chunked(), BSLX_CoseSc_HkdfContentKey(), BSLX_CoseSc_Mac0_Source(), BSLX_CoseSc_Mac_Source(), Encode_ASB(), LLVMFuzzerTestOneInput(), mock_bpa_ctr_encode(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_bsl_mock_encode_bundle(), test_bsl_mock_encode_canonical(), test_bsl_mock_encode_primary(), test_CCSDS_Example_Mac_Source(), test_CCSDS_Example_Mac_VerifyAccept(), and TestASBDecodeEncodeClosure().
| 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.
Matches BSL_CBOR_Encode_f signature.
References BSL_Data_Deinit(), BSL_Data_Init(), BSL_ERR_ENCODING, BSL_HostEID_EncodeToCBOR(), BSL_LOG_ERR, BSL_SUCCESS, and UsefulBufC_FROM_BSL_Data.
Referenced by BSL_AbsSecBlock_Encode(), bsl_mock_encode_primary(), BSLX_CoseSc_KdfContext_Encode(), and test_bsl_loopback_eid().