|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
Specific low-level tests of the Default Security Context. More...
#include "DefaultScUtils.h"#include <bsl/BPSecLib_Private.h>#include <bsl/crypto/CryptoInterface.h>#include <bsl/dynamic/PublicInterfaceImpl.h>#include <bsl/default_sc/DefaultSecContext.h>#include <bsl/default_sc/DefaultSecContext_Private.h>#include <bsl/mock_bpa/MockBPA.h>#include <stdio.h>#include <stdlib.h>#include <unity.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 const char * | ApxA2_AuthTag = "efa4b5ac0108e3816c5606479801bc04" |
| static const char * | ApxA2_Ciphertext = "3a09c1e63fe23a7f66a59c7303837241e070b02619fc59c5214a22f08cd70795e73e9a" |
| static const char * | ApxA2_PayloadData = "526561647920746f2067656e657261746520612033322d62797465207061796c6f6164" |
| static BSL_TestContext_t | LocalTestCtx |
Specific low-level tests of the Default Security Context.
Notes:
| int rfc3394_cek | ( | unsigned char * | buf, |
| int | len | ||
| ) |
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 | ) |
References BSL_CryptoDeinit(), BSL_TestContext_Deinit(), LocalTestCtx, and TEST_ASSERT_EQUAL().
| 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 tag matches what is in the RFC
References BIBTestContext_Deinit(), BIBTestContext_Init(), BSL_TestContext_t::bsl, BSL_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_IdValPair_GetAsBytestr(), BSL_SecOper_CountResults(), BSL_SecOper_FindResult(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_InitBIB_AppendixA1(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BIB_Execute(), mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectors_AppendixA1::hex_bundle_original, RFC9173_TestVectors_AppendixA1::hex_hmac, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, RFC9173_BIB_RESULTID_HMAC, rfc9173_byte_gen_fn_a1(), RFC9173_EXAMPLE_A1_KEY, BIBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_TRUE().
| void test_RFC9173_AppendixA_Example2_BCB_Acceptor | ( | void | ) |
Confirm that BCB executes with SUCCESS
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_Data_Deinit(), BSL_DATA_INIT_VIEW, BSL_ExecBCBVerifierAcceptor(), BSL_SECROLE_ACCEPTOR, BSL_SUCCESS, BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_IsB16StrEqualTo(), 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::hex_bundle_bcb, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, RFC9173_TestVectors_AppendixA2, BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_TRUE().
| 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_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_DATA_INIT_VIEW, BSL_IdValPair_GetAsBytestr(), BSL_SecOper_CountResults(), BSL_SecOper_FindResult(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_InitBCB_Appendix2(), BSL_TestUtils_IsB16StrEqualTo(), 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::hex_bundle_original, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, RFC9173_BCB_RESULTID_AUTHTAG, rfc9173_byte_gen_fn_a2_cek(), BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_TRUE().
| 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_Crypto_AddRegistryKeyName(), BSL_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_Data_Init(), BSL_DATA_INIT_VIEW, BSL_ExecBCBVerifierAcceptor(), BSL_ExecBIBVerifierAcceptor(), BSL_IdValPair_SetInt64(), BSL_IdValPair_SetTextstr(), BSL_POLICYACTION_DROP_BLOCK, BSL_SECBLOCKTYPE_BCB, BSL_SECBLOCKTYPE_BIB, BSL_SecOper_AppendOption(), BSL_SecOper_Populate(), BSL_SECROLE_ACCEPTOR, BSL_SUCCESS, BSL_TestUtils_DecodeBase16_cstr(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), BSLX_BCB_OPT_AES_VARIANT, BSLX_BCB_OPT_KEY_ID, BSLX_BCB_OPT_SCOPE, BSLX_BCB_OPT_USE_KEY_WRAP, BSLX_BIB_Execute(), BSLX_BIB_OPT_KEY_ID, BSLX_BIB_OPT_SCOPE, BSLX_BIB_OPT_SHA_VARIANT, BSLX_BIB_OPT_USE_KEY_WRAP, 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::opt_aes_variant, BIBTestContext::opt_scope_flags, BCBTestContext::opt_scope_flags, BIBTestContext::opt_sha_variant, BIBTestContext::opt_test_key, BCBTestContext::opt_test_key_id, BIBTestContext::opt_use_key_wrap, BCBTestContext::opt_use_key_wrap, BSL_Data_t::ptr, rfc3394_cek(), RFC9173_BCB_AADSCOPEFLAGID_INC_NONE, RFC9173_BCB_AES_VARIANT_A128GCM, RFC9173_BIB_SHA_HMAC512, BIBTestContext::sec_oper, BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_TRUE().
| 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_Crypto_AddRegistryKeyName(), BSL_Crypto_SetRngGenerator(), BSL_Data_Deinit(), BSL_Data_Init(), BSL_DATA_INIT_VIEW, BSL_IdValPair_GetAsBytestr(), BSL_IdValPair_SetInt64(), BSL_IdValPair_SetTextstr(), BSL_POLICYACTION_DROP_BLOCK, BSL_SECBLOCKTYPE_BCB, BSL_SECBLOCKTYPE_BIB, BSL_SecOper_AppendOption(), BSL_SecOper_CountResults(), BSL_SecOper_FindParam(), BSL_SecOper_FindResult(), BSL_SecOper_Populate(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_TestUtils_DecodeBase16_cstr(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), BSLX_BCB_Execute(), BSLX_BCB_OPT_AES_VARIANT, BSLX_BCB_OPT_KEY_ID, BSLX_BCB_OPT_SCOPE, BSLX_BCB_OPT_USE_KEY_WRAP, BSLX_BIB_Execute(), BSLX_BIB_OPT_KEY_ID, BSLX_BIB_OPT_SCOPE, BSLX_BIB_OPT_SHA_VARIANT, BSLX_BIB_OPT_USE_KEY_WRAP, MockBPA_CanonicalBlock_t::btsd, MockBPA_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle, mock_bpa_ctr_t::bundle_ref, RFC9173_TestVectors_AppendixA1::hex_bundle_original, BSL_Data_t::len, LocalTestCtx, BSL_TestContext_t::mock_bpa_ctr, BCBTestContext::opt_aes_variant, BIBTestContext::opt_scope_flags, BCBTestContext::opt_scope_flags, BIBTestContext::opt_sha_variant, BIBTestContext::opt_test_key, BCBTestContext::opt_test_key_id, BIBTestContext::opt_use_key_wrap, BCBTestContext::opt_use_key_wrap, BSL_Data_t::ptr, rfc3394_cek(), RFC9173_BCB_AADSCOPEFLAGID_INC_NONE, RFC9173_BCB_AES_VARIANT_A128GCM, RFC9173_BCB_RESULTID_AUTHTAG, RFC9173_BCB_SECPARAM_WRAPPEDKEY, RFC9173_BIB_PARAMID_WRAPPED_KEY, RFC9173_BIB_RESULTID_HMAC, RFC9173_BIB_SHA_HMAC512, BIBTestContext::sec_oper, BCBTestContext::sec_oper, TEST_ASSERT_EQUAL(), and TEST_ASSERT_TRUE().
|
static |
Referenced by test_RFC9173_AppendixA_Example2_BCB_Source().
|
static |
Referenced by test_RFC9173_AppendixA_Example2_BCB_Source().
|
static |
Referenced by test_RFC9173_AppendixA_Example2_BCB_Acceptor().