Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Coverage Updates #53

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/utest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ jobs:
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
- name: Test-TC_APPLY
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ${{github.workspace}}/build/bin/ut_tc_apply

- name: Test-CRYPTO_CONFIG
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ${{github.workspace}}/build/bin/ut_crypto_config



5 changes: 3 additions & 2 deletions src/src_main/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ int32_t Crypto_compare_less_equal(uint8_t *actual, uint8_t *expected, int length
uint8_t Crypto_Prep_Reply(uint8_t *ingest, uint8_t appID)
{
uint8_t count = 0;

if(ingest == NULL) return count;

// Prepare CCSDS for reply
sdls_frame.hdr.pvn = 0;
sdls_frame.hdr.type = 0;
Expand Down Expand Up @@ -576,7 +577,7 @@ int32_t Crypto_PDU(uint8_t *ingest, TC_t *tc_frame)
}

#ifdef CCSDS_DEBUG
if (status > 0)
if ((status > 0) && (ingest != NULL))
{
printf(KMAG "CCSDS message put on software bus: 0x" RESET);
for (int x = 0; x < status; x++)
Expand Down
7 changes: 3 additions & 4 deletions src/src_main/crypto_key_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int32_t Crypto_Key_inventory(uint8_t *ingest)
uint16_t range = 0;
crypto_key_t* ek_ring = cryptography_if->get_ek_ring();

if ( ek_ring == NULL )
if ( ek_ring == NULL || ingest == NULL)
{
return CRYPTOGRAPHY_UNSUPPORTED_OPERATION_FOR_KEY_RING;
}
Expand Down Expand Up @@ -330,7 +330,7 @@ int32_t Crypto_Key_verify(uint8_t *ingest, TC_t *tc_frame)
#ifdef PDU_DEBUG
printf("Crypto_Key_verify: Requested %d key(s) to verify \n", pdu_keys);
#endif

// Read in PDU
for (int x = 0; x < pdu_keys; x++)
{
Expand All @@ -349,13 +349,12 @@ int32_t Crypto_Key_verify(uint8_t *ingest, TC_t *tc_frame)
printf("\n");
#endif
}

// Prepare for Reply
sdls_frame.pdu.pdu_len = pdu_keys * (2 + IV_SIZE + CHALLENGE_SIZE + CHALLENGE_MAC_SIZE);
sdls_frame.hdr.pkt_length = sdls_frame.pdu.pdu_len + 9;
count = Crypto_Prep_Reply(ingest, 128);
crypto_key_t* ek_ring = cryptography_if->get_ek_ring();

if ( ek_ring == NULL ) // Can't verify key without a key ring, action supported for this cryptography interface!
{
return CRYPTOGRAPHY_UNSUPPORTED_OPERATION_FOR_KEY_RING;
Expand Down
5 changes: 5 additions & 0 deletions src/src_main/crypto_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int32_t Crypto_MC_ping(uint8_t *ingest)
**/
int32_t Crypto_MC_status(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;
int count = 0;

// TODO: Update log_summary.rs;
Expand Down Expand Up @@ -78,6 +79,7 @@ int32_t Crypto_MC_status(uint8_t *ingest)
**/
int32_t Crypto_MC_dump(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;
int count = 0;

// Prepare for Reply
Expand Down Expand Up @@ -113,6 +115,7 @@ int32_t Crypto_MC_dump(uint8_t *ingest)
**/
int32_t Crypto_MC_erase(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;
int count = 0;

// Zero Logs
Expand Down Expand Up @@ -152,6 +155,7 @@ int32_t Crypto_MC_erase(uint8_t *ingest)
**/
int32_t Crypto_MC_selftest(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;
uint8_t count = 0;
uint8_t result = ST_OK;

Expand All @@ -174,6 +178,7 @@ int32_t Crypto_MC_selftest(uint8_t *ingest)
**/
int32_t Crypto_SA_readARSN(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;
uint8_t count = 0;
uint16_t spi = 0x0000;
SecurityAssociation_t *sa_ptr;
Expand Down
1 change: 1 addition & 0 deletions src/src_main/crypto_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, const uint16_t in_fra
printf(KYEL "DEBUG - Received Control/Command frame - nothing to do.\n" RESET);
#endif
status = CRYPTO_LIB_ERR_INVALID_CC_FLAG;
return status;
}

if (status == CRYPTO_LIB_SUCCESS)
Expand Down
2 changes: 2 additions & 0 deletions src/src_main/sadb_routine_inmemory.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ static int32_t sadb_sa_setARSNW(void)
**/
static int32_t sadb_sa_status(uint8_t *ingest)
{
if(ingest == NULL) return CRYPTO_LIB_ERROR;

// Local variables
int count = 0;
uint16_t spi = 0x0000;
Expand Down
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ add_test(NAME UT_TC_APPLY
COMMAND ${PROJECT_BINARY_DIR}/bin/ut_tc_apply
WORKING_DIRECTORY ${PROJECT_TEST_DIR})

add_test(NAME UT_CRYPTO_CONFIG
COMMAND ${PROJECT_BINARY_DIR}/bin/ut_crypto_config
WORKING_DIRECTORY ${PROJECT_TEST_DIR})

add_test(NAME UT_CRYPTO
COMMAND ${PROJECT_BINARY_DIR}/bin/ut_crypto
WORKING_DIRECTORY ${PROJECT_TEST_DIR})

if(${ENCTEST})
add_test(NAME ET_DT_VALIDATION
COMMAND ${PROJECT_BINARY_DIR}/bin/et_dt_validation
Expand Down
35 changes: 35 additions & 0 deletions util/include/ut_crypto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.
All Foreign Rights are Reserved to the U.S. Government.

This software is provided "as is" without any warranty of any kind, either expressed, implied, or statutory,
including, but not limited to, any warranty that the software will conform to specifications, any implied warranties
of merchantability, fitness for a particular purpose, and freedom from infringement, and any warranty that the
documentation will conform to the program, or any warranty that the software will be error free.

In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or
consequential damages, arising out of, resulting from, or in any way connected with the software or its
documentation, whether or not based upon warranty, contract, tort or otherwise, and whether or not loss was sustained
from, or arose out of the results of, or use of, the software, documentation or services provided hereunder.

ITC Team
NASA IV&V
[email protected]
*/

#ifndef CRYPTOLIB_UT_CRYPTO_H
#define CRYPTOLIB_UT_CRYPTO_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "crypto.h"
#include "shared_util.h"
#include <stdio.h>

#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif

#endif // CRYPTOLIB_UT_CRYPTO_H
35 changes: 35 additions & 0 deletions util/include/ut_crypto_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.
All Foreign Rights are Reserved to the U.S. Government.

This software is provided "as is" without any warranty of any kind, either expressed, implied, or statutory,
including, but not limited to, any warranty that the software will conform to specifications, any implied warranties
of merchantability, fitness for a particular purpose, and freedom from infringement, and any warranty that the
documentation will conform to the program, or any warranty that the software will be error free.

In no event shall NASA be liable for any damages, including, but not limited to direct, indirect, special or
consequential damages, arising out of, resulting from, or in any way connected with the software or its
documentation, whether or not based upon warranty, contract, tort or otherwise, and whether or not loss was sustained
from, or arose out of the results of, or use of, the software, documentation or services provided hereunder.

ITC Team
NASA IV&V
[email protected]
*/

#ifndef CRYPTOLIB_UT_CRYPTO_CONFIG_H
#define CRYPTOLIB_UT_CRYPTO_CONFIG_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "crypto.h"
#include "shared_util.h"
#include <stdio.h>

#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif

#endif // CRYPTOLIB_UT_CRYPTO_CONFIG_H
Loading