|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
Header for COSE message structures [15]. More...
#include "bsl/front/BSLMemory.h"#include "bsl/dynamic/CBOR.h"#include "bsl/dynamic/IdValPair.h"#include <m-array.h>#include <m-bptree.h>#include <m-shared-ptr.h>
Include dependency graph for CoseMsg.h:
This graph shows which files directly or indirectly include this file:Data Structures | |
| struct | BSLX_CoseMsg_Headers_t |
| Common header storage and logic. More... | |
| struct | BSLX_CoseMsg_Mac0_t |
| Decoded COSE_Mac0. More... | |
| struct | BSLX_CoseMsg_Encrypt0_t |
| Decoded COSE_Encrypt0. More... | |
| struct | BSLX_CoseMsg_Recipient_t |
| Each recipient of a COSE_Mac or COSE_Encrypt. More... | |
| struct | BSLX_CoseMsg_Mac_t |
| Decoded COSE_Mac. More... | |
| struct | BSLX_CoseMsg_Encrypt_t |
| Decoded COSE_Encrypt. More... | |
Macros | |
| #define | BSLX_COSEMSG_RECIPIENTS_LIMIT 10 |
| Artificial limit on number of recipients supported. | |
| #define | BSLX_COSEMSG_AESGCM_IV_LEN (12) |
| Length of generated IV byte strings. | |
Header for COSE message structures [15].
| #define BSLX_COSEMSG_AESGCM_IV_LEN (12) |
Length of generated IV byte strings.
From https://www.rfc-editor.org/rfc/rfc9053.html#section-4.1 "This document fixes the size of the nonce at 96 bits."
| #define BSLX_COSEMSG_RECIPIENTS_LIMIT 10 |
Artificial limit on number of recipients supported.
| enum BSLX_CoseMsg_Alg_e |
Algorithm code points managed by IANA.
https://www.iana.org/assignments/cose/cose.xhtml#algorithms
Header parameters managed by IANA.
https://www.iana.org/assignments/cose/cose.xhtml#header-parameters
Key parameter code points managed by IANA.
https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
| int BSLX_CoseMsg_Encrypt0_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Encrypt0_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References ASSERT_ARG_NONNULL, BSL_ERR_DECODING, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode(), and BSLX_CoseMsg_Encrypt0_t::headers.
Referenced by BSLX_CoseSc_Encrypt0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example4_BCB_Source().
| void BSLX_CoseMsg_Encrypt0_Deinit | ( | BSLX_CoseMsg_Encrypt0_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSLX_CoseMsg_Headers_Deinit(), and BSLX_CoseMsg_Encrypt0_t::headers.
Referenced by BSLX_CoseSc_Encrypt0_Source(), BSLX_CoseSc_Encrypt0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example4_BCB_Source().
| int BSLX_CoseMsg_Encrypt0_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Encrypt0_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References ASSERT_ARG_NONNULL, BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode(), and BSLX_CoseMsg_Encrypt0_t::headers.
Referenced by BSLX_CoseSc_Encrypt0_Source(), and LLVMFuzzerTestOneInput().
| void BSLX_CoseMsg_Encrypt0_Init | ( | BSLX_CoseMsg_Encrypt0_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSLX_CoseMsg_Headers_Init(), and BSLX_CoseMsg_Encrypt0_t::headers.
Referenced by BSLX_CoseSc_Encrypt0_Source(), BSLX_CoseSc_Encrypt0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example4_BCB_Source().
| int BSLX_CoseMsg_Encrypt_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Encrypt_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References ASSERT_ARG_NONNULL, BSL_ERR_DECODING, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode(), BSLX_CoseMsg_RecipientList_Decode(), BSLX_CoseMsg_Encrypt_t::headers, and BSLX_CoseMsg_Encrypt_t::recipients.
Referenced by BSLX_CoseSc_Encrypt_VerifyAccept(), LLVMFuzzerTestOneInput(), test_AppendixA_Example5_BCB_Source(), and test_AppendixA_Example6_BCB_Source().
| void BSLX_CoseMsg_Encrypt_Deinit | ( | BSLX_CoseMsg_Encrypt_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSLX_CoseMsg_Headers_Deinit(), BSLX_CoseMsg_Encrypt_t::headers, and BSLX_CoseMsg_Encrypt_t::recipients.
Referenced by BSLX_CoseSc_Encrypt_Source(), BSLX_CoseSc_Encrypt_VerifyAccept(), LLVMFuzzerTestOneInput(), test_AppendixA_Example5_BCB_Source(), and test_AppendixA_Example6_BCB_Source().
| int BSLX_CoseMsg_Encrypt_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Encrypt_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References ASSERT_ARG_NONNULL, BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode(), BSLX_CoseMsg_RecipientList_Encode(), BSLX_CoseMsg_Encrypt_t::headers, and BSLX_CoseMsg_Encrypt_t::recipients.
Referenced by BSLX_CoseSc_Encrypt_Source(), and LLVMFuzzerTestOneInput().
| void BSLX_CoseMsg_Encrypt_Init | ( | BSLX_CoseMsg_Encrypt_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSLX_CoseMsg_Headers_Init(), BSLX_CoseMsg_Encrypt_t::headers, and BSLX_CoseMsg_Encrypt_t::recipients.
Referenced by BSLX_CoseSc_Encrypt_Source(), BSLX_CoseSc_Encrypt_VerifyAccept(), LLVMFuzzerTestOneInput(), test_AppendixA_Example5_BCB_Source(), and test_AppendixA_Example6_BCB_Source().
| void BSLX_CoseMsg_HdrMapTree_update | ( | BSLX_CoseMsg_HdrMapTree_t | base, |
| const BSLX_CoseMsg_HdrMapTree_t | addl | ||
| ) |
Update a base map with an additional map, adding items when the key is not already present.
Referenced by BSLX_CoseSc_VerifyHeaders().
| int BSLX_CoseMsg_Headers_CheckCrit | ( | const BSLX_CoseMsg_Headers_t * | obj | ) |
Check for the presence of crit header referencing unsupported parameters.
| [in] | obj | The headers to search. |
References BSL_CBOR_Decode(), BSL_ERR_DECODING, BSL_IdValPair_GetAsRaw(), BSL_LOG_ERR, BSL_SUCCESS, BSLX_COSEMSG_HDR_CRIT, BSLX_CoseMsg_Headers_CheckCrit_Decode(), and BSLX_CoseMsg_Headers_Get().
Referenced by BSLX_CoseSc_VerifyHeaders().
| int BSLX_CoseMsg_Headers_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Headers_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References BSL_Data_CopyFrom(), BSL_ERR_DECODING, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode_Map(), BSL_Data_t::len, BSLX_CoseMsg_Headers_t::phdr, BSLX_CoseMsg_Headers_t::phdr_bstr, and BSLX_CoseMsg_Headers_t::uhdr.
Referenced by BSLX_CoseMsg_Encrypt0_Decode(), BSLX_CoseMsg_Encrypt_Decode(), BSLX_CoseMsg_Mac0_Decode(), BSLX_CoseMsg_Mac_Decode(), and BSLX_CoseMsg_Recipient_Decode().
| int BSLX_CoseMsg_Headers_Decode_Map | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_HdrMapTree_t * | map | ||
| ) |
Decode a header parameter map.
Matches BSL_CBOR_Encode_f signature.
References BSL_ERR_DECODING, BSL_IdValPair_Decode(), and BSL_SUCCESS.
Referenced by BSLX_CoseMsg_Headers_Decode(), and BSLX_CoseSc_GetAndValidateAddlHeaders().
| void BSLX_CoseMsg_Headers_Deinit | ( | BSLX_CoseMsg_Headers_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSLX_CoseMsg_Headers_t::phdr, BSLX_CoseMsg_Headers_t::phdr_bstr, and BSLX_CoseMsg_Headers_t::uhdr.
Referenced by BSLX_CoseMsg_Encrypt0_Deinit(), BSLX_CoseMsg_Encrypt_Deinit(), BSLX_CoseMsg_Mac0_Deinit(), BSLX_CoseMsg_Mac_Deinit(), and BSLX_CoseMsg_Recipient_Deinit().
| int BSLX_CoseMsg_Headers_DerivePhdr | ( | BSLX_CoseMsg_Headers_t * | obj | ) |
Derive BSLX_CoseMsg_Headers_t::phdr_bstr from protected headers in BSLX_CoseMsg_Headers_t::phdr.
This is needed before cryptographic calculation and encoding.
| [in,out] | obj | The headers to encode and store into. |
References BSL_CBOR_Encode_Twopass(), BSL_Data_Resize(), BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode_Map(), BSLX_CoseMsg_Headers_t::phdr, and BSLX_CoseMsg_Headers_t::phdr_bstr.
Referenced by BSLX_CoseSc_SourceHeaders().
| int BSLX_CoseMsg_Headers_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Headers_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode_Map(), BSLX_CoseMsg_Headers_t::phdr_bstr, BSLX_CoseMsg_Headers_t::uhdr, and UsefulBufC_FROM_BSL_Data.
Referenced by BSLX_CoseMsg_Encrypt0_Encode(), BSLX_CoseMsg_Encrypt_Encode(), BSLX_CoseMsg_Mac0_Encode(), BSLX_CoseMsg_Mac_Encode(), and BSLX_CoseMsg_Recipient_Encode().
| int BSLX_CoseMsg_Headers_Encode_Map | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_HdrMapTree_t * | map | ||
| ) |
Encode a header parameter map.
Matches BSL_CBOR_Encode_f signature.
References BSL_IdValPair_Encode(), and BSL_SUCCESS.
Referenced by BSLX_CoseMsg_Headers_DerivePhdr(), and BSLX_CoseMsg_Headers_Encode().
| const BSL_IdValPair_t * BSLX_CoseMsg_Headers_Get | ( | const BSLX_CoseMsg_Headers_t * | obj, |
| int64_t | label, | ||
| bool | need_phdr | ||
| ) |
Get a desired header parameter.
| [in] | obj | The headers to search. |
| label | The label to search for. | |
| need_phdr | If true the parameter needs to be in the protected map when it is present. This does not imply that it needs to be present. |
References BSL_LOG_ERR, BSLX_CoseMsg_Headers_t::phdr, and BSLX_CoseMsg_Headers_t::uhdr.
Referenced by BSLX_CoseMsg_Headers_CheckCrit(), BSLX_CoseSc_ExtractIV(), BSLX_CoseSc_GetAndValidateKey(), BSLX_CoseSc_GetAndValidateTarget(), and BSLX_CoseSc_HkdfContentKey().
| void BSLX_CoseMsg_Headers_Init | ( | BSLX_CoseMsg_Headers_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Init(), BSLX_CoseMsg_Headers_t::phdr, BSLX_CoseMsg_Headers_t::phdr_bstr, and BSLX_CoseMsg_Headers_t::uhdr.
Referenced by BSLX_CoseMsg_Encrypt0_Init(), BSLX_CoseMsg_Encrypt_Init(), BSLX_CoseMsg_Mac0_Init(), BSLX_CoseMsg_Mac_Init(), and BSLX_CoseMsg_Recipient_Init().
| int BSLX_CoseMsg_Mac0_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Mac0_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References BSL_Data_CopyFrom(), BSL_ERR_DECODING, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode(), BSLX_CoseMsg_Mac0_t::headers, BSL_Data_t::len, and BSLX_CoseMsg_Mac0_t::tag.
Referenced by BSLX_CoseSc_Mac0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example1_BIB_Source().
| void BSLX_CoseMsg_Mac0_Deinit | ( | BSLX_CoseMsg_Mac0_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSLX_CoseMsg_Headers_Deinit(), BSLX_CoseMsg_Mac0_t::headers, and BSLX_CoseMsg_Mac0_t::tag.
Referenced by BSLX_CoseSc_Mac0_Source(), BSLX_CoseSc_Mac0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example1_BIB_Source().
| int BSLX_CoseMsg_Mac0_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Mac0_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode(), BSLX_CoseMsg_Mac0_t::headers, BSLX_CoseMsg_Mac0_t::tag, and UsefulBufC_FROM_BSL_Data.
Referenced by BSLX_CoseSc_Mac0_Source(), and LLVMFuzzerTestOneInput().
| void BSLX_CoseMsg_Mac0_Init | ( | BSLX_CoseMsg_Mac0_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Init(), BSLX_CoseMsg_Headers_Init(), BSLX_CoseMsg_Mac0_t::headers, and BSLX_CoseMsg_Mac0_t::tag.
Referenced by BSLX_CoseSc_Mac0_Source(), BSLX_CoseSc_Mac0_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_AppendixA_Example1_BIB_Source().
| int BSLX_CoseMsg_Mac_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Mac_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References ASSERT_ARG_NONNULL, BSL_Data_CopyFrom(), BSL_ERR_DECODING, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode(), BSLX_CoseMsg_RecipientList_Decode(), BSLX_CoseMsg_Mac_t::headers, BSL_Data_t::len, BSLX_CoseMsg_Mac_t::recipients, and BSLX_CoseMsg_Mac_t::tag.
Referenced by BSLX_CoseSc_Mac_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_CCSDS_Example_Mac_Source().
| void BSLX_CoseMsg_Mac_Deinit | ( | BSLX_CoseMsg_Mac_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSLX_CoseMsg_Headers_Deinit(), BSLX_CoseMsg_Mac_t::headers, BSLX_CoseMsg_Mac_t::recipients, and BSLX_CoseMsg_Mac_t::tag.
Referenced by BSLX_CoseSc_Mac_Source(), BSLX_CoseSc_Mac_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_CCSDS_Example_Mac_Source().
| int BSLX_CoseMsg_Mac_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Mac_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References ASSERT_ARG_NONNULL, BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode(), BSLX_CoseMsg_RecipientList_Encode(), BSLX_CoseMsg_Mac_t::headers, BSLX_CoseMsg_Mac_t::recipients, BSLX_CoseMsg_Mac_t::tag, and UsefulBufC_FROM_BSL_Data.
Referenced by BSLX_CoseSc_Mac_Source(), and LLVMFuzzerTestOneInput().
| void BSLX_CoseMsg_Mac_Init | ( | BSLX_CoseMsg_Mac_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Init(), BSLX_CoseMsg_Headers_Init(), BSLX_CoseMsg_Mac_t::headers, BSLX_CoseMsg_Mac_t::recipients, and BSLX_CoseMsg_Mac_t::tag.
Referenced by BSLX_CoseSc_Mac_Source(), BSLX_CoseSc_Mac_VerifyAccept(), LLVMFuzzerTestOneInput(), and test_CCSDS_Example_Mac_Source().
| int BSLX_CoseMsg_Recipient_Decode | ( | QCBORDecodeContext * | dec, |
| BSLX_CoseMsg_Recipient_t * | obj | ||
| ) |
Match BSL_CBOR_Decode_f signature.
References ASSERT_ARG_NONNULL, BSL_Data_CopyFrom(), BSL_ERR_DECODING, BSL_LOG_ERR, BSL_SUCCESS, BSLX_CoseMsg_Headers_Decode(), BSLX_CoseMsg_Recipient_t::ciphertext, BSLX_CoseMsg_Recipient_t::headers, and BSL_Data_t::len.
Referenced by BSLX_CoseMsg_RecipientList_Decode().
| void BSLX_CoseMsg_Recipient_Deinit | ( | BSLX_CoseMsg_Recipient_t * | obj | ) |
Deinitialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Deinit(), BSLX_CoseMsg_Headers_Deinit(), BSLX_CoseMsg_Recipient_t::ciphertext, and BSLX_CoseMsg_Recipient_t::headers.
| int BSLX_CoseMsg_Recipient_Encode | ( | QCBOREncodeContext * | enc, |
| const BSLX_CoseMsg_Recipient_t * | obj | ||
| ) |
Match BSL_CBOR_Encode_f signature.
References ASSERT_ARG_NONNULL, BSL_SUCCESS, BSLX_CoseMsg_Headers_Encode(), BSLX_CoseMsg_Recipient_t::ciphertext, BSLX_CoseMsg_Recipient_t::headers, and UsefulBufC_FROM_BSL_Data.
Referenced by BSLX_CoseMsg_RecipientList_Encode().
| void BSLX_CoseMsg_Recipient_Init | ( | BSLX_CoseMsg_Recipient_t * | obj | ) |
Initialize the struct.
References ASSERT_ARG_NONNULL, BSL_Data_Init(), BSLX_CoseMsg_Headers_Init(), BSLX_CoseMsg_Recipient_t::ciphertext, and BSLX_CoseMsg_Recipient_t::headers.
| void BSLX_CoseMsg_RecipientList_ResizeNew | ( | BSLX_CoseMsg_RecipientList_t | obj, |
| size_t | size | ||
| ) |
Resize recipients array, preserving existing if possible.
References ASSERT_ARG_NONNULL.
Referenced by BSLX_CoseMsg_RecipientList_Decode(), BSLX_CoseSc_Encrypt_Source(), and BSLX_CoseSc_Mac_Source().