AES鍵インポート、更なる修正

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@145 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2010-01-06 06:15:14 +00:00
parent b7f0389252
commit 5f36638c42

View File

@ -17,8 +17,8 @@
#define MODULE_ID 1 #define MODULE_ID 1
#define DATA_LEN 256 // bytes #define DATA_LEN 256 // bytes
#define KEY_FILE "/opt/nfast/work/ctr_eFuse/hsm_utils/aes-key.der" #define KEY_FILE "/opt/nfast/work/ctr_eFuse/hsm_utils/real_key/dev/eFuse_aesKey.bin"
const NFKM_KeyIdent keyident = { (char*)"simple", (char*)"import-aes-key" }; const NFKM_KeyIdent keyident = { (char*)"simple", (char*)"efuse-aes-dev" };
//#define CARD_PROTECT //#define CARD_PROTECT
//#define EXPORT_KEY //#define EXPORT_KEY
@ -51,10 +51,25 @@ int main( int argc, char *argv[] )
NFKM_WorldInfo *world = NULL; NFKM_WorldInfo *world = NULL;
RQCard card; RQCard card;
RQCard_FIPS fips; RQCard_FIPS fips;
M_KeyID ltid; // the cardset loaded into the module M_KeyID ltid = 0; // the cardset loaded into the module
M_KeyID keyid; M_KeyID keyid;
NFKM_Key *keyinfo; NFKM_Key *keyinfo;
NFKM_CardSet *cardset = NULL; NFKM_CardSet *cardset = NULL;
FILE *fp;
unsigned char aesData[16];
// key data open & read
printf( "filename : %s\n", KEY_FILE );
fp = fopen( KEY_FILE, "rb" );
if ( !fp )
{
printf( "error : fopen\n" );
return 0;
}
fread( aesData, 16, 1, fp );
for( i = 0; i < 16; i++ )
printf( "%02X ", aesData[i] );
printf( "\n" );
// init nFast // init nFast
result = NFastApp_InitEx( &handle, NULL, NULL ); result = NFastApp_InitEx( &handle, NULL, NULL );
@ -204,12 +219,11 @@ int main( int argc, char *argv[] )
} }
// import key // import key
NFKM_KeyIdent keyident = { (char*)"custom", (char*)"aes-import-key" };
tc.cmd.cmd = Cmd_Import; tc.cmd.cmd = Cmd_Import;
tc.cmd.args.import.module = MODULE_ID; tc.cmd.args.import.module = MODULE_ID;
tc.cmd.args.import.data.type = KeyType_Rijndael; tc.cmd.args.import.data.type = KeyType_Rijndael;
tc.cmd.args.import.data.data.random.k.len = 32; tc.cmd.args.import.data.data.random.k.len = 16;
tc.cmd.args.import.data.data.random.k.ptr = aes_key_data; tc.cmd.args.import.data.data.random.k.ptr = aesData;
result = NFastApp_Transact( nc, NULL, &(tc.cmd), &(tc.reply), NULL ); result = NFastApp_Transact( nc, NULL, &(tc.cmd), &(tc.reply), NULL );
if ( result != Status_OK ) if ( result != Status_OK )
{ {