ECDSA鍵ペアロード成功

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@127 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2009-12-29 05:05:40 +00:00
parent b2d392fec9
commit c74a9a8c02
2 changed files with 93 additions and 1 deletions

View File

@ -53,7 +53,6 @@ NFAST_LDLIBS = \
# nFast OBJS
NFAST_OBJS_PATH = $(NFAST_EXAMPLES)/nfuser/build-gcc-lib
NFAST_OBJS_LIST = \
$(NFAST_OBJS_PATH)/simplebignum.o \
$(NFAST_OBJS_PATH)/nfutil.o \
else # !USE_HSM

View File

@ -149,6 +149,16 @@ const NFKM_KeyIdent hsmRsaKeyidentProd = { (char*)"simple", (char*)"rsa-dummykey
static int hsm_rsa_load_keypair( NFKM_KeyIdent keyident, M_KeyID *privKeyid, M_KeyID *pubKeyid );
#endif // ENCRYPT_AES
// ECDSA key
M_KeyID hsmEcdsaPrivkeyidDev, hsmEcdsaPubkeyidDev;
M_KeyID hsmEcdsaPrivkeyidProd, hsmEcdsaPubkeyidProd;
const NFKM_KeyIdent hsmEcdsaPrivkeyidentDev = { (char*)"simple", (char*)"nintendo-ctr2-priv-dummy-dev" };
const NFKM_KeyIdent hsmEcdsaPubkeyidentDev = { (char*)"simple", (char*)"nintendo-ctr2-pub-dummy-dev" };
const NFKM_KeyIdent hsmEcdsaPrivkeyidentProd = { (char*)"simple", (char*)"nintendo-ctr2-priv-dummy-prod" };
const NFKM_KeyIdent hsmEcdsaPubkeyidentProd = { (char*)"simple", (char*)"nintendo-ctr2-pub-dummy-prod" };
int hsm_ecdsa_load_keypair( NFKM_KeyIdent privKeyident, M_KeyID *privKeyid,
NFKM_KeyIdent pubKeyident, M_KeyID *pubKeyid );
// init HSM
int hsm_initialize( void )
{
@ -237,6 +247,23 @@ int hsm_initialize( void )
}
#endif // ENCRYPT_AES
// load ecdsa dev keypair
ret_code = hsm_ecdsa_load_keypair( hsmEcdsaPrivkeyidentDev, &hsmEcdsaPrivkeyidDev,
hsmEcdsaPubkeyidentDev, &hsmEcdsaPrivkeyidDev );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
// load ecdsa prod keypair
ret_code = hsm_ecdsa_load_keypair( hsmEcdsaPrivkeyidentProd, &hsmEcdsaPrivkeyidProd,
hsmEcdsaPubkeyidentProd, &hsmEcdsaPrivkeyidProd );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
return ret_code;
}
return ret_code;
} // hsm_initialize
@ -714,4 +741,70 @@ int hsm_rsa_decrypt( unsigned char *dst_buf, unsigned char *org_buf, int size, u
#endif // !ENCRYPT_AES
int hsm_ecdsa_load_keypair( NFKM_KeyIdent privKeyident, M_KeyID *privKeyid,
NFKM_KeyIdent pubKeyident, M_KeyID *pubKeyid )
{
int ret_code = CR_GENID_SUCCESS;
NFKM_Key *keyinfo = NULL;
NFKM_ModuleInfo *moduleinfo = NULL;
M_ByteBlock *blobptr = NULL;
// find priv key
ret_code = NFKM_findkey( hsmHandle, privKeyident, &keyinfo, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
goto end;
}
// get usable Module
moduleinfo = hsmWorld->modules[0];
ret_code = NFKM_getusablemodule( hsmWorld, HSM_MODULE_ID, &moduleinfo );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
goto end;
}
// load priv key blob
blobptr = &keyinfo->privblob;
ret_code = NFKM_cmd_loadblob( hsmHandle, hsmConnection,
moduleinfo->module, blobptr,
0, privKeyid,
"loading priv key blob", NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
goto end;
}
NFKM_freekey( hsmHandle, keyinfo, NULL );
keyinfo = NULL;
// find pub key
ret_code = NFKM_findkey( hsmHandle, pubKeyident, &keyinfo, NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
goto end;
}
// load public key blob
blobptr = &keyinfo->pubblob;
ret_code = NFKM_cmd_loadblob( hsmHandle, hsmConnection,
moduleinfo->module, blobptr,
0, pubKeyid,
"loading pub key blob", NULL );
if ( ret_code != CR_GENID_SUCCESS )
{
SetErrorInfo( __FUNCTION__, __LINE__ );
goto end;
}
end:
NFKM_freekey( hsmHandle, keyinfo, NULL );
return ret_code;
} // hsm_ecdsa_load_keypair
#endif // USE_HSM