BSL v1.1.1 - 50.g42e5d9b
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
CoseContext.h File Reference

Header for the implementation of the COSE context [17]. More...

+ Include dependency graph for CoseContext.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  BSLX_CoseSc_AadScope_Item_t
 Native C structure for each item of COSE Context AAD Scope. More...
 

Macros

#define BSLX_COSESC_CTX_ID   3
 Registered BPSec context ID.
 

Enumerations

enum  BSLX_CoseSc_Option_e {
  BSLX_COSESC_OPTION_KEY_ID = 3000 , BSLX_COSESC_OPTION_KEY_ALG , BSLX_COSESC_OPTION_TGT_ALG , BSLX_COSESC_OPTION_AAD_SCOPE ,
  BSLX_COSESC_OPTION_IV_COUNTER_OFFSET , BSLX_COSESC_OPTION_IV_BASE , BSLX_COSESC_OPTION_SALT_LENGTH , BSLX_COSESC_OPTION_SALT_COUNTER_OFFSET ,
  BSLX_COSESC_OPTION_SALT_BASE
}
 Internal option enumerations. More...
 
enum  BSLX_CoseSc_Param_e { BSLX_COSESC_PARAM_ADDL_PHDR = 3 , BSLX_COSESC_PARAM_ADDL_UHDR = 4 , BSLX_COSESC_PARAM_AAD_SCOPE = 5 }
 From https://www.ietf.org/archive/id/draft-ietf-dtn-bpsec-cose-16.html#section-2.2. More...
 
enum  BSLX_CoseSc_Result_e {
  BSLX_COSESC_RESULT_COSE_ENCRYPT0 = 16 , BSLX_COSESC_RESULT_COSE_MAC0 = 17 , BSLX_COSESC_RESULT_COSE_SIGN1 = 18 , BSLX_COSESC_RESULT_COSE_ENCRYPT = 96 ,
  BSLX_COSESC_RESULT_COSE_MAC = 97 , BSLX_COSESC_RESULT_COSE_SIGN = 98
}
 From https://www.ietf.org/archive/id/draft-ietf-dtn-bpsec-cose-16.html#section-2.3. More...
 
enum  BSLX_CoseSc_AadScope_Special_e { BSLX_COSESC_AADSCOPE_SPECIAL_TARGET = -1 , BSLX_COSESC_AADSCOPE_SPECIAL_SECURITY = -2 }
 Special keys for AAD Scope parameter. More...
 
enum  BSLX_CoseSc_AadScope_Flag_e { BSLX_COSESC_AADSCOPE_FLAG_METADATA = 0x1 , BSLX_COSESC_AADSCOPE_FLAG_BTSD = 0x2 }
 Flags for AAD Scope parameter. More...
 

Functions

int BSLX_CoseSc_SetAadScope (BSL_Variant_t *option, const BSLX_CoseSc_AadScope_Item_t *list, size_t count)
 Utility to set the BSLX_COSESC_OPTION_AAD_SCOPE option without exposing the encoding internals.
 
bool BSLX_CoseSc_Validate (BSL_LibCtx_t *lib, BSL_BundleRef_t *bundle, BSL_SecOper_t *sec_oper)
 Match signature BSL_SecCtx_Validate_f.
 
int BSLX_CoseSc_Execute (BSL_LibCtx_t *lib, BSL_BundleRef_t *bundle, BSL_SecOper_t *sec_oper)
 Match signature BSL_SecCtx_Execute_f.
 

Detailed Description

Header for the implementation of the COSE context [17].

Macro Definition Documentation

◆ BSLX_COSESC_CTX_ID

#define BSLX_COSESC_CTX_ID   3

Registered BPSec context ID.

Enumeration Type Documentation

◆ BSLX_CoseSc_AadScope_Flag_e

Flags for AAD Scope parameter.

Enumerator
BSLX_COSESC_AADSCOPE_FLAG_METADATA 

Include block header items in AAD.

BSLX_COSESC_AADSCOPE_FLAG_BTSD 

Include BTSD in AAD.

◆ BSLX_CoseSc_AadScope_Special_e

Special keys for AAD Scope parameter.

Enumerator
BSLX_COSESC_AADSCOPE_SPECIAL_TARGET 

Reference the security target block.

BSLX_COSESC_AADSCOPE_SPECIAL_SECURITY 

Reference the parent security block.

◆ BSLX_CoseSc_Option_e

Internal option enumerations.

Enumerator
BSLX_COSESC_OPTION_KEY_ID 

Key ID as a byte string.

The value is a byte string (which may contain encoded UTF8 text). Required for source and optional filter for verifier/acceptor. If they key algorithm is different than BSLX_COSESC_OPTION_TGT_ALG option, the key will be used for the recipient layer, otherwise it will be used for a single-layer message.

BSLX_COSESC_OPTION_KEY_ALG 

Optional recipient algorithm as an integer.

The value is a COSE algorithm code point (BSLX_CoseMsg_Alg_e). Optional for source and optional filter for verifier/acceptor. When not present, the key itself must have an algorithm parameter.

BSLX_COSESC_OPTION_TGT_ALG 

Content-layer algorithm as an integer.

The value is a COSE algorithm code point (BSLX_CoseMsg_Alg_e). Required for source and optional filter for verifier/acceptor.

BSLX_COSESC_OPTION_AAD_SCOPE 

AAD Scope as raw encoded data.

The value is encoded CBOR interpreted as BSLX_CoseSc_AadScope_t, and can use the BSLX_CoseSc_SetAadScope() helper in policy providers. Optional for source, optional exact-match for verifier/acceptor.

BSLX_COSESC_OPTION_IV_COUNTER_OFFSET 

An option to use the key telemetry counter (number of security operations performed) as the basis of a unique IV or Partial IV for encryption.

The value is an offset (as int64_t) to add to the counter which is then converted to a byte string in network byte order. When used as IV this is padded to the needed length, when used as Partial IV it is not padded. Optional for source and unused for verifier/acceptor.

BSLX_COSESC_OPTION_IV_BASE 

An option to define a Base IV outside a COSE key.

The value is a byte string used in the same way that RFC 9052 defines the Base IV of a key. When present, this base will not be visible in the messaging. Optional for source and unused for verifier/acceptor.

BSLX_COSESC_OPTION_SALT_LENGTH 

An option to select a salt length for KDF sources.

The value is a length in bytes (as int64_t) to generate a salt. Optional for source and unused for verifier/acceptor. When not present, the default salt length for the KDF algorithm will be used.

BSLX_COSESC_OPTION_SALT_COUNTER_OFFSET 

An option to use the key telemetry counter (number of security operations performed) as the basis of a unique salt for key derivation.

The value is an offset (as int64_t) to add to the counter which is then converted to a byte string in network byte order. When used as a salt this is not padded. Optional for source and unused for verifier/acceptor.

BSLX_COSESC_OPTION_SALT_BASE 

An option to define a base salt value (similar in function to a Base IV).

The value is a byte string used to determine the full salt length and XOR-ed with the salt counter. When present, this base will not be visible in the messaging. Optional for source and unused for verifier/acceptor.

◆ BSLX_CoseSc_Param_e

From https://www.ietf.org/archive/id/draft-ietf-dtn-bpsec-cose-16.html#section-2.2.

Enumerator
BSLX_COSESC_PARAM_ADDL_PHDR 

Additional Protected headers.

BSLX_COSESC_PARAM_ADDL_UHDR 

Additional Unprotected headers.

BSLX_COSESC_PARAM_AAD_SCOPE 

AAD Scope map.

◆ BSLX_CoseSc_Result_e

From https://www.ietf.org/archive/id/draft-ietf-dtn-bpsec-cose-16.html#section-2.3.

Enumerator
BSLX_COSESC_RESULT_COSE_ENCRYPT0 
BSLX_COSESC_RESULT_COSE_MAC0 
BSLX_COSESC_RESULT_COSE_SIGN1 
BSLX_COSESC_RESULT_COSE_ENCRYPT 
BSLX_COSESC_RESULT_COSE_MAC 
BSLX_COSESC_RESULT_COSE_SIGN 

Function Documentation

◆ BSLX_CoseSc_Execute()

◆ BSLX_CoseSc_SetAadScope()

int BSLX_CoseSc_SetAadScope ( BSL_Variant_t *  option,
const BSLX_CoseSc_AadScope_Item_t list,
size_t  count 
)

Utility to set the BSLX_COSESC_OPTION_AAD_SCOPE option without exposing the encoding internals.

Parameters
[in,out]optionPointer to the option to set the AAD Scope on.
[in]listPointer to an array of integer values, each subsequent pair of values is interpreted as a (key, value) in the scope map. The order of keys in this form is not significant.
countThe number of pairs of values in the list array.
Returns
BSL_SUCCESS if successful.

References ASSERT_ARG_NONNULL, BSL_CBOR_Encode_Twopass(), BSL_Data_Deinit(), BSL_Data_Init(), BSL_LOG_ERR, BSL_SUCCESS, BSL_Variant_SetRaw(), BSLX_CoseSc_AadScope_Encode(), BSLX_CoseSc_AadScope_Item_t::flags, BSLX_CoseSc_AadScope_Item_t::key, BSL_Data_t::len, and BSL_Data_t::ptr.

Referenced by BSLP_PolicyOptions_SC3(), 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().

◆ BSLX_CoseSc_Validate()