162 lines
3.3 KiB
C
162 lines
3.3 KiB
C
|
|
#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 DIMANETWORKFAILURE -1020
|
|
|
|
#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 1
|
|
#define SIGN_SIZE 256 //bytes
|
|
|
|
#define NETBUFSIZE 2048
|
|
#define PAD 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 isECC // 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
|
|
|
|
#define Cl_verfd 1
|
|
#define Cl_active 0
|
|
#define Cl_fault -1
|
|
#define DFL_CL_STAT Cl_active
|
|
|
|
//Client capabilities master, node, leaf
|
|
//evita full, med, small
|
|
#define CAP_FULL 1
|
|
|
|
#define DFL_CAP CAP_FULL
|
|
|
|
|
|
|
|
|
|
#define SERVER_ADD "localhost"
|
|
#define SERVER_PORT "11999"
|
|
#define PLAINTEXT "==Hello there!=="
|
|
|
|
#define MASTER_ID "01"
|
|
#define CLIENT1_ID "02"
|
|
#define CLIENT2_ID "03"
|
|
#define CLIENT3_ID "04"
|
|
|
|
#define DFL_ID MASTER_ID //change ID according to node
|
|
#define NODE_ID_SIZE 8
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
#endif //DEFINE_HEADERS_SEEN
|
|
//End of file
|