diff --git a/cr_generate_id.c b/cr_generate_id.c index b8527d3..8daa86d 100644 --- a/cr_generate_id.c +++ b/cr_generate_id.c @@ -129,27 +129,10 @@ #include "cr_generate_id_private.h" #include "cr_alloc.h" -// TODO: 仕様FIXする必要あり -typedef struct { - u32 magic_number; /* 0x00 - 0x03 0x01234567 確定!*/ - u32 serial0; /* 0x04 - 0x07 */ - u32 openssl_err_code; /* 0x08 - 0x0b */ - s32 top; /* 0x0c - 0x0f */ - s32 bottom; /* 0x10 - 0x13 */ - - /* #define ERR_NUM_ERRORS 16 */ - u32 err_buffer[ERR_NUM_ERRORS]; /* 0x14 - 0x17 .... 0x50 - 0x53 */ - //#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) - //#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) - //#define ERR_GET_REASON(l) (int)((l)&0xfffL) - //#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) - s32 err_line[ERR_NUM_ERRORS]; /* 0x54 - 0x57 .... 0x90 - 0x93 */ -} CR_ERR_BUFFER; - +static u64 generatingCount = 0; // 現在生成中のID(起動時からの通算) int cr_print_flag = 0; - // generate_id関数のイニシャライズ int cr_generate_id_initialize( void ) { @@ -205,6 +188,8 @@ int cr_generate_id( u32 serial[CR_NUM_OF_SERIAL], u8 id_buf[CR_ID_BUF_SIZE], u8 CR_ID_BUFFER *cr_id_buf; EC_KEY *deviceKeyPair = NULL; + generatingCount++; + if( sizeof(CR_ID_BUFFER) != 256 ) { ret_code = CR_GENID_ERROR_ID_BUF_SIZE; goto end; @@ -413,3 +398,8 @@ void DebugFileOutput( u32 deviceId, char *pSuffix, const u8 *pSrc, int length ) } } +// 起動してから現在いくつ目のIDを生成中か返す +u64 GetGeneratingCount( void ) +{ + return generatingCount; +} diff --git a/cr_generate_id_private.h b/cr_generate_id_private.h index 2c64931..065bdb6 100644 --- a/cr_generate_id_private.h +++ b/cr_generate_id_private.h @@ -182,6 +182,22 @@ typedef struct { u8 hash[ SHA256_DIGEST_LENGTH ]; /* 0xE0 - 0xFF "0x00-0xDF"̈SHA256nbV */ } CR_ID_BUFFER; /* v256bytes = 2048bit */ +// TODO: dlFIXKv +typedef struct { + u32 magic_number; /* 0x00 - 0x03 0x01234567 mI*/ + u32 serial0; /* 0x04 - 0x07 */ + u32 openssl_err_code; /* 0x08 - 0x0b */ + s32 top; /* 0x0c - 0x0f */ + s32 bottom; /* 0x10 - 0x13 */ + + /* #define ERR_NUM_ERRORS 16 */ + u32 err_buffer[ERR_NUM_ERRORS]; /* 0x14 - 0x17 .... 0x50 - 0x53 */ + //#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) + //#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) + //#define ERR_GET_REASON(l) (int)((l)&0xfffL) + //#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + s32 err_line[ERR_NUM_ERRORS]; /* 0x54 - 0x57 .... 0x90 - 0x93 */ +} CR_ERR_BUFFER; extern int GetTimestamp( u8 *pYear, u8 *pMonth, u8 *pMday, u8 *pHour, u8 *pMin, u8 *pSec, time_t *pTime); extern int GenerateRandom( u8 *pDst, int length ); @@ -191,6 +207,7 @@ extern int GenerateCTRDeviceCert( EC_KEY *pECkey, u32 deviceId, u8 bondingOptio extern int EncryptID( unsigned char *dst_buf, unsigned char *org_buf, u8 bondingOption ); extern void DebugPrintArray( char *pStr, const u8 *pData, int length ); extern void DebugFileOutput( u32 deviceId, char *pSuffix, const u8 *pSrc, int length ); +extern u64 GetGeneratingCount( void ); #ifdef __cplusplus } diff --git a/cr_hsm_util.c b/cr_hsm_util.c index 3a3bdc7..89f3aed 100644 --- a/cr_hsm_util.c +++ b/cr_hsm_util.c @@ -223,4 +223,14 @@ int GenerateRandom( u8 *pDst, int length ) #endif // USE_HSM return ret_code; +} + +// G[L^ +void SaveErrorInfo( int errorCode, char fileName[], int line ) +{ + + + + + }