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

Merge Dev into Main for KMC 1.1 release #107

Merged
merged 142 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
4390ef9
Add libgcrypt error string prints when it fails
iysaleh Feb 7, 2022
ccd44fc
Merge pull request #71 from nasa/Libgcrypt_ErrorStrings
IbraheemYSaleh Feb 7, 2022
f83919d
Merge branch 'collab_dev' into dev
jlucas9 Feb 8, 2022
427ecea
Update auth / validate_Auth references to use akid
dccutrig Feb 14, 2022
a894a57
Update CI YAMLs to main/dev
dccutrig Feb 14, 2022
cef4e19
Update auth/validate_auth key refs to akid
dccutrig Feb 14, 2022
15ecde3
Use AKID in KMC Crypto Service Cryptography for auth functions instea…
iysaleh Feb 14, 2022
ebb0074
Merge pull request #74 from nasa/auth_ek_ak_development
dccutrig Feb 15, 2022
45a2250
Create Check_AntiReplay function, fix bug in Crypto_Window, reject ou…
dccutrig Feb 16, 2022
1320438
Minor typos
dccutrig Feb 16, 2022
17287d9
Add ARSN pointer to crypto_if, addiional mac_Close handles for returns
dccutrig Feb 22, 2022
befc08d
ut_tc_process stubs and cmake work
dccutrig Feb 14, 2022
74cbc88
Change all ARC/ARSN refs to ARSN, add ARSN TC_Process UTs
dccutrig Feb 23, 2022
ee38525
Add test cases to IV verify UTs
dccutrig Feb 23, 2022
e64cc3e
Add ARN test cases
dccutrig Feb 28, 2022
7585a01
Fix KMC warnings
dccutrig Feb 28, 2022
cf873cb
Create Check_AntiReplay function, fix bug in Crypto_Window, reject ou…
dccutrig Feb 16, 2022
7d6ee51
Minor typos
dccutrig Feb 16, 2022
698bdf4
Add ARSN pointer to crypto_if, addiional mac_Close handles for returns
dccutrig Feb 22, 2022
0e6f10c
ut_tc_process stubs and cmake work
dccutrig Feb 14, 2022
fa28b14
Change all ARC/ARSN refs to ARSN, add ARSN TC_Process UTs
dccutrig Feb 23, 2022
985ce18
Add test cases to IV verify UTs
dccutrig Feb 23, 2022
5f9ab52
Add ARN test cases
dccutrig Feb 28, 2022
bb31a3e
Fix KMC warnings
dccutrig Feb 28, 2022
fb0009c
Fix ACS as bytefield parsing from mariadb sadb queries and Crypto Ser…
IbraheemYSaleh Mar 1, 2022
cd92108
Merge mariadb from dev to branch
IbraheemYSaleh Mar 1, 2022
6eb6e80
Small bug fix, minor print statement update
dccutrig Mar 1, 2022
0fc0f93
Cleanup un-needed pointers, move Check ARSN/IV to crypto_tc, update y…
dccutrig Mar 2, 2022
6a165c0
Modify yaml build step
dccutrig Mar 2, 2022
b5fc902
Modify YAMLs
dccutrig Mar 2, 2022
ddbca50
Update UTs failing because IV checks are now working appropriately
dccutrig Mar 3, 2022
22fe01d
Add create_sadb.sql minor update from KG feedback
IbraheemYSaleh Mar 3, 2022
e0895de
Merge pull request #78 from nasa/tc_process_refactor
dccutrig Mar 3, 2022
ad9968c
Init SA ACS ptr to NULL
dccutrig Mar 3, 2022
780e19b
Update auth / validate auth to use acs enums, add get_acs_algo function
dccutrig Mar 7, 2022
98954da
Minor spacing
dccutrig Mar 7, 2022
32e986a
Update Crypto_Get_Acs_Algo comment
dccutrig Mar 7, 2022
cd85081
Add gcry_mac_close statements
dccutrig Mar 7, 2022
248cf1d
Add UTs for a valid/invalid acs algo
dccutrig Mar 7, 2022
2984087
Merge pull request #83 from nasa/76-zeroise-mac-cipher-handles-at-all…
dccutrig Mar 7, 2022
3899eb2
Adjust IV memcpy block to be reliant on SA configuration
dccutrig Mar 7, 2022
7388cf7
Fix SA to have 2 byte ARSN, not an IV; Add encrypt/decrypt UT for pla…
dccutrig Mar 7, 2022
2d26c54
Add Encrypt_decrypt test description
dccutrig Mar 8, 2022
78342a0
Relocate get_acs_algo code to crypto_if to not be a core dependency
dccutrig Mar 8, 2022
0b63aba
Merge branch 'dev' into 60-maturation-of-acs-ecs
dccutrig Mar 8, 2022
492c3d0
Merge pull request #82 from nasa/60-maturation-of-acs-ecs
dccutrig Mar 8, 2022
3b2c0ef
Add additional checks for invalid SA that do not cause segfault, UTs …
dccutrig Mar 8, 2022
8acc132
Merge branch 'dev' into 84-cleartext-bug-reported-by-jpl
dccutrig Mar 8, 2022
34ab020
Fix incorrect return code
dccutrig Mar 8, 2022
9fec569
Missing parenthesis
dccutrig Mar 8, 2022
b7d23e2
Merge pull request #86 from nasa/84-cleartext-bug-reported-by-jpl
dccutrig Mar 9, 2022
42e359e
Add Max frame size as managed parameter
dccutrig Mar 11, 2022
55d59c9
Separate managed param max length check and spec max length check
dccutrig Mar 14, 2022
5d395ad
Add length maximum UTs
dccutrig Mar 14, 2022
0097af2
Merge pull request #87 from nasa/62-maximum-frame-length
dccutrig Mar 14, 2022
56d8625
Add new enum defs, rename old ones for consistency
dccutrig Mar 14, 2022
6c3b1b2
Add get_acs switch cases for hmac, add unsupported ecs error
dccutrig Mar 14, 2022
e7e3fde
GH19: Fix ACS enum checking in KMC crypto interface
IbraheemYSaleh Mar 16, 2022
0812b26
AMMOSGH33: Properly set RPATH to $ORIGIN, add install target, add inc…
IbraheemYSaleh Mar 16, 2022
c329b41
AMMOSGH29: Add install dir to gitignore
IbraheemYSaleh Mar 16, 2022
d3af74b
AMMOSGH29 : reset RPATH to /../lib
IbraheemYSaleh Mar 17, 2022
770994a
AMMOSGH34: Add empty response checking/error handling for KMC Crypto …
IbraheemYSaleh Mar 17, 2022
488df01
Merge pull request #90 from nasa/AMMOSGH29-install_target_dev
jlucas9 Mar 18, 2022
f9b059a
Merge pull request #92 from nasa/AMMOSGH34
IbraheemYSaleh Mar 18, 2022
e4d7d1c
Add get_ecs_algo function
dccutrig Mar 21, 2022
ce5d7ee
Add key_len as field in ek_ring, max key_len now 512 bytes
dccutrig Mar 21, 2022
42276df
WIP on passing key_len through crypto_if
dccutrig Mar 21, 2022
8995998
Ensure CMAC encrypt UTs use akid with key_len key metadata
dccutrig Mar 23, 2022
4350445
Update CMAC decrypt UT to use akid, not ekid
dccutrig Mar 23, 2022
096995d
Add Python Authentication class, add HMAC SHA256 test w/ bitmask of 0
dccutrig Jan 25, 2022
2fd0a33
Fix UT with errant free, Add SHA256 MAC encrypt UT w/ bitmask of 1s
dccutrig Mar 23, 2022
6b86449
Add UTs for SHA512 and bitmasks of 0s and 1s, add corresponding python
dccutrig Mar 23, 2022
6ef869b
Add HMAC Decrypt UTs for SHA256 bitmask of 0s or 1s
dccutrig Mar 23, 2022
01c46e9
SHA512 encrypt/decrypt UTs w/ 32 byte key
dccutrig Mar 23, 2022
e7d4611
Add SHA512 UTs w/ 64 byte keys
dccutrig Mar 23, 2022
d662122
Merge branch 'dev' into 59-add-hmac-support
dccutrig Mar 23, 2022
03c95f1
Fix status variable declarations in some UTs
dccutrig Mar 24, 2022
fd3a266
Remove ek_ring refs outside of core, add get_ecs/acs algo keylengths
dccutrig Mar 31, 2022
c7ffa8d
Merge branch '59-add-hmac-support' of github.com:nasa/CryptoLib into …
dccutrig Mar 31, 2022
2479ab3
Add get_ecs_algo UT
dccutrig Mar 31, 2022
56e3865
Merge pull request #93 from nasa/59-add-hmac-support
dccutrig Mar 31, 2022
2ce118a
WIP on partially transmitted IVs
dccutrig Mar 31, 2022
5c4d800
WIP on IVs and UTs
dccutrig Mar 31, 2022
c011a5e
WIP IV Changes && Unit Test Updates
rjbrown6 Mar 31, 2022
c762550
Bobbys turn
dccutrig Mar 31, 2022
f6444a9
Fix print statement typos, update UT
dccutrig Mar 31, 2022
db2a16d
WIP: UT IV Changes
rjbrown6 Mar 31, 2022
7d43dc4
AMMOSGH-51: Add working TC Process Security unit test for partial IVs
IbraheemYSaleh Apr 1, 2022
202ca3b
AMMOSGH-51: Update MariaDB SADB handling of iv_len field, update SQL …
IbraheemYSaleh Apr 1, 2022
509e074
Merge pull request #97 from nasa/ammos-github-51
IbraheemYSaleh Apr 1, 2022
c29a3d8
AMMOSGH32: Fix arsnw queries from MariaDB interface, remove arsnw_len…
IbraheemYSaleh Apr 5, 2022
bc9b6d4
Merge pull request #98 from nasa/AMMOSGH32
IbraheemYSaleh Apr 5, 2022
4363d8a
AMMOSGH52: Add KMC Crypto HMAC implementation, fix broken authenticat…
IbraheemYSaleh Apr 7, 2022
28da53b
AMMOSGH52: Fix libgcrypt mac_verify segfault, fix unit test misconfig…
IbraheemYSaleh Apr 7, 2022
31d4507
AMMOSGH-52: Use pointers instead of preallocated memory blocks for se…
IbraheemYSaleh Apr 7, 2022
c2e9408
Merge pull request #99 from nasa/GH52
IbraheemYSaleh Apr 12, 2022
788402d
AMMOSGH-65: Rename sadb mariadb admin scripts to sadb-mariadb-sql
IbraheemYSaleh Apr 12, 2022
bac4e64
AMMOSGH-66: Add empty and list SQL scripts
IbraheemYSaleh Apr 12, 2022
527c019
Fix control logic, minor test cleanup
dccutrig Apr 13, 2022
267ac6b
Commented out two tests for now - WIP on resolving that issue
dccutrig Apr 13, 2022
812de92
Fixed based on PR
dccutrig Apr 13, 2022
382990d
Merge pull request #102 from nasa/101-incorrect-decryption-logic-for-…
dccutrig Apr 13, 2022
6d3636d
AMMOSGH-74, AMMOSGH-72, fix MySQL shutdown cleanup logic when no vali…
IbraheemYSaleh Apr 13, 2022
cc84af0
Merge branch 'dev' into AMMOSGH7XBugs
IbraheemYSaleh Apr 13, 2022
7b93189
AMMOSGH-71: Handle error case where no valid ECS set but EST=1
IbraheemYSaleh Apr 13, 2022
863bce3
AMMOSGH-73: Add test for misconfigured SA for with seg headers
IbraheemYSaleh Apr 13, 2022
c99e888
AMMOSGH-72: Remove code checking for crypto service truncated mac val…
IbraheemYSaleh Apr 13, 2022
c59c38c
AMMOSGH-61: Add MariaDB Bad Password and BadUsername Tests
IbraheemYSaleh Apr 13, 2022
7561de6
Merge pull request #103 from nasa/AMMOSGH7XBugs
IbraheemYSaleh Apr 14, 2022
de7cec4
AMMOSGH-41: Update user permissions example script to limit sadb_user…
IbraheemYSaleh Apr 14, 2022
095e13f
AMMOSGH-XX: update base64 calculations to use exact sizes instead of …
IbraheemYSaleh Apr 14, 2022
49cb5dc
Merge pull request #104 from nasa/AMMOSGH-41
IbraheemYSaleh Apr 14, 2022
32ff4f0
Update for partial ARSN transmission and fix replay checking
dccutrig Apr 14, 2022
c05d6d8
Added partial ARSN transmission
dccutrig Apr 14, 2022
75180b4
WIP on bug
dccutrig Apr 14, 2022
cf322a8
GH105: Handle non-incrementing static IV rollover case
IbraheemYSaleh Apr 14, 2022
1d55895
Merge pull request #106 from nasa/105-partial-arsn-trans
IbraheemYSaleh Apr 14, 2022
b6e095b
GH96: Add fix for incrementing non-transmitted portion logic for IV &…
IbraheemYSaleh Apr 15, 2022
0acb9c6
GH96: Fix misleading comment
IbraheemYSaleh Apr 15, 2022
7c1f5f5
Merge pull request #108 from nasa/GH96
IbraheemYSaleh Apr 18, 2022
e6a61e7
WIP: MariaDB Testing
rjbrown6 Apr 20, 2022
edb35e5
Turn SQL Build on
rjbrown6 Apr 20, 2022
e473169
Adding Unit Tests for Automated MariaDB
rjbrown6 Apr 22, 2022
841f31f
Updating relative sql script path
rjbrown6 Apr 22, 2022
f0d2ef5
Update automated branches to build on main/dev
rjbrown6 Apr 22, 2022
9c80aa9
CMake update for tests
rjbrown6 Apr 22, 2022
506253d
Fix UTs failing due to incorrect key length, remove UTs that shouldnt…
dccutrig Apr 26, 2022
f6dc8a1
Fix UTs setup improperly
dccutrig Apr 27, 2022
5223bef
Update UT originally created with wrong MAC key
dccutrig Apr 27, 2022
afce6dc
Segfault was caused by UT error, not a code error. Since the relevant…
dccutrig Apr 26, 2022
9af6236
Merge pull request #109 from nasa/88-add-github-automated-build-integ…
dccutrig May 4, 2022
7dd861c
Merge pull request #112 from nasa/hmac_fixes
dccutrig May 4, 2022
c6d228e
Update mariadb.yml
rjbrown2 May 4, 2022
4e92ee1
AMMOSGH-85: Add support for macLength KMC Crypto Service parameter fo…
IbraheemYSaleh May 5, 2022
6abf3aa
AMMOSGH-87: Update mysql sample script file locations and references
IbraheemYSaleh May 5, 2022
1c860d0
AMMOSGH-87: Fix test yml for permissions sql rename
IbraheemYSaleh May 5, 2022
1da6391
Merge pull request #114 from nasa/AMMOSGH-85
IbraheemYSaleh May 9, 2022
7f837f0
AMMOSGH-89: Fix missing SDLS processed frame FECF parsing
IbraheemYSaleh May 9, 2022
6e9d14a
Merge pull request #115 from nasa/AMMOSGH-89
IbraheemYSaleh May 10, 2022
7813f54
AMMOSGH-91: Add sanity frame length checks against provided input frames
IbraheemYSaleh May 10, 2022
46eb0f8
AMMOSGH-91: Fix length check
IbraheemYSaleh May 10, 2022
e8d33c7
Merge pull request #116 from nasa/AMMOSGH-91
IbraheemYSaleh May 11, 2022
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
20 changes: 19 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [ collab_main ]
branches: [ main, dev ]
pull_request:

jobs:
Expand All @@ -15,6 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat

Expand All @@ -37,6 +40,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat libcurl4-openssl-dev

Expand All @@ -60,6 +66,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat libcurl4-openssl-dev

Expand All @@ -83,6 +92,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat libcurl4-openssl-dev

Expand All @@ -106,6 +118,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat libcurl4-openssl-dev

Expand All @@ -129,6 +144,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmariadb-dev libmariadb-dev-compat libcurl4-openssl-dev

Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/mariadb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: MDB Build

on:
push:
branches: [ main,dev ]
pull_request:

jobs:
mariadb_build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
container: rbrown00/cryptolib:latest
steps:
- uses: actions/checkout@v2
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DDEBUG=1 -DMYSQL=1 -DLIBGCRYPT=1 -DKMCCRYPTO=0

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build

- name: Initailize SADB
working-directory: ${{github.workspace}}/build
#Maybe create a variable for this SQL location
run: |
cd /__w/CryptoLib/CryptoLib/src/crypto_sadb/sadb_mariadb_sql
echo "----------------"
/etc/init.d/mysql start
mysql --host=localhost -uroot -pitc123! < delete_sadb.sql
mysql --host=localhost -uroot -pitc123! < create_sadb.sql
cd /__w/CryptoLib/CryptoLib/src/crypto_sadb/test_sadb_mariadb_sql
mysql --host=localhost -uroot -pitc123! < create_sadb_unit_test_user_grant_permissions.sql
mysql --host=localhost -uroot -pitc123! < create_sadb_jpl_unit_test_security_associations.sql
cd /__w/CryptoLib/CryptoLib/build/bin
./ut_mariadb

# mysql --host=localhost -uroot -pitc123! < create_sadb_unit_test_security_associations.sql
5 changes: 4 additions & 1 deletion .github/workflows/utest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Unit Tests

on:
push:
branches: [ collab_main ]
branches: [ main, dev ]
pull_request:

env:
Expand All @@ -19,6 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Validation Tests

on:
push:
branches: [ collab_main ]
branches: [ main, dev]
pull_request:

env:
Expand All @@ -19,6 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Update
run: sudo apt-get update

- name: Install Dependencies
run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev python3 lcov

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ cmake-build-debug
_deps

DartConfiguration.tcl

install
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@
cmake_minimum_required(VERSION 3.14.0)
project(CRYPTO C)

set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")

OPTION(DEBUG "Debug" OFF) # Disabled by default, enable with: -DDEBUG=ON
OPTION(MYSQL "Mysql" OFF) # Disabled by default, enable with: -DMYSQL=ON
OPTION(LIBGCRYPT "Libgcrypt" ON) # Enabled by default, disable with: -DLIBGCRYPT=OFF
OPTION(KMCCRYPTO "KmcCrypto" OFF) # Disabled by default, enable with: -DKMCCRYPTO=ON
OPTION(ENCTEST "Encryption-Tests" OFF) # Disabled by default, enable with: -DENCTEST=ON
OPTION(CODECOV "Code-Coverage" OFF) # Disabled by default, enable with: -DCODECOV=ON
OPTION(SYSTEM_INSTALL "SystemInstall" OFF) #Disabled by default, enable with: -DSYSTEM_INSTALL=ON

set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install)

IF(CRYPTO_SUBMODULE_INSTALL) #If building CryptoLib as a submodule of another build system (EG, JPL KMC, Nasa NOS3, etc...)
set(CMAKE_INSTALL_PREFIX ${CRYPTO_SUBMODULE_INSTALL})
ENDIF()

IF(SYSTEM_INSTALL)
set(CMAKE_INSTALL_PREFIX /usr/local)
ENDIF()


IF(DEBUG)
ADD_DEFINITIONS(-DDEBUG -DOCF_DEBUG -DFECF_DEBUG -DSA_DEBUG -DPDU_DEBUG -DCCSDS_DEBUG -DTC_DEBUG -DMAC_DEBUG -DTM_DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Build](https://github.com/nasa/CryptoLib/actions/workflows/build.yml/badge.svg) ![Unit Tests](https://github.com/nasa/CryptoLib/actions/workflows/utest.yml/badge.svg) ![Validation Tests](https://github.com/nasa/CryptoLib/actions/workflows/validation.yml/badge.svg) [![CodeCov](https://codecov.io/gh/nasa/CryptoLib/branch/collab_main/graph/badge.svg?token=KCOMCQO0ZU)](https://codecov.io/gh/nasa/CryptoLib)
![Build](https://github.com/nasa/CryptoLib/actions/workflows/build.yml/badge.svg) ![Unit Tests](https://github.com/nasa/CryptoLib/actions/workflows/utest.yml/badge.svg) ![Validation Tests](https://github.com/nasa/CryptoLib/actions/workflows/validation.yml/badge.svg) ![MariaDB Tests](https://github.com/nasa/CryptoLib/actions/workflows/mariadb.yml/badge.svg) [![CodeCov](https://codecov.io/gh/nasa/CryptoLib/branch/collab_main/graph/badge.svg?token=KCOMCQO0ZU)](https://codecov.io/gh/nasa/CryptoLib)

# CryptoLib

Expand Down
8 changes: 6 additions & 2 deletions include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
// Crypto Library Configuration functions
extern int32_t Crypto_Config_CryptoLib(uint8_t sadb_type, uint8_t cryptography_type, uint8_t crypto_create_fecf, uint8_t process_sdls_pdus,
uint8_t has_pus_hdr, uint8_t ignore_sa_state, uint8_t ignore_anti_replay,
uint8_t unique_sa_per_mapid, uint8_t crypto_check_fecf, uint8_t vcid_bitmask);
uint8_t unique_sa_per_mapid, uint8_t crypto_check_fecf, uint8_t vcid_bitmask, uint8_t crypto_increment_nontransmitted_iv);
extern int32_t Crypto_Config_MariaDB(char* mysql_hostname, char* mysql_database, uint16_t mysql_port,
uint8_t mysql_require_secure_transport, uint8_t mysql_tls_verify_server,
char* mysql_tls_ca, char* mysql_tls_capath, char* mysql_mtls_cert,
Expand All @@ -66,7 +66,7 @@ extern int32_t Crypto_Config_Kmc_Crypto_Service(char* protocol, char* kmc_crypto
char* mtls_client_cert_type, char* mtls_client_key_path,
char* mtls_client_key_pass, char* mtls_issuer_cert);
extern int32_t Crypto_Config_Add_Gvcid_Managed_Parameter(uint8_t tfvn, uint16_t scid, uint8_t vcid, uint8_t has_fecf,
uint8_t has_segmentation_hdr);
uint8_t has_segmentation_hdr, uint16_t max_tc_frame_size);

// Initialization
extern int32_t Crypto_Init(void); // Initialize CryptoLib After Configuration Calls
Expand Down Expand Up @@ -110,6 +110,9 @@ int32_t Crypto_window(uint8_t* actual, uint8_t* expected, int length, int window
uint16_t Crypto_Calc_FECF(uint8_t* ingest, int len_ingest);
void Crypto_Calc_CRC_Init_Table(void);
uint16_t Crypto_Calc_CRC16(uint8_t* data, int size);
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);

// Key Management Functions
int32_t Crypto_Key_OTAR(void);
Expand Down Expand Up @@ -146,6 +149,7 @@ int32_t Crypto_Get_Managed_Parameters_For_Gvcid(uint8_t tfvn, uint16_t scid, uin
GvcidManagedParameters_t** managed_parameters_out);
int32_t crypto_config_add_gvcid_managed_parameter_recursion(uint8_t tfvn, uint16_t scid, uint8_t vcid,
uint8_t has_fecf, uint8_t has_segmentation_hdr,
uint16_t max_tc_frame_size,
GvcidManagedParameters_t* managed_parameter);
void Crypto_Free_Managed_Parameters(GvcidManagedParameters_t* managed_parameters);

Expand Down
14 changes: 7 additions & 7 deletions include/crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
#define SA_DELETE 0
// SA Additional Directives
#define SA_STATUS 8
#define SA_SETARC 9
#define SA_SETARCW 10
#define SA_SETARSN 9
#define SA_SETARSNW 10

// Key State Defines
#define KEY_PREACTIVE 0
Expand All @@ -103,21 +103,21 @@
// Generic Defines
#define NUM_SA 64
#define SPI_LEN 2 /* bytes */
#define KEY_SIZE 32
#define KEY_SIZE 512 /* bytes */
#define KEY_ID_SIZE 8
#define NUM_KEYS 256
#define DISABLED 0
#define ENABLED 1
#define IV_SIZE 16 /* TM IV size bytes */
#define IV_SIZE_TC 4 /* TC IV size bytes */
#define OCF_SIZE 4
#define MAC_SIZE 16 /* bytes */
#define MAC_SIZE 16 /* bytes */ /* Deprecated, todo - remove throughout & use SA mac field specification */
#define FECF_SIZE 2
#define SEGMENT_HDR_SIZE 1
#define ECS_SIZE 4 /* bytes */
#define ABM_SIZE 1024 // 20 /* bytes */
#define ARC_SIZE 20 /* total messages */
#define ARCW_SIZE 1 /* bytes */
#define ARSN_SIZE 20 /* total messages */
#define ARSNW_SIZE 1 /* bytes */
#define SN_SIZE 0
#define CHALLENGE_SIZE 16 /* bytes */
#define CHALLENGE_MAC_SIZE 16 /* bytes */
Expand Down Expand Up @@ -160,7 +160,7 @@

// TC Defines
#define TC_SH_SIZE 8 /* bits */
#define TC_SN_SIZE 0
#define TC_SN_SIZE 2
#define TC_SN_WINDOW 10 /* +/- value */
#define TC_PAD_SIZE 0
#define TC_FRAME_DATA_SIZE 1740 /* bytes */
Expand Down
18 changes: 13 additions & 5 deletions include/crypto_config_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,26 @@ typedef enum
TC_CHECK_FECF_FALSE,
TC_CHECK_FECF_TRUE
} TcCheckFecfBool;
typedef enum
{
SA_INCREMENT_NONTRANSMITTED_IV_FALSE,
SA_INCREMENT_NONTRANSMITTED_IV_TRUE
} SaIncrementNonTransmittedIvPortion;

/*
** Used for selecting supported algorithms
*/
typedef enum
{
CRYPTO_ACS_NONE,
CRYPTO_AES256_CMAC,
CRYPTO_AES256_GMAC
CRYPTO_MAC_NONE,
CRYPTO_MAC_CMAC_AES256,
CRYPTO_MAC_HMAC_SHA256,
CRYPTO_MAC_HMAC_SHA512
} AuthCipherSuite;
typedef enum
{
CRYPTO_ECS_NONE,
CRYPTO_AES256_GCM
CRYPTO_CIPHER_NONE,
CRYPTO_CIPHER_AES256_GCM
} EncCipherSuite;

/*
Expand All @@ -115,6 +121,7 @@ typedef struct
TcUniqueSaPerMapId unique_sa_per_mapid;
TcCheckFecfBool crypto_check_fecf;
uint8_t vcid_bitmask;
uint8_t crypto_increment_nontransmitted_iv; // Whether or not CryptoLib increments the non-transmitted portion of the IV field
} CryptoConfig_t;
#define CRYPTO_CONFIG_SIZE (sizeof(CryptoConfig_t))

Expand All @@ -126,6 +133,7 @@ struct _GvcidManagedParameters_t
uint8_t vcid : 6; // Virtual Channel ID
TcFecfPresent has_fecf;
TcSegmentHdrsPresent has_segmentation_hdr;
uint16_t max_tc_frame_size; // Maximum TC Frame Length with headers
GvcidManagedParameters_t* next; // Will be a list of managed parameters!
};
#define GVCID_MANAGED_PARAMETERS_SIZE (sizeof(GvcidManagedParameters_t))
Expand Down
25 changes: 23 additions & 2 deletions include/crypto_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#define CRYPTOGRAHPY_KMC_CRYPTO_SERVICE_AUTHENTICATION_ERROR 509
#define CRYPTOGRAHPY_KMC_CRYPTO_SERVICE_MAC_VALIDATION_ERROR 510
#define CRYPTOGRAHPY_KMC_ICV_NOT_FOUND_IN_JSON_RESPONSE 511

#define CRYPTOGRAHPY_KMC_NULL_ENCRYPTION_KEY_REFERENCE_IN_SA 512
#define CRYPTOGRAHPY_KMC_NULL_AUTHENTICATION_KEY_REFERENCE_IN_SA 513
#define CRYPTOGRAHPY_KMC_CRYPTO_SERVICE_EMPTY_RESPONSE 514


#define CRYPTO_LIB_SUCCESS (0)
Expand All @@ -61,7 +63,7 @@
#define CRYPTO_LIB_ERR_UT_BYTE_MISMATCH (-10)
#define CRYPTO_LIB_ERR_NO_CONFIG (-11)
#define CRYPTO_LIB_ERR_INVALID_FECF (-12)
#define CRYPTO_LIB_ERR_BAD_ANTIREPLAY_WINDOW (-13)
#define CRYPTO_LIB_ERR_ARSN_OUTSIDE_WINDOW (-13)
#define CRYPTO_LIB_ERR_LIBGCRYPT_ERROR (-14)
#define CRYPTO_LIB_ERR_AUTHENTICATION_ERROR (-15)
#define CRYPTO_LIB_ERR_NULL_IV (-16)
Expand All @@ -71,5 +73,24 @@
#define CRYPTO_LIB_ERR_MAC_RETRIEVAL_ERROR (-20)
#define CRYPTO_LIB_ERR_MAC_VALIDATION_ERROR (-21)
#define CRYPTO_LIB_ERR_INVALID_HEADER (-22)
#define CRYPTO_LIB_ERR_IV_OUTSIDE_WINDOW (-23)
#define CRYPTO_LIB_ERR_NULL_ARSN (-24)
#define CRYPTO_LIB_ERR_NULL_SA (-25)
#define CRYPTO_LIB_ERR_UNSUPPORTED_ACS (-26)
#define CRYPTO_LIB_ERR_ENCRYPTION_ERROR (-27)
#define CRYPTO_LIB_ERR_INVALID_SA_CONFIGURATION (-28)
#define CRYPTO_LIB_ERR_TC_FRAME_SIZE_EXCEEDS_MANAGED_PARAM_MAX_LIMIT (-29)
#define CRYPTO_LIB_ERR_TC_FRAME_SIZE_EXCEEDS_SPEC_LIMIT (-30)
#define CRYPTO_LIB_ERR_UNSUPPORTED_ECS (-31)
#define CRYPTO_LIB_ERR_KEY_LENGTH_ERROR (-32)
#define CRYPTO_LIB_ERR_NULL_ECS_PTR (-33)
#define CRYPTO_LIB_ERR_IV_NOT_SUPPORTED_FOR_ACS_ALGO (-34)
#define CRYPTO_LIB_ERR_NULL_CIPHERS (-35)
#define CRYPTO_LIB_ERR_NO_ECS_SET_FOR_ENCRYPTION_MODE (-36)
#define CRYPTO_LIB_ERR_IV_LEN_SHORTER_THAN_SEC_HEADER_LENGTH (-37)
#define CRYPTO_LIB_ERR_ARSN_LEN_SHORTER_THAN_SEC_HEADER_LENGTH (-38)
#define CRYPTO_LIB_ERR_FRAME_COUNTER_DOESNT_MATCH_SA (-39)
#define CRYPTO_LIB_ERR_INPUT_FRAME_TOO_SHORT_FOR_TC_STANDARD (-40)
#define CRYPTO_LIB_ERR_INPUT_FRAME_LENGTH_SHORTER_THAN_FRAME_HEADERS_LENGTH (-41)

#endif //_crypto_error_h_
Loading