|
BSL v1.0.0 - 16.g9d98179
AMMOS Bundle Protocol Security Library (BSL)
|
Managed memory interface using only C99 types and functions. More...
#include <stdbool.h>#include <stdint.h>#include <stddef.h>
Include dependency graph for Data.h:
This graph shows which files directly or indirectly include this file:Data Structures | |
| struct | BSL_Data_t |
| Optional heap data storage and views. More... | |
Macros | |
| #define | BSL_DATA_INIT_NULL |
| Static initializer for a data store. | |
Typedefs | |
| typedef uint8_t * | BSL_DataPtr_t |
| Data pointer for BSL_Data_t. | |
| typedef const uint8_t * | BSL_DataConstPtr_t |
| Pointer to constant data for BSL_Data_t. | |
Functions | |
| int | BSL_Data_Init (BSL_Data_t *data) |
| Initialize an empty data struct. | |
| int | BSL_Data_InitBuffer (BSL_Data_t *data, size_t bytelen) |
| Initialize with an owned buffer of size bytelen. | |
| int | BSL_Data_InitView (BSL_Data_t *data, size_t len, BSL_DataPtr_t src) |
| Initialize a data struct as an overlay on optional external data. | |
| void | BSL_Data_InitMove (BSL_Data_t *data, BSL_Data_t *src) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| int | BSL_Data_Deinit (BSL_Data_t *data) |
| De-initialize a data struct, freeing if necessary. | |
| int | BSL_Data_Resize (BSL_Data_t *data, size_t len) |
| Resize the data, copying if necessary. | |
| int | BSL_Data_CopyFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
| Set an initialized data struct to a given size. | |
| int | BSL_Data_AppendFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
| Append an initialized data struct with a given size. | |
Managed memory interface using only C99 types and functions.
| #define BSL_DATA_INIT_NULL |
Static initializer for a data store.
| typedef const uint8_t* BSL_DataConstPtr_t |
Pointer to constant data for BSL_Data_t.
| typedef uint8_t* BSL_DataPtr_t |
Data pointer for BSL_Data_t.
| int BSL_Data_AppendFrom | ( | BSL_Data_t * | data, |
| size_t | len, | ||
| BSL_DataConstPtr_t | src | ||
| ) |
Append an initialized data struct with a given size.
| [in,out] | data | The data to copy into, which must not be NULL. |
| [in] | len | The total length to allocate, which may be non-zero. |
| [in] | src | An optional source buffer to copy from, from which len bytes will be copied. |
References BSL_Data_Resize(), BSL_LOG_ERR, BSL_SUCCESS, CHK_ARG_EXPR, CHK_ARG_NONNULL, BSL_Data_t::len, and BSL_Data_t::ptr.
Referenced by BSL_Crypto_UnwrapKey(), BSL_Crypto_WrapKey(), and MockBPA_Agent_Exec().
| int BSL_Data_CopyFrom | ( | BSL_Data_t * | data, |
| size_t | len, | ||
| BSL_DataConstPtr_t | src | ||
| ) |
Set an initialized data struct to a given size.
| [in,out] | data | The data to copy into, which must not be NULL. |
| [in] | len | The total length to allocate, which may be non-zero. |
| [in] | src | An optional source buffer to copy from, from which len bytes will be copied. |
References bsl_data_int_reset(), BSL_Data_Resize(), BSL_LOG_ERR, BSL_SUCCESS, CHK_ARG_NONNULL, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_Crypto_AddRegistryKey(), BSL_Crypto_WrapKey(), bsl_mock_decode_eid(), and TEST_CASE().
| int BSL_Data_Deinit | ( | BSL_Data_t * | data | ) |
De-initialize a data struct, freeing if necessary.
| [in,out] | data | The data to de-initialize, which must not be NULL. |
References bsl_data_int_free(), BSL_SUCCESS, and CHK_ARG_NONNULL.
Referenced by BSL_AbsSecBlock_DecodeFromCBOR(), BSL_AbsSecBlock_EncodeToCBOR(), BSL_API_QuerySecurity(), BSL_CryptoKey_Deinit(), BSL_ExecBCBAcceptor(), BSL_ExecBIBAccept(), bsl_mock_decode_eid_from_ctx(), bsl_mock_eid_deinit(), bsl_mock_encode_eid_from_ctx(), BSL_PrimaryBlock_deinit(), BSL_SecOutcome_Deinit(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_ComputeAAD(), BSLX_BCB_Decrypt(), BSLX_BCB_Deinit(), BSLX_BIB_Deinit(), BSLX_BIB_Execute(), BSLX_BIB_GenIPPT(), Encode_ASB(), LLVMFuzzerTestOneInput(), mock_bpa_ctr_deinit(), MockBPA_Bundle_Deinit(), printencoded(), test_bsl_loopback_bundle(), test_bsl_loopback_eid(), test_bsl_mock_encode_canonical(), test_BSL_TestUtils_DecodeBase16_valid(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), test_DecodeBase16(), test_qcbor_decode_only_head(), test_qcbor_decode_with_head(), test_qcbor_decode_without_head(), test_sec_accept_keyunwrap(), test_sec_source_keywrap(), and TestASBDecodeEncodeClosure().
| int BSL_Data_Init | ( | BSL_Data_t * | data | ) |
Initialize an empty data struct.
| [in,out] | data | The data to initialize, which must not be NULL. |
References bsl_data_int_reset(), BSL_SUCCESS, and CHK_ARG_NONNULL.
Referenced by BSL_Crypto_AddRegistryKey(), BSL_Crypto_WrapKey(), BSL_CryptoKey_Init(), bsl_mock_decode_eid(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), Encode_ASB(), LLVMFuzzerTestOneInput(), mock_bpa_ctr_init(), setUp(), test_bsl_loopback_bundle(), test_bsl_loopback_eid(), test_bsl_mock_encode_canonical(), test_BSL_TestUtils_DecodeBase16_valid(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), test_DecodeBase16(), test_qcbor_decode_only_head(), test_qcbor_decode_with_head(), test_qcbor_decode_without_head(), test_sec_accept_keyunwrap(), and test_sec_source_keywrap().
| int BSL_Data_InitBuffer | ( | BSL_Data_t * | data, |
| size_t | bytelen | ||
| ) |
Initialize with an owned buffer of size bytelen.
| [in,out] | data | The data to initialize. |
| [in] | bytelen | Length of buffer to allocate. |
References bsl_data_int_reset(), BSL_malloc(), BSL_SUCCESS, CHK_ARG_EXPR, CHK_ARG_NONNULL, CHK_POSTCONDITION, BSL_Data_t::len, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_AbsSecBlock_EncodeToCBOR(), BSL_API_QuerySecurity(), BSL_Crypto_GenKey(), BSL_ExecBCBAcceptor(), BSL_ExecBIBAccept(), bsl_mock_decode_primary(), bsl_mock_encode_eid_from_ctx(), BSL_SecOutcome_Init(), BSLX_BCB_ComputeAAD(), BSLX_BCB_Encrypt(), BSLX_BCB_Init(), BSLX_BIB_Execute(), BSLX_BIB_GenHMAC(), BSLX_BIB_GenIPPT(), Encode_ASB(), TEST_CASE(), and TestASBDecodeEncodeClosure().
| void BSL_Data_InitMove | ( | BSL_Data_t * | data, |
| BSL_Data_t * | src | ||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References ASSERT_ARG_NONNULL, and bsl_data_int_reset().
Referenced by mock_bpa_ctr_init_move().
| int BSL_Data_InitView | ( | BSL_Data_t * | data, |
| size_t | len, | ||
| BSL_DataPtr_t | src | ||
| ) |
Initialize a data struct as an overlay on optional external data.
| [in,out] | data | The data to initialize, which must not be NULL. |
| [in] | len | The total length to allocate, which may be zero. |
| [in] | src | An optional source buffer to point to. |
References BSL_SUCCESS, CHK_ARG_NONNULL, BSL_Data_t::len, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_AbsSecBlock_DecodeFromCBOR(), bsl_mock_decode_eid_from_ctx(), BSL_SecParam_GetAsBytestr(), BSL_SecResult_GetAsBytestr(), BSLX_BCB_Decrypt(), BSLX_BCB_GetParams(), BSLX_BIB_InitFromSecOper(), LLVMFuzzerTestOneInput(), MockBPA_GetBundleMetadata(), printencoded(), test_BSL_TestUtils_DecodeBase16_valid(), and TestASBDecodeEncodeClosure().
| int BSL_Data_Resize | ( | BSL_Data_t * | data, |
| size_t | len | ||
| ) |
Resize the data, copying if necessary.
| [in,out] | data | The data to resize, which must not be NULL. |
| [in] | len | The new total size. |
References bsl_data_int_free(), bsl_data_int_reset(), BSL_ERR_INSUFFICIENT_SPACE, BSL_LOG_ERR, BSL_realloc(), BSL_SUCCESS, CHK_ARG_NONNULL, BSL_Data_t::len, BSL_Data_t::owned, BSL_Data_t::ptr, and UNLIKELY.
Referenced by BSL_Crypto_UnwrapKey(), BSL_Data_AppendFrom(), BSL_Data_CopyFrom(), BSL_TestUtils_DecodeBase16(), BSLX_BCB_ComputeAAD(), LLVMFuzzerTestOneInput(), M_ALGO_DEF(), test_bsl_loopback_bundle(), and test_bsl_loopback_eid().