BSL v0.0.0 - 0.geda3e66
AMMOS Bundle Protocol Security Library (BSL)
|
Concrete implementation of the Abstract Security Block defined in RFC 9172. More...
#include <qcbor/qcbor_encode.h>
#include <qcbor/qcbor_spiffy_decode.h>
#include <BPSecLib_Private.h>
#include "AbsSecBlock.h"
Functions | |
size_t | BSL_AbsSecBlock_Sizeof (void) |
Returns the size of the ::BSL_AbsSecBlock_t struct in bytes. | |
bool | BSL_AbsSecBlock_IsConsistent (const BSL_AbsSecBlock_t *self) |
Checks internal consistency and sanity of this structure. | |
void | BSL_AbsSecBlock_Print (const BSL_AbsSecBlock_t *self) |
Prints to LOG INFO. | |
void | BSL_AbsSecBlock_InitEmpty (BSL_AbsSecBlock_t *self) |
Initialize a pre-allocated ASB with no contents. | |
void | BSL_AbsSecBlock_Init (BSL_AbsSecBlock_t *self, int64_t sec_context_id, BSL_HostEID_t source_eid) |
Populate a pre-allocated Abstract Security Block. | |
void | BSL_AbsSecBlock_Deinit (BSL_AbsSecBlock_t *self) |
Deinitializes and clears this ASB, clearing and releasing any owned memory. | |
bool | BSL_AbsSecBlock_IsEmpty (const BSL_AbsSecBlock_t *self) |
Returns true if this ASB contains nothing (i.e., no targets, params and results) | |
bool | BSL_AbsSecBlock_ContainsTarget (const BSL_AbsSecBlock_t *self, uint64_t target_block_num) |
Returns true if a given ASB contains the given block number as a security target. | |
void | BSL_AbsSecBlock_AddTarget (BSL_AbsSecBlock_t *self, uint64_t target_block_id) |
Adds a given block ID as a security target covered by this ASB. | |
void | BSL_AbsSecBlock_AddParam (BSL_AbsSecBlock_t *self, const BSL_SecParam_t *param) |
Add a security parameter to this security block (does NOT copy) | |
void | BSL_AbsSecBlock_AddResult (BSL_AbsSecBlock_t *self, const BSL_SecResult_t *result) |
Add a security result to this security block (does NOT copy) | |
static size_t | BSL_AbsSecBlock_GetResultCnt (const BSL_AbsSecBlock_t *self, uint64_t target_block_id) |
int | BSL_AbsSecBlock_StripResults (BSL_AbsSecBlock_t *self, uint64_t target_block_num) |
Remove security parameters and results found in outcome from this ASB. | |
ssize_t | BSL_AbsSecBlock_EncodeToCBOR (const BSL_AbsSecBlock_t *self, UsefulBuf buf) |
Encodes this ASB into a CBOR string into the space pre-allocated indicated by the argument. | |
int | BSL_AbsSecBlock_DecodeFromCBOR (BSL_AbsSecBlock_t *self, const BSL_Data_t *encoded_cbor) |
Decodes and populates this ASB from a CBOR string. | |
Concrete implementation of the Abstract Security Block defined in RFC 9172.
void BSL_AbsSecBlock_AddParam | ( | BSL_AbsSecBlock_t * | self, |
const BSL_SecParam_t * | param | ||
) |
Add a security parameter to this security block (does NOT copy)
[in,out] | self | This security block |
[in] | param | Non-Null Security parameter pointer to add to list |
References BSL_AbsSecBlock_IsConsistent().
void BSL_AbsSecBlock_AddResult | ( | BSL_AbsSecBlock_t * | self, |
const BSL_SecResult_t * | result | ||
) |
Add a security result to this security block (does NOT copy)
[in,out] | self | This security block |
[in] | result | Non-Null Security result pointer to add to list |
References BSL_AbsSecBlock_IsConsistent().
void BSL_AbsSecBlock_AddTarget | ( | BSL_AbsSecBlock_t * | self, |
uint64_t | target_block_id | ||
) |
Adds a given block ID as a security target covered by this ASB.
[in,out] | self | This ASB. |
[in] | target_block_id | ID of a block, 0 indicates primary block as usual. |
References BSL_AbsSecBlock_IsConsistent().
bool BSL_AbsSecBlock_ContainsTarget | ( | const BSL_AbsSecBlock_t * | self, |
uint64_t | target_block_num | ||
) |
Returns true if a given ASB contains the given block number as a security target.
[in,out] | self | This ASB. |
[in] | target_block_num | ID of a block, 0 indicates primary block |
References BSL_AbsSecBlock_IsConsistent().
Referenced by BSL_API_QuerySecurity().
int BSL_AbsSecBlock_DecodeFromCBOR | ( | BSL_AbsSecBlock_t * | self, |
const BSL_Data_t * | encoded_cbor | ||
) |
Decodes and populates this ASB from a CBOR string.
[in,out] | self | This allocated, but uninitialized ASB to populate. |
[in] | encoded_cbor | A buffer containing a CBOR string representing the ASB |
References BSL_AbsSecBlock_InitEmpty(), BSL_AbsSecBlock_IsConsistent(), BSL_Data_InitView(), BSL_ERR_DECODING, BSL_HostEID_DecodeFromCBOR(), BSL_HostEID_Init(), BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_WARNING, BSL_SecParam_InitBytestr(), BSL_SecParam_InitInt64(), BSL_SecResult_Init(), BSL_SUCCESS, BSL_Data_t::len, BSL_Data_t::owned, and BSL_Data_t::ptr.
Referenced by BSL_API_QuerySecurity().
void BSL_AbsSecBlock_Deinit | ( | BSL_AbsSecBlock_t * | self | ) |
Deinitializes and clears this ASB, clearing and releasing any owned memory.
[in,out] | self | This ASB |
References BSL_AbsSecBlock_IsConsistent(), and BSL_HostEID_Deinit().
Referenced by BSL_API_QuerySecurity().
ssize_t BSL_AbsSecBlock_EncodeToCBOR | ( | const BSL_AbsSecBlock_t * | self, |
UsefulBuf | buf | ||
) |
Encodes this ASB into a CBOR string into the space pre-allocated indicated by the argument.
[in] | self | This ASB. |
[in] | buf | A buffer with allocated space for the encoded CBOR or the SizeCalculateUsefulBuf value to get the real size. |
References BSL_AbsSecBlock_IsConsistent(), BSL_ERR_ENCODING, BSL_HostEID_EncodeToCBOR(), BSL_LOG_ERR, BSL_LOG_INFO, BSL_SecParam_GetAsBytestr(), BSL_SecParam_GetAsUInt64(), BSL_SecParam_IsInt64(), BSL_Data_t::len, and BSL_Data_t::ptr.
void BSL_AbsSecBlock_Init | ( | BSL_AbsSecBlock_t * | self, |
int64_t | sec_context_id, | ||
BSL_HostEID_t | source_eid | ||
) |
Populate a pre-allocated Abstract Security Block.
[in,out] | self | This ASB |
[in] | sec_context_id | Security Context ID |
[in] | source_eid | Source EID in format native to host BPA. |
References BSL_AbsSecBlock_IsConsistent().
void BSL_AbsSecBlock_InitEmpty | ( | BSL_AbsSecBlock_t * | self | ) |
Initialize a pre-allocated ASB with no contents.
[in,out] | self | This ASB |
Referenced by BSL_AbsSecBlock_DecodeFromCBOR().
bool BSL_AbsSecBlock_IsConsistent | ( | const BSL_AbsSecBlock_t * | self | ) |
Checks internal consistency and sanity of this structure.
[in] | self | This ASB |
Referenced by BSL_AbsSecBlock_AddParam(), BSL_AbsSecBlock_AddResult(), BSL_AbsSecBlock_AddTarget(), BSL_AbsSecBlock_ContainsTarget(), BSL_AbsSecBlock_DecodeFromCBOR(), BSL_AbsSecBlock_Deinit(), BSL_AbsSecBlock_EncodeToCBOR(), BSL_AbsSecBlock_Init(), BSL_AbsSecBlock_StripResults(), and BSL_SecOutcome_IsInAbsSecBlock().
bool BSL_AbsSecBlock_IsEmpty | ( | const BSL_AbsSecBlock_t * | self | ) |
Returns true if this ASB contains nothing (i.e., no targets, params and results)
[in] | self | This ASB. |
void BSL_AbsSecBlock_Print | ( | const BSL_AbsSecBlock_t * | self | ) |
Prints to LOG INFO.
[in] | self | This ASB |
References BSL_Log_DumpAsHexString(), and BSL_LOG_INFO.
size_t BSL_AbsSecBlock_Sizeof | ( | void | ) |
Returns the size of the ::BSL_AbsSecBlock_t struct in bytes.
Referenced by BSL_API_QuerySecurity().
int BSL_AbsSecBlock_StripResults | ( | BSL_AbsSecBlock_t * | self, |
uint64_t | target_block_num | ||
) |
Remove security parameters and results found in outcome
from this ASB.
[in,out] | self | This ASB |
[in] | outcome | Security Operation outcome containing params and results |
References BSL_AbsSecBlock_IsConsistent(), BSL_ERR_PROPERTY_CHECK_FAILED, and BSL_LOG_ERR.