mirror of
https://github.com/rvtr/ctr_eFuse.git
synced 2025-11-02 00:11:04 -04:00
RSA処理部が抜けていたので追加(cr_rsa_enc_dec関数の中身)
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@20 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
parent
63b3edb02c
commit
a656144f01
32
cr_enc_id.c
32
cr_enc_id.c
@ -153,6 +153,9 @@ int EncryptID( unsigned char *dst_buf, unsigned char *org_buf )
|
|||||||
|
|
||||||
int crypto_aes_enc_dec( unsigned char *dst_buf, unsigned char *org_buf )
|
int crypto_aes_enc_dec( unsigned char *dst_buf, unsigned char *org_buf )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
int ret_code = 0;
|
||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
ret_code = hsm_aes_encrypt( local_buf_1, org_buf, CR_ID_BUF_SIZE );
|
ret_code = hsm_aes_encrypt( local_buf_1, org_buf, CR_ID_BUF_SIZE );
|
||||||
if ( ret_code != CR_GENID_SUCCESS )
|
if ( ret_code != CR_GENID_SUCCESS )
|
||||||
@ -256,7 +259,36 @@ int crypto_aes_enc_dec( unsigned char *dst_buf, unsigned char *org_buf )
|
|||||||
|
|
||||||
int crypto_rsa_enc_dec( unsigned char *dst_buf,unsigned char *org_buf )
|
int crypto_rsa_enc_dec( unsigned char *dst_buf,unsigned char *org_buf )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
int ret_code = 0;
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
ret_code = hsm_rsa_encrypt( local_buf_1, org_buf, CR_ID_BUF_SIZE );
|
||||||
|
if ( ret_code != CR_GENID_SUCCESS )
|
||||||
|
{
|
||||||
|
printf( "error(%d) : hsm_rsa_encyrpt\n", ret_code );
|
||||||
|
return ret_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// decyrpt
|
||||||
|
ret_code = hsm_rsa_decrypt( local_buf_2, local_buf_1, CR_ID_BUF_SIZE );
|
||||||
|
if ( ret_code != CR_GENID_SUCCESS )
|
||||||
|
{
|
||||||
|
printf( "error(%d) : hsm_rsa_decrypt\n", ret_code );
|
||||||
|
return ret_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ベリファイ
|
||||||
|
for ( i = 0 ; i < CR_ID_BUF_SIZE ; i++ )
|
||||||
|
{
|
||||||
|
if( org_buf[i] != local_buf_2[i] )
|
||||||
|
{
|
||||||
|
return CR_GENID_ERROR_AES_VERIFY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// バッファコピー
|
||||||
|
memcpy( dst_buf, local_buf_1, CR_ID_BUF_SIZE );
|
||||||
|
|
||||||
return CR_GENID_SUCCESS;
|
return CR_GENID_SUCCESS;
|
||||||
} // hsm_crypto_rsa_enc_dec
|
} // hsm_crypto_rsa_enc_dec
|
||||||
|
|||||||
@ -154,7 +154,7 @@ int cr_print_flag = 0;
|
|||||||
|
|
||||||
int cr_generate_id_initialize( void )
|
int cr_generate_id_initialize( void )
|
||||||
{
|
{
|
||||||
int ret_code = 0;
|
int ret_code = 0;
|
||||||
|
|
||||||
#ifdef USE_HSM
|
#ifdef USE_HSM
|
||||||
ret_code = hsm_initialize();
|
ret_code = hsm_initialize();
|
||||||
@ -170,7 +170,6 @@ int cr_generate_id_initialize( void )
|
|||||||
return ( ret_code );
|
return ( ret_code );
|
||||||
} // cr_generate_id_initialize
|
} // cr_generate_id_initialize
|
||||||
|
|
||||||
|
|
||||||
// generate_id関数のファイナライズ
|
// generate_id関数のファイナライズ
|
||||||
int cr_generate_id_finalize( void )
|
int cr_generate_id_finalize( void )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -140,6 +140,9 @@
|
|||||||
#define CR_GENID_ERROR_ID_BUF_SIZE (-19)
|
#define CR_GENID_ERROR_ID_BUF_SIZE (-19)
|
||||||
#define CR_GENID_ERROR_ERR_BUF_SIZE (-20)
|
#define CR_GENID_ERROR_ERR_BUF_SIZE (-20)
|
||||||
#define CR_GENID_ERROR_PRIVKEY_SCRAMBLE (-21)
|
#define CR_GENID_ERROR_PRIVKEY_SCRAMBLE (-21)
|
||||||
|
#define CR_GENID_ERROR_AES_ENC (-22)
|
||||||
|
#define CR_GENID_ERROR_AES_DEC (-23)
|
||||||
|
#define CR_GENID_ERROR_AES_VERIFY (-24)
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// HSMの処理結果によるエラーコード
|
// HSMの処理結果によるエラーコード
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user