BSL v0.0.0
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:

Go to the source code of this file.

Functions

size_t BSL_SecParam_Sizeof (void)
 Return size of BSL_SecParam_t struct type.
 
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 paramter.
 

Detailed Description

Implementation of a RFC9172 Parameter.

Definition in file SecParam.c.

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
selfThis Security Parameter
resultPointer to pre-allocated data into which the bytestring is copied.
Returns
Negative on error.

Definition at line 77 of file SecParam.c.

References BSL_SecParam_s::_bytelen, BSL_SecParam_s::_bytes, BSL_Data_InitView(), and BSL_SecParam_IsConsistent().

Referenced by 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
selfThis Security Parameter
Returns
Integer value of parameter if present, panics/aborts otherwise.

Definition at line 69 of file SecParam.c.

References BSL_SecParam_s::_type, BSL_SecParam_s::_uint_value, and BSL_SECPARAM_TYPE_INT64.

Referenced by 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

Definition at line 85 of file SecParam.c.

References BSL_SecParam_IsConsistent(), and BSL_SecParam_s::param_id.

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
self[in,out]This Security Paramter
param_id[in]ID of the parameter
value[in]View of bytes, which get copied into this Security Parameter.
Returns
Negative on an error.

Definition at line 34 of file SecParam.c.

References BSL_SecParam_s::_bytelen, BSL_SecParam_s::_bytes, BSL_SecParam_s::_type, BSL_SECPARAM_TYPE_BYTESTR, BSL_SUCCESS, BSL_Data_s::len, BSL_SecParam_s::param_id, and BSL_Data_s::ptr.

◆ 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
selfThis Security Paramter
param_idID of the parameter
valueView of bytes, which get copied into this Security Parameter.
Returns
Negative on an error.

Definition at line 51 of file SecParam.c.

References BSL_SecParam_s::_type, BSL_SecParam_s::_uint_value, BSL_SECPARAM_TYPE_INT64, BSL_SUCCESS, and BSL_SecParam_s::param_id.

◆ BSL_SecParam_IsConsistent()

bool BSL_SecParam_IsConsistent ( const BSL_SecParam_t self)

◆ BSL_SecParam_IsInt64()

int BSL_SecParam_IsInt64 ( const BSL_SecParam_t self)

Returns true when the value type is an integer.

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

Definition at line 63 of file SecParam.c.

References BSL_SecParam_s::_type, and BSL_SECPARAM_TYPE_INT64.

Referenced by 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 paramter.

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.

Definition at line 111 of file SecParam.c.

References BSL_SECPARAM_TYPE_INT_STARTINDEX.

◆ BSL_SecParam_Sizeof()

size_t BSL_SecParam_Sizeof ( void  )

Return size of BSL_SecParam_t struct type.

Definition at line 29 of file SecParam.c.

Referenced by BSLP_PolicyRule_AddParam(), BSLP_PolicyRule_EvaluateAsSecOper(), and BSLP_PolicyRule_Init().