エラーバッファ周り叩き台(CR_ERR_BUFFER構造体を private.h に移しました)

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@46 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2009-12-23 04:32:50 +00:00
parent 3a8205d8e4
commit 05c038de67
3 changed files with 35 additions and 18 deletions

View File

@ -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;
}

View File

@ -182,6 +182,22 @@ typedef struct {
u8 hash[ SHA256_DIGEST_LENGTH ]; /* 0xE0 - 0xFF "0x00-0xDF"—̈æÌSHA256ƒnƒbƒVƒ… */
} CR_ID_BUFFER; /* <20>‡Œv256bytes = 2048bit */
// 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;
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
}

View File

@ -223,4 +223,14 @@ int GenerateRandom( u8 *pDst, int length )
#endif // USE_HSM
return ret_code;
}
// エラー情報を記録する
void SaveErrorInfo( int errorCode, char fileName[], int line )
{
}