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

Cutright dev #9

Merged
merged 18 commits into from
Nov 9, 2021
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
29 changes: 20 additions & 9 deletions fsw/crypto_util/app/apply_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/*
* Simple apply security program that reads a file into memory and calls the Crypto_TC_ApplySecurity function on the data.
*/
*/

#include "apply_security.h"

Expand All @@ -40,27 +40,38 @@ int main(int argc, char *argv[]) {
}
buffer = c_read_file(filename,&buffer_size);
debug_printf("File buffer size:%lu\n",buffer_size);
int buffer_size_i = (int) buffer_size;
uint32 buffer_size_i = (uint32) buffer_size;
debug_printf("File buffer size int:%d\n",buffer_size_i);
debug_printf("File content: \n");
debug_hexprintf(buffer,buffer_size_i);


//Setup & Initialize CryptoLib
Crypto_Init();

uint8 * ptr_enc_frame = NULL;
uint16 enc_frame_len;

//Call ApplySecurity on buffer contents depending on type.
if (strcmp(security_type,"tc")==0){
//Crypto_TC_ApplySecurity(&buffer, &buffer_size_i);
Crypto_TC_ApplySecurity(buffer, buffer_size_i, &ptr_enc_frame, &enc_frame_len);
} else if (strcmp(security_type,"tm")==0){
//Crypto_TM_ApplySecurity(buffer, &buffer_size_i);
Crypto_TM_ApplySecurity(buffer, &buffer_size_i);
} else if (strcmp(security_type,"aos")==0){
//Crypto_AOS_ApplySecurity(buffer, &buffer_size_i);
Crypto_AOS_ApplySecurity(buffer, &buffer_size_i);
}

debug_printf("Applied Security buffer size int:%d\n",buffer_size_i);
debug_printf("File content: \n");
debug_hexprintf(buffer,buffer_size_i);
#ifdef TC_DEBUG
OS_printf(KYEL "ApplySecurity Output:\n" RESET);
OS_printf(KYEL "\tBuffer size int:%d\n" RESET, enc_frame_len);
OS_printf(KYEL "\tEncrypted Frame Contents: \n\t" RESET);

for(int i=0; i < enc_frame_len; i++)
{
OS_printf(KYEL "%02X" RESET, *(ptr_enc_frame+i));
}
OS_printf("\n");
#endif

free(buffer);
free(ptr_enc_frame);
}
4 changes: 2 additions & 2 deletions fsw/crypto_util/app/crypto_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {

int arg_index = 0;
uint8 * ptr_enc_frame = NULL;
uint32 enc_frame_len;
uint16 enc_frame_len;

while(arg_index != argc-1){
security_type = argv[++arg_index];
Expand All @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {

//Call Apply/ProcessSecurity on buffer contents depending on type.
if (strcmp(security_type,"tc_a")==0){
Crypto_TC_ApplySecurity(buffer, buffer_size_i, &ptr_enc_frame, enc_frame_len);}
Crypto_TC_ApplySecurity(buffer, buffer_size_i, &ptr_enc_frame, &enc_frame_len);}
else if (strcmp(security_type,"tm_a")==0){
Crypto_TM_ApplySecurity(buffer, &buffer_size_i);
} else if (strcmp(security_type,"aos_a")==0){
Expand Down
4 changes: 2 additions & 2 deletions fsw/public_inc/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ [email protected]
// Initialization
extern int32 Crypto_Init(void);
// Telecommand (TC)
extern int32 Crypto_TC_ApplySecurity(const uint8* in_frame, const uint32 in_frame_length, \
uint8 **enc_frame, uint32 *enc_frame_len);
extern int32 Crypto_TC_ApplySecurity(const uint8* p_in_frame, const uint16 in_frame_length, \
uint8 **pp_enc_frame, uint16 *p_enc_frame_len);
extern int32 Crypto_TC_ProcessSecurity(char* ingest, int* len_ingest, TC_t* tc_sdls_processed_frame);
// Telemetry (TM)
extern int32 Crypto_TM_ApplySecurity(char* ingest, int* len_ingest);
Expand Down
6 changes: 6 additions & 0 deletions fsw/public_inc/crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ [email protected]
#define KEY_DESTROYED 3
#define KEY_CORRUPTED 4

// SA Service Types
#define SA_PLAINTEXT 0
#define SA_AUTHENTICATION 1
#define SA_ENCRYPTION 2
#define SA_AUTHENTICATED_ENCRYPTION 3

// Generic Defines
#define NUM_SA 64
#define KEY_SIZE 32
Expand Down
Loading