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

Definition of an (id, value) pair container. More...

#include "IdValPair.h"
+ Include dependency graph for IdValPair.c:

Functions

size_t BSL_IdValPair_Sizeof (void)
 Return size of BSL_IdValPair_s struct type.
 
void BSL_IdValPair_Init (BSL_IdValPair_t *self)
 Initialize to a default empty state.
 
void BSL_IdValPair_InitSet (BSL_IdValPair_t *self, const BSL_IdValPair_t *src)
 Initialize to a copy of another value.
 
void BSL_IdValPair_Deinit (BSL_IdValPair_t *self)
 De-initialize a parameter.
 
void BSL_IdValPair_Set (BSL_IdValPair_t *self, const BSL_IdValPair_t *src)
 Overwrite with a copy of another value.
 
void BSL_IdValPair_Move (BSL_IdValPair_t *self, BSL_IdValPair_t *src)
 Move from another value.
 
void BSL_IdValPair_SetTextstr (BSL_IdValPair_t *self, int64_t param_id, const char *value)
 Initialize as a parameter containing a byte string with a null-terminated text value.
 
bool BSL_IdValPair_IsTextstr (const BSL_IdValPair_t *self)
 Returns true when the value type is a text string.
 
void BSL_IdValPair_SetBytestr (BSL_IdValPair_t *self, int64_t param_id, BSL_Data_t value)
 Initialize as a parameter containing a bytestring.
 
void BSL_IdValPair_SetInt64 (BSL_IdValPair_t *self, int64_t param_id, uint64_t value)
 Set to an signed integer value.
 
bool BSL_IdValPair_IsInt64 (const BSL_IdValPair_t *self)
 Returns true when the value type is an integer.
 
int BSL_IdValPair_GetAsInt64 (const BSL_IdValPair_t *self, int64_t *out)
 Retrieve integer value of result when this result type is integer.
 
bool BSL_IdValPair_IsBytestr (const BSL_IdValPair_t *self)
 Returns true when the value type is a byte string.
 
int BSL_IdValPair_GetAsBytestr (const BSL_IdValPair_t *self, BSL_Data_t *out)
 Retrieve byte string value of a parameter.
 
int BSL_IdValPair_GetAsTextstr (const BSL_IdValPair_t *self, const char **out)
 Retrieve bytestring value of result when security parameter type is bytestring.
 
void BSL_IdValPair_SetRaw (BSL_IdValPair_t *self, int64_t param_id, const void *ptr, size_t len)
 Initialize as a parameter containing raw encoded content.
 
bool BSL_IdValPair_IsRaw (const BSL_IdValPair_t *self)
 Returns true when the value type is raw encoded CBOR.
 
int BSL_IdValPair_GetAsRaw (const BSL_IdValPair_t *self, BSL_Data_t *out)
 Retrieve bytestring value of result when security parameter type is bytestring.
 
uint64_t BSL_IdValPair_GetId (const BSL_IdValPair_t *self)
 Get parameter ID of this param.
 
bool BSL_IdValPair_IsConsistent (const BSL_IdValPair_t *self)
 Return true if invariant conditions pass.
 
int BSL_IdValPair_Decode (QCBORDecodeContext *dec, BSL_IdValPair_t *pair)
 Decode from CBOR, as a pair of items either in an array or from a map key-value.
 
void BSL_IdValPair_Encode (QCBOREncodeContext *enc, const BSL_IdValPair_t *pair)
 Encode to CBOR, as a pair of items either in an array or a map key-value.
 

Detailed Description

Definition of an (id, value) pair container.

Function Documentation

◆ BSL_IdValPair_Decode()

int BSL_IdValPair_Decode ( QCBORDecodeContext *  dec,
BSL_IdValPair_t *  pair 
)

◆ BSL_IdValPair_Deinit()

◆ BSL_IdValPair_Encode()

void BSL_IdValPair_Encode ( QCBOREncodeContext *  enc,
const BSL_IdValPair_t *  pair 
)

◆ BSL_IdValPair_GetAsBytestr()

◆ BSL_IdValPair_GetAsInt64()

int BSL_IdValPair_GetAsInt64 ( const BSL_IdValPair_t *  self,
int64_t *  out 
)

Retrieve integer value of result when this result type is integer.

Parameters
[in]selfThis Security Parameter
[out]outThe optional value
Returns
Zero if the value is an integer.

References BSL_CHKRET, BSL_ERR_NOT_FOUND, BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_INT64, BSL_SUCCESS, and CHK_PRECONDITION.

Referenced by BSL_IdValPair_Encode(), BSLX_BCB_Execute(), BSLX_BCB_GetOptions(), BSLX_BIB_Execute(), BSLX_BIB_InitFromSecOper(), BSLX_CoseSc_GetAndValidateKey(), BSLX_CoseSc_GetAndValidateTarget(), and BSLX_CoseSc_GetOptions().

◆ BSL_IdValPair_GetAsRaw()

int BSL_IdValPair_GetAsRaw ( const BSL_IdValPair_t *  self,
BSL_Data_t out 
)

Retrieve bytestring value of result when security parameter type is bytestring.

Parameters
[in]selfThis Security Parameter
[out]outPointer to optional struct which will be made a view onto this parameter value. That view must not outlive this pair instance.
Returns
Negative on error.

References BSL_CHKRET, BSL_Data_InitView(), BSL_ERR_NOT_FOUND, BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_RAW, BSL_SUCCESS, and CHK_PRECONDITION.

Referenced by BSL_IdValPair_Encode(), BSLX_CoseMsg_Headers_CheckCrit(), BSLX_CoseSc_GetAndValidateAadScope(), and BSLX_CoseSc_GetOptions().

◆ BSL_IdValPair_GetAsTextstr()

int BSL_IdValPair_GetAsTextstr ( const BSL_IdValPair_t *  self,
const char **  out 
)

Retrieve bytestring value of result when security parameter type is bytestring.

Parameters
[in]selfThis Security Parameter
[in,out]outPointer to optional string pointer for view onto this parameter value. That view must not outlive this pair instance.
Returns
Negative on error.

References BSL_CHKRET, BSL_ERR_NOT_FOUND, BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_TEXTSTR, BSL_SUCCESS, and CHK_PRECONDITION.

Referenced by BSL_IdValPair_Print(), BSLX_BCB_GetOptions(), and BSLX_BIB_InitFromSecOper().

◆ BSL_IdValPair_GetId()

uint64_t BSL_IdValPair_GetId ( const BSL_IdValPair_t *  self)

◆ BSL_IdValPair_Init()

◆ BSL_IdValPair_InitSet()

void BSL_IdValPair_InitSet ( BSL_IdValPair_t *  self,
const BSL_IdValPair_t *  src 
)

Initialize to a copy of another value.

Parameters
[out]selfThe object to initialize.
[in]srcThe source of the copy.

References BSL_IdValPair_Init(), and BSL_IdValPair_Set().

◆ BSL_IdValPair_IsBytestr()

bool BSL_IdValPair_IsBytestr ( const BSL_IdValPair_t *  self)

Returns true when the value type is a byte string.

Parameters
[in]selfThis Security Parameter
Returns
True when value type is byte string.

References BSL_IDVALPAIR_TYPE_BYTESTR, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_Encode(), BSL_IdValPair_Print(), BSLX_BIB_Execute(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example6_BCB_Source(), and test_CCSDS_Example_Mac_Source().

◆ BSL_IdValPair_IsConsistent()

bool BSL_IdValPair_IsConsistent ( const BSL_IdValPair_t *  self)

Return true if invariant conditions pass.

Parameters
[in]selfThis security parameter
Returns
true if valid, false otherwise.

References BSL_IDVALPAIR_TYPE_RAW, BSL_IDVALPAIR_TYPE_UNKNOWN, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_GetAsBytestr(), BSL_IdValPair_GetAsInt64(), BSL_IdValPair_GetAsRaw(), BSL_IdValPair_GetAsTextstr(), BSL_IdValPair_GetId(), BSL_SecOper_AppendOption(), and BSL_SecOper_AppendParam().

◆ BSL_IdValPair_IsInt64()

bool BSL_IdValPair_IsInt64 ( const BSL_IdValPair_t *  self)

Returns true when the value type is an integer.

Parameters
[in]selfThis Security Parameter
Returns
True when value type is integer.

References BSL_IDVALPAIR_TYPE_INT64, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_Encode(), and BSL_IdValPair_Print().

◆ BSL_IdValPair_IsRaw()

bool BSL_IdValPair_IsRaw ( const BSL_IdValPair_t *  self)

Returns true when the value type is raw encoded CBOR.

Parameters
[in]selfThis Security Parameter
Returns
True when value type is raw.

References BSL_IDVALPAIR_TYPE_RAW, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_Encode().

◆ BSL_IdValPair_IsTextstr()

bool BSL_IdValPair_IsTextstr ( const BSL_IdValPair_t *  self)

Returns true when the value type is a text string.

Parameters
[in]selfThis Security Parameter
Returns
True when value type is text string.

References BSL_IDVALPAIR_TYPE_TEXTSTR, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_Print().

◆ BSL_IdValPair_Move()

void BSL_IdValPair_Move ( BSL_IdValPair_t *  self,
BSL_IdValPair_t *  src 
)

Move from another value.

The other value is left deinitialized.

Parameters
[in,out]selfThe object to overwrite.
[in]srcThe source of the copy.

References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), BSL_IDVALPAIR_TYPE_BYTESTR, BSL_IDVALPAIR_TYPE_INT64, BSL_IDVALPAIR_TYPE_RAW, BSL_IDVALPAIR_TYPE_TEXTSTR, and BSL_IDVALPAIR_TYPE_UNKNOWN.

Referenced by test_MultiplePolicyProviders(), and test_PolicyProvider_Inspect_RFC9173_BIB().

◆ BSL_IdValPair_Set()

void BSL_IdValPair_Set ( BSL_IdValPair_t *  self,
const BSL_IdValPair_t *  src 
)

◆ BSL_IdValPair_SetBytestr()

◆ BSL_IdValPair_SetInt64()

◆ BSL_IdValPair_SetRaw()

void BSL_IdValPair_SetRaw ( BSL_IdValPair_t *  self,
int64_t  param_id,
const void *  ptr,
size_t  len 
)

◆ BSL_IdValPair_SetTextstr()

void BSL_IdValPair_SetTextstr ( BSL_IdValPair_t *  self,
int64_t  param_id,
const char *  value 
)

◆ BSL_IdValPair_Sizeof()

size_t BSL_IdValPair_Sizeof ( void  )

Return size of BSL_IdValPair_s struct type.