BSL v0.0.0 - 0.geda3e66
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
test_DefaultSecurityContext.c File Reference

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)
 

Variables

static BSL_TestContext_t LocalTestCtx
 

Detailed Description

Specific low-level tests of the Default Security Context.

Notes:

  • These tests use constructs defined in the BSL to exercise the Default Security Context
  • It uses test inputs and vectors from RFC9173 Appendix A.
  • It does NOT use any of the "Plumbing" inside the BSL.
  • It only directly calls the interfaces exposed by the Default Security Context.
  • BCB internally is functionally complete, however it needs better integration with BPA to overwrite BTSD.

Function Documentation

◆ test_RFC9173_AppendixA_Example1_BIB_Source()

void test_RFC9173_AppendixA_Example1_BIB_Source ( void  )

Purpose: Exercise BIB applying security to a target payload block.

Steps:

  • Get an unsecured bundle with a primary and payload block (From RFC9173)
  • Decode it into a BSL_BundleCtx struct
  • Create a BIB security operation with hard-coded arguments (From RFC9173 A1 ASB)
  • Run the DefaultSecuritContext's BSLX_BIB_Execute function and confirm result is 0.
  • Capture the outcome from the above function to confirm 1 result (the authentication code)
  • Capture the auth code and ensure it matches the value in the test vector.

Notes:

  • Common repeated patterns are in the process of being factored out
  • All values are drawn from RFC9173 Appendix A.

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 BSL_CALLOC, BSL_Crypto_SetRngGenerator(), BSL_FREE, BSL_SecOper_Deinit(), BSL_SECROLE_SOURCE, BSL_SUCCESS, and mock_bpa_ctr_t::bundle_ref.

◆ test_RFC9173_AppendixA_Example2_BCB_Acceptor()

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 BSL_BundleCtx_GetBlockMetadata(), BSL_CALLOC, BSL_FREE, BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_SecOper_Deinit(), BSL_SECROLE_ACCEPTOR, BSL_SUCCESS, BSL_CanonicalBlock_t::btsd, BSL_CanonicalBlock_t::btsd_len, and mock_bpa_ctr_t::bundle_ref.

◆ test_RFC9173_AppendixA_Example2_BCB_Source()

void test_RFC9173_AppendixA_Example2_BCB_Source ( void  )

Purpose: Exercise BCB applying security to a target payload block.

Steps:

  • Get an unsecured bundle with a primary and payload block (From RFC9173)
  • Decode it into a BSL_BundleCtx struct
  • Create a BCB security operation with hard-coded arguments (From RFC9173 A2 ASB)
  • Run the DefaultSecuritContext's BSLX_BCB_Execute function and confirm result is 0.
  • Capture the outcome from the above function to confirm 1 result (the auth tag) is present
  • Capture the auth tag and ensure it matches the value in the test vector.

Notes:

  • Incomplete since it does not modify the bundle BTSD (This still needs to be worked out)

References BSL_BundleCtx_GetBlockMetadata(), BSL_CALLOC, BSL_Crypto_SetRngGenerator(), BSL_FREE, BSL_Log_DumpAsHexString(), BSL_LOG_INFO, BSL_SecOper_Deinit(), BSL_SECROLE_SOURCE, BSL_SUCCESS, BSL_CanonicalBlock_t::btsd, BSL_CanonicalBlock_t::btsd_len, mock_bpa_ctr_t::bundle_ref, and RFC9173_BCB_RESULTID_AUTHTAG.