mirror of
https://github.com/rvtr/ctr_eFuse.git
synced 2025-11-02 00:11:04 -04:00
CR_ERR_BUFFERの仮フォーマットとそれに対する処理追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@48 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
parent
fa5d5ce2e2
commit
0dc4a08d32
@ -189,6 +189,10 @@ int cr_generate_id( u32 serial[CR_NUM_OF_SERIAL], u8 id_buf[CR_ID_BUF_SIZE], u8
|
||||
|
||||
generatingCount++;
|
||||
|
||||
StoreErrorInfo( 100, __FILE__, __LINE__ );
|
||||
ret_code = 100;
|
||||
goto end;
|
||||
|
||||
if( sizeof(CR_ID_BUFFER) != 256 ) {
|
||||
ret_code = CR_GENID_ERROR_ID_BUF_SIZE;
|
||||
goto end;
|
||||
@ -335,22 +339,20 @@ int cr_generate_id( u32 serial[CR_NUM_OF_SERIAL], u8 id_buf[CR_ID_BUF_SIZE], u8
|
||||
// 終了処理
|
||||
//--------------------------------------------------------------
|
||||
end:
|
||||
|
||||
/* id_buf[]にエラーログを書き込む。 */
|
||||
// TODO: 仕様をFIXする必要あり
|
||||
if( ret_code != CR_GENID_SUCCESS ) {
|
||||
ERR_STATE *es = NULL;
|
||||
// TODO: 仕様をFIXする必要あり -> TORIAEZU version
|
||||
if ( ret_code != CR_GENID_SUCCESS )
|
||||
{
|
||||
CR_ERR_BUFFER *cr_err_buf = (CR_ERR_BUFFER *)id_buf;
|
||||
memset( cr_err_buf, 0, sizeof(CR_ERR_BUFFER) );
|
||||
memset( cr_err_buf, 0, sizeof( CR_ERR_BUFFER ) );
|
||||
cr_err_buf->totalCount = generatingCount;
|
||||
cr_err_buf->magic_number = 0x01234567;
|
||||
cr_err_buf->serial0 = serial[0];
|
||||
cr_err_buf->openssl_err_code = ERR_get_error();
|
||||
es=ERR_get_state();
|
||||
cr_err_buf->top = es->top;
|
||||
cr_err_buf->bottom = es->bottom;
|
||||
for( i = 0 ; i < ERR_NUM_ERRORS ; i++ ) {
|
||||
cr_err_buf->err_buffer[i] = es->err_buffer[i];
|
||||
cr_err_buf->err_line[i] = es->err_line[i];
|
||||
}
|
||||
GetErrorInfo( &(cr_err_buf->errorCode),
|
||||
cr_err_buf->fileName,
|
||||
&cr_err_buf->lineNumber );
|
||||
cr_err_buf->bondingOption = bondingOption;
|
||||
}
|
||||
|
||||
// リソースの解放
|
||||
@ -396,9 +398,3 @@ void DebugFileOutput( u32 deviceId, char *pSuffix, const u8 *pSrc, int length )
|
||||
fclose( fp );
|
||||
}
|
||||
}
|
||||
|
||||
// 起動してから現在いくつ目のIDを生成中か返す
|
||||
u64 GetGeneratingCount( void )
|
||||
{
|
||||
return generatingCount;
|
||||
}
|
||||
|
||||
@ -183,32 +183,30 @@ typedef struct {
|
||||
u8 hash[ SHA256_DIGEST_LENGTH ]; /* 0xE0 - 0xFF "0x00-0xDF"—̈æ‚ÌSHA256ƒnƒbƒVƒ… */
|
||||
} CR_ID_BUFFER; /* <20>‡Œv256bytes = 2048bit */
|
||||
|
||||
// TODO: 仕様FIXする必要あり
|
||||
// TODO: 仕様FIXする必要あり -> 仮 version
|
||||
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 */
|
||||
u64 totalCount; /* 0x00 - 0x07 */
|
||||
u32 magic_number; /* 0x08 - 0x0b 0x01234567 確定!*/
|
||||
u32 serial0; /* 0x0c - 0x0f */
|
||||
s32 errorCode; /* 0x10 - 0x13 */
|
||||
u32 lineNumber; /* 0x14 - 0x17 */
|
||||
char fileName[ 64 ]; /* 0x18 - 0x57 */ // いくつあれば十分か?
|
||||
u8 bondingOption; /* 0x58 - 0x58 */
|
||||
u8 reserve[ 167 ]; /* 0x59 - 0xff */
|
||||
} 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 );
|
||||
extern int GenarateECCKeyPair( EC_KEY **ppECkey, u8 *pECPrivkey );
|
||||
|
||||
extern void StoreErrorInfo( s32 errorCode, char *fileName, u32 line );
|
||||
extern void GetErrorInfo( s32 *errorCode, char *fileName, u32 *line );
|
||||
|
||||
extern int TestECDSA( EC_KEY *pECkey );
|
||||
extern int GenerateCTRDeviceCert( EC_KEY *pECkey, u32 deviceId, u8 bondingOption, u8 *pDevCertSign, u32 *pExpiryDate );
|
||||
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
|
||||
}
|
||||
|
||||
@ -124,6 +124,16 @@
|
||||
#include "cr_generate_id.h"
|
||||
#include "cr_generate_id_private.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s32 errorCode;
|
||||
u32 lineNumber;
|
||||
char fileName[64];
|
||||
}
|
||||
errorInfoStruct;
|
||||
|
||||
static errorInfoStruct errorInfo;
|
||||
|
||||
// タイムスタンプを取得してセット
|
||||
int GetTimestamp( u8 *pYear, u8 *pMonth, u8 *pMday, u8 *pHour, u8 *pMin, u8 *pSec, time_t *pTime)
|
||||
{
|
||||
@ -226,11 +236,33 @@ int GenerateRandom( u8 *pDst, int length )
|
||||
}
|
||||
|
||||
// エラー情報を記録する
|
||||
void SaveErrorInfo( int errorCode, char fileName[], int line )
|
||||
void StoreErrorInfo( s32 errorCode, char fileName[], u32 line )
|
||||
{
|
||||
static u8 stored = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ( !stored )
|
||||
{
|
||||
stored = 1;
|
||||
|
||||
memset( &errorInfo, 0, sizeof( errorInfo ) );
|
||||
|
||||
errorInfo.errorCode = errorCode;
|
||||
strncpy( errorInfo.fileName, fileName, strlen( fileName ) );
|
||||
errorInfo.lineNumber = line;
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
printf( "Error info was already stored!\n" );
|
||||
}
|
||||
#endif
|
||||
} // StoreErrorInfo
|
||||
|
||||
// エラー情報を引数にセットする
|
||||
void GetErrorInfo( s32 *errorCode, char *fileName, u32 *line )
|
||||
{
|
||||
*errorCode = errorInfo.errorCode;
|
||||
strncpy( fileName, errorInfo.fileName, strlen( errorInfo.fileName ) );
|
||||
*line = errorInfo.lineNumber;
|
||||
} // GetErrorInfo
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user