BSL v1.1.1 - 19.g31939de
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, uint64_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, uint64_t param_id, BSL_Data_t value)
 Initialize as a parameter containing a bytestring.
 
void BSL_IdValPair_SetInt64 (BSL_IdValPair_t *self, uint64_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, uint64_t param_id, const void *ptr, size_t len)
 Initialize as a parameter containing raw encoded content.
 
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.
 

Detailed Description

Definition of an (id, value) pair container.

Function Documentation

◆ BSL_IdValPair_Deinit()

◆ BSL_IdValPair_GetAsBytestr()

int BSL_IdValPair_GetAsBytestr ( const BSL_IdValPair_t *  self,
BSL_Data_t out 
)

Retrieve byte string value of a parameter.

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_Data_InitView(), BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_BYTESTR, BSL_SUCCESS, CHK_PRECONDITION, and CHK_PROPERTY.

Referenced by BSL_IdValPair_Encode(), BSL_IdValPair_Print(), BSLX_BCB_Execute(), BSLX_BCB_GetOptions(), BSLX_BIB_Execute(), BSLX_BIB_InitFromSecOper(), test_RFC9173_AppendixA_Example1_BIB_Source(), test_RFC9173_AppendixA_Example2_BCB_Source(), and test_sec_source_keywrap().

◆ 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 ASSERT_ARG_NONNULL, ASSERT_PRECONDITION, BSL_IDVALPAIR_TYPE_INT64, and BSL_SUCCESS.

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

◆ 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.

Warning
Always check type before using this.
Todo:
Clarify whether result contains copy or view of content
Parameters
[in]selfThis Security Parameter
[in,out]outPointer to optional string pointer for view onto this parameter value.
Returns
Negative on error.

References BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_TEXTSTR, BSL_SUCCESS, CHK_PRECONDITION, and CHK_PROPERTY.

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)

Get parameter ID of this param.

Parameters
[in]selfThis BPSec Param type
Returns
The parameter ID value

References ASSERT_PRECONDITION, and BSL_IdValPair_IsConsistent().

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

◆ BSL_IdValPair_Init()

void BSL_IdValPair_Init ( BSL_IdValPair_t *  self)

◆ 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(), and BSLX_BIB_Execute().

◆ 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_TEXTSTR, BSL_IDVALPAIR_TYPE_UNKNOWN, and CHK_AS_BOOL.

Referenced by BSL_IdValPair_GetAsBytestr(), 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_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 
)

Overwrite with a copy of another value.

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 _setUp(), BSL_IdValPair_InitSet(), BSLP_RegisterPolicyFromBitstring(), BSLP_RegisterPolicyFromJSON(), and setUp().

◆ BSL_IdValPair_SetBytestr()

void BSL_IdValPair_SetBytestr ( BSL_IdValPair_t *  self,
uint64_t  param_id,
BSL_Data_t  value 
)

Initialize as a parameter containing a bytestring.

Parameters
[in,out]selfThis Security Parameter
[in]param_idID of the parameter
[in]valueView of bytes, which get copied into this Security Parameter.

References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), BSL_IDVALPAIR_TYPE_BYTESTR, BSL_Data_t::len, and BSL_Data_t::ptr.

Referenced by BSL_IdValPair_Decode(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), and setUp().

◆ BSL_IdValPair_SetInt64()

◆ BSL_IdValPair_SetRaw()

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

Initialize as a parameter containing raw encoded content.

Parameters
[in,out]selfThis Security Parameter
[in]param_idID of the parameter
[in]ptrThe stat of the data.
lenThe length to copy.

References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), and BSL_IDVALPAIR_TYPE_RAW.

Referenced by BSL_IdValPair_Decode().

◆ BSL_IdValPair_SetTextstr()

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

◆ BSL_IdValPair_Sizeof()

size_t BSL_IdValPair_Sizeof ( void  )

Return size of BSL_IdValPair_s struct type.

Referenced by BSLP_InitParams_Init().