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

Declaration of a variant-type container for options, parameters, and results. More...

#include "bsl/BPSecLib_Private.h"
#include "bsl/dynamic/CBOR.h"
#include <m-array.h>
#include <m-bptree.h>
#include <m-bstring.h>
#include <m-shared-ptr.h>
#include <stdint.h>
+ Include dependency graph for Variant.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  BSL_Variant_t
 Represents a security option, parameter, or result within in an ASB. More...
 

Macros

#define M_OPL_BSL_Variant_t()
 OPLIST for BSL_Variant_s.
 

Enumerations

enum  BSLB_Variant_Type_e {
  BSLB_VARIANT_TYPE_UNKNOWN = 0 , BSLB_VARIANT_TYPE_INT64 , BSLB_VARIANT_TYPE_BYTESTR , BSLB_VARIANT_TYPE_TEXTSTR ,
  BSLB_VARIANT_TYPE_RAW
}
 Types of values in BSL_Variant_s. More...
 

Functions

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.
 
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.
 
static BSL_Variant_t * BSLB_VariantPtrMap_add (BSLB_VariantPtrMap_t map, int64_t key)
 Workaround default shared-ptr INIT being a NULL pointer.
 

Detailed Description

Declaration of a variant-type container for options, parameters, and results.

Declaration of an (id, value) pair container.

The details from the RFC Section 3.6 [1] are as follows:

This field captures one or more security context parameters that should be used when processing the security service described by this security block. This field SHALL be represented by a CBOR array. Each entry in this array is a single security context parameter. A single parameter SHALL also be represented as a CBOR array comprising a 2-tuple of the Id and value of the parameter, as follows.

Parameter Id:

  • This field identifies which parameter is being specified.
  • This field SHALL be represented as a CBOR unsigned integer.
  • Parameter Ids are selected as described in Section 3.10.

Parameter Value:

  • This field captures the value associated with this parameter.
  • This field SHALL be represented by the applicable CBOR representation of the parameter, in accordance with Section 3.10.

Author
Bill..nosp@m.Van..nosp@m.Besie.nosp@m.n@jh.nosp@m.uapl..nosp@m.edu

Macro Definition Documentation

◆ M_OPL_BSL_Variant_t

#define M_OPL_BSL_Variant_t ( )
Value:
(INIT(API_2(BSL_Variant_Init)), INIT_SET(API_6(BSL_Variant_InitSet)), INIT_MOVE(0), \
CLEAR(API_2(BSL_Variant_Deinit)), SET(API_6(BSL_Variant_Set)), MOVE(API_6(BSL_Variant_Move)))
void BSL_Variant_Init(BSL_Variant_t *self)
Initialize to a default empty state.
Definition Variant.c:34
void BSL_Variant_InitSet(BSL_Variant_t *self, const BSL_Variant_t *src)
Initialize to a copy of another value.
Definition Variant.c:41
void BSL_Variant_Set(BSL_Variant_t *self, const BSL_Variant_t *src)
Overwrite with a copy of another value.
Definition Variant.c:70
void BSL_Variant_Deinit(BSL_Variant_t *self)
De-initialize a parameter.
Definition Variant.c:51
void BSL_Variant_Move(BSL_Variant_t *self, BSL_Variant_t *src)
Move from another value.
Definition Variant.c:107

OPLIST for BSL_Variant_s.

Enumeration Type Documentation

◆ BSLB_Variant_Type_e

Types of values in BSL_Variant_s.

Security options, parameters, and results defined in RFC9173 may be unsigned integers or bytestrings.

Enumerator
BSLB_VARIANT_TYPE_UNKNOWN 

Indicates parsed value not of expected type.

BSLB_VARIANT_TYPE_INT64 

Indicates value type is a signed integer.

BSLB_VARIANT_TYPE_BYTESTR 

Indicates the value is a byte string.

BSLB_VARIANT_TYPE_TEXTSTR 

Indicates the value is a text string.

BSLB_VARIANT_TYPE_RAW 

Indicates the value is raw encoded bytes.

Function Documentation

◆ BSL_Variant_Decode()

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().

◆ BSL_Variant_Encode()

void BSL_Variant_Encode ( QCBOREncodeContext *  enc,
const BSL_Variant_t *  pair 
)

◆ BSLB_VariantPtrMap_add()

static BSL_Variant_t * BSLB_VariantPtrMap_add ( BSLB_VariantPtrMap_t  map,
int64_t  key 
)
inlinestatic

Workaround default shared-ptr INIT being a NULL pointer.

Parameters
[in,out]mapThe map to ensure a specific key exists in.
keyThe key to add or update.
Returns
A non-null pointer to a value in the map.

References BSL_LOG_WARNING.

Referenced by BSL_AbsSecBlock_Decode(), BSL_SecOper_AddOption(), BSL_SecOper_AddParam(), BSL_SecOper_AddResult(), BSLP_PolicyOptions_SC1(), BSLP_PolicyOptions_SC2(), BSLP_PolicyOptions_SC3(), BSLP_PolicyRule_AddOption(), and BSLP_RegisterPolicyFromBitstring().