#ifndef DEFINE_HEADERS_SEEN //check header file for re-def conflicts #define DEFINE_HEADERS_SEEN /* ERROR CODES TO BE USED IN DIMA */ #define DIMASTATUS int #define DIMASUCCESS 0 #define DIMAFAILURE -1 #define DIMAFILENOTFOUND -1001 #define DIMAINPUTERROR -1002 #define DIMAOUTPUTERROR -1003 #define DIMAINVALIDSTATE -1004 #define DIMASHAFAILURE -1005 #define DIMAECCFAILURE -1006 #define DIMARSAFAILURE -1007 #define DIMADRBGFAILURE -1008 #define DIMAHKDFFAILURE -1009 #define DIMAPKFAILURE -1010 #define DIMASIGNFAILURE -1011 #define DIMAVERIFYFAILURE -1012 #define DIMAINFOMISMATCH -1100 #define DIMAFAILUREUNKWN -1111 //////////////////////////////////////////////// /* CONSTANTS TO BE USED IN DIMA */ #define SHA256_DGST_SIZE 32 //bytes #define UDS_SIZE 8 #define HKDF_KEY_SIZE 32 #define HKDF_ALG MBEDTLS_MD_SHA256 #define ECC_CURVE MBEDTLS_ECP_DP_SECP256R1 //mbedtls_ecp_group_id #define RSA_HASH_ID MBEDTLS_MD_SHA256 #define RSA_SIZE 2048 //4096 #define RSA_EXP 65537 #define KEY_BUF_SIZE 16000 #define NONCE_SIZE 2 /* SPECIFIC AND SPECIAL VALUES */ /* DO NOT CHANGE THIS BLOCK */ #define IDENTITY "Identity" #define ALIAS "Alias" #define SESSION "Session" #define ACCUM_BUFF_OFFSET 2 #define ENTROPY_LEN 32 //////////////////////////////////////////////// /* DEFAULT CONFIGURATIONS */ #define DEBUG 0 //print all values when 1 #define isRSA 0 #define isECC 1 #define DFL_PKC isRSA // isECC, 1 = ECC, 0= RSA //#define BIN 2 #define PEM 0 #define DER 1 #define DFL_FORM PEM //#define DFL_PUB "keys/DID_pub." DFL_FORM //#define DFL_PRIV "SecureStorage/DID_priv" DFL_FORM //DRBG entropy source #define SW_PRNG 0 #define HW_TRNG 1 #define DETERM 2 #define DFL_ENT DETERM ////////////////////////////////////////////////// ///Stage 2 configs #define CL_NOS 2 //No of clients to be verified by THIS node //Clinet verification status #define Cl_unverf 0 #define Cl_verfd 1 #define Cl_fault -1 #define DFL_CL_STAT Cl_unverf //Client capabilities master, node, leaf //evita full, med, small #define CAP_FULL 1 #define DFL_CAP CAP_FULL /////////////////////////////////////////////////// /* typedefs */ typedef struct { /* Use this typedef to define settings and vlaues to be passed to deriveECCKeyPair() To be used or exchanging data between ROM and FW */ int ENT_MODE; //SW_PRNG,HW_TRNG,DETERM, int PKC_MODE; //isRSA, isECC const uint8_t * seed; const char * phrase; //IDENTITY,ALIAS,SESSION int KEY_FORM; //BIN,PEM,DER char * pub_file; char * priv_file; //placeholder, not implemented mbedtls_ecp_point * pub_key; //used to store keys in mem, if needed mbedtls_mpi * priv_key; } KeyDrv_context; typedef struct { /** Use this typedef to feed info to hash calculator **/ const char * filename; //in file size_t inLen; uint8_t * outbuf; //out buf } Hash_context; //useless structure ^ this one typedef struct { /* Use this struct to load, store and update client info on server side or both ways if mutual attestation is possible */ const char * cli_ID; const char * pub_file; mbedtls_ecp_point * pub_key; int Cli_STATUS; int Cli_CAP; const uint8_t * NONCE; } Client_info; typedef struct { //Use this struct to maintain uniformity between client and sever const char * cli_ID; const uint8_t * NONCE; const uint8_t * sign; const size_t sig_len; } Chall_context; typedef struct { //Use this struct to maintain uniformity between client and sever const char * cli_ID; const uint8_t * NONCE; const uint8_t * sign; const size_t sig_len; } Resp_context; #endif //DEFINE_HEADERS_SEEN //End of file