|
BSL v1.0.0 - 16.g9d98179
AMMOS Bundle Protocol Security Library (BSL)
|
Specific low-level tests of the Default Security Context. More...
#include <stdlib.h>#include <stdio.h>#include <unity.h>#include <BPSecLib_Private.h>#include <mock_bpa/MockBPA.h>#include <CryptoInterface.h>#include <backend/PublicInterfaceImpl.h>#include <security_context/DefaultSecContext.h>#include <security_context/DefaultSecContext_Private.h>#include <security_context/rfc9173.h>#include "bsl_test_utils.h"
Include dependency graph for test_DefaultSecurityContext.c:Functions | |
| void | suiteSetUp (void) |
| int | suiteTearDown (int failures) |
| void | setUp (void) |
| void | tearDown (void) |
| void | test_RFC9173_AppendixA_Example1_BIB_Source (void) |
| Purpose: Exercise BIB applying security to a target payload block. | |
| void | test_RFC9173_AppendixA_Example2_BCB_Source (void) |
| Purpose: Exercise BCB applying security to a target payload block. | |
| void | test_RFC9173_AppendixA_Example2_BCB_Acceptor (void) |
| int | rfc3394_cek (unsigned char *buf, int len) |
| void | test_sec_source_keywrap (bool wrap, bool bib) |
| void | test_sec_accept_keyunwrap (bool bib) |
Variables | |
| static BSL_TestContext_t | LocalTestCtx |
Specific low-level tests of the Default Security Context.
Notes:
| int rfc3394_cek | ( | unsigned char * | buf, |
| int | len | ||
| ) |
References buf.
Referenced by test_sec_accept_keyunwrap(), and test_sec_source_keywrap().
| void setUp | ( | void | ) |
| void suiteSetUp | ( | void | ) |
| int suiteTearDown | ( | int | failures | ) |
References BSL_HostDescriptors_Clear(), and mock_bpa_LogClose().
| void tearDown | ( | void | ) |
| void test_RFC9173_AppendixA_Example1_BIB_Source | ( | void | ) |
Purpose: Exercise BIB applying security to a target payload block.
Steps:
Notes:
Confirm running BIB as source executes without error
Confirm it produced only 1 result
Confirm the context and result result is the right ID (Defined in RFC)
Confirm the actual HMAC signature matches what is in the RFC
References ApxA1_HMAC, BIBTestContext_Deinit(), BIBTestContext_Init(), BSL_TestContext_t::bsl, BSL_calloc(), BSL_Crypto_SetRngGenerator(), BSL_free(), BSL_SecOutcome_CountResults(), BSL_SecOutcome_Deinit(), BSL_SecOutcome_GetResultAtIndex(), BSL_SecOutcome_Init(), BSL_SecOutcome_Sizeof(), BSL_SecResult_GetAsBytestr(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_InitBIB_AppendixA1(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BIB_Execute(), mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectors_AppendixA1::cbor_bundle_original, BSL_Data_t::len, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, BSL_Data_t::ptr, RFC9173_BIB_RESULTID_HMAC, rfc9173_byte_gen_fn_a1(), RFC9173_CONTEXTID_BIB_HMAC_SHA2, RFC9173_EXAMPLE_A1_KEY, BIBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_EQUAL_MEMORY().
| void test_RFC9173_AppendixA_Example2_BCB_Acceptor | ( | void | ) |
Confirm that BCB executes with SUCCESS
Confirm that running as ACCEPTOR consumes result.
Confirm that the target block is decrypted correctly.
References ApxA2_PayloadData, BCBTestContext_Deinit(), BCBTestContext_Init(), MockBPA_Bundle_t::blocks_num, BSL_TestContext_t::bsl, BSL_calloc(), BSL_free(), BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_SecOutcome_CountResults(), BSL_SecOutcome_Deinit(), BSL_SecOutcome_Init(), BSL_SecOutcome_Sizeof(), BSL_SECROLE_ACCEPTOR, BSL_SUCCESS, BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), MockBPA_CanonicalBlock_t::btsd, MockBPA_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle, mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectorsA2::cbor_bundle_bcb, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, RFC9173_TestVectors_AppendixA2, BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_EQUAL_MEMORY().
| void test_RFC9173_AppendixA_Example2_BCB_Source | ( | void | ) |
Purpose: Exercise BCB applying security to a target payload block.
Steps:
Notes:
References ApxA2_AuthTag, ApxA2_Ciphertext, BCBTestContext_Deinit(), BCBTestContext_Init(), MockBPA_Bundle_t::blocks_num, BSL_TestContext_t::bsl, BSL_calloc(), BSL_Crypto_SetRngGenerator(), BSL_free(), BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_SecOutcome_CountResults(), BSL_SecOutcome_Deinit(), BSL_SecOutcome_GetResultAtIndex(), BSL_SecOutcome_Init(), BSL_SecOutcome_Sizeof(), BSL_SecResult_GetAsBytestr(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), MockBPA_CanonicalBlock_t::btsd, MockBPA_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle, mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectors_AppendixA1::cbor_bundle_original, BSL_Data_t::len, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, BSL_Data_t::ptr, RFC9173_BCB_RESULTID_AUTHTAG, rfc9173_byte_gen_fn_a2_cek(), BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_EQUAL_MEMORY().
| void test_sec_accept_keyunwrap | ( | bool | bib | ) |
References BCBTestContext_Deinit(), BCBTestContext_Init(), BIBTestContext_Deinit(), BIBTestContext_Init(), MockBPA_Bundle_t::blocks_num, BSL_TestContext_t::bsl, BSL_calloc(), BSL_Crypto_AddRegistryKey(), BSL_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_Data_Init(), BSL_free(), BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_POLICYACTION_DROP_BLOCK, BSL_SECBLOCKTYPE_BCB, BSL_SECBLOCKTYPE_BIB, BSL_SecOper_AppendParam(), BSL_SecOper_Populate(), BSL_SecOutcome_Deinit(), BSL_SecOutcome_Init(), BSL_SecOutcome_Sizeof(), BSL_SecParam_InitBytestr(), BSL_SecParam_InitInt64(), BSL_SecParam_InitTextstr(), BSL_SECPARAM_TYPE_AUTH_TAG, BSL_SECPARAM_TYPE_KEY_ID, BSL_SECPARAM_USE_KEY_WRAP, BSL_SECROLE_ACCEPTOR, BSL_SUCCESS, BSL_TestUtils_DecodeBase16(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), MockBPA_CanonicalBlock_t::btsd, MockBPA_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle, mock_bpa_ctr_t::bundle_ref, BSL_Data_t::len, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, BCBTestContext::param_aes_variant, BCBTestContext::param_auth_tag, BCBTestContext::param_init_vec, BIBTestContext::param_scope_flags, BCBTestContext::param_scope_flags, BIBTestContext::param_sha_variant, BIBTestContext::param_test_key, BCBTestContext::param_test_key_id, BIBTestContext::param_wrapped_key, BCBTestContext::param_wrapped_key, BSL_Data_t::ptr, rfc3394_cek(), RFC9173_BCB_AADSCOPEFLAGID_INC_NONE, RFC9173_BCB_AES_VARIANT_A128GCM, RFC9173_BCB_SECPARAM_AADSCOPE, RFC9173_BCB_SECPARAM_AESVARIANT, RFC9173_BCB_SECPARAM_IV, RFC9173_BCB_SECPARAM_WRAPPEDKEY, RFC9173_BIB_PARAMID_INTEG_SCOPE_FLAG, RFC9173_BIB_PARAMID_SHA_VARIANT, RFC9173_BIB_PARAMID_WRAPPED_KEY, RFC9173_BIB_SHA_HMAC512, BIBTestContext::sec_oper, BCBTestContext::sec_oper, string_clear(), string_init_set_str(), TEST_ASSERT_EQUAL(), TEST_ASSERT_EQUAL_MEMORY(), BIBTestContext::use_key_wrap, and BCBTestContext::use_key_wrap.
| void test_sec_source_keywrap | ( | bool | wrap, |
| bool | bib | ||
| ) |
References BCBTestContext_Deinit(), BCBTestContext_Init(), BIBTestContext_Deinit(), BIBTestContext_Init(), MockBPA_Bundle_t::blocks_num, BSL_TestContext_t::bsl, BSL_calloc(), BSL_Crypto_AddRegistryKey(), BSL_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_Data_Init(), BSL_free(), BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_POLICYACTION_DROP_BLOCK, BSL_SECBLOCKTYPE_BCB, BSL_SECBLOCKTYPE_BIB, BSL_SecOper_AppendParam(), BSL_SecOper_Populate(), BSL_SecOutcome_CountParams(), BSL_SecOutcome_CountResults(), BSL_SecOutcome_Deinit(), BSL_SecOutcome_GetParamAt(), BSL_SecOutcome_GetResultAtIndex(), BSL_SecOutcome_Init(), BSL_SecOutcome_Sizeof(), BSL_SecParam_GetAsBytestr(), BSL_SecParam_InitInt64(), BSL_SecParam_InitTextstr(), BSL_SECPARAM_TYPE_KEY_ID, BSL_SECPARAM_USE_KEY_WRAP, BSL_SecResult_GetAsBytestr(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_DecodeBase16(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), BSLX_BIB_Execute(), MockBPA_CanonicalBlock_t::btsd, MockBPA_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle, mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectors_AppendixA1::cbor_bundle_original, BSL_Data_t::len, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, BCBTestContext::param_aes_variant, BIBTestContext::param_scope_flags, BCBTestContext::param_scope_flags, BIBTestContext::param_sha_variant, BIBTestContext::param_test_key, BCBTestContext::param_test_key_id, BSL_Data_t::ptr, rfc3394_cek(), RFC9173_BCB_AADSCOPEFLAGID_INC_NONE, RFC9173_BCB_AES_VARIANT_A128GCM, RFC9173_BCB_RESULTID_AUTHTAG, RFC9173_BCB_SECPARAM_AADSCOPE, RFC9173_BCB_SECPARAM_AESVARIANT, RFC9173_BCB_SECPARAM_WRAPPEDKEY, RFC9173_BIB_PARAMID_INTEG_SCOPE_FLAG, RFC9173_BIB_PARAMID_SHA_VARIANT, RFC9173_BIB_PARAMID_WRAPPED_KEY, RFC9173_BIB_RESULTID_HMAC, RFC9173_BIB_SHA_HMAC512, BIBTestContext::sec_oper, BCBTestContext::sec_oper, string_clear(), string_init_set_str(), TEST_ASSERT_EQUAL(), TEST_ASSERT_EQUAL_INT(), TEST_ASSERT_EQUAL_MEMORY(), BIBTestContext::use_key_wrap, and BCBTestContext::use_key_wrap.