hsm_utils:RSAキーペアインポート"自体"成功、ECDSA priv key インポート成功?

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@116 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2009-12-28 11:58:55 +00:00
parent ebd20afe39
commit e3b58c07cc
4 changed files with 672 additions and 228 deletions

View File

@ -383,7 +383,7 @@ int main( int argc, char *argv[] )
// 暗号化と復号化、署名とベリファイなど、相反する操作を持たせることはできない(エラーになる)
// e.g. NFKM_DEFOPPERMS_SIGN | NFKM_DEFOPPERMS_VERIFY -> エラー
// e.g. NFKM_DEFOPPERMS_ENCRYPT | NFKM_DEFOPPERMS_DECRYPT -> エラー
map.op_base = NFKM_DEFOPPERMS_SIGN | NFKM_DEFOPPERMS_ENCRYPT;
map.op_base = NFKM_DEFOPPERMS_SIGN;
map.cs = cardset;
result = NFKM_newkey_makeaclx( handle, nc, world, &map, &(cmd.args.import.acl), NULL );
if ( result != Status_OK )
@ -421,10 +421,11 @@ int main( int argc, char *argv[] )
NFKM_KeyIdent keyident = { (char*)"simple", (char*)"ecc-import-privkey" };
cmd.cmd = Cmd_Import;
cmd.args.import.module = MODULE_ID;
cmd.args.import.data.type = KeyType_ECPrivate;
cmd.args.import.data.data.ecprivate.curve.name = ECName_NISTK233;
//cmd.args.import.data.data.ecprivate.curve.name = ECName_NISTB233;
cmd.args.import.data.type = KeyType_ECDSAPrivate;
//cmd.args.import.data.data.ecprivate.curve.name = ECName_NISTK233;
cmd.args.import.data.data.ecprivate.curve.name = ECName_NISTB233;
#if 0
#if 0
cmd.args.import.data.data.ecprivate.curve.data.custom.F.type = FieldType_Prime;
cmd.args.import.data.data.ecprivate.curve.data.custom.F.data.prime.flags = 0; // ???
@ -454,6 +455,7 @@ int main( int argc, char *argv[] )
cmd.args.import.data.data.ecprivate.curve.data.customlcf.g.x = gyBn;
cmd.args.import.data.data.ecprivate.curve.data.customlcf.r = rBn;
cmd.args.import.data.data.ecprivate.curve.data.customlcf.h = hBn;
#endif
#endif
cmd.args.import.data.data.ecprivate.d = dBn;
@ -473,7 +475,7 @@ int main( int argc, char *argv[] )
printf( "done. next : make blob ...\n" );
#if 0
#if 1
// make blobs
NFKM_MakeBlobsParams mbp;

File diff suppressed because it is too large Load Diff

View File

@ -281,6 +281,47 @@ int my_bignum2char ( char *buf, int buflen,
/* --------------------- */
int my_bignum2bin ( unsigned char *buf, int buflen,
struct NFast_Application *app,
const struct NFast_Bignum *pBN )
{
int i, pos, len;
len = pBN->nbytes;
pos = len;
if ( buflen < pos )
return Status_BufferFull;
for ( i = 0; i < len; i++ )
{
buf[--pos] = getbyte( pBN, i );
}
return Status_OK;
} // my_bignum2bin
/* --------------------- */
int my_bignumCopy( struct NFast_Bignum **dst,
const struct NFast_Bignum *src,
struct NFast_Application *app )
{
struct NFast_Bignum *pBN;
pBN = (struct NFast_Bignum *)NFastApp_Malloc( app, sizeof(struct NFast_Bignum), NULL, NULL );
if ( !pBN ) return NOMEM;
pBN->msb_first = src->msb_first;
pBN->msw_first = src->msw_first;
pBN->nbytes = src->nbytes;
memcpy( pBN->bytes, src->bytes, src->nbytes );
*dst = pBN;
return Status_OK;
}
/* --------------------- */
void my_printbignum ( FILE *f, const char *prefix, const struct NFast_Bignum *pBN )
{
char buf[MAXBIGNUMBITS/4+1];

View File

@ -145,6 +145,16 @@ extern int my_bignum2char ( char *buf, int buflen,
struct NFast_Call_Context *cctx,
struct NFast_Transaction_Context *tctx );
// convert NFast_Bignum to binary
int my_bignum2bin ( unsigned char *buf, int buflen,
struct NFast_Application *app,
const struct NFast_Bignum *pBN );
// NFast_Bignum copy
int my_bignumCopy( struct NFast_Bignum **dst,
const struct NFast_Bignum *src,
struct NFast_Application *app );
/** Print a bignum in hex to a file
*
* Call ferror() to test for output errors.