BSL v0.0.0 - 0.geda3e66
AMMOS Bundle Protocol Security Library (BSL)
|
Implementation of the data containers for handling variable-sized buffers and ownership. More...
Functions | |
static void | bsl_data_int_reset (BSL_Data_t *data) |
static void | bsl_data_int_free (BSL_Data_t *data) |
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, const 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_CopyFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
Set an initialized data struct to a given size. | |
int | BSL_Data_Resize (BSL_Data_t *data, size_t len) |
Resize the data, copying if necessary. | |
int | BSL_Data_AppendFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
Append an initialized data struct with a given size. | |
Implementation of the data containers for handling variable-sized buffers and ownership.
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, BSL_Data_t::len, and BSL_Data_t::ptr.
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_Resize(), BSL_LOG_ERR, BSL_SUCCESS, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_Crypto_AddRegistryKey(), and bsl_mock_decode_eid().
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_SUCCESS.
Referenced by bsl_mock_eid_deinit(), and BSL_SecOutcome_Deinit().
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_SUCCESS.
Referenced by BSL_Crypto_AddRegistryKey(), and bsl_mock_decode_eid().
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_MALLOC, BSL_SUCCESS, BSL_Data_t::len, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_SecOutcome_Init().
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, BSL_Data_t::len, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_AbsSecBlock_DecodeFromCBOR(), BSL_API_QuerySecurity(), and BSL_SecParam_GetAsBytestr().
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_ERR_INSUFFICIENT_SPACE, BSL_LOG_ERR, BSL_REALLOC, BSL_SUCCESS, BSL_Data_t::len, BSL_Data_t::owned, BSL_Data_t::ptr, and UNLIKELY.
Referenced by BSL_Data_AppendFrom(), and BSL_Data_CopyFrom().