BSL v0.0.0 - 0.geda3e66
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
SecParam.c File Reference

Implementation of a RFC9172 Parameter. More...

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

Functions

size_t BSL_SecParam_Sizeof (void)
 Return size of BSL_SecParam_s struct type.
 
int BSL_SecParam_InitStr (BSL_SecParam_t *self, uint64_t param_id, const char *value)
 
int BSL_SecParam_InitBytestr (BSL_SecParam_t *self, uint64_t param_id, BSL_Data_t value)
 Initialize as a parameter containing a bytestring.
 
int BSL_SecParam_InitInt64 (BSL_SecParam_t *self, uint64_t param_id, uint64_t value)
 Initialize as a parameter containing an integer as a value.
 
int BSL_SecParam_IsInt64 (const BSL_SecParam_t *self)
 Returns true when the value type is an integer.
 
uint64_t BSL_SecParam_GetAsUInt64 (const BSL_SecParam_t *self)
 Retrieve integer value of result when this result type is integer.
 
int BSL_SecParam_GetAsBytestr (const BSL_SecParam_t *self, BSL_Data_t *result)
 Retrieve bytestring value of result when security parameter type is bytestring.
 
uint64_t BSL_SecParam_GetId (const BSL_SecParam_t *self)
 Get parameter ID of this param.
 
bool BSL_SecParam_IsConsistent (const BSL_SecParam_t *self)
 Return true if invariant conditions pass.
 
bool BSL_SecParam_IsParamIDOutput (uint64_t param_id)
 Indicates true when this parameter is NOT an implementation-specific security parameter.
 

Detailed Description

Implementation of a RFC9172 Parameter.

Function Documentation

◆ BSL_SecParam_GetAsBytestr()

int BSL_SecParam_GetAsBytestr ( const BSL_SecParam_t *  self,
BSL_Data_t result 
)

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

WARNING: Always check type before using.

Todo:
Clarify whether result contains copy or view of content
Parameters
[in]selfThis Security Parameter
[in,out]resultPointer to pre-allocated data into which the bytestring is copied.
Returns
Negative on error.

References BSL_Data_InitView(), and BSL_SecParam_IsConsistent().

Referenced by BSL_AbsSecBlock_EncodeToCBOR(), and BSLX_BIB_InitFromSecOper().

◆ BSL_SecParam_GetAsUInt64()

uint64_t BSL_SecParam_GetAsUInt64 ( const BSL_SecParam_t *  self)

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

Warning
Always check using BSL_SecParam_IsInt64() first.
Parameters
[in]selfThis Security Parameter
Returns
Integer value of parameter if present, panics/aborts otherwise.

References BSL_SECPARAM_TYPE_INT64.

Referenced by BSL_AbsSecBlock_EncodeToCBOR(), and BSLX_BIB_InitFromSecOper().

◆ BSL_SecParam_GetId()

uint64_t BSL_SecParam_GetId ( const BSL_SecParam_t *  self)

Get parameter ID of this param.

Parameters
[in]selfThis BPSec Param type
Returns

References BSL_SecParam_IsConsistent().

Referenced by BSLX_BIB_InitFromSecOper().

◆ BSL_SecParam_InitBytestr()

int BSL_SecParam_InitBytestr ( BSL_SecParam_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.
Returns
Negative on an error.

References BSL_SECPARAM_TYPE_BYTESTR, BSL_SUCCESS, BSL_Data_t::len, and BSL_Data_t::ptr.

Referenced by BSL_AbsSecBlock_DecodeFromCBOR().

◆ BSL_SecParam_InitInt64()

int BSL_SecParam_InitInt64 ( BSL_SecParam_t *  self,
uint64_t  param_id,
uint64_t  value 
)

Initialize as a parameter containing an integer as a value.

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

References BSL_SECPARAM_TYPE_INT64, and BSL_SUCCESS.

Referenced by BSL_AbsSecBlock_DecodeFromCBOR().

◆ BSL_SecParam_InitStr()

int BSL_SecParam_InitStr ( BSL_SecParam_t *  self,
uint64_t  param_id,
const char *  value 
)
Parameters
[in,out]selfThis Security Parameter
[in]param_idID of the parameter
[in]valuetext string of the parameter, copied into self
Returns
Negative on an error.

References BSL_SUCCESS.

◆ BSL_SecParam_IsConsistent()

bool BSL_SecParam_IsConsistent ( const BSL_SecParam_t *  self)

Return true if invariant conditions pass.

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

References BSL_SECPARAM_TYPE_INT64, and BSL_SECPARAM_TYPE_UNKNOWN.

Referenced by BSL_SecOper_AppendParam(), BSL_SecOutcome_AppendParam(), BSL_SecParam_GetAsBytestr(), BSL_SecParam_GetId(), and BSLP_PolicyRule_AddParam().

◆ BSL_SecParam_IsInt64()

int BSL_SecParam_IsInt64 ( const BSL_SecParam_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_SECPARAM_TYPE_INT64.

Referenced by BSL_AbsSecBlock_EncodeToCBOR(), and BSLX_BIB_InitFromSecOper().

◆ BSL_SecParam_IsParamIDOutput()

bool BSL_SecParam_IsParamIDOutput ( uint64_t  param_id)

Indicates true when this parameter is NOT an implementation-specific security parameter.

Todo:
Rename to avoid using negative logic and clarify.
Parameters
param_idID of the parameter
Returns
True when this is NOT an internal parameter ID.

References BSL_SECPARAM_TYPE_INT_STARTINDEX.