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

AKMC-108: Update Crypto_TC_ProcessSecurity to return unencrypted fram… #4

Merged
merged 4 commits into from
Oct 28, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")

OPTION(DEBUG "Debug" OFF) # Disabled by default
IF(DEBUG)
ADD_DEFINITIONS(-DDEBUG)
ADD_DEFINITIONS(-DDEBUG -DOCF_DEBUG -DFECF_DEBUG -DSA_DEBUG -DPDU_DEBUG -DCCSDS_DEBUG -DTC_DEBUG -DMAC_DEBUG -DTM_DEBUG)
add_compile_options(-ggdb)
ENDIF(DEBUG)

Expand Down
Binary file added fsw/crypto_tests/data/tc5.1.dat
Binary file not shown.
Binary file added fsw/crypto_tests/data/tc5.2.dat
Binary file not shown.
Binary file added fsw/crypto_tests/data/tc5.3.dat
Binary file not shown.
4 changes: 3 additions & 1 deletion fsw/crypto_util/app/crypto_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ int main(int argc, char *argv[]) {
} else if (strcmp(security_type,"aos_a")==0){
Crypto_AOS_ApplySecurity(buffer, &buffer_size_i);
} else if (strcmp(security_type,"tc_p")==0){
Crypto_TC_ProcessSecurity(buffer, &buffer_size_i);
TC_t* tc_sdls_processed_frame = malloc(sizeof(TC_t));
Crypto_TC_ProcessSecurity(buffer, &buffer_size_i,tc_sdls_processed_frame);
free(tc_sdls_processed_frame);
} else if (strcmp(security_type,"tm_p")==0){
Crypto_TM_ProcessSecurity(buffer, &buffer_size_i);
} else if (strcmp(security_type,"aos_p")==0){
Expand Down
4 changes: 3 additions & 1 deletion fsw/crypto_util/app/process_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ int main(int argc, char *argv[]) {

//Call ProcessSecurity on buffer contents depending on type.
if (strcmp(security_type,"tc")==0){
Crypto_TC_ProcessSecurity(buffer, &buffer_size_i);
TC_t* tc_sdls_processed_frame = malloc(sizeof(TC_t));
Crypto_TC_ProcessSecurity(buffer, &buffer_size_i,tc_sdls_processed_frame);
free(tc_sdls_processed_frame);
} else if (strcmp(security_type,"tm")==0){
Crypto_TM_ProcessSecurity(buffer, &buffer_size_i);
} else if (strcmp(security_type,"aos")==0){
Expand Down
5 changes: 0 additions & 5 deletions fsw/public_inc/common_types_minimum.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#endif

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/*
* NOTE - NOT DEFINING STRUCT_LOW_BIT_FIRST or STRUCT_HIGH_BIT_FIRST
Expand All @@ -59,9 +57,6 @@
typedef uint32_t uint32;
typedef uint64_t uint64;
typedef intptr_t intptr;
typedef uintptr_t cpuaddr;
typedef size_t cpusize;
typedef ptrdiff_t cpudiff;


#ifdef __cplusplus
Expand Down
4 changes: 3 additions & 1 deletion fsw/public_inc/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ ivv-itc@lists.nasa.gov
#include "cfe_minimum.h"
#endif

#include "crypto_structs.h"

#define CRYPTO_LIB_MAJOR_VERSION 1
#define CRYPTO_LIB_MINOR_VERSION 2
#define CRYPTO_LIB_REVISION 0
Expand All @@ -39,7 +41,7 @@ ivv-itc@lists.nasa.gov
extern int32 Crypto_Init(void);
// Telecommand (TC)
extern int32 Crypto_TC_ApplySecurity(char** ingest, int* len_ingest);
extern int32 Crypto_TC_ProcessSecurity(char* ingest, int* len_ingest);
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);
extern int32 Crypto_TM_ProcessSecurity(char* ingest, int* len_ingest);
Expand Down
17 changes: 13 additions & 4 deletions fsw/public_inc/crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ ivv-itc@lists.nasa.gov
// Build Defines
//#define BUILD_STATIC

// Debug Defines
// Debug Defines -- Use CMAKE options
//#define ARC_DEBUG
//#define CCSDS_DEBUG
//#define DEBUG //(CMAKE option, not hardcoded)
//#define FECF_DEBUG
//#define MAC_DEBUG
#define OCF_DEBUG
#define PDU_DEBUG
//#define OCF_DEBUG
//#define PDU_DEBUG
//#define SA_DEBUG
//#define TC_DEBUG
//#define TM_DEBUG
Expand Down Expand Up @@ -98,7 +98,8 @@ ivv-itc@lists.nasa.gov
#define NUM_KEYS 256
#define DISABLED 0
#define ENABLED 1
#define IV_SIZE 12
#define IV_SIZE 12 /* TM IV size bytes */
#define IV_SIZE_TC 4 /* TC IV size bytes */
#define OCF_SIZE 4
#define MAC_SIZE 16 /* bytes */
#define FECF_SIZE 2
Expand Down Expand Up @@ -155,10 +156,18 @@ ivv-itc@lists.nasa.gov

// CCSDS PUS Defines
#define TLV_DATA_SIZE 494 /* bytes */
#define PUS_HDR 1 //(1=true,0=false)

// TM Defines
#define TM_FRAME_DATA_SIZE 1740 /* bytes */
#define TM_FILL_SIZE 1145 /* bytes */
#define TM_PAD_SIZE 2 /* bytes */

// TC Behavior Defines
#define TC_PROCESS_SDLS_PDUS 1 //(1=true,0=false)
#define TC_SDLS_EP_VCID 4 //VCID which has SDLS PDUs (JPL uses VCIDs to determine TC type, there is no space packet layer with APIDs). Set to -1 if uses SP APIDs.
#define VCID_BITMASK 0b111111 //Some JPL missions do not use the entire CCSDS 6 bit field for VCID.
#define SEGMENTATION_HDR 1 //(1=true,0=false)
#define HAS_FECF 1 //(1=true,0=false)

#endif
8 changes: 7 additions & 1 deletion fsw/public_inc/crypto_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ ivv-itc@lists.nasa.gov
#define _crypto_structs_h_

#include "crypto_config.h"
#include <gcrypt.h>

#ifdef NOS3 //NOS3/cFS build is ready
#include "common_types.h"
#else //Assume build outside of NOS3/cFS infrastructure
#include "common_types_minimum.h"
#endif

/*
** Key Definitions
Expand Down Expand Up @@ -266,6 +271,7 @@ typedef struct
TC_FramePrimaryHeader_t tc_header;
TC_FrameSecurityHeader_t tc_sec_header;
uint8 tc_pdu[TC_FRAME_DATA_SIZE];
uint16 tc_pdu_len;
TC_FrameSecurityTrailer_t tc_sec_trailer;
} TC_t;
#define TC_SIZE (sizeof(TC_t))
Expand Down
41 changes: 41 additions & 0 deletions fsw/public_inc/itc_common_types_minimum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Minimal port of https://github.com/nasa-itc/osal/blob/master/src/os/inc/common_types.h
* needed to build standalone crypto library.
*
* Copyright (c) 2019 United States Government as represented by
* the Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _itc_common_types_minimum_
#define _itc_common_types_minimum_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

typedef uintptr_t cpuaddr;
typedef size_t cpusize;
typedef ptrdiff_t cpudiff;

#ifdef __cplusplus
}
#endif


#endif //itc_common_types_minimum_.h
Loading