/* 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 DIMAFAILUREUNKWN -1111 /* CONSTANTS TO BE USED IN DIMA */ #define SHA256_DGST_SIZE 32 //bytes #define UDS_SIZE 8 #define CDI_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 /* DEFAULT CONFIGURATIONS */ #define DEBUG 1 //print all values when 1 #define isRSA 0 #define isECC 1 #define DFL_PKC isECC // isECC, 1 = ECC, 0= RSA #define BIN 0 #define PEM 1 #define DER 2 #define DFL_FORM PEM //DRBG entropy source #define SW_PRNG 0 #define HW_TRNG 1 #define DETERM 2 #define DFL_ENT HW_TRNG /* 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 /* typedes */ 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; } 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_contxt;