リセットするには特権モードでの接続が必要。

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@90 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2009-12-25 01:19:15 +00:00
parent 1d475fdf1f
commit 4589b6b330

View File

@ -163,7 +163,6 @@ int hsm_initialize( void )
return ret_code;
}
// init HSM
ret_code = NFastApp_InitEx( &hsmHandle, NULL, NULL );
if ( ret_code != CR_GENID_SUCCESS )
@ -251,16 +250,34 @@ void hsm_finalize( void )
int hsm_reset_module( void )
{
int ret_code = CR_GENID_SUCCESS;
NFast_AppHandle handle;
NFastApp_Connection connection;
M_Command cmd;
M_Reply reply;
memset( &cmd, 0, sizeof( cmd ) );
memset( &reply, 0, sizeof( reply ) );
cmd.cmd = Cmd_ClearUnit;
cmd.args.clearunit.module = HSM_MODULE_ID;
// init HSM
ret_code = NFastApp_InitEx( &handle, NULL, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
ret_code = NFastApp_Transact( hsmConnection, NULL, &cmd, &reply, NULL );
// 特権モードで接続しないと、ClerUnit, RetryFailedModuleコマンドが発行できない
ret_code = NFastApp_Connect( handle, &connection, NFastApp_ConnectionFlags_Privileged, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
// failed state からの復旧要求
cmd.cmd = Cmd_RetryFailedModule;
cmd.args.retryfailedmodule.module = HSM_MODULE_ID;
ret_code = NFastApp_Transact( connection, NULL, &cmd, &reply, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
@ -273,8 +290,41 @@ int hsm_reset_module( void )
return ret_code;
}
NFastApp_Free_Command( hsmHandle, NULL, NULL, &cmd );
NFastApp_Free_Reply( hsmHandle, NULL, NULL, &reply );
NFastApp_Free_Command( handle, NULL, NULL, &cmd );
NFastApp_Free_Reply( handle, NULL, NULL, &reply );
memset( &cmd, 0, sizeof( cmd ) );
memset( &reply, 0, sizeof( reply ) );
// モジュールのリセット
cmd.cmd = Cmd_ClearUnit;
cmd.args.clearunit.module = HSM_MODULE_ID;
ret_code = NFastApp_Transact( connection, NULL, &cmd, &reply, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
ret_code = reply.status;
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
NFastApp_Free_Command( handle, NULL, NULL, &cmd );
NFastApp_Free_Reply( handle, NULL, NULL, &reply );
// 切断
ret_code = NFastApp_Disconnect( hsmConnection, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
// ハンドル破棄
NFastApp_Finish( handle, NULL );
return ret_code;
} // hsm_reset_module
@ -502,6 +552,7 @@ int hsm_aes_decrypt( unsigned char *dst_buf, unsigned char *org_buf, int size, u
#else // !ENCRYPT_AES
int hsm_rsa_load_keypair( NFKM_KeyIdent keyident, M_KeyID *privKeyid, M_KeyID *pubKeyid )
{
int ret_code = CR_GENID_SUCCESS;