|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
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. | |
Definition of an (id, value) pair container.
| 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.
Matches the BSL_CBOR_Decode_f signature.
References ASSERT_ARG_NONNULL, BSL_Data_InitView(), BSL_ERR_DECODING, BSL_IdValPair_SetBytestr(), BSL_IdValPair_SetInt64(), BSL_IdValPair_SetRaw(), BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_SUCCESS, and BSL_Data_t::len.
Referenced by BSL_AbsSecBlock_Decode(), and BSLX_CoseMsg_Headers_Decode_Map().
| void BSL_IdValPair_Deinit | ( | BSL_IdValPair_t * | self | ) |
De-initialize a parameter.
| [in,out] | self | The object to deinitialize. |
References ASSERT_ARG_NONNULL, BSL_IDVALPAIR_TYPE_BYTESTR, BSL_IDVALPAIR_TYPE_INT64, BSL_IDVALPAIR_TYPE_RAW, BSL_IDVALPAIR_TYPE_TEXTSTR, and BSL_IDVALPAIR_TYPE_UNKNOWN.
Referenced by _tearDown(), BCBTestContext_Deinit(), BIBTestContext_Deinit(), BSL_IdValPair_Move(), BSL_IdValPair_Set(), BSL_IdValPair_SetBytestr(), BSL_IdValPair_SetInt64(), BSL_IdValPair_SetRaw(), BSL_IdValPair_SetTextstr(), PublicInterfaceTestCtx_deinit(), set_CoseSc_InvalidOptions_Source_baseline(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_CCSDS_Example_Mac_VerifyAccept(), test_CoseSc_InvalidOptions_Verifier(), and test_SecurityContext_BIB_Verifier_Failure().
| 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.
Matches the BSL_CBOR_Encode_f signature.
References BSL_IdValPair_GetAsBytestr(), BSL_IdValPair_GetAsInt64(), BSL_IdValPair_GetAsRaw(), BSL_IdValPair_IsBytestr(), BSL_IdValPair_IsInt64(), BSL_IdValPair_IsRaw(), BSL_LOG_CRIT, and UsefulBufC_FROM_BSL_Data.
Referenced by BSL_AbsSecBlock_Encode(), and BSLX_CoseMsg_Headers_Encode_Map().
| int BSL_IdValPair_GetAsBytestr | ( | const BSL_IdValPair_t * | self, |
| BSL_Data_t * | out | ||
| ) |
Retrieve byte string value of a parameter.
| [in] | self | This Security Parameter |
| [out] | out | Pointer to optional struct which will be made a view onto this parameter value. That view must not outlive this pair instance. |
References BSL_CHKRET, BSL_Data_InitView(), BSL_ERR_NOT_FOUND, BSL_IdValPair_IsConsistent(), BSL_IDVALPAIR_TYPE_BYTESTR, BSL_SUCCESS, and CHK_PRECONDITION.
Referenced by BSL_IdValPair_Encode(), BSL_IdValPair_Print(), BSLX_BCB_Execute(), BSLX_BCB_GetOptions(), BSLX_BIB_Execute(), BSLX_BIB_InitFromSecOper(), BSLX_CoseSc_Encrypt0_VerifyAccept(), BSLX_CoseSc_Encrypt_VerifyAccept(), BSLX_CoseSc_ExtractIV(), BSLX_CoseSc_GenerateIV(), BSLX_CoseSc_GetAndValidateAddlHeaders(), BSLX_CoseSc_GetAndValidateKey(), BSLX_CoseSc_GetOptions(), BSLX_CoseSc_HkdfContentKey(), BSLX_CoseSc_Mac0_VerifyAccept(), BSLX_CoseSc_Mac_VerifyAccept(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_RFC9173_AppendixA_Example1_BIB_Source(), test_RFC9173_AppendixA_Example2_BCB_Source(), and test_sec_source_keywrap().
| int BSL_IdValPair_GetAsInt64 | ( | const BSL_IdValPair_t * | self, |
| int64_t * | out | ||
| ) |
Retrieve integer value of result when this result type is integer.
| [in] | self | This Security Parameter |
| [out] | out | The optional value |
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().
| int BSL_IdValPair_GetAsRaw | ( | const BSL_IdValPair_t * | self, |
| BSL_Data_t * | out | ||
| ) |
Retrieve bytestring value of result when security parameter type is bytestring.
| [in] | self | This Security Parameter |
| [out] | out | Pointer to optional struct which will be made a view onto this parameter value. That view must not outlive this pair instance. |
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().
| int BSL_IdValPair_GetAsTextstr | ( | const BSL_IdValPair_t * | self, |
| const char ** | out | ||
| ) |
Retrieve bytestring value of result when security parameter type is bytestring.
| [in] | self | This Security Parameter |
| [in,out] | out | Pointer to optional string pointer for view onto this parameter value. That view must not outlive this pair instance. |
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().
| uint64_t BSL_IdValPair_GetId | ( | const BSL_IdValPair_t * | self | ) |
Get parameter ID of this param.
| [in] | self | This BPSec Param type |
References ASSERT_PRECONDITION, and BSL_IdValPair_IsConsistent().
Referenced by BSLX_BCB_GetOptions(), BSLX_BIB_InitFromSecOper(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), and test_SecurityContext_BIB_Verifier_Failure().
| void BSL_IdValPair_Init | ( | BSL_IdValPair_t * | self | ) |
Initialize to a default empty state.
| [out] | self | The object to initialize. |
References ASSERT_ARG_NONNULL, and BSL_IDVALPAIR_TYPE_UNKNOWN.
Referenced by _setUp(), BCBTestContext_Init(), BIBTestContext_Init(), BSL_IdValPair_InitSet(), BSL_TestUtils_GetRFC9173_A1Params(), PublicInterfaceTestCtx_init(), set_CoseSc_InvalidOptions_Source_baseline(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_CCSDS_Example_Mac_VerifyAccept(), and test_CoseSc_InvalidOptions_Verifier().
| void BSL_IdValPair_InitSet | ( | BSL_IdValPair_t * | self, |
| const BSL_IdValPair_t * | src | ||
| ) |
Initialize to a copy of another value.
| [out] | self | The object to initialize. |
| [in] | src | The source of the copy. |
References BSL_IdValPair_Init(), and BSL_IdValPair_Set().
| bool BSL_IdValPair_IsBytestr | ( | const BSL_IdValPair_t * | self | ) |
Returns true when the value type is a byte string.
| [in] | self | This Security Parameter |
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().
| bool BSL_IdValPair_IsConsistent | ( | const BSL_IdValPair_t * | self | ) |
Return true if invariant conditions pass.
| [in] | self | This security parameter |
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().
| bool BSL_IdValPair_IsInt64 | ( | const BSL_IdValPair_t * | self | ) |
Returns true when the value type is an integer.
| [in] | self | This Security Parameter |
References BSL_IDVALPAIR_TYPE_INT64, and CHK_AS_BOOL.
Referenced by BSL_IdValPair_Encode(), and BSL_IdValPair_Print().
| bool BSL_IdValPair_IsRaw | ( | const BSL_IdValPair_t * | self | ) |
Returns true when the value type is raw encoded CBOR.
| [in] | self | This Security Parameter |
References BSL_IDVALPAIR_TYPE_RAW, and CHK_AS_BOOL.
Referenced by BSL_IdValPair_Encode().
| bool BSL_IdValPair_IsTextstr | ( | const BSL_IdValPair_t * | self | ) |
Returns true when the value type is a text string.
| [in] | self | This Security Parameter |
References BSL_IDVALPAIR_TYPE_TEXTSTR, and CHK_AS_BOOL.
Referenced by BSL_IdValPair_Print().
| void BSL_IdValPair_Move | ( | BSL_IdValPair_t * | self, |
| BSL_IdValPair_t * | src | ||
| ) |
Move from another value.
The other value is left deinitialized.
| [in,out] | self | The object to overwrite. |
| [in] | src | The 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().
| void BSL_IdValPair_Set | ( | BSL_IdValPair_t * | self, |
| const BSL_IdValPair_t * | src | ||
| ) |
Overwrite with a copy of another value.
| [in,out] | self | The object to overwrite. |
| [in] | src | The 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_PolicyParser_ReadOneRule(), BSLP_RegisterPolicyFromBitstring(), and setUp().
| void BSL_IdValPair_SetBytestr | ( | BSL_IdValPair_t * | self, |
| int64_t | param_id, | ||
| BSL_Data_t | value | ||
| ) |
Initialize as a parameter containing a bytestring.
| [in,out] | self | This Security Parameter |
| [in] | param_id | ID of the parameter |
| [in] | value | View 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(), BSLP_PolicyOptions_SC3(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), BSLX_CoseSc_Encrypt0_Source(), BSLX_CoseSc_Encrypt_Source(), BSLX_CoseSc_GenerateIV(), BSLX_CoseSc_HkdfContentKey(), BSLX_CoseSc_Mac0_Source(), BSLX_CoseSc_Mac_Source(), BSLX_CoseSc_SourceHeaders(), mock_bpa_key_registry_cosekey_decode(), set_CoseSc_InvalidOptions_Source_baseline(), setUp(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), and test_CCSDS_Example_Mac_VerifyAccept().
| void BSL_IdValPair_SetInt64 | ( | BSL_IdValPair_t * | self, |
| int64_t | param_id, | ||
| uint64_t | value | ||
| ) |
Set to an signed integer value.
| [in,out] | self | This Security Parameter |
| [in] | param_id | ID of the parameter |
| [in] | value | The value to use. |
References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), and BSL_IDVALPAIR_TYPE_INT64.
Referenced by _setUp(), BSL_IdValPair_Decode(), BSL_TestUtils_GetRFC9173_A1Params(), BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_InitBIB_AppendixA1(), BSLP_PolicyOptions_SC1(), BSLP_PolicyOptions_SC2(), BSLP_PolicyOptions_SC3(), BSLP_RegisterPolicyFromBitstring(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), BSLX_CoseSc_SourceHeaders(), mock_bpa_key_registry_cosekey_decode(), set_CoseSc_InvalidOptions_Source_baseline(), setUp(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_CCSDS_Example_Mac_VerifyAccept(), test_CoseSc_InvalidOptions_Verifier(), test_RFC9173_AppendixA_Example3_Acceptor(), test_RFC9173_AppendixA_Example3_Source(), test_RFC9173_AppendixA_Example4_Acceptor(), test_RFC9173_AppendixA_Example4_Source(), test_sec_accept_keyunwrap(), and test_sec_source_keywrap().
| 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.
| [in,out] | self | This Security Parameter |
| [in] | param_id | ID of the parameter |
| [in] | ptr | The stat of the data. |
| len | The length to copy. |
References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), and BSL_IDVALPAIR_TYPE_RAW.
Referenced by BSL_IdValPair_Decode(), BSLP_PolicyOptions_SC3(), BSLX_CoseSc_AddAadScope(), test_AppendixA_Example1_BIB_Source(), test_AppendixA_Example1_BIB_VerifyAccept(), test_AppendixA_Example4_BCB_Source(), test_AppendixA_Example4_BCB_VerifyAccept(), test_AppendixA_Example5_BCB_Source(), test_AppendixA_Example5_BCB_VerifyAccept(), test_AppendixA_Example6_BCB_Source(), test_CCSDS_Example_Mac_Source(), test_CCSDS_Example_Mac_VerifyAccept(), and test_CoseSc_InvalidOptions_Verifier().
| 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.
| [in,out] | self | This Security Parameter |
| [in] | param_id | ID of the parameter |
| [in] | value | text string of the parameter, copied into self |
References ASSERT_ARG_NONNULL, BSL_IdValPair_Deinit(), and BSL_IDVALPAIR_TYPE_TEXTSTR.
Referenced by _setUp(), BSL_TestUtils_GetRFC9173_A1Params(), BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_InitBIB_AppendixA1(), BSLP_PolicyOptions_SC1(), BSLP_PolicyOptions_SC2(), BSLP_RegisterPolicyFromBitstring(), setUp(), test_CoseSc_InvalidOptions_Verifier(), test_RFC9173_AppendixA_Example3_Acceptor(), test_RFC9173_AppendixA_Example3_Source(), test_RFC9173_AppendixA_Example4_Acceptor(), test_RFC9173_AppendixA_Example4_Source(), test_sec_accept_keyunwrap(), test_sec_source_keywrap(), and test_SecurityContext_BIB_Verifier_Failure().
| size_t BSL_IdValPair_Sizeof | ( | void | ) |
Return size of BSL_IdValPair_s struct type.