diff --git a/hsm_utils/import_aes_key.c b/hsm_utils/import_aes_key.c index d092be2..19db292 100644 --- a/hsm_utils/import_aes_key.c +++ b/hsm_utils/import_aes_key.c @@ -17,8 +17,8 @@ #define MODULE_ID 1 #define DATA_LEN 256 // bytes -#define KEY_FILE "/opt/nfast/work/ctr_eFuse/hsm_utils/aes-key.der" -const NFKM_KeyIdent keyident = { (char*)"simple", (char*)"import-aes-key" }; +#define KEY_FILE "/opt/nfast/work/ctr_eFuse/hsm_utils/real_key/dev/eFuse_aesKey.bin" +const NFKM_KeyIdent keyident = { (char*)"simple", (char*)"efuse-aes-dev" }; //#define CARD_PROTECT //#define EXPORT_KEY @@ -51,10 +51,25 @@ int main( int argc, char *argv[] ) NFKM_WorldInfo *world = NULL; RQCard card; 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; NFKM_Key *keyinfo; 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 result = NFastApp_InitEx( &handle, NULL, NULL ); @@ -204,12 +219,11 @@ int main( int argc, char *argv[] ) } // import key - NFKM_KeyIdent keyident = { (char*)"custom", (char*)"aes-import-key" }; tc.cmd.cmd = Cmd_Import; tc.cmd.args.import.module = MODULE_ID; 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.ptr = aes_key_data; + tc.cmd.args.import.data.data.random.k.len = 16; + tc.cmd.args.import.data.data.random.k.ptr = aesData; result = NFastApp_Transact( nc, NULL, &(tc.cmd), &(tc.reply), NULL ); if ( result != Status_OK ) {