This commit is contained in:
atul.jha 2020-05-22 12:54:01 +02:00
parent c202d01c40
commit a3af41a78e
5 changed files with 33 additions and 12 deletions

View File

@ -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");

View File

@ -4,12 +4,18 @@
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/sha.h>
#include <openssl/ec.h>
#include <openssl/pem.h>
#include <openssl/kdf.h>
#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

View File

@ -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);
free(UDS_ID);
free(FW_ID);
// uint8_t* _CD_ID = calloc(1,sizeof(uint8_t)*SHA256_dig_t);
// _calcCDID(_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);
free(CD_ID);
free(_CD_ID);
// free(_CD_ID);
}

View File

@ -11,3 +11,6 @@
#define SHA256_dig_t 32 //bytes
void startProtocol();
int deriveKDF();
int deriveECC_Key();

Binary file not shown.