|
BSL v1.1.1 - 50.g42e5d9b
AMMOS Bundle Protocol Security Library (BSL)
|
Definition of a variant-type container. More...
#include "Variant.h"
Include dependency graph for Variant.c:Functions | |
| size_t | BSL_Variant_Sizeof (void) |
| Return size of BSL_Variant_s struct type. | |
| void | BSL_Variant_Init (BSL_Variant_t *self) |
| Initialize to a default empty state. | |
| void | BSL_Variant_InitSet (BSL_Variant_t *self, const BSL_Variant_t *src) |
| Initialize to a copy of another value. | |
| void | BSL_Variant_Deinit (BSL_Variant_t *self) |
| De-initialize a parameter. | |
| void | BSL_Variant_Set (BSL_Variant_t *self, const BSL_Variant_t *src) |
| Overwrite with a copy of another value. | |
| void | BSL_Variant_Move (BSL_Variant_t *self, BSL_Variant_t *src) |
| Move from another value. | |
| void | BSL_Variant_SetTextstr (BSL_Variant_t *self, const char *value) |
| Initialize as a parameter containing a byte string with a null-terminated text value. | |
| bool | BSL_Variant_IsTextstr (const BSL_Variant_t *self) |
| Returns true when the value type is a text string. | |
| void | BSL_Variant_SetBytestr (BSL_Variant_t *self, BSL_Data_t value) |
| Initialize as a parameter containing a bytestring. | |
| void | BSL_Variant_SetInt64 (BSL_Variant_t *self, int64_t value) |
| Set to an signed integer value. | |
| bool | BSL_Variant_IsInt64 (const BSL_Variant_t *self) |
| Returns true when the value type is an integer. | |
| int | BSL_Variant_GetAsInt64 (const BSL_Variant_t *self, int64_t *out) |
| Retrieve integer value of result when this result type is integer. | |
| bool | BSL_Variant_IsBytestr (const BSL_Variant_t *self) |
| Returns true when the value type is a byte string. | |
| int | BSL_Variant_GetAsBytestr (const BSL_Variant_t *self, BSL_Data_t *out) |
| Retrieve byte string value of a parameter. | |
| int | BSL_Variant_GetAsTextstr (const BSL_Variant_t *self, const char **out) |
| Retrieve bytestring value of result when security parameter type is bytestring. | |
| void | BSL_Variant_SetRaw (BSL_Variant_t *self, const void *ptr, size_t len) |
| Initialize as a parameter containing raw encoded content. | |
| bool | BSL_Variant_IsRaw (const BSL_Variant_t *self) |
| Returns true when the value type is raw encoded CBOR. | |
| int | BSL_Variant_GetAsRaw (const BSL_Variant_t *self, BSL_Data_t *out) |
| Retrieve bytestring value of result when security parameter type is bytestring. | |
| bool | BSL_Variant_IsConsistent (const BSL_Variant_t *self) |
| Return true if invariant conditions pass. | |
| int | BSL_Variant_Decode (QCBORDecodeContext *dec, BSL_Variant_t *var) |
| Decode from CBOR, as a pair of items either in an array or from a map key-value. | |
| void | BSL_Variant_Encode (QCBOREncodeContext *enc, const BSL_Variant_t *pair) |
| Encode to CBOR, as a pair of items either in an array or a map key-value. | |
Definition of a variant-type container.
| int BSL_Variant_Decode | ( | QCBORDecodeContext * | dec, |
| BSL_Variant_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_LOG_DEBUG, BSL_LOG_ERR, BSL_SUCCESS, BSL_Variant_SetBytestr(), BSL_Variant_SetInt64(), BSL_Variant_SetRaw(), and BSL_Data_t::len.
Referenced by BSL_AbsSecBlock_Decode(), and BSLX_CoseMsg_Headers_Decode_Map().
| void BSL_Variant_Deinit | ( | BSL_Variant_t * | self | ) |
De-initialize a parameter.
| [in,out] | self | The object to deinitialize. |
References ASSERT_ARG_NONNULL, BSLB_VARIANT_TYPE_BYTESTR, BSLB_VARIANT_TYPE_INT64, BSLB_VARIANT_TYPE_RAW, BSLB_VARIANT_TYPE_TEXTSTR, and BSLB_VARIANT_TYPE_UNKNOWN.
Referenced by BSL_Variant_Move(), BSL_Variant_Set(), BSL_Variant_SetBytestr(), BSL_Variant_SetInt64(), BSL_Variant_SetRaw(), and BSL_Variant_SetTextstr().
| void BSL_Variant_Encode | ( | QCBOREncodeContext * | enc, |
| const BSL_Variant_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_LOG_CRIT, BSL_Variant_GetAsBytestr(), BSL_Variant_GetAsInt64(), BSL_Variant_GetAsRaw(), BSL_Variant_IsBytestr(), BSL_Variant_IsInt64(), BSL_Variant_IsRaw(), and UsefulBufC_FROM_BSL_Data.
Referenced by BSL_AbsSecBlock_Encode(), and BSLX_CoseMsg_Headers_Encode_Map().
| int BSL_Variant_GetAsBytestr | ( | const BSL_Variant_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_SUCCESS, BSL_Variant_IsConsistent(), BSLB_VARIANT_TYPE_BYTESTR, and CHK_PRECONDITION.
Referenced by BSL_Variant_Encode(), BSL_Variant_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_Variant_GetAsInt64 | ( | const BSL_Variant_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_SUCCESS, BSL_Variant_IsConsistent(), BSLB_VARIANT_TYPE_INT64, and CHK_PRECONDITION.
Referenced by BSL_Variant_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_Variant_GetAsRaw | ( | const BSL_Variant_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_SUCCESS, BSL_Variant_IsConsistent(), BSLB_VARIANT_TYPE_RAW, and CHK_PRECONDITION.
Referenced by BSL_Variant_Encode(), BSLX_CoseMsg_Headers_CheckCrit(), BSLX_CoseSc_GetAndValidateAadScope(), and BSLX_CoseSc_GetOptions().
| int BSL_Variant_GetAsTextstr | ( | const BSL_Variant_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_SUCCESS, BSL_Variant_IsConsistent(), BSLB_VARIANT_TYPE_TEXTSTR, and CHK_PRECONDITION.
Referenced by BSL_Variant_Print(), BSLX_BCB_GetOptions(), and BSLX_BIB_InitFromSecOper().
| void BSL_Variant_Init | ( | BSL_Variant_t * | self | ) |
Initialize to a default empty state.
| [out] | self | The object to initialize. |
References ASSERT_ARG_NONNULL, and BSLB_VARIANT_TYPE_UNKNOWN.
Referenced by BSL_Variant_InitSet(), and test_CCSDS_Example_Mac_VerifyAccept().
| void BSL_Variant_InitSet | ( | BSL_Variant_t * | self, |
| const BSL_Variant_t * | src | ||
| ) |
Initialize to a copy of another value.
| [out] | self | The object to initialize. |
| [in] | src | The source of the copy. |
References BSL_Variant_Init(), and BSL_Variant_Set().
| bool BSL_Variant_IsBytestr | ( | const BSL_Variant_t * | self | ) |
Returns true when the value type is a byte string.
| [in] | self | This Security Parameter |
References BSLB_VARIANT_TYPE_BYTESTR, and CHK_AS_BOOL.
Referenced by BSL_Variant_Encode(), BSL_Variant_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_Variant_IsConsistent | ( | const BSL_Variant_t * | self | ) |
Return true if invariant conditions pass.
| [in] | self | This security parameter |
References BSLB_VARIANT_TYPE_RAW, BSLB_VARIANT_TYPE_UNKNOWN, and CHK_AS_BOOL.
Referenced by BSL_Variant_GetAsBytestr(), BSL_Variant_GetAsInt64(), BSL_Variant_GetAsRaw(), and BSL_Variant_GetAsTextstr().
| bool BSL_Variant_IsInt64 | ( | const BSL_Variant_t * | self | ) |
Returns true when the value type is an integer.
| [in] | self | This Security Parameter |
References BSLB_VARIANT_TYPE_INT64, and CHK_AS_BOOL.
Referenced by BSL_Variant_Encode(), and BSL_Variant_Print().
| bool BSL_Variant_IsRaw | ( | const BSL_Variant_t * | self | ) |
Returns true when the value type is raw encoded CBOR.
| [in] | self | This Security Parameter |
References BSLB_VARIANT_TYPE_RAW, and CHK_AS_BOOL.
Referenced by BSL_Variant_Encode().
| bool BSL_Variant_IsTextstr | ( | const BSL_Variant_t * | self | ) |
Returns true when the value type is a text string.
| [in] | self | This Security Parameter |
References BSLB_VARIANT_TYPE_TEXTSTR, and CHK_AS_BOOL.
Referenced by BSL_Variant_Print().
| void BSL_Variant_Move | ( | BSL_Variant_t * | self, |
| BSL_Variant_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_Variant_Deinit(), BSLB_VARIANT_TYPE_BYTESTR, BSLB_VARIANT_TYPE_INT64, BSLB_VARIANT_TYPE_RAW, BSLB_VARIANT_TYPE_TEXTSTR, and BSLB_VARIANT_TYPE_UNKNOWN.
| void BSL_Variant_Set | ( | BSL_Variant_t * | self, |
| const BSL_Variant_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_Variant_Deinit(), BSLB_VARIANT_TYPE_BYTESTR, BSLB_VARIANT_TYPE_INT64, BSLB_VARIANT_TYPE_RAW, BSLB_VARIANT_TYPE_TEXTSTR, and BSLB_VARIANT_TYPE_UNKNOWN.
Referenced by BSL_Variant_InitSet(), BSLP_PolicyParser_ReadOneRule(), BSLP_PolicyRule_EvaluateAsSecOper(), and BSLP_RegisterPolicyFromBitstring().
| void BSL_Variant_SetBytestr | ( | BSL_Variant_t * | self, |
| BSL_Data_t | value | ||
| ) |
Initialize as a parameter containing a bytestring.
| [in,out] | self | This Security Parameter |
| [in] | value | View of bytes, which get copied into this Security Parameter. |
References ASSERT_ARG_NONNULL, BSL_Variant_Deinit(), BSLB_VARIANT_TYPE_BYTESTR, BSL_Data_t::len, and BSL_Data_t::ptr.
Referenced by BSL_Crypto_KeyLoader_LoadCoseKeySet_decode(), BSL_Variant_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(), 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_Variant_SetInt64 | ( | BSL_Variant_t * | self, |
| int64_t | value | ||
| ) |
Set to an signed integer value.
| [in,out] | self | This Security Parameter |
| [in] | value | The value to use. |
References ASSERT_ARG_NONNULL, BSL_Variant_Deinit(), and BSLB_VARIANT_TYPE_INT64.
Referenced by _setUp(), BSL_Crypto_KeyLoader_LoadCoseKeySet_decode(), BSL_TestUtils_GetRFC9173_A1Params(), BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_InitBIB_AppendixA1(), BSL_Variant_Decode(), BSLP_PolicyOptions_SC1(), BSLP_PolicyOptions_SC2(), BSLP_PolicyOptions_SC3(), BSLP_RegisterPolicyFromBitstring(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), BSLX_CoseSc_SourceHeaders(), 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_Variant_SetRaw | ( | BSL_Variant_t * | self, |
| const void * | ptr, | ||
| size_t | len | ||
| ) |
Initialize as a parameter containing raw encoded content.
| [in,out] | self | This Security Parameter |
| [in] | ptr | The stat of the data. |
| len | The length to copy. |
References ASSERT_ARG_NONNULL, BSL_Variant_Deinit(), and BSLB_VARIANT_TYPE_RAW.
Referenced by BSL_Variant_Decode(), BSLX_CoseSc_AddAadScope(), BSLX_CoseSc_SetAadScope(), and test_CoseSc_InvalidOptions_Verifier().
| void BSL_Variant_SetTextstr | ( | BSL_Variant_t * | self, |
| const char * | value | ||
| ) |
Initialize as a parameter containing a byte string with a null-terminated text value.
| [in,out] | self | This Security Parameter |
| [in] | value | text string of the parameter, copied into self |
References ASSERT_ARG_NONNULL, BSL_Variant_Deinit(), and BSLB_VARIANT_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(), and test_sec_source_keywrap().
| size_t BSL_Variant_Sizeof | ( | void | ) |
Return size of BSL_Variant_s struct type.