diff --git a/trial1/layer1.c b/trial1/layer1.c index c08858b..bc484b0 100644 --- a/trial1/layer1.c +++ b/trial1/layer1.c @@ -53,7 +53,7 @@ int readUDS(uint8_t* UDS_M) if(!fp) perror("Opening seed file to read failed\n"); - if (BIO_read(fp,UDSbuf,UDSsize) < 0) + if (BIO_read(fp,UDSbuf,UDSsize) < 0) //Suspecting a ENDian issue in reading. data is half byte reversed perror("BIO read failed\n"); //Compute hash of UDS @@ -171,6 +171,15 @@ int calcCDID(uint8_t * UDS_M, uint8_t * FW_M, uint8_t * CDID) int _calcCDID(uint8_t * _CDID) { + /* + ***BUG*** : + CDI hash value returned is not correct or consistent. + hash generated by readUDS() and readFWID() are correct and consistent but + caclCDID() is broken. + + Do not use this wrapper function unless fixed + */ + BIO * out = BIO_new_fp(stdout, BIO_NOCLOSE); BIO_printf(out, "\n");BIO_printf(out, "\n");BIO_printf(out, "\n"); @@ -203,4 +212,4 @@ int _calcCDID(uint8_t * _CDID) BIO_free(out); return 1; -} \ No newline at end of file +} diff --git a/trial1/layer1.h b/trial1/layer1.h index 7587675..e7f87c7 100644 --- a/trial1/layer1.h +++ b/trial1/layer1.h @@ -4,12 +4,18 @@ #include #include #include +#include +#include +#include + #define SHA256_dig_t 32 //bytes +#define ECC_curve int readUDS(uint8_t* UDSdigest); int createUDS(); int readFWID(uint8_t * FW_M); int calcCDID(uint8_t * UDS_M, uint8_t * FW_M, uint8_t * CDID); -int _calcCDID(uint8_t * CDID); +int _calcCDID(uint8_t * CDID); //wrapper function broken, do not use + diff --git a/trial1/layer2.c b/trial1/layer2.c index 256eaca..aac4f33 100644 --- a/trial1/layer2.c +++ b/trial1/layer2.c @@ -25,16 +25,19 @@ void startProtocol() //setp 3 : Derive Composite Device ID uint8_t* CD_ID = calloc(1,sizeof(uint8_t)*SHA256_dig_t); calcCDID(UDS_ID,FW_ID,CD_ID); - - - uint8_t* _CD_ID = calloc(1,sizeof(uint8_t)*SHA256_dig_t); - _calcCDID(_CD_ID); - - - //End block free(UDS_ID); free(FW_ID); + + // uint8_t* _CD_ID = calloc(1,sizeof(uint8_t)*SHA256_dig_t); + // _calcCDID(_CD_ID); + + + + + + //End block + free(CD_ID); - free(_CD_ID); + // free(_CD_ID); } diff --git a/trial1/layer2.h b/trial1/layer2.h index 06361a1..93c0541 100644 --- a/trial1/layer2.h +++ b/trial1/layer2.h @@ -10,4 +10,7 @@ #define SHA256_dig_t 32 //bytes -void startProtocol(); \ No newline at end of file +void startProtocol(); + +int deriveKDF(); +int deriveECC_Key(); \ No newline at end of file diff --git a/trial1/out/main2 b/trial1/out/main2 index 40f4da6..19c3daa 100755 Binary files a/trial1/out/main2 and b/trial1/out/main2 differ