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

150 conditional error code review #400

Merged
merged 3 commits into from
Feb 5, 2025
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
1 change: 1 addition & 0 deletions include/crypto.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.

Check notice on line 1 in include/crypto.h

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/crypto.h

File include/crypto.h does not conform to Custom style guidelines. (lines 139, 140, 141, 142, 236, 323, 325, 326, 327, 337)
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,
Expand Down Expand Up @@ -245,6 +245,7 @@
int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t *sa_ptr, uint8_t *arsn, uint8_t *iv);
int32_t Crypto_Get_ECS_Algo_Keylen(uint8_t algo);
int32_t Crypto_Get_ACS_Algo_Keylen(uint8_t algo);
uint8_t Crypto_Is_ACS_Only_Algo(uint8_t algo);

int32_t Crypto_Check_Anti_Replay_Verify_Pointers(SecurityAssociation_t *sa_ptr, uint8_t *arsn, uint8_t *iv);
int32_t Crypto_Check_Anti_Replay_ARSNW(SecurityAssociation_t *sa_ptr, uint8_t *arsn, int8_t *arsn_valid);
Expand Down
3 changes: 2 additions & 1 deletion include/crypto_config_structs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.

Check notice on line 1 in include/crypto_config_structs.h

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/crypto_config_structs.h

File include/crypto_config_structs.h does not conform to Custom style guidelines. (lines 247, 248, 249, 250, 252, 253, 254, 255, 257, 268, 269, 271, 272, 273, 274, 275, 276, 277, 278, 290, 291, 292, 293, 294)
All Foreign Rights are Reserved to the U.S. Government.

This software is provided "as is" without any warranty of any, kind either express, implied, or statutory, including,
Expand Down Expand Up @@ -184,7 +184,8 @@
CRYPTO_MAC_NONE,
CRYPTO_MAC_CMAC_AES256,
CRYPTO_MAC_HMAC_SHA256,
CRYPTO_MAC_HMAC_SHA512
CRYPTO_MAC_HMAC_SHA512,
CRYPTO_ACS_MAX = 3
} AuthCipherSuite;
typedef enum
{
Expand Down
15 changes: 15 additions & 0 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ uint8_t Crypto_Is_AEAD_Algorithm(uint32_t cipher_suite_id)
return status;
}

/**
* @brief Function: Crypto_Is_ACS_Only_Algo
* Looks up cipher suite ID and determines if it's an ACS algorithm. Returns 1 if true, 0 if false;
* @param cipher_suite_id: uint8_t
* @return int: Success/Failure
**/
uint8_t Crypto_Is_ACS_Only_Algo(uint8_t algo)
{
if (algo > 0 && algo <= CRYPTO_ACS_MAX)
{
return CRYPTO_TRUE;
}
return CRYPTO_FALSE;
}

/**
* @brief Function: Crypto_increment
* Increments the bytes within a uint8_t array
Expand Down
6 changes: 2 additions & 4 deletions src/core/crypto_aos.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.

Check notice on line 1 in src/core/crypto_aos.c

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on src/core/crypto_aos.c

File src/core/crypto_aos.c does not conform to Custom style guidelines. (lines 910)
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,
Expand Down Expand Up @@ -243,11 +243,9 @@

if (sa_ptr->est == 0 && sa_ptr->ast == 1)
{
if (sa_ptr->acs_len != 0)
if (sa_ptr->acs_len > 0)
{
if ((sa_ptr->acs == CRYPTO_MAC_CMAC_AES256 || sa_ptr->acs == CRYPTO_MAC_HMAC_SHA256 ||
sa_ptr->acs == CRYPTO_MAC_HMAC_SHA512) &&
sa_ptr->iv_len > 0)
if (Crypto_Is_ACS_Only_Algo(sa_ptr->acs) && sa_ptr->iv_len > 0)
{
status = CRYPTO_LIB_ERR_IV_NOT_SUPPORTED_FOR_ACS_ALGO;
mc_if->mc_log(status);
Expand Down
6 changes: 2 additions & 4 deletions src/core/crypto_tc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.

Check notice on line 1 in src/core/crypto_tc.c

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on src/core/crypto_tc.c

File src/core/crypto_tc.c does not conform to Custom style guidelines. (lines 342, 343, 344, 618, 619, 808, 941, 942, 947, 953, 1754, 1758, 1759)
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,
Expand Down Expand Up @@ -263,11 +263,9 @@
int32_t status = CRYPTO_LIB_SUCCESS;
if ((sa_ptr->est == 0) && (sa_ptr->ast == 1))
{
if (sa_ptr->acs_len != 0)
if (sa_ptr->acs_len > 0)
{
if ((sa_ptr->acs == CRYPTO_MAC_CMAC_AES256 || sa_ptr->acs == CRYPTO_MAC_HMAC_SHA256 ||
sa_ptr->acs == CRYPTO_MAC_HMAC_SHA512) &&
sa_ptr->iv_len > 0)
if (Crypto_Is_ACS_Only_Algo(sa_ptr->acs) && sa_ptr->iv_len > 0)
{
status = CRYPTO_LIB_ERR_IV_NOT_SUPPORTED_FOR_ACS_ALGO;
mc_if->mc_log(status);
Expand Down
6 changes: 2 additions & 4 deletions src/core/crypto_tm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Copyright (C) 2009 - 2022 National Aeronautics and Space Administration.

Check notice on line 1 in src/core/crypto_tm.c

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on src/core/crypto_tm.c

File src/core/crypto_tm.c does not conform to Custom style guidelines. (lines 1703, 1708, 1709)
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,
Expand Down Expand Up @@ -161,11 +161,9 @@

if (sa_ptr->est == 0 && sa_ptr->ast == 1)
{
if (sa_ptr->acs_len != 0)
if (sa_ptr->acs_len > 0)
{
if ((sa_ptr->acs == CRYPTO_MAC_CMAC_AES256 || sa_ptr->acs == CRYPTO_MAC_HMAC_SHA256 ||
sa_ptr->acs == CRYPTO_MAC_HMAC_SHA512) &&
sa_ptr->iv_len > 0)
if (Crypto_Is_ACS_Only_Algo(sa_ptr->acs) && sa_ptr->iv_len > 0)
{
status = CRYPTO_LIB_ERR_IV_NOT_SUPPORTED_FOR_ACS_ALGO;
mc_if->mc_log(status);
Expand Down
Loading