Skip to content

Commit b62f109

Browse files
authored
Merge pull request #333 from nasa/331-combine-extended-procedures-branches-and-test-before-merging-to-dev
331 combine extended procedures branches and test before merging to dev
2 parents d3ccd23 + d560e6d commit b62f109

31 files changed

+2461
-556
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,33 @@ jobs:
1111
minimal_build:
1212
# Container Setup
1313
runs-on: ubuntu-latest
14+
container:
15+
image: ivvitc/cryptolib:20240814
1416
steps:
1517
- uses: actions/checkout@v4
1618
- name: Update
17-
run: sudo apt-get update
19+
run: apt-get update
1820
- name: Install Dependencies
19-
run: sudo apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3
21+
run: apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3
2022
- name: Install Python Libraries
21-
run: sudo pip install pycryptodome
23+
run: pip install pycryptodome
2224
- name: Install Libgcrypt
2325
run: >
2426
curl
2527
-LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2
2628
-o /tmp/libgpg-error-1.50.tar.bz2
2729
&& tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/
2830
&& cd /tmp/libgpg-error-1.50
29-
&& sudo ./configure
30-
&& sudo make install
31+
&& ./configure
32+
&& make install
3133
&& curl
3234
-LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2
3335
-o /tmp/libgcrypt-1.11.0.tar.bz2
3436
&& tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/
3537
&& cd /tmp/libgcrypt-1.11.0
36-
&& sudo ./configure
37-
&& sudo make install
38-
&& sudo ldconfig
38+
&& ./configure
39+
&& make install
40+
&& ldconfig
3941
# End Container Setup
4042

4143
- name: Minimal Build Script
@@ -48,31 +50,33 @@ jobs:
4850
internal_build:
4951
# Container Setup
5052
runs-on: ubuntu-latest
53+
container:
54+
image: ivvitc/cryptolib:20240814
5155
steps:
5256
- uses: actions/checkout@v4
5357
- name: Update
54-
run: sudo apt-get update
58+
run: apt-get update
5559
- name: Install Dependencies
56-
run: sudo apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3
60+
run: apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3
5761
- name: Install Python Libraries
58-
run: sudo pip install pycryptodome
62+
run: pip install pycryptodome
5963
- name: Install Libgcrypt
6064
run: >
6165
curl
6266
-LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2
6367
-o /tmp/libgpg-error-1.50.tar.bz2
6468
&& tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/
6569
&& cd /tmp/libgpg-error-1.50
66-
&& sudo ./configure
67-
&& sudo make install
70+
&& ./configure
71+
&& make install
6872
&& curl
6973
-LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2
7074
-o /tmp/libgcrypt-1.11.0.tar.bz2
7175
&& tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/
7276
&& cd /tmp/libgcrypt-1.11.0
73-
&& sudo ./configure
74-
&& sudo make install
75-
&& sudo ldconfig
77+
&& ./configure
78+
&& make install
79+
&& ldconfig
7680
# End Container Setup
7781

7882
- name: Internal Build Script
@@ -146,31 +150,33 @@ jobs:
146150
wolf_build:
147151
# Container Setup
148152
runs-on: ubuntu-latest
153+
container:
154+
image: ivvitc/cryptolib:20240814
149155
steps:
150156
- uses: actions/checkout@v4
151157
- name: Update
152-
run: sudo apt-get update
158+
run: apt-get update
153159
- name: Install Dependencies
154-
run: sudo apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 autoconf libtool
160+
run: apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 autoconf libtool
155161
- name: Install Python Libraries
156-
run: sudo pip install pycryptodome
162+
run: pip install pycryptodome
157163
- name: Install Libgcrypt
158164
run: >
159165
curl
160166
-LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2
161167
-o /tmp/libgpg-error-1.50.tar.bz2
162168
&& tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/
163169
&& cd /tmp/libgpg-error-1.50
164-
&& sudo ./configure
165-
&& sudo make install
170+
&& ./configure
171+
&& make install
166172
&& curl
167173
-LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2
168174
-o /tmp/libgcrypt-1.11.0.tar.bz2
169175
&& tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/
170176
&& cd /tmp/libgcrypt-1.11.0
171-
&& sudo ./configure
172-
&& sudo make install
173-
&& sudo ldconfig
177+
&& ./configure
178+
&& make install
179+
&& ldconfig
174180
- name: Clone WolfSSL
175181
run: git clone --depth 1 --branch v5.6.0-stable https://github.com/wolfSSL/wolfssl.git /tmp/wolfssl
176182

@@ -188,8 +194,8 @@ jobs:
188194
cd /tmp/wolfssl/build;
189195
cmake -DWOLFSSL_AESCCM=yes -DWOLFSSL_AESSIV=yes -DWOLFSSL_CMAC=yes ..;
190196
cmake --build .;
191-
sudo make install;
192-
sudo ldconfig;
197+
make install;
198+
ldconfig;
193199
# End Container Setup
194200

195201
- name: Wolf Build Script
@@ -262,4 +268,4 @@ jobs:
262268
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
263269
with:
264270
files: 'coverage/*.c.gcov'
265-
verbose: true
271+
verbose: true

.github/workflows/codeql.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
build_internal:
2222
name: Analyze Build_Internal
2323
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
24+
container:
25+
image: ivvitc/cryptolib:20240814
2426
permissions:
2527
# required for all workflows
2628
security-events: write
@@ -71,6 +73,8 @@ jobs:
7173
build_minimal:
7274
name: Analyze Build_Minimal
7375
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
76+
container:
77+
image: ivvitc/cryptolib:20240814
7478
permissions:
7579
# required for all workflows
7680
security-events: write
@@ -121,6 +125,8 @@ jobs:
121125
build_wolf:
122126
name: Analyze Build_Wolf
123127
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
128+
container:
129+
image: ivvitc/cryptolib:20240814
124130
permissions:
125131
# required for all workflows
126132
security-events: write
@@ -153,29 +159,29 @@ jobs:
153159
cd /tmp/wolfssl/build;
154160
cmake -DWOLFSSL_AESCCM=yes -DWOLFSSL_AESSIV=yes -DWOLFSSL_CMAC=yes ..;
155161
cmake --build .;
156-
sudo make install;
157-
sudo ldconfig;
162+
make install;
163+
ldconfig;
158164
- name: Install Dependencies
159165
run: |
160-
sudo apt-get update
161-
sudo apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 autoconf libtool
166+
apt-get update
167+
apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 autoconf libtool
162168
163169
- name: Install Python Libraries
164-
run: sudo pip install pycryptodome
170+
run: pip install pycryptodome
165171

166172
- name: Update Dependencies
167173
run: >
168174
curl -LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2 -o /tmp/libgpg-error-1.50.tar.bz2
169175
&& tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/
170176
&& cd /tmp/libgpg-error-1.50
171-
&& sudo ./configure
172-
&& sudo make install
177+
&& ./configure
178+
&& make install
173179
&& curl -LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2 -o /tmp/libgcrypt-1.11.0.tar.bz2
174180
&& tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/
175181
&& cd /tmp/libgcrypt-1.11.0
176-
&& sudo ./configure
177-
&& sudo make install
178-
&& sudo ldconfig
182+
&& ./configure
183+
&& make install
184+
&& ldconfig
179185
180186
- name: Checkout repository
181187
uses: actions/checkout@v4
@@ -200,6 +206,8 @@ jobs:
200206
build_rhel:
201207
name: Analyze Build_RHEL
202208
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
209+
container:
210+
image: ivvitc/cryptolib:20240814
203211
permissions:
204212
# required for all workflows
205213
security-events: write

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ venv
1616
vgcore*
1717
core.*
1818
log.txt
19+
cmake_install.cmake
20+
CMakeCache.txt
21+
CTestTestfile.cmake
22+
DartConfiguration.tcl
23+
sa_save_file.bin
24+
bin/*
25+
CMakeFiles/*
26+
src/cmake_install.cmake
27+
src/CTestTestfile.cmake
28+
src/CMakeFiles/*
29+
test/cmake_install.cmake
30+
test/CTestTestfile.cmake
31+
test/CMakeFiles/*
32+
Testing/Temporary/*

include/crypto.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ void Crypto_TM_Calc_PDU_MAC(uint16_t* pdu_len, uint16_t byte_idx, SecurityAssoci
176176
int32_t Crypto_TM_Do_Decrypt(uint8_t sa_service_type, SecurityAssociation_t* sa_ptr, uint8_t ecs_is_aead_algorithm, uint16_t byte_idx, uint8_t* p_new_dec_frame, uint16_t pdu_len, uint8_t* p_ingest, crypto_key_t* ekp, crypto_key_t* akp, uint8_t iv_loc, int mac_loc, uint16_t aad_len, uint8_t* aad, uint8_t** pp_processed_frame, uint16_t* p_decrypted_length);
177177
void Crypto_TM_Process_Debug_Print(uint16_t byte_idx, uint16_t pdu_len, SecurityAssociation_t* sa_ptr);
178178

179-
180-
extern uint8_t Crypto_Prep_Reply(uint8_t* ingest, uint8_t appID);
181179
extern int32_t Crypto_increment(uint8_t* num, int length);
182180
int32_t Crypto_Get_tmLength(int len);
183181
uint8_t Crypto_Is_AEAD_Algorithm(uint32_t cipher_suite_id);
@@ -200,11 +198,16 @@ int32_t Crypto_Check_Anti_Replay_Verify_Pointers(SecurityAssociation_t* sa_ptr,
200198
int32_t Crypto_Check_Anti_Replay_ARSNW(SecurityAssociation_t* sa_ptr, uint8_t* arsn, int8_t* arsn_valid);
201199
int32_t Crypto_Check_Anti_Replay_GCM(SecurityAssociation_t* sa_ptr, uint8_t* iv, int8_t* iv_valid);
202200

201+
// SDLS Related Functions
202+
extern uint8_t Crypto_Prep_Reply(uint8_t* ingest, uint8_t appID);
203+
extern void Crypto_Print_Sdls_Ep_Reply(void);
204+
extern int32_t Crypto_Get_Sdls_Ep_Reply(uint8_t* buffer, uint16_t* length);
205+
203206
// Key Management Functions
204207
int32_t Crypto_Key_OTAR(void);
205208
int32_t Crypto_Key_update(uint8_t state);
206-
int32_t Crypto_Key_inventory(uint8_t* );
207-
int32_t Crypto_Key_verify(uint8_t* , TC_t* tc_frame);
209+
int32_t Crypto_Key_inventory(uint8_t*);
210+
int32_t Crypto_Key_verify(TC_t* tc_frame);
208211

209212
// Security Monitoring & Control Procedure
210213
int32_t Crypto_MC_ping(uint8_t* ingest);
@@ -252,6 +255,8 @@ extern char* crypto_deep_copy_string(char* src_string);
252255
*/
253256
// Data stores used in multiple components
254257
extern CCSDS_t sdls_frame;
258+
extern SDLS_KEYV_RPLY_t sdls_ep_keyv_reply;
259+
extern uint8_t sdls_ep_reply[TC_MAX_FRAME_SIZE];
255260
// extern TM_t tm_frame;
256261
extern uint8_t tm_frame[1786];
257262
extern TM_FramePrimaryHeader_t tm_frame_pri_hdr;
@@ -276,7 +281,6 @@ extern SaInterface sa_if;
276281
extern CryptographyInterface cryptography_if;
277282

278283
// extern crypto_key_t ak_ring[NUM_KEYS];
279-
extern CCSDS_t sdls_frame;
280284
extern SadbMariaDBConfig_t* sa_mariadb_config;
281285
extern GvcidManagedParameters_t* gvcid_managed_parameters;
282286
extern GvcidManagedParameters_t* current_managed_parameters;

include/crypto_config.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@
158158
// Service Group - Security Association Management
159159
#define SG_SA_MGMT 0x01 // 0b01
160160
#define PID_CREATE_SA 0x01 //0b0001
161-
#define PID_REKEY_SA 0x05 //0b0110
161+
#define PID_REKEY_SA 0x06 //0b0110
162162
#define PID_START_SA 0x0B //0b1011
163163
#define PID_STOP_SA 0x0E // 0b1110
164164
#define PID_EXPIRE_SA 0x09 // 0b1001
165165
#define PID_DELETE_SA 0x04 // 0b0100
166166
#define PID_SET_ARSN 0x0A //0b1010
167-
#define PID_SET_ARSNW 0x06 // 0b0101
167+
#define PID_SET_ARSNW 0x05 // 0b0101
168168
#define PID_READ_ARSN 0x00 // 0b0000
169169
#define PID_SA_STATUS 0x0F // 0b1111
170170
// Service Group - Security Monitoring & Control
@@ -205,6 +205,12 @@
205205
#define AOS_FRAME_DATA_SIZE 1786 /* bytes */
206206
#define AOS_FILL_SIZE 1145 /* bytes */
207207

208+
// SDLS Behavior Defines
209+
#define SDLS_KEYV_MAX_KEYS 21 /* keys */
210+
#define SDLS_IV_LEN 12 /* bytes */
211+
#define SDLS_KEYV_KEY_ID_LEN 2 /* bytes */
212+
#define SDLS_KEY_LEN 32 /* bytes */
213+
208214
// TC Behavior Defines
209215
#define TC_SDLS_EP_VCID \
210216
4 // VCID which has SDLS PDUs (JPL uses VCIDs to determine TC type, there is no space packet layer with APIDs). Set

include/crypto_config_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct _GvcidManagedParameters_t
233233
TcSegmentHdrsPresent has_segmentation_hdr;
234234
uint16_t max_frame_size; // Maximum TC/TM Frame Length with headers
235235
OcfPresent has_ocf;
236-
int set_flag; // Will be a list of managed parameters!
236+
int set_flag;
237237
};
238238
#define GVCID_MANAGED_PARAMETERS_SIZE (sizeof(GvcidManagedParameters_t))
239239

include/crypto_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
#define CRYPTO_LIB_ERR_SPI_INDEX_OOB (-56)
130130
#define CRYPTO_LIB_ERR_SA_NOT_OPERATIONAL (-57)
131131
#define CRYPTO_LIB_ERR_IV_GREATER_THAN_MAX_LENGTH (-58)
132+
#define CRYPTO_LIB_ERR_KEY_STATE_TRANSITION_ERROR (-59)
132133

133134
// Define codes for returning MDB Strings, and determining error based on strings
134135
#define CAM_ERROR_CODES 600
@@ -149,7 +150,7 @@
149150
#define CONFIGURATION_ERROR_CODES 100
150151
#define CONFIGURATION_ERROR_CODES_MAX 103
151152

152-
#define CRYPTO_CORE_ERROR_CODES_MAX -57
153+
#define CRYPTO_CORE_ERROR_CODES_MAX -59
153154

154155
extern char *crypto_enum_errlist_core[];
155156
extern char *crypto_enum_errlist_config[];

0 commit comments

Comments
 (0)