BSL v1.1.1 - 64.gc92ac12
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
BIB_HMAC_SHA2.c File Reference

Header for the implementation of an example default security context (RFC 9173). More...

#include "DefaultSecContext.h"
#include "DefaultSecContext_Private.h"
#include "rfc9173.h"
#include "bsl/BPSecLib_Private.h"
#include "bsl/crypto/CryptoInterface.h"
#include "bsl/dynamic/CBOR.h"
#include <qcbor/qcbor_encode.h>
#include <qcbor/qcbor_spiffy_decode.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
+ Include dependency graph for BIB_HMAC_SHA2.c:

Functions

bool BSLX_BIB_Validate (BSL_LibCtx_t *lib, BSL_BundleRef_t *bundle, BSL_SecOper_t *sec_oper)
 Match signature BSL_SecCtx_Validate_f.
 
static BSL_Crypto_SHAVariant_e map_rfc9173_sha_variant_to_crypto (uint64_t rfc9173_sha_variant)
 Provides the mapping from the security-context-specific ID defined in RFC9173 to the local ID of the SHA variant used by the crypto engine (OpenSSL).
 
int BSLX_BIB_InitFromSecOper (BSLX_BIB_t *self, const BSL_BundleRef_t *bundle, const BSL_SecOper_t *sec_oper)
 Populate the BIB parameters convenience struct from the security operation struct.
 
void BSLX_BIB_Deinit (BSLX_BIB_t *self)
 
int BSLX_BIB_GenIPPT (const BSLX_BIB_t *self, BSL_Data_t *ippt_space)
 Computes the Integrity-Protected Plaintext (IPPT) according to Section 3.7 of RFC 9173 [2].
 
int BSLX_BIB_GenHMAC (BSLX_BIB_t *self, const BSL_Data_t *ippt_data)
 Performs the actual HMAC over the given IPPT, placing the result in hmac_result.
 
int BSLX_BIB_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 an example default security context (RFC 9173).

Note the prefix "xdefsc" means "Example Default Security Context".

Function Documentation

◆ BSLX_BIB_Deinit()

◆ BSLX_BIB_Execute()

int BSLX_BIB_Execute ( BSL_LibCtx_t *  lib,
BSL_BundleRef_t bundle,
BSL_SecOper_t *  sec_oper 
)

Match signature BSL_SecCtx_Execute_f.

References BSL_BundleCtx_GetBlockMetadata(), BSL_BundleCtx_GetBundleMetadata(), BSL_Crypto_Compare(), BSL_Data_Deinit(), BSL_DATA_INIT_NULL, BSL_Data_InitBuffer(), BSL_ERR_SECURITY_CONTEXT_FAILED, BSL_LOG_DEBUG, BSL_LOG_ERR, BSL_LOG_WARNING, BSL_SecOper_AddParam(), BSL_SecOper_AddResult(), BSL_SecOper_FindParam(), BSL_SecOper_FindResult(), BSL_SecOper_GetSecurityBlockNum(), BSL_SecOper_GetTargetBlockNum(), BSL_SecOper_IsConsistent(), BSL_SUCCESS, BSL_Variant_GetAsBytestr(), BSL_Variant_GetAsInt64(), BSL_Variant_IsBytestr(), BSL_Variant_SetBytestr(), BSL_Variant_SetInt64(), BSLX_BIB_Deinit(), BSLX_BIB_GenHMAC(), BSLX_BIB_GenIPPT(), BSLX_BIB_InitFromSecOper(), CHK_ARG_NONNULL, CHK_PRECONDITION, CHK_PROPERTY, BSLX_BIB_t::crypto_sha_variant, BSLX_BIB_t::err_count, BSLX_BIB_t::hmac_result_val, BSLX_BIB_t::ippt_scope, BSLX_BIB_t::is_source, BSLX_BIB_t::keywrap, BSL_Data_t::len, map_rfc9173_sha_variant_to_crypto(), BSLX_BIB_t::opt_ippt_scope, BSLX_BIB_t::opt_keywrap, BSLX_BIB_t::opt_sha_variant, BSLX_BIB_t::primary_block, BSL_Data_t::ptr, RFC9173_BIB_PARAMID_INTEG_SCOPE_FLAG, RFC9173_BIB_PARAMID_SHA_VARIANT, RFC9173_BIB_PARAMID_WRAPPED_KEY, RFC9173_BIB_RESULTID_HMAC, RFC9173_BIB_SHA_HMAC384, BSLX_BIB_t::sec_block, BSLX_BIB_t::sha_variant, BSLX_BIB_t::target_block, and BSLX_BIB_t::wrapped_key.

Referenced by BSL_TestUtils_SetupDefaultSecurityContext(), MockBPA_Agent_Init(), test_RFC9173_AppendixA_Example1_BIB_Source(), test_sec_accept_keyunwrap(), and test_sec_source_keywrap().

◆ BSLX_BIB_GenHMAC()

◆ BSLX_BIB_GenIPPT()

◆ BSLX_BIB_InitFromSecOper()

◆ BSLX_BIB_Validate()

bool BSLX_BIB_Validate ( BSL_LibCtx_t *  lib,
BSL_BundleRef_t bundle,
BSL_SecOper_t *  sec_oper 
)

◆ map_rfc9173_sha_variant_to_crypto()

static BSL_Crypto_SHAVariant_e map_rfc9173_sha_variant_to_crypto ( uint64_t  rfc9173_sha_variant)
static

Provides the mapping from the security-context-specific ID defined in RFC9173 to the local ID of the SHA variant used by the crypto engine (OpenSSL).

References BSL_CRYPTO_SHA_256, BSL_CRYPTO_SHA_384, BSL_CRYPTO_SHA_512, BSL_LOG_DEBUG, BSL_LOG_ERR, RFC9173_BIB_SHA_HMAC256, RFC9173_BIB_SHA_HMAC384, and RFC9173_BIB_SHA_HMAC512.

Referenced by BSLX_BIB_Execute(), and BSLX_BIB_InitFromSecOper().