mirror of
https://github.com/rvtr/ctr_eFuse.git
synced 2025-11-02 00:11:04 -04:00
OpenSSL用のアロケータ登録は起動時に一回だけでよい。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@177 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
parent
577c5fc792
commit
9dcee8d97b
@ -185,7 +185,7 @@ int GenerateCTRDeviceCert( EC_KEY *pECkey, u32 device_id, u8 bonding_option, u8
|
|||||||
|
|
||||||
memset( &deviceCert, 0, sizeof(deviceCert) );
|
memset( &deviceCert, 0, sizeof(deviceCert) );
|
||||||
|
|
||||||
// sigType
|
// sigType
|
||||||
// ECDSA+SHA256 = 0x00010005, ECDSA+SHA1 = 0x00010002
|
// ECDSA+SHA256 = 0x00010005, ECDSA+SHA1 = 0x00010002
|
||||||
deviceCert.sigType[0] = 0x00;
|
deviceCert.sigType[0] = 0x00;
|
||||||
deviceCert.sigType[1] = 0x01;
|
deviceCert.sigType[1] = 0x01;
|
||||||
|
|||||||
@ -155,7 +155,20 @@ int cr_generate_id_initialize( u8 err_buf[CR_ID_BUF_SIZE] )
|
|||||||
|
|
||||||
// init for error info
|
// init for error info
|
||||||
InitErrorInfo();
|
InitErrorInfo();
|
||||||
|
|
||||||
|
// OpenSSL のメモリリーク防止のため、オリジナルのアロケータを使用。
|
||||||
|
if ( CRYPTO_set_mem_functions( cr_mem_malloc, cr_mem_realloc, cr_mem_free ) != 1 )
|
||||||
|
{
|
||||||
|
CR_ERR_BUFFER *cr_err_buf = (CR_ERR_BUFFER *)err_buf;
|
||||||
|
memset( cr_err_buf, 0, sizeof( CR_ERR_BUFFER ) );
|
||||||
|
cr_err_buf->errorCode = CR_GENID_ERROR_SET_MEM_FUNCTIONS;
|
||||||
|
GetErrorInfo( cr_err_buf->callStack, &cr_err_buf->recordSize );
|
||||||
|
#ifdef DEBUG_PRINT
|
||||||
|
printf( "error(%d), CALL_STACK : %s\n", (int)cr_err_buf->errorCode, cr_err_buf->callStack );
|
||||||
|
#endif
|
||||||
|
return CR_GENID_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_HSM
|
#ifdef USE_HSM
|
||||||
ret_code = hsm_initialize();
|
ret_code = hsm_initialize();
|
||||||
if ( ret_code != CR_GENID_SUCCESS )
|
if ( ret_code != CR_GENID_SUCCESS )
|
||||||
@ -225,15 +238,13 @@ int cr_generate_id( u32 device_id[CR_NUM_OF_DEVICEID], u8 id_buf[CR_ID_BUF_SIZE]
|
|||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// 暗号処理初期化
|
// 暗号処理初期化
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
cr_mem_bufmgr_initialize();
|
||||||
// メモリリーク防止のため、オリジナルのアロケータを使用。
|
|
||||||
CRYPTO_set_mem_functions(cr_mem_malloc, cr_mem_realloc, cr_mem_free);
|
|
||||||
cr_mem_bufmgr_initialize();
|
|
||||||
|
|
||||||
#ifdef MY_CRYPTO_DEBUG
|
#ifdef MY_CRYPTO_DEBUG
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
#endif /* MY_CRYPTO_DEBUG */
|
#endif /* MY_CRYPTO_DEBUG */
|
||||||
|
|
||||||
|
|
||||||
// ダイジェストアルゴリズムを追加する
|
// ダイジェストアルゴリズムを追加する
|
||||||
OpenSSL_add_all_digests();
|
OpenSSL_add_all_digests();
|
||||||
|
|
||||||
@ -267,7 +278,7 @@ int cr_generate_id( u32 device_id[CR_NUM_OF_DEVICEID], u8 id_buf[CR_ID_BUF_SIZE]
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_PRINT */
|
#endif /* DEBUG_PRINT */
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// タイムスタンプセット
|
// タイムスタンプセット
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
@ -282,7 +293,7 @@ int cr_generate_id( u32 device_id[CR_NUM_OF_DEVICEID], u8 id_buf[CR_ID_BUF_SIZE]
|
|||||||
SetErrorInfo( __FUNCTION__, __LINE__ );
|
SetErrorInfo( __FUNCTION__, __LINE__ );
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// 乱数を生成してセット
|
// 乱数を生成してセット
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
@ -301,7 +312,7 @@ int cr_generate_id( u32 device_id[CR_NUM_OF_DEVICEID], u8 id_buf[CR_ID_BUF_SIZE]
|
|||||||
SetErrorInfo( __FUNCTION__, __LINE__ );
|
SetErrorInfo( __FUNCTION__, __LINE__ );
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// 生成した鍵ペアをECDSAで動作確認
|
// 生成した鍵ペアをECDSAで動作確認
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
|||||||
@ -174,6 +174,7 @@ extern "C" {
|
|||||||
#define CR_GENID_ERROR_RSA_ENC (-15)
|
#define CR_GENID_ERROR_RSA_ENC (-15)
|
||||||
#define CR_GENID_ERROR_RSA_DEC (-16)
|
#define CR_GENID_ERROR_RSA_DEC (-16)
|
||||||
#define CR_GENID_ERROR_RSA_VERIFY (-17)
|
#define CR_GENID_ERROR_RSA_VERIFY (-17)
|
||||||
|
#define CR_GENID_ERROR_SET_MEM_FUNCTIONS (-18)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 magic_number; /* 0x00 - 0x03 = 0xdeadb00f Šm’è<E28099>I*/
|
u32 magic_number; /* 0x00 - 0x03 = 0xdeadb00f Šm’è<E28099>I*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user