diff --git a/trial4/ECCtrial.c b/ch-resp-self/ECCtrial.c similarity index 100% rename from trial4/ECCtrial.c rename to ch-resp-self/ECCtrial.c diff --git a/trial4/KeyGen.c b/ch-resp-self/KeyGen.c similarity index 99% rename from trial4/KeyGen.c rename to ch-resp-self/KeyGen.c index 75894b8..d9b7c37 100644 --- a/trial4/KeyGen.c +++ b/ch-resp-self/KeyGen.c @@ -49,6 +49,8 @@ void cleanup() DIMASTATUS use_dev_random(void *data, unsigned char *output, size_t len, size_t *olen ) { + //initiate HW TRNG + FILE *file; size_t ret, left = len; unsigned char *p = output; diff --git a/trial4/KeyGen.h b/ch-resp-self/KeyGen.h similarity index 90% rename from trial4/KeyGen.h rename to ch-resp-self/KeyGen.h index c031a55..d381277 100644 --- a/trial4/KeyGen.h +++ b/ch-resp-self/KeyGen.h @@ -1,3 +1,8 @@ +#ifndef KEYGEN_HEADERS_SEEN +//check header file for re-def conflicts + +#define KEYGEN_HEADERS_SEEN + #include #include @@ -47,3 +52,6 @@ DIMASTATUS AsymmKeyGen(KeyDrv_context * KD_ctx); DIMASTATUS WritePrivKey(KeyDrv_context * KD_ctx, mbedtls_pk_context * key_ctx); DIMASTATUS WritePubKey(KeyDrv_context * KD_ctx, mbedtls_pk_context * key_ctx); + + +#endif //KEYGEN_HEADERS_SEEN \ No newline at end of file diff --git a/ch-resp-self/ROMprotocol.c b/ch-resp-self/ROMprotocol.c new file mode 100644 index 0000000..0ce64b0 --- /dev/null +++ b/ch-resp-self/ROMprotocol.c @@ -0,0 +1,273 @@ +#include "ROMprotocol.h" + + +/* + DIMASTATUS ret = 0; + int len = 0; + + +if(DEBUG) +{printf("PASS \n");} + +if(ret < DIMASUCCESS) + { + perror("\n"); + + //other cleanup + exit(); + } + +*/ + +DIMASTATUS ROMprotocol() +{ + + printf("PASS 10\n"); + + DIMASTATUS ret = 0; + int len = 0; + + if(DEBUG) + {printf("PASS 11\n");} + + + //Calculate DIMA RTM hash + + //////////////TODO//////////////// + //this should be calculated on the DIMA bin and remain static. + //how to do that? + //hardcoding junk value for now + + uint8_t RTM_ID[SHA256_DGST_SIZE] = { 0xbe,0x67,0x0a,0xf8,0xf3,0x92,0x0e,0x4f, + 0xba,0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc, + 0xf1,0xd9,0x30,0xe2,0x33,0xcc,0x28,0xc5, + 0x7b,0xbb,0x38,0x7d,0xe6,0x66,0xbb,0x1e }; + + //Calculating UDS hash + + FILE *fp = NULL; + fp = fopen("SecureStorage/RANDFILE", "rb"); + if(!fp) + { + perror("DIMAFILENOTFOUND: Unable to access UDS\n"); + + fclose(fp); + exit(DIMAFILENOTFOUND); + } + + if(DEBUG) +{printf("PASS 12\n");} + + uint8_t *UDSbuf = calloc(1, sizeof(uint8_t)*SHA256_DGST_SIZE); + fread(UDSbuf,UDS_SIZE,1,fp); + fclose(fp); + +if(DEBUG) +{printf("PASS 13\n");} + + + uint8_t* UDS_ID = calloc(1,sizeof(uint8_t)*SHA256_DGST_SIZE); + ret = mbedtls_sha256_ret( UDSbuf,UDS_SIZE,UDS_ID,0 ); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILUE:\n"); + + free(UDSbuf); + free(UDS_ID); + exit(DIMAFAILUREUNKWN); + } + + free(UDSbuf); + //UDS_ID contains the UDS hash + //Printer +if(DEBUG) +{ + for (int i = 0; i < UDS_SIZE; i++) + printf("%hhx", UDSbuf[i]); + printf(" : fuse secret\n" ); + + for (int i = 0; i < SHA256_DGST_SIZE; i++) + printf("%hhx", UDS_ID[i]); + printf(" : UDS ID\n" ); +} + + //Calculating CDI SHA256 + + uint8_t* CDI = calloc(1,sizeof(uint8_t)*SHA256_DGST_SIZE); + mbedtls_sha256_context CDI_ctx; + mbedtls_sha256_init(&CDI_ctx); + + ret = mbedtls_sha256_starts_ret(&CDI_ctx,0); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE\n"); + mbedtls_sha256_free(&CDI_ctx); + exit(DIMASHAFAILURE); + } + + ret = mbedtls_sha256_update_ret(&CDI_ctx, UDS_ID, SHA256_DGST_SIZE); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE\n"); + mbedtls_sha256_free(&CDI_ctx); + exit(DIMASHAFAILURE); + } + + ret = mbedtls_sha256_update_ret(&CDI_ctx, RTM_ID, SHA256_DGST_SIZE); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE\n"); + mbedtls_sha256_free(&CDI_ctx); + exit(DIMASHAFAILURE); + } + + ret = mbedtls_sha256_finish_ret(&CDI_ctx,CDI); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE\n"); + mbedtls_sha256_free(&CDI_ctx); + exit(DIMASHAFAILURE); + } + + free(UDS_ID); + //free(RTM_ID); + mbedtls_sha256_free(&CDI_ctx); + +if(DEBUG) +{ + for(int i = 0; i < SHA256_DGST_SIZE; i++) + printf("%hhx",CDI[i]); + printf(" : CDI\n"); +} + +if(DEBUG) +{printf("PASS 14\n");} + //Calculating CDI key, HKDF + + const mbedtls_md_info_t * md_info; + if(!(md_info = mbedtls_md_info_from_type(HKDF_ALG))) + { + perror("DIMAHKDFFAILURE: MD alg type def failed\n"); + exit(DIMAHKDFFAILURE); + } + + uint8_t salt[32] = { 0x30,0xe2,0x3e,0xcc,0x28,0xc5,0x7b,0xbb, + 0x38,0x7d,0xe6,0x66,0xbb,0xf1,0xd9,0x1e, + 0xbe,0x67,0x0a,0xf8,0xf3,0x92,0x0e,0xba, + 0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc,0x4f }; + + uint8_t * CDIKEY = calloc(1, sizeof(uint8_t)*HKDF_KEY_SIZE); + ret = mbedtls_hkdf(md_info, salt, sizeof(salt), CDI, SHA256_DGST_SIZE, + IDENTITY, sizeof(IDENTITY), CDIKEY, HKDF_KEY_SIZE); + + if(ret < DIMASUCCESS) + { + perror("DIMAHKDFFAILURE\n"); + free(CDI); + free(CDIKEY); + exit(DIMAHKDFFAILURE); + } + + //free(CDI); + +if(DEBUG) +{ + for(int i = 0; i < HKDF_KEY_SIZE; i++) + printf("%hhx",CDIKEY[i]); + printf(" : CDIKEY\n"); +} + +if(DEBUG) +{printf("PASS 15\n");} + + + + //Every key derivation should start with a new KD contxt + //setting context for DID + + KeyDrv_context DID_ctx; + DID_ctx.ENT_MODE = DETERM; + DID_ctx.PKC_MODE = DFL_PKC; + DID_ctx.seed = CDIKEY; + DID_ctx.phrase = IDENTITY; + DID_ctx.KEY_FORM = DFL_FORM; + //DID_ctx.pub_file = DFL_PUB; + //DID_ctx.priv_file = DFL_PRIV; //Dont save DID priv outside SS + +if(DEBUG) +{printf("PASS 16\n");} + + //Deriving and storing DID + ret = AsymmKeyGen(&DID_ctx); + if(ret < DIMASUCCESS) + { + perror("DIMAFAILURE : DID key gen failed\n"); + free(CDIKEY); + exit(DIMAFAILURE); + } + + free(CDIKEY); //But CDIKey is needed to gen AliasKP + //delete DID_ctx?? + + //setting context for Alias keys + +//////////////////////////deriving alisa keys + + + //placeholder FW_ID + uint8_t FW_ID[SHA256_DGST_SIZE] = { 0xf3,0x92,0x0e,0x4f,0xbe,0x67,0x0a,0xf8, + 0xf1,0xd9,0x30,0xe2,0x33,0xcc,0x28,0xc5, + 0xba,0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc, + 0xe6,0x66,0xbb,0x1e,0x7b,0xbb,0x38,0x7d }; + + uint8_t * FWKEY = calloc(1, sizeof(uint8_t)*HKDF_KEY_SIZE); + + //create Alias key derivation material using CDI and seed and FW_ID as salt + //Alternatively do composite hash of CDI and FW_ID to create Alias key der material + ret = mbedtls_hkdf(md_info, FW_ID, sizeof(FW_ID), CDI, SHA256_DGST_SIZE, + ALIAS, sizeof(ALIAS), FWKEY, HKDF_KEY_SIZE); + + if(ret < DIMASUCCESS) + { + perror("DIMAHKDFFAILURE\n"); + exit(DIMAHKDFFAILURE); + } + + KeyDrv_context ALIAS_ctx; + ALIAS_ctx.ENT_MODE = DETERM; + ALIAS_ctx.PKC_MODE = DFL_PKC; + ALIAS_ctx.seed = FWKEY; + ALIAS_ctx.phrase = ALIAS; + ALIAS_ctx.KEY_FORM = DFL_FORM; + + printf("Generating Alias keys\n"); + + ret = AsymmKeyGen(&ALIAS_ctx); + if(ret < DIMASUCCESS) + { + perror("DIMAFAILURE : ALIAS key gen failed\n"); + exit(DIMAFAILURE); + } + + + //session keys? + + free(CDI); + free(FWKEY); + + +if(DEBUG) +{printf("PASS 17\n");} + + + + +if(DEBUG) +{printf("PASS 100\n");} + return DIMASUCCESS; + +} + + + +///////////////////////// diff --git a/trial4/ROMprotocol.h b/ch-resp-self/ROMprotocol.h similarity index 75% rename from trial4/ROMprotocol.h rename to ch-resp-self/ROMprotocol.h index 8556253..57d4fef 100644 --- a/trial4/ROMprotocol.h +++ b/ch-resp-self/ROMprotocol.h @@ -1,3 +1,9 @@ +#ifndef ROMprot_HEADERS_SEEN +//check header file for re-def conflicts + +#define ROMprot_HEADERS_SEEN + + #include "KeyGen.h" #include @@ -21,4 +27,9 @@ -DIMASTATUS ROMprotocol(void); \ No newline at end of file +DIMASTATUS ROMprotocol(void); + + + + +#endif \ No newline at end of file diff --git a/ch-resp-self/SecureStorage/Identity_priv.pem b/ch-resp-self/SecureStorage/Identity_priv.pem new file mode 100644 index 0000000..3484778 --- /dev/null +++ b/ch-resp-self/SecureStorage/Identity_priv.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA1FomNTVE/DdCHc0JAOZW6BC6zwcZOklne1FFni0EXJYNL4mY +XyDvigv6zOQObjYtgKIwj01WSxAA1/4EcjfcVt6sR+I0ufEjoSDF/WX+5jFc/k5l +dnWwZzBBEfZVSuZu8LAhqpj7woY95x9QzvNGKq0neEIonihRSnQTfwingDsKd6+c +i0H85Pi7lJ9bGpVTGlE9AMQBQvHRlnl3Ig+L7UDeNN4CDAXYvIqXTq0RQ+OvdvMY +g1AfZ4rGoa91Cw208zb3FCnGIpCQWGUSDypdQgo0ptQU8UiaTmF0hW0q3TeG8763 +uMKQA3QVZIASA6hp2oMVcDjeWo8+pd7Ig2iqsQIDAQABAoIBACquowrjVeYfIkA0 +r9hZNAMpp67Ipbq4Od9IzuYz9LI6a9SQAssuJs+XyFWqCjd/VsaJ8xo+qHdmdFD1 +ywV9MmHYmIbLUh9Et41htcIQ3/r7VY59CfpVPfuDsLSQT4UCS66/rEiqvsHS8zrT +Kc4rCkG2M56Bp8HgZzSAn9GTFv3YImFzqb7fnJA84vAmWqneet6+uZK6iYjznJ3p +jlyyUhMtnqI55nRlArlwb9stcwVRqtgTB+ztUFVCuAtYRWUBWmWdXhllzF2AO22Z +tq03kC0y2QT178Smgkn7AT9/DLG7TnqS5xbCPwg5wK48IPh7okwYritJaSKlLPQu +Xbha9TUCgYEA8W/Pw2I1yALKyNEzkPp2jFczUjcuxT8zPYEq9tLAItw3V3AIJbbI +tE3UFqnFcCszcsJnHmsnxkbfRQlnq0gGiopGs5KjqUDae4QiL/s03U2Voo937ghG ++BtWn2uf6CV7GBe0W7XqLwltWurUZQj0Y9Q+nPY19Libnm/1CGdWSJ0CgYEA4Sk4 +714u5IqK5eH69ETMmYZoapE41vykr6Pn0iWF/tNPlIV/x2MU1+5n9rfqQ3ty2zlk +Bn5+In89a8Jqw8kMOG1nOaIWb0uz5Xs3bRxOXTdfB1S4ENdTYlbag9FcRG1kHGI6 +5wyIDVy3dC/4fB10QoIt8P4h3OW6DO1xLvZLHCUCgYEA616HewB5Ub13F4Lq9IFX +pMU14Qau79gHCgSsb+dRLCrnQLSVHL8utqfRBS8IratQAqaGhN8N7XwWGWVrzUzw +I4teFZ31MwFofVV5RrFs/fmu0MVws3saRLHSJqRzRYuUjw4849Nas/RKyYF5Ae5S +4id9yuM0ApkeDL00cbbcJPkCgYAWWGj2GHq+46D1P4AQTeOgON6T9OWXMGuHotSW +3nJ137K+IqGTwBmJdHeM3KO7Hr0/VGrA2jzaX5ZQ43KFC6bS0sizx4pCcVjhJWFS +ysRcK+qaZ6X8xeHYmJYHDvgBMnoE9xqxY2T9Ln5mYXxflOy8zP6SNCZYLdRRBB9/ +caHyoQKBgQDhJqhzsNBiNp8ViVh9hGNfC991M2BeXojSuTwOY07uaepMgk5qcvaR +H0HQULeflblkRuf2BxslmRMmNp/1P8uCFVnd1t+XIjz7r6RFxTsgnSTd/ee6V7Nl +vgMTOj11Kz7cWjH+4LCfc/CtIZKvkQnM/1uAQMzjr2K6+fNQAZFBKw== +-----END RSA PRIVATE KEY----- diff --git a/trial4/SecureStorage/RANDFILE b/ch-resp-self/SecureStorage/RANDFILE similarity index 66% rename from trial4/SecureStorage/RANDFILE rename to ch-resp-self/SecureStorage/RANDFILE index fd3981b..3a0d8a4 100644 Binary files a/trial4/SecureStorage/RANDFILE and b/ch-resp-self/SecureStorage/RANDFILE differ diff --git a/ch-resp-self/Stage2.c b/ch-resp-self/Stage2.c new file mode 100644 index 0000000..c710b45 --- /dev/null +++ b/ch-resp-self/Stage2.c @@ -0,0 +1,218 @@ +#include "Stage2.h" + +/* + Client_info + const char * cli_ID; + const char * pub_file; + mbedtls_ecp_point * pub_key; + int Cli_STATUS; + int Cli_CAP; +*/ + + +DIMASTATUS load_nodes(Client_info * Cl_list) +{ + + printf("PASS 20\n"); + DIMASTATUS ret = 0; + int len = 0; + + mbedtls_entropy_context entropy; + mbedtls_entropy_init(&entropy); + + uint8_t * RAND = calloc(1, sizeof(uint8_t)*NONCE_SIZE); + + if(DEBUG) + {printf("PASS 21\n");} + + //load from access list? + //////////////////////////TODO//////////////////////////// + //Protected accesslist must be unlocked with Alias key + //Allow access to client list only after successful DICE + + + //itrate over client list : perclient + Client_info Cl1_ctx; + Cl1_ctx.cli_ID = "Node1"; + Cl1_ctx.pub_file = "clientkeys/Client1_pub.pem"; + Cl1_ctx.Cli_STATUS = Cl_unverf; + Cl1_ctx.Cli_CAP = DFL_CAP; + + //mbedtls_entropy_gather(&entropy); + ret = mbedtls_entropy_func(&entropy, RAND, sizeof(RAND)); + if(ret < DIMASUCCESS) + { + perror("DIMADRBGFAILURE : Failed to gen NONCE\n"); + exit(DIMADRBGFAILURE); + } + + Cl1_ctx.NONCE = RAND; + + /* + if(DEBUG) + { + for(int i = 0; i < NONCE_SIZE; i++) + printf("%hhx",Cl1_ctx.NONCE[i]); + printf(" : NONCE inter\n"); + } + */ + + //add to the client list + Cl_list[1] = Cl1_ctx; + + //end perclient itetration + + mbedtls_entropy_free(&entropy); + return DIMASUCCESS; +} + +/* NOT USING THIS + +DIMASTATUS genNONCE(Client_info * Cl_ctx) +{ + +// +//1. create new genNONCe session n entropy per client +//2. pass client list iterate over active clients genNONCE for all +// + + mbedtls_entropy_context entropy; + mbedtls_entropy_init(&entropy); + + DIMASTATUS ret = 0; + + uint8_t * RAND = calloc(1, sizeof(uint8_t)*NONCE_SIZE); +if(DEBUG)printf("Pass1\n"); + + //mbedtls_entropy_gather(&entropy); + ret = mbedtls_entropy_func(&entropy, RAND, sizeof(RAND)); + if(ret < DIMASUCCESS) + { + perror("DIMADRBGFAILURE : Failed to gen NONCE\n"); + exit(DIMADRBGFAILURE); + } + +if(DEBUG)printf("Pass2\n"); + Cl_ctx -> NONCE = RAND; + + if(DEBUG) + { + for(int i = 0; i < NONCE_SIZE; i++) + printf("%hhx",RAND[i]); + printf(" : RAND\n"); + } + if(DEBUG) + { + for(int i = 0; i < NONCE_SIZE; i++) + printf("%hhx",Cl_ctx -> NONCE[i]); + printf(" : NONCE\n"); + } + + mbedtls_entropy_free(&entropy); + + return DIMASUCCESS; +} + + +*/ + +DIMASTATUS challenge( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, uint8_t *sign, size_t *signlen) +{ + + DIMASTATUS ret = 0; + uint8_t* dgst = calloc(1,sizeof(uint8_t)*SHA256_DGST_SIZE); + + ret = mbedtls_sha256_ret( Cl_ctx->NONCE,NONCE_SIZE,dgst,0 ); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE : could not perfom SHA digest\n"); + return DIMASHAFAILURE; + } + +// ret = mbedtls_md(mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), +// Cl_list[1].NONCE, NONCE_SIZE, hash ); + + if(DEBUG) + { + for (int i = 0; i < SHA256_DGST_SIZE; i++) + printf("%hhx", dgst[i]); + printf(" : sha dgst\n" ); + + } + + //ret = mbedtls_pk_sign( &pk_ctx, MBEDTLS_MD_SHA256, dgst, SHA256_DGST_SIZE, sign, &signlen, + // mbedtls_ctr_drbg_random, &drbgCtx ); + ret = mbedtls_pk_sign( pk_ctx, MBEDTLS_MD_SHA256, dgst, SHA256_DGST_SIZE, sign, signlen, + NULL,NULL ); + + if(ret < DIMASUCCESS) + { + perror("DIMASIGNFAILURE : could not perfom private key signature\n"); + return DIMASIGNFAILURE; + } + + if(DEBUG) + { + for (int i = 0; i < *signlen; i++) + printf("%hhx", sign[i]); + printf(" :signature intr\n" ); + + } + return DIMASUCCESS; + +} + + +DIMASTATUS response( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, uint8_t *sign, size_t signlen) +{ + + //Paramer checks + if(Cl_ctx->Cli_STATUS != Cl_unverf) + { + printf("DIMAINFOMISMATCH :Client %s verification already performed. skipping to next client..", Cl_ctx->cli_ID); + return DIMAINFOMISMATCH; + } + + ////// + + DIMASTATUS ret = 0; + uint8_t* dgst = calloc(1,sizeof(uint8_t)*SHA256_DGST_SIZE); + + ret = mbedtls_sha256_ret( Cl_ctx->NONCE,NONCE_SIZE,dgst,0 ); + if(ret < DIMASUCCESS) + { + perror("DIMASHAFAILURE : could not perfom SHA digest\n"); + return DIMASHAFAILURE; + } + + /* + if(DEBUG) + { + for(int i = 0; i < NONCE_SIZE; i++) + printf("%hhx",Cl_ctx.NONCE[i]); + printf(" : NONCE verf\n"); + } + + if(DEBUG) + { + for (int i = 0; i < signlen; i++) + printf("%hhx", sign[i]); + printf(" :signature verf\n" ); + + } + */ + + ret = mbedtls_pk_verify( pk_ctx, MBEDTLS_MD_SHA256, dgst, 0, sign, signlen ); + if (ret < DIMASUCCESS) + { + perror("DIMAVERIFYFAILURE : could not verify signature\n"); + Cl_ctx->Cli_STATUS = Cl_fault; + return DIMAVERIFYFAILURE; + } + + Cl_ctx->Cli_STATUS = Cl_verfd; + + + return DIMASUCCESS; + +} \ No newline at end of file diff --git a/ch-resp-self/Stage2.h b/ch-resp-self/Stage2.h new file mode 100644 index 0000000..1198f31 --- /dev/null +++ b/ch-resp-self/Stage2.h @@ -0,0 +1,45 @@ +#ifndef STAGE2_HEADERS_SEEN +//check header file for re-def conflicts + +#define STAGE2_HEADERS_SEEN + +#include +#include +#include +#include + +#include "mbedtls/config.h" + +#include "mbedtls/aes.h" +#include "mbedtls/bignum.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ecp.h" +#include "mbedtls/ecdh.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/hkdf.h" +#include "mbedtls/md.h" +#include "mbedtls/pk.h" +#include "mbedtls/rsa.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" + + +#include "defines.h" + + +DIMASTATUS load_nodes(Client_info * Cl_list); + +DIMASTATUS genNONCE( Client_info * Cl_ctx); + +DIMASTATUS challenge( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, uint8_t *sign, size_t *signlen); +//DIMASTATUS challengeCTX( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, Chall_context * ch_ctx); + + +DIMASTATUS response( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, uint8_t *sign, size_t signlen); +//DIMASTATUS responseCTX( mbedtls_pk_context * pk_ctx, Client_info * Cl_ctx, Resp_context * resp_ctx); + + + +#endif \ No newline at end of file diff --git a/ch-resp-self/clientkeys/Client1_pub.pem b/ch-resp-self/clientkeys/Client1_pub.pem new file mode 100644 index 0000000..4a6b64a --- /dev/null +++ b/ch-resp-self/clientkeys/Client1_pub.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3oUdlMtMjJjf6Co58GJZEV2bvqrQ +KUOu4cC822amlPgucZnX7gI4VbqqJ/Tjk5IieiNBFbh0/2vsyRo3Lis58A== +-----END PUBLIC KEY----- diff --git a/trial4/defines.h b/ch-resp-self/defines.h similarity index 58% rename from trial4/defines.h rename to ch-resp-self/defines.h index 5d8e631..9a527e7 100644 --- a/trial4/defines.h +++ b/ch-resp-self/defines.h @@ -1,4 +1,9 @@ +#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 @@ -16,6 +21,11 @@ #define DIMADRBGFAILURE -1008 #define DIMAHKDFFAILURE -1009 #define DIMAPKFAILURE -1010 +#define DIMASIGNFAILURE -1011 +#define DIMAVERIFYFAILURE -1012 + + +#define DIMAINFOMISMATCH -1100 #define DIMAFAILUREUNKWN -1111 @@ -33,6 +43,10 @@ #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 */ @@ -51,7 +65,7 @@ #define isRSA 0 #define isECC 1 -#define DFL_PKC isECC // isECC, 1 = ECC, 0= RSA +#define DFL_PKC isRSA // isECC, 1 = ECC, 0= RSA //#define BIN 2 #define PEM 0 @@ -72,6 +86,24 @@ ////////////////////////////////////////////////// +///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 */ @@ -88,6 +120,9 @@ typedef struct 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; @@ -99,6 +134,49 @@ typedef struct const char * filename; //in file size_t inLen; uint8_t * outbuf; //out buf -} Hash_contxt; +} 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 \ No newline at end of file diff --git a/trial4/include/.gitignore b/ch-resp-self/include/.gitignore similarity index 100% rename from trial4/include/.gitignore rename to ch-resp-self/include/.gitignore diff --git a/trial4/include/CMakeLists.txt b/ch-resp-self/include/CMakeLists.txt similarity index 100% rename from trial4/include/CMakeLists.txt rename to ch-resp-self/include/CMakeLists.txt diff --git a/trial4/include/mbedtls/aes.h b/ch-resp-self/include/mbedtls/aes.h similarity index 100% rename from trial4/include/mbedtls/aes.h rename to ch-resp-self/include/mbedtls/aes.h diff --git a/trial4/include/mbedtls/aesni.h b/ch-resp-self/include/mbedtls/aesni.h similarity index 100% rename from trial4/include/mbedtls/aesni.h rename to ch-resp-self/include/mbedtls/aesni.h diff --git a/trial4/include/mbedtls/arc4.h b/ch-resp-self/include/mbedtls/arc4.h similarity index 100% rename from trial4/include/mbedtls/arc4.h rename to ch-resp-self/include/mbedtls/arc4.h diff --git a/trial4/include/mbedtls/aria.h b/ch-resp-self/include/mbedtls/aria.h similarity index 100% rename from trial4/include/mbedtls/aria.h rename to ch-resp-self/include/mbedtls/aria.h diff --git a/trial4/include/mbedtls/asn1.h b/ch-resp-self/include/mbedtls/asn1.h similarity index 100% rename from trial4/include/mbedtls/asn1.h rename to ch-resp-self/include/mbedtls/asn1.h diff --git a/trial4/include/mbedtls/asn1write.h b/ch-resp-self/include/mbedtls/asn1write.h similarity index 100% rename from trial4/include/mbedtls/asn1write.h rename to ch-resp-self/include/mbedtls/asn1write.h diff --git a/trial4/include/mbedtls/base64.h b/ch-resp-self/include/mbedtls/base64.h similarity index 100% rename from trial4/include/mbedtls/base64.h rename to ch-resp-self/include/mbedtls/base64.h diff --git a/trial4/include/mbedtls/bignum.h b/ch-resp-self/include/mbedtls/bignum.h similarity index 100% rename from trial4/include/mbedtls/bignum.h rename to ch-resp-self/include/mbedtls/bignum.h diff --git a/trial4/include/mbedtls/blowfish.h b/ch-resp-self/include/mbedtls/blowfish.h similarity index 100% rename from trial4/include/mbedtls/blowfish.h rename to ch-resp-self/include/mbedtls/blowfish.h diff --git a/trial4/include/mbedtls/bn_mul.h b/ch-resp-self/include/mbedtls/bn_mul.h similarity index 100% rename from trial4/include/mbedtls/bn_mul.h rename to ch-resp-self/include/mbedtls/bn_mul.h diff --git a/trial4/include/mbedtls/camellia.h b/ch-resp-self/include/mbedtls/camellia.h similarity index 100% rename from trial4/include/mbedtls/camellia.h rename to ch-resp-self/include/mbedtls/camellia.h diff --git a/trial4/include/mbedtls/ccm.h b/ch-resp-self/include/mbedtls/ccm.h similarity index 100% rename from trial4/include/mbedtls/ccm.h rename to ch-resp-self/include/mbedtls/ccm.h diff --git a/trial4/include/mbedtls/certs.h b/ch-resp-self/include/mbedtls/certs.h similarity index 100% rename from trial4/include/mbedtls/certs.h rename to ch-resp-self/include/mbedtls/certs.h diff --git a/trial4/include/mbedtls/chacha20.h b/ch-resp-self/include/mbedtls/chacha20.h similarity index 100% rename from trial4/include/mbedtls/chacha20.h rename to ch-resp-self/include/mbedtls/chacha20.h diff --git a/trial4/include/mbedtls/chachapoly.h b/ch-resp-self/include/mbedtls/chachapoly.h similarity index 100% rename from trial4/include/mbedtls/chachapoly.h rename to ch-resp-self/include/mbedtls/chachapoly.h diff --git a/trial4/include/mbedtls/check_config.h b/ch-resp-self/include/mbedtls/check_config.h similarity index 100% rename from trial4/include/mbedtls/check_config.h rename to ch-resp-self/include/mbedtls/check_config.h diff --git a/trial4/include/mbedtls/cipher.h b/ch-resp-self/include/mbedtls/cipher.h similarity index 100% rename from trial4/include/mbedtls/cipher.h rename to ch-resp-self/include/mbedtls/cipher.h diff --git a/trial4/include/mbedtls/cipher_internal.h b/ch-resp-self/include/mbedtls/cipher_internal.h similarity index 100% rename from trial4/include/mbedtls/cipher_internal.h rename to ch-resp-self/include/mbedtls/cipher_internal.h diff --git a/trial4/include/mbedtls/cmac.h b/ch-resp-self/include/mbedtls/cmac.h similarity index 100% rename from trial4/include/mbedtls/cmac.h rename to ch-resp-self/include/mbedtls/cmac.h diff --git a/trial4/include/mbedtls/compat-1.3.h b/ch-resp-self/include/mbedtls/compat-1.3.h similarity index 100% rename from trial4/include/mbedtls/compat-1.3.h rename to ch-resp-self/include/mbedtls/compat-1.3.h diff --git a/trial4/include/mbedtls/config.h b/ch-resp-self/include/mbedtls/config.h similarity index 100% rename from trial4/include/mbedtls/config.h rename to ch-resp-self/include/mbedtls/config.h diff --git a/trial4/include/mbedtls/ctr_drbg.h b/ch-resp-self/include/mbedtls/ctr_drbg.h similarity index 100% rename from trial4/include/mbedtls/ctr_drbg.h rename to ch-resp-self/include/mbedtls/ctr_drbg.h diff --git a/trial4/include/mbedtls/debug.h b/ch-resp-self/include/mbedtls/debug.h similarity index 100% rename from trial4/include/mbedtls/debug.h rename to ch-resp-self/include/mbedtls/debug.h diff --git a/trial4/include/mbedtls/des.h b/ch-resp-self/include/mbedtls/des.h similarity index 100% rename from trial4/include/mbedtls/des.h rename to ch-resp-self/include/mbedtls/des.h diff --git a/trial4/include/mbedtls/dhm.h b/ch-resp-self/include/mbedtls/dhm.h similarity index 100% rename from trial4/include/mbedtls/dhm.h rename to ch-resp-self/include/mbedtls/dhm.h diff --git a/trial4/include/mbedtls/ecdh.h b/ch-resp-self/include/mbedtls/ecdh.h similarity index 100% rename from trial4/include/mbedtls/ecdh.h rename to ch-resp-self/include/mbedtls/ecdh.h diff --git a/trial4/include/mbedtls/ecdsa.h b/ch-resp-self/include/mbedtls/ecdsa.h similarity index 100% rename from trial4/include/mbedtls/ecdsa.h rename to ch-resp-self/include/mbedtls/ecdsa.h diff --git a/trial4/include/mbedtls/ecjpake.h b/ch-resp-self/include/mbedtls/ecjpake.h similarity index 100% rename from trial4/include/mbedtls/ecjpake.h rename to ch-resp-self/include/mbedtls/ecjpake.h diff --git a/trial4/include/mbedtls/ecp.h b/ch-resp-self/include/mbedtls/ecp.h similarity index 100% rename from trial4/include/mbedtls/ecp.h rename to ch-resp-self/include/mbedtls/ecp.h diff --git a/trial4/include/mbedtls/ecp_internal.h b/ch-resp-self/include/mbedtls/ecp_internal.h similarity index 100% rename from trial4/include/mbedtls/ecp_internal.h rename to ch-resp-self/include/mbedtls/ecp_internal.h diff --git a/trial4/include/mbedtls/entropy.h b/ch-resp-self/include/mbedtls/entropy.h similarity index 100% rename from trial4/include/mbedtls/entropy.h rename to ch-resp-self/include/mbedtls/entropy.h diff --git a/trial4/include/mbedtls/entropy_poll.h b/ch-resp-self/include/mbedtls/entropy_poll.h similarity index 100% rename from trial4/include/mbedtls/entropy_poll.h rename to ch-resp-self/include/mbedtls/entropy_poll.h diff --git a/trial4/include/mbedtls/error.h b/ch-resp-self/include/mbedtls/error.h similarity index 100% rename from trial4/include/mbedtls/error.h rename to ch-resp-self/include/mbedtls/error.h diff --git a/trial4/include/mbedtls/gcm.h b/ch-resp-self/include/mbedtls/gcm.h similarity index 100% rename from trial4/include/mbedtls/gcm.h rename to ch-resp-self/include/mbedtls/gcm.h diff --git a/trial4/include/mbedtls/havege.h b/ch-resp-self/include/mbedtls/havege.h similarity index 100% rename from trial4/include/mbedtls/havege.h rename to ch-resp-self/include/mbedtls/havege.h diff --git a/trial4/include/mbedtls/hkdf.h b/ch-resp-self/include/mbedtls/hkdf.h similarity index 100% rename from trial4/include/mbedtls/hkdf.h rename to ch-resp-self/include/mbedtls/hkdf.h diff --git a/trial4/include/mbedtls/hmac_drbg.h b/ch-resp-self/include/mbedtls/hmac_drbg.h similarity index 100% rename from trial4/include/mbedtls/hmac_drbg.h rename to ch-resp-self/include/mbedtls/hmac_drbg.h diff --git a/trial4/include/mbedtls/md.h b/ch-resp-self/include/mbedtls/md.h similarity index 100% rename from trial4/include/mbedtls/md.h rename to ch-resp-self/include/mbedtls/md.h diff --git a/trial4/include/mbedtls/md2.h b/ch-resp-self/include/mbedtls/md2.h similarity index 100% rename from trial4/include/mbedtls/md2.h rename to ch-resp-self/include/mbedtls/md2.h diff --git a/trial4/include/mbedtls/md4.h b/ch-resp-self/include/mbedtls/md4.h similarity index 100% rename from trial4/include/mbedtls/md4.h rename to ch-resp-self/include/mbedtls/md4.h diff --git a/trial4/include/mbedtls/md5.h b/ch-resp-self/include/mbedtls/md5.h similarity index 100% rename from trial4/include/mbedtls/md5.h rename to ch-resp-self/include/mbedtls/md5.h diff --git a/trial4/include/mbedtls/md_internal.h b/ch-resp-self/include/mbedtls/md_internal.h similarity index 100% rename from trial4/include/mbedtls/md_internal.h rename to ch-resp-self/include/mbedtls/md_internal.h diff --git a/trial4/include/mbedtls/memory_buffer_alloc.h b/ch-resp-self/include/mbedtls/memory_buffer_alloc.h similarity index 100% rename from trial4/include/mbedtls/memory_buffer_alloc.h rename to ch-resp-self/include/mbedtls/memory_buffer_alloc.h diff --git a/trial4/include/mbedtls/net.h b/ch-resp-self/include/mbedtls/net.h similarity index 100% rename from trial4/include/mbedtls/net.h rename to ch-resp-self/include/mbedtls/net.h diff --git a/trial4/include/mbedtls/net_sockets.h b/ch-resp-self/include/mbedtls/net_sockets.h similarity index 100% rename from trial4/include/mbedtls/net_sockets.h rename to ch-resp-self/include/mbedtls/net_sockets.h diff --git a/trial4/include/mbedtls/nist_kw.h b/ch-resp-self/include/mbedtls/nist_kw.h similarity index 100% rename from trial4/include/mbedtls/nist_kw.h rename to ch-resp-self/include/mbedtls/nist_kw.h diff --git a/trial4/include/mbedtls/oid.h b/ch-resp-self/include/mbedtls/oid.h similarity index 100% rename from trial4/include/mbedtls/oid.h rename to ch-resp-self/include/mbedtls/oid.h diff --git a/trial4/include/mbedtls/padlock.h b/ch-resp-self/include/mbedtls/padlock.h similarity index 100% rename from trial4/include/mbedtls/padlock.h rename to ch-resp-self/include/mbedtls/padlock.h diff --git a/trial4/include/mbedtls/pem.h b/ch-resp-self/include/mbedtls/pem.h similarity index 100% rename from trial4/include/mbedtls/pem.h rename to ch-resp-self/include/mbedtls/pem.h diff --git a/trial4/include/mbedtls/pk.h b/ch-resp-self/include/mbedtls/pk.h similarity index 100% rename from trial4/include/mbedtls/pk.h rename to ch-resp-self/include/mbedtls/pk.h diff --git a/trial4/include/mbedtls/pk_internal.h b/ch-resp-self/include/mbedtls/pk_internal.h similarity index 100% rename from trial4/include/mbedtls/pk_internal.h rename to ch-resp-self/include/mbedtls/pk_internal.h diff --git a/trial4/include/mbedtls/pkcs11.h b/ch-resp-self/include/mbedtls/pkcs11.h similarity index 100% rename from trial4/include/mbedtls/pkcs11.h rename to ch-resp-self/include/mbedtls/pkcs11.h diff --git a/trial4/include/mbedtls/pkcs12.h b/ch-resp-self/include/mbedtls/pkcs12.h similarity index 100% rename from trial4/include/mbedtls/pkcs12.h rename to ch-resp-self/include/mbedtls/pkcs12.h diff --git a/trial4/include/mbedtls/pkcs5.h b/ch-resp-self/include/mbedtls/pkcs5.h similarity index 100% rename from trial4/include/mbedtls/pkcs5.h rename to ch-resp-self/include/mbedtls/pkcs5.h diff --git a/trial4/include/mbedtls/platform.h b/ch-resp-self/include/mbedtls/platform.h similarity index 100% rename from trial4/include/mbedtls/platform.h rename to ch-resp-self/include/mbedtls/platform.h diff --git a/trial4/include/mbedtls/platform_time.h b/ch-resp-self/include/mbedtls/platform_time.h similarity index 100% rename from trial4/include/mbedtls/platform_time.h rename to ch-resp-self/include/mbedtls/platform_time.h diff --git a/trial4/include/mbedtls/platform_util.h b/ch-resp-self/include/mbedtls/platform_util.h similarity index 100% rename from trial4/include/mbedtls/platform_util.h rename to ch-resp-self/include/mbedtls/platform_util.h diff --git a/trial4/include/mbedtls/poly1305.h b/ch-resp-self/include/mbedtls/poly1305.h similarity index 100% rename from trial4/include/mbedtls/poly1305.h rename to ch-resp-self/include/mbedtls/poly1305.h diff --git a/trial4/include/mbedtls/psa_util.h b/ch-resp-self/include/mbedtls/psa_util.h similarity index 100% rename from trial4/include/mbedtls/psa_util.h rename to ch-resp-self/include/mbedtls/psa_util.h diff --git a/trial4/include/mbedtls/ripemd160.h b/ch-resp-self/include/mbedtls/ripemd160.h similarity index 100% rename from trial4/include/mbedtls/ripemd160.h rename to ch-resp-self/include/mbedtls/ripemd160.h diff --git a/trial4/include/mbedtls/rsa.h b/ch-resp-self/include/mbedtls/rsa.h similarity index 100% rename from trial4/include/mbedtls/rsa.h rename to ch-resp-self/include/mbedtls/rsa.h diff --git a/trial4/include/mbedtls/rsa_internal.h b/ch-resp-self/include/mbedtls/rsa_internal.h similarity index 100% rename from trial4/include/mbedtls/rsa_internal.h rename to ch-resp-self/include/mbedtls/rsa_internal.h diff --git a/trial4/include/mbedtls/sha1.h b/ch-resp-self/include/mbedtls/sha1.h similarity index 100% rename from trial4/include/mbedtls/sha1.h rename to ch-resp-self/include/mbedtls/sha1.h diff --git a/trial4/include/mbedtls/sha256.h b/ch-resp-self/include/mbedtls/sha256.h similarity index 100% rename from trial4/include/mbedtls/sha256.h rename to ch-resp-self/include/mbedtls/sha256.h diff --git a/trial4/include/mbedtls/sha512.h b/ch-resp-self/include/mbedtls/sha512.h similarity index 100% rename from trial4/include/mbedtls/sha512.h rename to ch-resp-self/include/mbedtls/sha512.h diff --git a/trial4/include/mbedtls/ssl.h b/ch-resp-self/include/mbedtls/ssl.h similarity index 100% rename from trial4/include/mbedtls/ssl.h rename to ch-resp-self/include/mbedtls/ssl.h diff --git a/trial4/include/mbedtls/ssl_cache.h b/ch-resp-self/include/mbedtls/ssl_cache.h similarity index 100% rename from trial4/include/mbedtls/ssl_cache.h rename to ch-resp-self/include/mbedtls/ssl_cache.h diff --git a/trial4/include/mbedtls/ssl_ciphersuites.h b/ch-resp-self/include/mbedtls/ssl_ciphersuites.h similarity index 100% rename from trial4/include/mbedtls/ssl_ciphersuites.h rename to ch-resp-self/include/mbedtls/ssl_ciphersuites.h diff --git a/trial4/include/mbedtls/ssl_cookie.h b/ch-resp-self/include/mbedtls/ssl_cookie.h similarity index 100% rename from trial4/include/mbedtls/ssl_cookie.h rename to ch-resp-self/include/mbedtls/ssl_cookie.h diff --git a/trial4/include/mbedtls/ssl_internal.h b/ch-resp-self/include/mbedtls/ssl_internal.h similarity index 100% rename from trial4/include/mbedtls/ssl_internal.h rename to ch-resp-self/include/mbedtls/ssl_internal.h diff --git a/trial4/include/mbedtls/ssl_ticket.h b/ch-resp-self/include/mbedtls/ssl_ticket.h similarity index 100% rename from trial4/include/mbedtls/ssl_ticket.h rename to ch-resp-self/include/mbedtls/ssl_ticket.h diff --git a/trial4/include/mbedtls/threading.h b/ch-resp-self/include/mbedtls/threading.h similarity index 100% rename from trial4/include/mbedtls/threading.h rename to ch-resp-self/include/mbedtls/threading.h diff --git a/trial4/include/mbedtls/timing.h b/ch-resp-self/include/mbedtls/timing.h similarity index 100% rename from trial4/include/mbedtls/timing.h rename to ch-resp-self/include/mbedtls/timing.h diff --git a/trial4/include/mbedtls/version.h b/ch-resp-self/include/mbedtls/version.h similarity index 100% rename from trial4/include/mbedtls/version.h rename to ch-resp-self/include/mbedtls/version.h diff --git a/trial4/include/mbedtls/x509.h b/ch-resp-self/include/mbedtls/x509.h similarity index 100% rename from trial4/include/mbedtls/x509.h rename to ch-resp-self/include/mbedtls/x509.h diff --git a/trial4/include/mbedtls/x509_crl.h b/ch-resp-self/include/mbedtls/x509_crl.h similarity index 100% rename from trial4/include/mbedtls/x509_crl.h rename to ch-resp-self/include/mbedtls/x509_crl.h diff --git a/trial4/include/mbedtls/x509_crt.h b/ch-resp-self/include/mbedtls/x509_crt.h similarity index 100% rename from trial4/include/mbedtls/x509_crt.h rename to ch-resp-self/include/mbedtls/x509_crt.h diff --git a/trial4/include/mbedtls/x509_csr.h b/ch-resp-self/include/mbedtls/x509_csr.h similarity index 100% rename from trial4/include/mbedtls/x509_csr.h rename to ch-resp-self/include/mbedtls/x509_csr.h diff --git a/trial4/include/mbedtls/xtea.h b/ch-resp-self/include/mbedtls/xtea.h similarity index 100% rename from trial4/include/mbedtls/xtea.h rename to ch-resp-self/include/mbedtls/xtea.h diff --git a/trial4/include/psa/crypto.h b/ch-resp-self/include/psa/crypto.h similarity index 100% rename from trial4/include/psa/crypto.h rename to ch-resp-self/include/psa/crypto.h diff --git a/trial4/include/psa/crypto_accel_driver.h b/ch-resp-self/include/psa/crypto_accel_driver.h similarity index 100% rename from trial4/include/psa/crypto_accel_driver.h rename to ch-resp-self/include/psa/crypto_accel_driver.h diff --git a/trial4/include/psa/crypto_compat.h b/ch-resp-self/include/psa/crypto_compat.h similarity index 100% rename from trial4/include/psa/crypto_compat.h rename to ch-resp-self/include/psa/crypto_compat.h diff --git a/trial4/include/psa/crypto_driver_common.h b/ch-resp-self/include/psa/crypto_driver_common.h similarity index 100% rename from trial4/include/psa/crypto_driver_common.h rename to ch-resp-self/include/psa/crypto_driver_common.h diff --git a/trial4/include/psa/crypto_entropy_driver.h b/ch-resp-self/include/psa/crypto_entropy_driver.h similarity index 100% rename from trial4/include/psa/crypto_entropy_driver.h rename to ch-resp-self/include/psa/crypto_entropy_driver.h diff --git a/trial4/include/psa/crypto_extra.h b/ch-resp-self/include/psa/crypto_extra.h similarity index 100% rename from trial4/include/psa/crypto_extra.h rename to ch-resp-self/include/psa/crypto_extra.h diff --git a/trial4/include/psa/crypto_platform.h b/ch-resp-self/include/psa/crypto_platform.h similarity index 100% rename from trial4/include/psa/crypto_platform.h rename to ch-resp-self/include/psa/crypto_platform.h diff --git a/trial4/include/psa/crypto_se_driver.h b/ch-resp-self/include/psa/crypto_se_driver.h similarity index 100% rename from trial4/include/psa/crypto_se_driver.h rename to ch-resp-self/include/psa/crypto_se_driver.h diff --git a/trial4/include/psa/crypto_sizes.h b/ch-resp-self/include/psa/crypto_sizes.h similarity index 100% rename from trial4/include/psa/crypto_sizes.h rename to ch-resp-self/include/psa/crypto_sizes.h diff --git a/trial4/include/psa/crypto_struct.h b/ch-resp-self/include/psa/crypto_struct.h similarity index 100% rename from trial4/include/psa/crypto_struct.h rename to ch-resp-self/include/psa/crypto_struct.h diff --git a/trial4/include/psa/crypto_types.h b/ch-resp-self/include/psa/crypto_types.h similarity index 100% rename from trial4/include/psa/crypto_types.h rename to ch-resp-self/include/psa/crypto_types.h diff --git a/trial4/include/psa/crypto_values.h b/ch-resp-self/include/psa/crypto_values.h similarity index 100% rename from trial4/include/psa/crypto_values.h rename to ch-resp-self/include/psa/crypto_values.h diff --git a/ch-resp-self/keys/Alias_priv.pem b/ch-resp-self/keys/Alias_priv.pem new file mode 100644 index 0000000..230055a --- /dev/null +++ b/ch-resp-self/keys/Alias_priv.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAr6sq5kOG6A/12geq+/i8Ta2BnaMGqxLR4a9PciukW7awogS9 +WNpA8DlWV2B1M5zSZSKPPS9PDdC/JqXSiMWt5fHZpRCyZ3Zokclc/V8TWgDkRxZF +xHkPWUDshUIXaMzwj+eJvm2qH+LWrjr0zxqvKj2a8qFs0gYMqGB1jGun/N41Tz8B +/QmWjeakd8Zr3iY6cxVqd4GvUTgn/KC4YeZ2/CkdQTPQx6fdYrVHF0DMqrAZCSns +yRAa02oAZhiBzz4gw//fB5+k42/+Mrzrnmv/l4HnQwnGPIBQK4IDYe7YyOt7ZWRF +RkQydwHXE5fVifjrmKOj0vM1tRKjfZ1CoRxEFQIDAQABAoIBAD/6co7XZCBLg8pL +BaJsRkRyHyVG1SxkF81+uEwICf2fDTiMyls8be8vqrr69eR8xoGv8wQhIUUSVDPi +q8lFWZ7IFPDRonAdB1ulPzlGMbmTXpBnU7SJNKZYh2vHFNiF301B0gBpV07yoiZl +cXimKsqTEkYwtX3OVzjRnK4uHUnyF1zO/BrAaXBXy8cBwsad18uZlPrjkMxCT10O +dK45SkyjUb8xyU+gAiEKmIrqrkJesVhjjgatMvbBoXTI54Hyl5vxxYRVMkzBdPGR +PFxVD6kBTpwO94eJP1jKCjwwExPP0PGbT8ZI02XKzBHF5igtR4hgwv3I6sxTTqAH +rHNn/5cCgYEA2/JJYfr0FK3JmY8HjH7pTaHtlst/mbawZxUosUdWYT84CUqMlr2b +36hTtMUzmtXofuQpRrqX4xNTP8ou48Untl+9hHooqVtiH+XFLpTNg+OvJcGQWVJM +5XrRDtce5EoIGPGW6IfxbnI9YGNSM7zEfw41oynWNVR0PMsFmn4STSMCgYEAzHbU +suofi1aA7WJYQ8CuwUnYRoPJixNo/d50wQLZZfssvUvmC6cXL41xzFmvhw4PM+to +dKcXELcyTGI/r5D8UevRuJNz4Ei0/ssIVNmYxwFG/zSLmqdGyyNlRV3dNBfknYHl +5eIXb55x2NuSJ0SfV/T6dXnlQrCu2AIaKf/jCWcCgYAocoH0NsY0F1F/n8HvoFcf +I6whkwLALcx66HU3RLsp3wpbCw6Xmf7UPoxGLg2zZ6r9ys+cZiwQYjlo/bFpyZPo +AetENYLMwjVlUEfWrR6uJmzLMLFu+6eQe+l+JSlVKhgbHjJ2SKmpefC3jQxM32Xz +R5Wtj8AIxqMpmtxI8O5EqQKBgQCQ4oPGZHEF475oeI/jMt6iyRkgnrJqgs6bVs+V +FdfHlD0Xxni1OSoM4EYLcGIZabUMLXxPbTfC+I4D4nsOhcbGpjxuds5d2CephWXZ ++ndwTU9p+GoUpQRdXi+c/+6Hw4aUtj+arqO8zKIP8UeX2+CuC0KPjFkQ8PJ0zsiL +im/vcQKBgQClGriNpXHBH1Sge07qtsw8JnySjOfrrPXyGyeLzlkD6kRrB+Wr1VpN +mDWr4yHLLdJnPl3V1gdSPLI/2e+gaDoT8qRnsAaJfh1ItA0LfKad4kycHsE+VQJ6 +phDsZ6iqIkgD5r6+14Lsv0YMRxnnvQGPwvQs9TqJqK6/Coqf3pfw/w== +-----END RSA PRIVATE KEY----- diff --git a/ch-resp-self/keys/Alias_pub.pem b/ch-resp-self/keys/Alias_pub.pem new file mode 100644 index 0000000..cce3af4 --- /dev/null +++ b/ch-resp-self/keys/Alias_pub.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr6sq5kOG6A/12geq+/i8 +Ta2BnaMGqxLR4a9PciukW7awogS9WNpA8DlWV2B1M5zSZSKPPS9PDdC/JqXSiMWt +5fHZpRCyZ3Zokclc/V8TWgDkRxZFxHkPWUDshUIXaMzwj+eJvm2qH+LWrjr0zxqv +Kj2a8qFs0gYMqGB1jGun/N41Tz8B/QmWjeakd8Zr3iY6cxVqd4GvUTgn/KC4YeZ2 +/CkdQTPQx6fdYrVHF0DMqrAZCSnsyRAa02oAZhiBzz4gw//fB5+k42/+Mrzrnmv/ +l4HnQwnGPIBQK4IDYe7YyOt7ZWRFRkQydwHXE5fVifjrmKOj0vM1tRKjfZ1CoRxE +FQIDAQAB +-----END PUBLIC KEY----- diff --git a/ch-resp-self/keys/Identity_pub.pem b/ch-resp-self/keys/Identity_pub.pem new file mode 100644 index 0000000..6847cee --- /dev/null +++ b/ch-resp-self/keys/Identity_pub.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1FomNTVE/DdCHc0JAOZW +6BC6zwcZOklne1FFni0EXJYNL4mYXyDvigv6zOQObjYtgKIwj01WSxAA1/4Ecjfc +Vt6sR+I0ufEjoSDF/WX+5jFc/k5ldnWwZzBBEfZVSuZu8LAhqpj7woY95x9QzvNG +Kq0neEIonihRSnQTfwingDsKd6+ci0H85Pi7lJ9bGpVTGlE9AMQBQvHRlnl3Ig+L +7UDeNN4CDAXYvIqXTq0RQ+OvdvMYg1AfZ4rGoa91Cw208zb3FCnGIpCQWGUSDypd +Qgo0ptQU8UiaTmF0hW0q3TeG8763uMKQA3QVZIASA6hp2oMVcDjeWo8+pd7Ig2iq +sQIDAQAB +-----END PUBLIC KEY----- diff --git a/ch-resp-self/keys/session1_priv.pem b/ch-resp-self/keys/session1_priv.pem new file mode 100644 index 0000000..f36fb58 --- /dev/null +++ b/ch-resp-self/keys/session1_priv.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAxjNp2QVTj7a31kgNwQ8ATisSfcAfg002bDZEeXi3NrgQJNyG +Rsz9x0aYWxz5iT2c5aj8WNL3jzAdbm4RH3gV309XIaRmuivU5ICkW4glxFpDeG0A ++I1Wf2Yu5e/0FNPTSYah5tNyGNbh9jfacqu5SfA3ejsvOIGRs2WahtcPw3F1IbWP +FiapRf0o8m2s2ihSugCwdkA5mRq0svJ7xJpU32FRti1DEHcVNJ1Q2ZuvkzJuVywF +c1kZwh/Ou6ED45aj27Xidbt1rPX6cmZvt11xzx0MHNrvUiToR158IbHjjQZx2oyP +Z8qSwkHPuMp7kVFZRxz1/4hARxJSaVXfiXJmKwIDAQABAoIBABDnMJdADjTQSJRf +QmuyZlHETZ2ThXx9WMSuH3UxQjAfTs0opiZNSYq1rrz9LHDeZCOX9Pwe8zBEfQtp +GqURk41JvGy+Pb6R32RPbkpEwwfLCjxae33hu+c95TEEn6R+aONj4SneODmoayPu +9n6CE67GbEzMgFtJfY4MU7s9MHcimW1/tlrszMDp89IM9Q5PUDeu/fR908gFC4PH +iO/pUL2X955z0RhQYPKV91Nd4AUWROA4/E2znWYWHJhRsqgb2oVPkyvkNQON4jut +QnK6/kOftTNN64R3lfVtws0QuwgocmJsCOAYn9WF2ZcmR8HCXkf+7RsuIajoqYBi +xy0ifU0CgYEA/VJxg8hCR42ovAorHdQ9I4XI5DZ3sArKtN5f8tKgw0rQxZU9VDXL +ZuXAjFrBae2zTUX5hmaBVMs6RvcqmbCEMJ12bO5Ay9jbNZbhTopIS4o7IaC1mIzI +UCBAUBsgAkpfJGRl7h3Ds6MLycIojf1ZCjJVPI3Yvv/YmoqR2iMKrq8CgYEAyEvM +JYE+zcBreff1KYTxmHWL0xUJTDmnX9lRgAvw8XE7w51qzA+W5bVR2+x4/+H9LjCp +nPdVoZKOqCc7ECMQQNo5qnS8btxQy6v2MilryyWAS45U68nG5gwu7tVUjZNxc6L5 +BQbPpOReaJuLTE3gz2d5tbLaKZY0l6kxrZG//0UCgYEAlqiurGKw0J92iAdAJ2hv +yC2sEdY3DrMMZc+PnvoX9K4NRkWBCRFJXHQuNQtQ1rAxIDcKtR1Hs+d+THB5nJg3 +tjYgFZ8JWHMrxE5sx2pEnvCiRFixR/4KsGTN+xZ2zgXvWdSALsLy/mZs/1yDBBd2 +GjNfMDlofAfridX58pM+qi8CgYA6Zsd2pBHQ4ms0HBWS7p2XK6cCfB7C6AiijPYT +lOfDLpYTeoHaUC1aex0MOA4r5hPxdOTvzLpeKyKHazDwipjBoB+yUOlklb7FNDXL ++IHisOOQpEaknafuCd1hbDiEM1qgMgPT8GF5HdFdRQU/0XFcaDp3vVeZSp+5HO9M +QbQu1QKBgQCUM/P3p89QWMC80bYujNGD1dIBEEwvby9xgTTw8DeumOHpVwUp60hS +kOHP1biCT2nBihfHqFbs21XiYhZuywFEYWv44PziFXMdIuAYXKZ6JRcR04bg3vpW +j3VPiLbW9/5Wl4fmaWh+P4nGQPK+m3fDnfQrTDqLf2tb8IxPkXDiig== +-----END RSA PRIVATE KEY----- diff --git a/ch-resp-self/keys/session1_pub.pem b/ch-resp-self/keys/session1_pub.pem new file mode 100644 index 0000000..184735c --- /dev/null +++ b/ch-resp-self/keys/session1_pub.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjNp2QVTj7a31kgNwQ8A +TisSfcAfg002bDZEeXi3NrgQJNyGRsz9x0aYWxz5iT2c5aj8WNL3jzAdbm4RH3gV +309XIaRmuivU5ICkW4glxFpDeG0A+I1Wf2Yu5e/0FNPTSYah5tNyGNbh9jfacqu5 +SfA3ejsvOIGRs2WahtcPw3F1IbWPFiapRf0o8m2s2ihSugCwdkA5mRq0svJ7xJpU +32FRti1DEHcVNJ1Q2ZuvkzJuVywFc1kZwh/Ou6ED45aj27Xidbt1rPX6cmZvt11x +zx0MHNrvUiToR158IbHjjQZx2oyPZ8qSwkHPuMp7kVFZRxz1/4hARxJSaVXfiXJm +KwIDAQAB +-----END PUBLIC KEY----- diff --git a/trial4/links.txt b/ch-resp-self/links.txt similarity index 100% rename from trial4/links.txt rename to ch-resp-self/links.txt diff --git a/trial4/main b/ch-resp-self/main similarity index 100% rename from trial4/main rename to ch-resp-self/main diff --git a/ch-resp-self/main.c b/ch-resp-self/main.c new file mode 100644 index 0000000..af7062f --- /dev/null +++ b/ch-resp-self/main.c @@ -0,0 +1,202 @@ +#include "ROMprotocol.h" +#include "Stage2.h" + +int main() +{ + printf("Hello World!\n"); + + DIMASTATUS ret = 0; + + /*lock all resources, no interruptons*/ + /*unlock Secure Storage to read UDS and write DID Priv key*/ + + ret = ROMprotocol(); + + /*lock Secure Storage*/ + + + //ALIAS and session keys, firmware execution + + //measure firmware.bin + //measure firmware.conf + //measure .... + //calculate FW_ID - composite hash of all above measurements + //create ALIAS KD_ctx + //keygen + //publish keys + + + + //Session key creation + //receive session nonce from verifier? + //placeholder + char * PERS = "session1"; + + KeyDrv_context SSN1_ctx; + SSN1_ctx.ENT_MODE = SW_PRNG; //non determ, gen new key for every session + SSN1_ctx.PKC_MODE = DFL_PKC; + SSN1_ctx.seed = NULL; + SSN1_ctx.phrase = PERS; + SSN1_ctx.KEY_FORM = DFL_FORM; + + printf("Generating Session keys\n"); + + ret = AsymmKeyGen(&SSN1_ctx); + if(ret < DIMASUCCESS) + { + perror("DIMAFAILURE : SESSION key gen failed\n"); + exit(DIMAFAILURE); + } + + /////////////////KEY gen protocol ends here + /////////////////DID Priv key is purged/secure, other keys are available for use + + //////////////////////Now STAGE 2 protocols/////////////////// + //read verifier signing key + //load connected nodes information + //wait for connection init + //recv prover info + //load prover Pubkey + //challenge NONCE N + //sign N with Aik + //Encrypt N with Pub-Prv + //sendNonce() + //wait + //recv Resp R + //Decrypt R with Aik + //Verify signature with Pub-prv + //verify N + //issue ACK + //close conn. + + + mbedtls_pk_context pk_ctx; + mbedtls_pk_init(&pk_ctx); + + //mbedtls_entropy_context entropyCtx; + //mbedtls_entropy_init(&entropyCtx); + + //mbedtls_ctr_drbg_context drbgCtx; + //mbedtls_ctr_drbg_init(&drbgCtx); + + //ret = mbedtls_ctr_drbg_seed(&drbgCtx, mbedtls_entropy_func, &entropyCtx, NULL, 0); + if(ret < DIMASUCCESS) + { + perror("DIMAFAILURE : CRT DRBG failed\n"); + exit(DIMAFAILURE); + } + + if(DEBUG) {printf("Loading signing key\n");} + ret = mbedtls_pk_parse_keyfile( &pk_ctx, "keys/Alias_priv.pem", "" ); + if(ret < DIMASUCCESS) + { + perror("DIMAPKFAILURE : Failed to load signing key\n"); + exit(DIMAPKFAILURE); + } + +////////////// Key capability check /////////// + ret = mbedtls_pk_can_do(&pk_ctx, MBEDTLS_PK_ECKEY); //1 - can; 0 - cannot + if(!ret) + { + perror("DIMAPKFAILURE : This key cannot perform EC Key operations\n"); + + } + if (DEBUG) {printf("successful load signing key\n");} + ret = mbedtls_pk_can_do(&pk_ctx, MBEDTLS_PK_ECDSA); + if(!ret) + { + perror("DIMAPKFAILURE : This key cannot perform ECDSA operations\n"); + + } + ret = mbedtls_pk_can_do(&pk_ctx, MBEDTLS_PK_ECKEY_DH); + if(!ret) + { + perror("DIMAPKFAILURE : This key cannot perform EC DHM operations\n"); + + } +////////////// Key check end /////////// + +////////////// load client info //////// + Client_info * Cl_list = calloc(1, sizeof(Client_info)*CL_NOS); + + ret = load_nodes(Cl_list); + + printf("Client list complete, waiting for Client to init..\n"); + + +////////////// wait for conn init ////// + + + +////////////// active clients ///////// + printf("client ID : %s\n", Cl_list[1].cli_ID); + printf("client Pubkey at : %s\n", Cl_list[1].pub_file); + + + //for each active client + //sign NONCE + //send NONCE and sig + + //cacl hash + + uint8_t* sign = calloc(1,sizeof(uint8_t)*MBEDTLS_MPI_MAX_SIZE);//MBEDTLS_ECDSA_MAX_LEN); + size_t signlen = 0; + + ret = challenge( &pk_ctx, &Cl_list[1], sign, &signlen); +/* + if(DEBUG) + { + for(int i = 0; i < NONCE_SIZE; i++) + printf("%hhx",Cl_list[1].NONCE[i]); + printf(" : NONCE main\n"); + } + + if(DEBUG) + { + for (int i = 0; i < signlen; i++) + printf("%hhx", sign[i]); + printf(" :signature main\n" ); + + } +*/ + + //net send (Cl_list[1].NONCE); + //net send (sign); + + //net recv (response) + + //verify + //ret = verify(&Cl_list[1], &response); + + + mbedtls_pk_context pubk_ctx; + mbedtls_pk_init( &pubk_ctx ); + + + ret = mbedtls_pk_parse_public_keyfile( &pubk_ctx, "keys/Alias_pub.pem" ); + if(ret < DIMASUCCESS) + { + perror("DIMAPKFAILURE : Public key failure"); + return DIMAPKFAILURE; + } + + ret = response( &pubk_ctx, &Cl_list[1], sign, signlen); + if (ret < DIMASUCCESS) + { + perror("DIMAVERIFYFAILURE : could not verify client\n"); + return DIMAVERIFYFAILURE; + } + + + if(Cl_list[1].Cli_STATUS == Cl_verfd) + { printf( "\n . OK (the signature is valid)\n\n" ); } + + + + + /*release resources, pass control to firmware, etc */ + + printf("Successful exit\n"); + + return 1; +} diff --git a/trial4/makefile b/ch-resp-self/makefile similarity index 54% rename from trial4/makefile rename to ch-resp-self/makefile index 3631e7e..ee1b233 100644 --- a/trial4/makefile +++ b/ch-resp-self/makefile @@ -2,7 +2,7 @@ CC=gcc IDIR=./include LDIR=./include ODIR=./out -_DEPS = ROMprotocol.h KeyGen.h defines.h +_DEPS = ROMprotocol.h KeyGen.h Stage2.h defines.h DEPS = $(pathsbst %,(IDIR)/%,%(_DEPS)) @@ -11,18 +11,18 @@ CFLAGS= -I. -T$(IDIR) .PHONY: all debug clean -all: main.c ROMprotocol.c KeyGen.c - ${CC} -o $(ODIR)/main main.c KeyGen.c ROMprotocol.c -lm -lmbedcrypto -lmbedtls -lmbedx509 +all: main.c ROMprotocol.c KeyGen.c Stage2.c + ${CC} -o $(ODIR)/main main.c KeyGen.c ROMprotocol.c Stage2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 debug: - ${CC} -gdwarf-2 -g3 -o $(ODIR)/dbg-main main.c KeyGen.c ROMprotocol.c -lm -lmbedcrypto -lmbedtls -lmbedx509 + ${CC} -gdwarf-2 -g3 -o $(ODIR)/dbg-main main.c KeyGen.c ROMprotocol.c Stage2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 trial: ${CC} -g -o $(ODIR)/trial ECCtrial.c -lm -lmbedcrypto -lmbedtls -lmbedx509 remake: rm -r $(ODIR)/* - ${CC} -o $(ODIR)/main main.c KeyGen.c ROMprotocol.c -lm -lmbedcrypto -lmbedtls -lmbedx509 + ${CC} -o $(ODIR)/main main.c KeyGen.c ROMprotocol.c Stage2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 clean: rm -r $(ODIR)/* diff --git a/ch-resp-self/out/main b/ch-resp-self/out/main new file mode 100755 index 0000000..b8fe6b2 Binary files /dev/null and b/ch-resp-self/out/main differ diff --git a/ch-resp-self/sslkeys/Alias_priv.pem b/ch-resp-self/sslkeys/Alias_priv.pem new file mode 100644 index 0000000..3495c91 --- /dev/null +++ b/ch-resp-self/sslkeys/Alias_priv.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIPXKwvHFzcbXu3BLgumTpX0rXNVavwVL5D6A4UWOjGRHoAoGCCqGSM49 +AwEHoUQDQgAECF3jSVCzo8u2Vk/TPe6Qk+7ATSQSkxWVH0QM4JlIqjxkcwffOP7C +T9DQ1HxcTG2VaRvICjdU02ks106x5x/zfw== +-----END EC PRIVATE KEY----- diff --git a/ch-resp-self/sslkeys/Alias_pub.pem b/ch-resp-self/sslkeys/Alias_pub.pem new file mode 100644 index 0000000..efb17b9 --- /dev/null +++ b/ch-resp-self/sslkeys/Alias_pub.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAECF3jSVCzo8u2Vk/TPe6Qk+7ATSQS +kxWVH0QM4JlIqjxkcwffOP7CT9DQ1HxcTG2VaRvICjdU02ks106x5x/zfw== +-----END PUBLIC KEY----- diff --git a/ch-resp-self/sslkeys/test_privkey.pem b/ch-resp-self/sslkeys/test_privkey.pem new file mode 100644 index 0000000..6225b2a --- /dev/null +++ b/ch-resp-self/sslkeys/test_privkey.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIHG05abfmNN/KmSP2mWxotwGKvbIBytPrtQHLBxVlS4GoAoGCCqGSM49 +AwEHoUQDQgAEAbMa657LA8MgDMlU7//wQLto5Ji9fKZp7R7MQJP/q/MWV35Qzfwr +XReZqG0sYEfFkmyOZhFkSoHBS8OeM2NtpA== +-----END EC PRIVATE KEY----- diff --git a/ch-resp-self/sslkeys/test_public.pem b/ch-resp-self/sslkeys/test_public.pem new file mode 100644 index 0000000..8417e4e --- /dev/null +++ b/ch-resp-self/sslkeys/test_public.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAbMa657LA8MgDMlU7//wQLto5Ji9 +fKZp7R7MQJP/q/MWV35QzfwrXReZqG0sYEfFkmyOZhFkSoHBS8OeM2NtpA== +-----END PUBLIC KEY----- diff --git a/trial4/ROMProtocol.c b/trial4/ROMProtocol.c deleted file mode 100644 index 6b5de1a..0000000 --- a/trial4/ROMProtocol.c +++ /dev/null @@ -1,102 +0,0 @@ -#include "ROMprotocol.h" - - -/* - DIMASTATUS ret = 0; - int len = 0; - - -if(DEBUG) -{printf("PASS \n");} - -if(ret < DIMASUCCESS) - { - perror("\n"); - - //other cleanup - exit(); - } - -*/ - -DIMASTATUS ROMprotocol() -{ - - DIMASTATUS ret = 0; - int len = 0; - - if(DEBUG) - {printf("PASS 1\n");} - - - //Calculate DIMA RTM hash - - //this should be calculated on the DIMA bin and remain static. - //how to do that? - //hardcoding junk value for now - - uint8_t RTM_ID[SHA256_DGST_SIZE] = {0xbe,0x67,0x0a,0xf8,0xf3,0x92,0x0e,0xba,0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc,0x4f, - 0xf1,0xd9,0x30,0xe2,0x3e,0xcc,0x28,0xc5,0x7b,0xbb,0x38,0x7d,0xe6,0x66,0xbb,0x1e}; - - //Calculating UDS hash - - FILE *fp = NULL; - fp = fopen("RANDFILE", "rb"); - if(!fp) - { - perror("DIMAFILENOTFOUND: Unable to access UDS\n"); - - fclose(fp); - exit(DIMAFILENOTFOUND); - } - - if(DEBUG) -{printf("PASS 2\n");} - - uint8_t *UDSbuf = calloc(1, sizeof(uint8_t)*SHA256_DGST_SIZE); - fread(UDSbuf,UDS_SIZE,1,fp); - { - perror("File read error: Unable to read UDS\n"); - - fclose(fp); - free(UDSbuf); - exit(DIMAFAILUREUNKWN); - } - - fclose(fp); - -if(DEBUG) -{printf("PASS 3\n");} - - - uint8_t* UDS_ID = calloc(1,sizeof(uint8_t)*SHA256_DGST_SIZE); - ret = mbedtls_sha256_ret( UDSbuf,UDS_SIZE,UDS_ID,0 ); - if(ret < DIMASUCCESS) - { - perror("DIMASHAFAILUE:\n"); - - free(UDSbuf); - free(UDS_ID); - exit(DIMAFAILUREUNKWN); - } - - //UDS_ID contains the UDS hash - //Printer - if(DEBUG) - { - for (int i = 0; i < UDS_SIZE; i++) - printf("%hhx", UDSbuf[i]); - printf(" : fuse secret\n" ); - - for (int i = 0; i < SHA256_DGST_SIZE; i++) - printf("%hhx", UDS_ID[i]); - printf(" : UDS ID\n" ); - } - - - -if(DEBUG) -{printf("PASS 100\n");} - return DIMASUCCESS; - -} \ No newline at end of file diff --git a/trial4/ROMprotocol.c b/trial4/ROMprotocol.c index 0a9a8e4..554c56f 100644 --- a/trial4/ROMprotocol.c +++ b/trial4/ROMprotocol.c @@ -168,7 +168,7 @@ if(DEBUG) exit(DIMAHKDFFAILURE); } - free(CDI); + //free(CDI); if(DEBUG) { @@ -186,7 +186,7 @@ if(DEBUG) //setting context for DID KeyDrv_context DID_ctx; - DID_ctx.ENT_MODE = DFL_ENT; + DID_ctx.ENT_MODE = DETERM; DID_ctx.PKC_MODE = DFL_PKC; DID_ctx.seed = CDIKEY; DID_ctx.phrase = IDENTITY; @@ -206,16 +206,54 @@ if(DEBUG) exit(DIMAFAILURE); } - free(CDIKEY); + free(CDIKEY); //But CDIKey is needed to gen AliasKP //delete DID_ctx?? //setting context for Alias keys - //deriving alisa keys +//////////////////////////deriving alisa keys + + + //placeholder FW_ID + uint8_t FW_ID[SHA256_DGST_SIZE] = { 0xf3,0x92,0x0e,0x4f,0xbe,0x67,0x0a,0xf8, + 0xf1,0xd9,0x30,0xe2,0x33,0xcc,0x28,0xc5, + 0xba,0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc, + 0xe6,0x66,0xbb,0x1e,0x7b,0xbb,0x38,0x7d }; + + uint8_t * FWKEY = calloc(1, sizeof(uint8_t)*HKDF_KEY_SIZE); + + //create Alias key derivation material using CDI and seed and FW_ID as salt + //Alternatively do composite hash of CDI and FW_ID to create Alias key der material + ret = mbedtls_hkdf(md_info, FW_ID, sizeof(FW_ID), CDI, SHA256_DGST_SIZE, + ALIAS, sizeof(ALIAS), FWKEY, HKDF_KEY_SIZE); + + if(ret < DIMASUCCESS) + { + perror("DIMAHKDFFAILURE\n"); + exit(DIMAHKDFFAILURE); + } + + KeyDrv_context ALIAS_ctx; + ALIAS_ctx.ENT_MODE = DETERM; + ALIAS_ctx.PKC_MODE = DFL_PKC; + ALIAS_ctx.seed = FWKEY; + ALIAS_ctx.phrase = ALIAS; + ALIAS_ctx.KEY_FORM = DFL_FORM; + + printf("Generating Alias keys\n"); + + ret = AsymmKeyGen(&ALIAS_ctx); + if(ret < DIMASUCCESS) + { + perror("DIMAFAILURE : ALIAS key gen failed\n"); + exit(DIMAFAILURE); + } + //session keys? - + free(CDI); + free(FWKEY); if(DEBUG) diff --git a/trial4/main.c b/trial4/main.c deleted file mode 100644 index 6a1581f..0000000 --- a/trial4/main.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "ROMprotocol.h" - -void main() -{ - printf("Hello World!\n"); - - DIMASTATUS ret = 0; - - /*lock all resources, no interruptons*/ - ret = ROMprotocol(); - /*release resources*/ - - //ALIAS and session keys, firmware execution - - //measure firmware.bin - //measure firmware.conf - //measure .... - //calculate FW_ID - composite hash of all above measurements - //create ALIAS KD_ctx - //keygen - //publish keys - - - //placeholder FW_ID - uint8_t FW_ID[SHA256_DGST_SIZE] = { 0xf3,0x92,0x0e,0x4f,0xbe,0x67,0x0a,0xf8, - 0xf1,0xd9,0x30,0xe2,0x33,0xcc,0x28,0xc5, - 0xba,0x68,0xd1,0x56,0xea,0x34,0x3f,0xbc, - 0xe6,0x66,0xbb,0x1e,0x7b,0xbb,0x38,0x7d }; - - const mbedtls_md_info_t * md_info; - if(!(md_info = mbedtls_md_info_from_type(HKDF_ALG))) - { - perror("DIMAHKDFFAILURE: MD alg type def failed\n"); - exit(DIMAHKDFFAILURE); - } - - uint8_t salt[32] = { 0x68, 0x5e, 0x4e, 0xbe, 0xf2, 0xbe, 0xb9, 0xd5, 0x13, - 0x7c, 0x14, 0x71, 0x20, 0xfb, 0x42, 0x32, 0x54, 0x12, - 0x3e, 0x31, 0xa6, 0x89, 0x4c, 0xe0, 0x58, 0x51, 0x0e, - 0x26, 0xb0, 0xdd, 0x78, 0x55 }; - - uint8_t * FWKEY = calloc(1, sizeof(uint8_t)*HKDF_KEY_SIZE); - ret = mbedtls_hkdf(md_info, salt, sizeof(salt), FW_ID, SHA256_DGST_SIZE, - ALIAS, sizeof(ALIAS), FWKEY, HKDF_KEY_SIZE); - - if(ret < DIMASUCCESS) - { - perror("DIMAHKDFFAILURE\n"); - exit(DIMAHKDFFAILURE); - } - - KeyDrv_context ALIAS_ctx; - ALIAS_ctx.ENT_MODE = DFL_ENT; - ALIAS_ctx.PKC_MODE = DFL_PKC; - ALIAS_ctx.seed = FWKEY; - ALIAS_ctx.phrase = ALIAS; - ALIAS_ctx.KEY_FORM = DFL_FORM; - - printf("Generating Alias keys\n"); - - ret = AsymmKeyGen(&ALIAS_ctx); - if(ret < DIMASUCCESS) - { - perror("DIMAFAILURE : ALIAS key gen failed\n"); - exit(DIMAFAILURE); - } - - - - //Session key creation - //receive session nonce from verifier? - //placeholder - char * NONCE = "session1"; - - KeyDrv_context SSN1_ctx; - SSN1_ctx.ENT_MODE = SW_PRNG; //non determ, gen new key for every session - SSN1_ctx.PKC_MODE = DFL_PKC; - SSN1_ctx.seed = NULL; - SSN1_ctx.phrase = NONCE; - SSN1_ctx.KEY_FORM = DFL_FORM; - - printf("Generating Session keys\n"); - - ret = AsymmKeyGen(&SSN1_ctx); - if(ret < DIMASUCCESS) - { - perror("DIMAFAILURE : SESSION key gen failed\n"); - exit(DIMAFAILURE); - } - - printf("Successful exit\n"); - - return; -} diff --git a/trial4/nbproject/configurations.xml b/trial4/nbproject/configurations.xml deleted file mode 100644 index c3d8f93..0000000 --- a/trial4/nbproject/configurations.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - layer1.c - layer2.c - main.c - - - nbproject/private/launcher.properties - makefile - - - ^(nbproject)$ - - . - - makefile - - - - default - false - false - - - - - - . - ${MAKE} -f makefile - ${MAKE} -f makefile clean - ./out/main - - - . - - - - - - - - - - - - diff --git a/trial4/nbproject/private/CodeAssistancePathMapper.properties b/trial4/nbproject/private/CodeAssistancePathMapper.properties deleted file mode 100644 index 7f5ded8..0000000 --- a/trial4/nbproject/private/CodeAssistancePathMapper.properties +++ /dev/null @@ -1 +0,0 @@ -# Automatic path mapper. CRC = 1 diff --git a/trial4/nbproject/private/Default-build.log b/trial4/nbproject/private/Default-build.log deleted file mode 100644 index e375ab1..0000000 --- a/trial4/nbproject/private/Default-build.log +++ /dev/null @@ -1 +0,0 @@ -gcc -o ./out/main main.c layer1.c layer2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 diff --git a/trial4/nbproject/private/Default-exec.log b/trial4/nbproject/private/Default-exec.log deleted file mode 100644 index 1bfffae..0000000 --- a/trial4/nbproject/private/Default-exec.log +++ /dev/null @@ -1,73 +0,0 @@ -called: gcc - /home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3 - gcc - -o - ./out/main - main.c - layer1.c - layer2.c - -lm - -lmbedcrypto - -lmbedtls - -lmbedx509 - -called: /usr/bin/ld - /home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3 - /usr/bin/ld - -plugin - /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so - -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper - -plugin-opt=-fresolution=/tmp/ccYhvDjB.res - -plugin-opt=-pass-through=-lgcc - -plugin-opt=-pass-through=-lgcc_s - -plugin-opt=-pass-through=-lc - -plugin-opt=-pass-through=-lgcc - -plugin-opt=-pass-through=-lgcc_s - --sysroot=/ - --build-id - --eh-frame-hdr - -m - elf_x86_64 - --hash-style=gnu - --as-needed - -dynamic-linker - /lib64/ld-linux-x86-64.so.2 - -pie - -z - now - -z - relro - -o - ./out/main - /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o - /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o - /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o - -L/usr/lib/gcc/x86_64-linux-gnu/7 - -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu - -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib - -L/lib/x86_64-linux-gnu - -L/lib/../lib - -L/usr/lib/x86_64-linux-gnu - -L/usr/lib/../lib - -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. - /tmp/ccFS4XDz.o - /tmp/ccUxoFtf.o - /tmp/ccdM7foV.o - -lm - -lmbedcrypto - -lmbedtls - -lmbedx509 - -lgcc - --push-state - --as-needed - -lgcc_s - --pop-state - -lc - -lgcc - --push-state - --as-needed - -lgcc_s - --pop-state - /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o - /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o - diff --git a/trial4/nbproject/private/Default.properties b/trial4/nbproject/private/Default.properties deleted file mode 100644 index d1c26be..0000000 --- a/trial4/nbproject/private/Default.properties +++ /dev/null @@ -1,3 +0,0 @@ -/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/layer1.c=/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3#-o ./out/main main.c layer1.c layer2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 -/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/main.c=/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3#-o ./out/main main.c layer1.c layer2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 -/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/layer2.c=/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3#-o ./out/main main.c layer1.c layer2.c -lm -lmbedcrypto -lmbedtls -lmbedx509 diff --git a/trial4/nbproject/private/c_standard_headers_indexer.c b/trial4/nbproject/private/c_standard_headers_indexer.c deleted file mode 100644 index c2548d2..0000000 --- a/trial4/nbproject/private/c_standard_headers_indexer.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - */ - -// List of standard headers was taken in http://en.cppreference.com/w/c/header - -#include // Conditionally compiled macro that compares its argument to zero -#include // Functions to determine the type contained in character data -#include // Macros reporting error conditions -#include // Limits of float types -#include // Sizes of basic types -#include // Localization utilities -#include // Common mathematics functions -#include // Nonlocal jumps -#include // Signal handling -#include // Variable arguments -#include // Common macro definitions -#include // Input/output -#include // String handling -#include // General utilities: memory management, program utilities, string conversions, random numbers -#include // Time/date utilities -#include // (since C95) Alternative operator spellings -#include // (since C95) Extended multibyte and wide character utilities -#include // (since C95) Wide character classification and mapping utilities -#ifdef _STDC_C99 -#include // (since C99) Complex number arithmetic -#include // (since C99) Floating-point environment -#include // (since C99) Format conversion of integer types -#include // (since C99) Boolean type -#include // (since C99) Fixed-width integer types -#include // (since C99) Type-generic math (macros wrapping math.h and complex.h) -#endif -#ifdef _STDC_C11 -#include // (since C11) alignas and alignof convenience macros -#include // (since C11) Atomic types -#include // (since C11) noreturn convenience macros -#include // (since C11) Thread library -#include // (since C11) UTF-16 and UTF-32 character utilities -#endif diff --git a/trial4/nbproject/private/configurations.xml b/trial4/nbproject/private/configurations.xml deleted file mode 100644 index 7534ff3..0000000 --- a/trial4/nbproject/private/configurations.xml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - aes.h - aesni.h - arc4.h - aria.h - asn1.h - asn1write.h - base64.h - bignum.h - blowfish.h - bn_mul.h - camellia.h - ccm.h - certs.h - chacha20.h - chachapoly.h - check_config.h - cipher.h - cipher_internal.h - cmac.h - compat-1.3.h - config.h - ctr_drbg.h - debug.h - des.h - dhm.h - ecdh.h - ecdsa.h - ecjpake.h - ecp.h - ecp_internal.h - entropy.h - entropy_poll.h - error.h - gcm.h - havege.h - hkdf.h - hmac_drbg.h - md.h - md2.h - md4.h - md5.h - md_internal.h - memory_buffer_alloc.h - net.h - net_sockets.h - nist_kw.h - oid.h - padlock.h - pem.h - pk.h - pk_internal.h - pkcs11.h - pkcs12.h - pkcs5.h - platform.h - platform_time.h - platform_util.h - poly1305.h - ripemd160.h - rsa.h - rsa_internal.h - sha1.h - sha256.h - sha512.h - ssl.h - ssl_cache.h - ssl_ciphersuites.h - ssl_cookie.h - ssl_internal.h - ssl_ticket.h - threading.h - timing.h - version.h - x509.h - x509_crl.h - x509_crt.h - x509_csr.h - xtea.h - - - - - - - ECCtrial.c - defines.h - layer1.c - layer1.h - layer2.c - layer2.h - main.c - - - makefile - - - - localhost - 2 - - - - . - ${AUTO_FOLDER} - - ${AUTO_FOLDER} - - ${MAKE} ${ITEM_NAME}.o - ${AUTO_COMPILE} - - ${AUTO_COMPILE} - - - - - - - - - - - - - - - gdb - - - - "${OUTPUT_PATH}" - - "${OUTPUT_PATH}" - . - false - 0 - 0 - - - - - - diff --git a/trial4/nbproject/private/cpp_standard_headers_indexer.cpp b/trial4/nbproject/private/cpp_standard_headers_indexer.cpp deleted file mode 100644 index 04f6fa6..0000000 --- a/trial4/nbproject/private/cpp_standard_headers_indexer.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - */ - -// List of standard headers was taken in http://en.cppreference.com/w/cpp/header - -#include // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search -#include // Functions and macro constants for signal management -#include // Macro (and function) that saves (and jumps) to an execution context -#include // Handling of variable length argument lists -#include // Runtime type information utilities -#include // std::bitset class template -#include // Function objects, designed for use with the standard algorithms -#include // Various utility components -#include // C-style time/date utilites -#include // typedefs for types such as size_t, NULL and others -#include // Low-level memory management utilities -#include // Higher level memory management utilities -#include // limits of integral types -#include // limits of float types -#include // standardized way to query properties of arithmetic types -#include // Exception handling utilities -#include // Standard exception objects -#include // Conditionally compiled macro that compares its argument to zero -#include // Macro containing the last error number -#include // functions to determine the type contained in character data -#include // functions for determining the type of wide character data -#include // various narrow character string handling functions -#include // various wide and multibyte string handling functions -#include // std::basic_string class template -#include // std::vector container -#include // std::deque container -#include // std::list container -#include // std::set and std::multiset associative containers -#include // std::map and std::multimap associative containers -#include // std::stack container adaptor -#include // std::queue and std::priority_queue container adaptors -#include // Algorithms that operate on containers -#include // Container iterators -#include // Common mathematics functions -#include // Complex number type -#include // Class for representing and manipulating arrays of values -#include // Numeric operations on values in containers -#include // forward declarations of all classes in the input/output library -#include // std::ios_base class, std::basic_ios class template and several typedefs -#include // std::basic_istream class template and several typedefs -#include // std::basic_ostream, std::basic_iostream class templates and several typedefs -#include // several standard stream objects -#include // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs -#include // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs -#include // std::strstream, std::istrstream, std::ostrstream(deprecated) -#include // Helper functions to control the format or input and output -#include // std::basic_streambuf class template -#include // C-style input-output functions -#include // Localization utilities -#include // C localization utilities -#include // empty header. The macros that appear in iso646.h in C are keywords in C++ -#if __cplusplus >= 201103L -#include // (since C++11) std::type_index -#include // (since C++11) Compile-time type information -#include // (since C++11) C++ time utilites -#include // (since C++11) std::initializer_list class template -#include // (since C++11) std::tuple class template -#include // (since C++11) Nested allocator class -#include // (since C++11) fixed-size types and limits of other types -#include // (since C++11) formatting macros , intmax_t and uintmax_t math and conversions -#include // (since C++11) defines std::error_code, a platform-dependent error code -#include // (since C++11) C-style Unicode character conversion functions -#include // (since C++11) std::array container -#include // (since C++11) std::forward_list container -#include // (since C++11) std::unordered_set and std::unordered_multiset unordered associative containers -#include // (since C++11) std::unordered_map and std::unordered_multimap unordered associative containers -#include // (since C++11) Random number generators and distributions -#include // (since C++11) Compile-time rational arithmetic -#include // (since C++11) Floating-point environment access functions -#include // (since C++11) Unicode conversion facilities -#include // (since C++11) Classes, algorithms and iterators to support regular expression processing -#include // (since C++11) Atomic operations library -#include // (since C++11)(deprecated in C++17) simply includes the header -#include // (since C++11)(deprecated in C++17) simply includes the headers (until C++17) (since C++17) and : the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers -#include // (since C++11)(deprecated in C++17) defines one compatibility macro constant -#include // (since C++11)(deprecated in C++17) defines one compatibility macro constant -#include // (since C++11) std::thread class and supporting functions -#include // (since C++11) mutual exclusion primitives -#include // (since C++11) primitives for asynchronous computations -#include // (since C++11) thread waiting conditions -#endif -#if __cplusplus >= 201300L -#include // (since C++14) shared mutual exclusion primitives -#endif -#if __cplusplus >= 201500L -#include // (since C++17) std::any class template -#include // (since C++17) std::optional class template -#include // (since C++17) std::variant class template -#include // (since C++17) Polymorphic allocators and memory resources -#include // (since C++17) std::basic_string_view class template -#include // (since C++17) Predefined execution policies for parallel versions of the algorithms -#include // (since C++17) std::path class and supporting functions -#endif diff --git a/trial4/nbproject/private/launcher.properties b/trial4/nbproject/private/launcher.properties deleted file mode 100644 index 3edc2d8..0000000 --- a/trial4/nbproject/private/launcher.properties +++ /dev/null @@ -1,42 +0,0 @@ -# Launchers File syntax: -# -# [Must-have property line] -# launcher1.runCommand= -# [Optional extra properties] -# launcher1.displayName= -# launcher1.hide= -# launcher1.buildCommand= -# launcher1.runDir= -# launcher1.runInOwnTab= -# launcher1.symbolFiles= -# launcher1.env.= -# (If this value is quoted with ` it is handled as a native command which execution result will become the value) -# [Common launcher properties] -# common.runDir= -# (This value is overwritten by a launcher specific runDir value if the latter exists) -# common.env.= -# (Environment variables from common launcher are merged with launcher specific variables) -# common.symbolFiles= -# (This value is overwritten by a launcher specific symbolFiles value if the latter exists) -# -# In runDir, symbolFiles and env fields you can use these macroses: -# ${PROJECT_DIR} - project directory absolute path -# ${OUTPUT_PATH} - linker output path (relative to project directory path) -# ${OUTPUT_BASENAME}- linker output filename -# ${TESTDIR} - test files directory (relative to project directory path) -# ${OBJECTDIR} - object files directory (relative to project directory path) -# ${CND_DISTDIR} - distribution directory (relative to project directory path) -# ${CND_BUILDDIR} - build directory (relative to project directory path) -# ${CND_PLATFORM} - platform name -# ${CND_CONF} - configuration name -# ${CND_DLIB_EXT} - dynamic library extension -# -# All the project launchers must be listed in the file! -# -# launcher1.runCommand=... -# launcher2.runCommand=... -# ... -# common.runDir=... -# common.env.KEY=VALUE - -# launcher1.runCommand= \ No newline at end of file diff --git a/trial4/nbproject/private/private.xml b/trial4/nbproject/private/private.xml deleted file mode 100644 index 89b112f..0000000 --- a/trial4/nbproject/private/private.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - true - - - 0 - 0 - - - - - file:/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/layer2.c - file:/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/layer1.c - file:/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/nbproject/private/launcher.properties - file:/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/makefile - file:/home/atul/Projects/GIT/RIoT/openSSL-DICE/trial3/main.c - - - diff --git a/trial4/nbproject/project.xml b/trial4/nbproject/project.xml deleted file mode 100644 index d443805..0000000 --- a/trial4/nbproject/project.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - trial3 - c - - h - UTF-8 - - - . - - - - Default - 0 - - - - false - - - - diff --git a/trial4/out/main b/trial4/out/main deleted file mode 100755 index aa8be77..0000000 Binary files a/trial4/out/main and /dev/null differ