From a3af41a78e4f24bdf9fc88b9d36fd5873502bec9 Mon Sep 17 00:00:00 2001 From: "atul.jha" Date: Fri, 22 May 2020 12:54:01 +0200 Subject: [PATCH] Backup 1 --- trial1/layer1.c | 13 +++++++++++-- trial1/layer1.h | 8 +++++++- trial1/layer2.c | 19 +++++++++++-------- trial1/layer2.h | 5 ++++- trial1/out/main2 | Bin 13480 -> 13480 bytes 5 files changed, 33 insertions(+), 12 deletions(-) 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 40f4da6e7f38351c48fdd6fe39d9a2d3242f88ee..19c3daac8739609fbcdc3e1f33d1237b8775c001 100755 GIT binary patch delta 1085 zcmZuxT}%{L6ux(0WoO;L*&UsQxLpQ8Dvju{ikOOJHJc0sB|#RcDUzUp7&UDzZK9U6 zDOfw*ZUl~L_0_-1L(#ZC;1fZjMy19+SRxn;3T9d~uA+3Q(CN9mLbd5l=6+|sbIy0p zJ##Z>cAnYUc8e$JB)Qt}^a%Y6llB}!Cmj+S%A4<-PQ>1+SiOC8QC7?Cv!?3rqer>A^PNuVRSPUeXW@}iyIj`Jj>Shg;Z@!ZF%HGS3Pqr_}ehF z;B-s#wDGAG$qyL$C6eLbv~~rF2DmeSbC!;3`nxEj1xLr%Bkg5z7K~HF!I&CZl?$7! zS@a})Y!x%p(1#)4u$=jrqiVsp+R_{+i3(56aLT%b8#lwx)@<%qGfY_X=p}f|Cess8 zVv}eDYHWU51>YgF3c75c`|8sYg1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