Skip to content

Commit

Permalink
[#197] Added aes_gcm_siv unit test files (utest throwing errors, in p…
Browse files Browse the repository at this point in the history
…rogress)
  • Loading branch information
Donnie-Ice committed Jul 18, 2024
1 parent a29dd8f commit 15c0364
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ set(PROJECT_TEST_DIR ${CMAKE_BINARY_DIR})
# COMMAND ${PROJECT_BINARY_DIR}/bin/process_security tc ${PROJECT_TEST_DIR}/data/tc4.1.dat
# WORKING_DIRECTORY ${PROJECT_TEST_DIR})

add_test(NAME UT_AES_GCM_SIV
COMMAND ${PROJECT_BINARY_DIR}/bin/ut_aes_gcm_siv
WORKING_DIRECTORY ${PROJECT_TEST_DIR})

add_test(NAME UT_TC_APPLY
COMMAND ${PROJECT_BINARY_DIR}/bin/ut_tc_apply
WORKING_DIRECTORY ${PROJECT_TEST_DIR})
Expand Down
18 changes: 18 additions & 0 deletions test/include/ut_aes_gcm_siv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef CRYPTOLIB_UT_AES_GCM_SIV_H
#define CRYPTOLIB_UT_AES_GCM_SIV_H

#ifdef __cplusplus
extern "C"
{
#endif

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

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

#endif //CRYPTOLIB_UT_AES_GCM_SIV_H
52 changes: 52 additions & 0 deletions test/unit/ut_aes_gcm_siv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// /* 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]
// */

#include "ut_aes_gcm_siv.h"
#include "crypto.h"
#include "crypto_error.h"
#include "sa_interface.h"
#include "utest.h"

/**
* @brief Unit Test: Crypto ECS Get Algorithm response for AES-GCM-SIV
**/
UTEST(AES_GCM_SIV, GET_ECS_ALGO_SIV)
{
remove("sa_save_file.bin");
int32_t libgcrypt_algo = -1;
int8_t crypto_algo = CRYPTO_CIPHER_AES256_GCM_SIV;

// Convert CRYPTOAES enum to GCRY_CIPHER_AES256
//libgcrypt_algo = cryptography_if->cryptography_get_ecs_algo(crypto_algo);
//ASSERT_EQ(libgcrypt_algo, GCRY_CIPHER_AES256);

libgcrypt_algo = cryptography_if->cryptography_get_ecs_algo(crypto_algo);
ASSERT_EQ(libgcrypt_algo, 9);
}

/**
* @brief Unit Test: Crypto ECS Get Algorithm key length response for AES-GCM-SIV
**/
UTEST(AES_GCM_SIV, GET_ECS_ALGO_KEY_LEN_SIV)
{
remove("sa_save_file.bin");
int32_t algo_keylen = -1;
uint8_t crypto_algo = CRYPTO_CIPHER_AES256_GCM_SIV;
algo_keylen = Crypto_Get_ACS_Algo_Keylen(crypto_algo);
ASSERT_EQ(algo_keylen, 32);
}

0 comments on commit 15c0364

Please sign in to comment.