#include "layer2.h" //RIOT core void ROMprotocol(void) { printf("Hello function!\n"); //readUDS function uint8_t * CDIKEY = calloc(1, sizeof(uint8_t)*CDI_KEY_SIZE); _calcCDIKEY(CDIKEY); for(int i = 0; i < CDI_KEY_SIZE; i++) printf("%x",CDIKEY[i]); printf(" : CDIKEY main\n"); printf("USE_ECC %d\n", USE_ECC); deriveDeviceIDKeyPair(CDIKEY, USE_ECC); deriveDeviceIDKeyPair(CDIKEY, !USE_ECC); printf("pass 100\n"); return; } void seedRNGSource(uint8_t * CDIKEY) { //srand(); lib fun call //https://stackoverflow.com/questions/55927662/generate-every-time-same-rsa-key-with-c //ctr_drbg //programs/test/benchmark.c:705 //hmac_drbg //seed rng with CDIKEY //init //drbg seed return; } void deriveDeviceIDKeyPair(uint8_t * CDIKEY, int isECC) { //firt generate ECC/RA key. //check for deterministic consistency //seed RNGs with CDI //let's see how it goes //add entropy source? //seed RNG //create ctx //init //gen keypair //return pubkey and privkey both to L2? if(isECC) { mbedtls_mpi secret; mbedtls_mpi_init(&secret); mbedtls_ecp_point Public; mbedtls_ecp_point_init(&Public); //return pubkey and privkey both to L2? deriveECCKeyPair(&secret, &Public); //secret and Public contain raw key inormation of generated keys //Public also needs group and context to handle ECP //Converting raw info to PEM is not easible like this return; } else { deriveRSAKeyPair(); return; } }