hsm_utils

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@113 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2009-12-28 01:03:51 +00:00
parent 915d377370
commit 4118586ac2
6 changed files with 25 additions and 60 deletions

View File

@ -109,7 +109,7 @@ import_rsa_keypair: import_rsa_keypair.c $(EXTRA_OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) -o import_rsa_keypair import_rsa_keypair.c $(COMMON_OBJECTS) $(EXTRA_OBJECTS) $(LDLIBS) $(CC) $(CFLAGS) $(CPPFLAGS) -o import_rsa_keypair import_rsa_keypair.c $(COMMON_OBJECTS) $(EXTRA_OBJECTS) $(LDLIBS)
import_ecc_keypair: import_ecc_keypair.c $(EXTRA_OBJECTS) import_ecc_keypair: import_ecc_keypair.c $(EXTRA_OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) -o import_ecc_keypair import_ecc_keypair.c $(COMMON_OBJECTS) $(EXTRA_OBJECTS) $(LDLIBS) $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o import_ecc_keypair import_ecc_keypair.c $(COMMON_OBJECTS) $(EXTRA_OBJECTS) $(LDLIBS)
# All single-threaded targets # All single-threaded targets

View File

@ -11,10 +11,11 @@
#include "rqcard-applic.h" #include "rqcard-applic.h"
#include "rqcard-fips.h" #include "rqcard-fips.h"
#include "ncthread-upcalls.h" //#include "ncthread-upcalls.h"
//#include "picky-upcalls.h" //#include "picky-upcalls.h"
#include "mybignum.h" #include "my_hsm_bignum.h"
#include "my_hsm_alloc.h"
#define MODULE_ID 1 #define MODULE_ID 1
#define DATA_LEN 256 // bytes #define DATA_LEN 256 // bytes

View File

@ -358,55 +358,13 @@ int main( int argc, char *argv[] )
struct NFast_Bignum *dmq1Bn = NULL; struct NFast_Bignum *dmq1Bn = NULL;
struct NFast_Bignum *iqmpBn = NULL; struct NFast_Bignum *iqmpBn = NULL;
struct NFast_Bignum *eBn = NULL; struct NFast_Bignum *eBn = NULL;
{
// p
result = sbn_bin2bignum( &pBn, handle, pPtr, pLen );
if ( result != Status_OK )
{
printf( "error(%d) : sbn_bin2bignum( p )\n", result );
return 0;
}
// q my_bin2bignum( &pBn, handle, pPtr, pLen );
result = sbn_bin2bignum( &qBn, handle, qPtr, qLen ); my_bin2bignum( &qBn, handle, qPtr, qLen );
if ( result != Status_OK ) my_bin2bignum( &dmp1Bn, handle, dmp1Ptr, dmp1Len );
{ my_bin2bignum( &dmq1Bn, handle, dmq1Ptr, dmq1Len );
printf( "error(%d) : sbn_bin2bignum( q )\n", result ); my_bin2bignum( &iqmpBn, handle, iqmpPtr, iqmpLen );
return 0; my_bin2bignum( &eBn, handle, ePtr, eLen );
}
// dmp1
result = sbn_bin2bignum( &dmp1Bn, handle, dmp1Ptr, dmp1Len );
if ( result != Status_OK )
{
printf( "error(%d) : sbn_bin2bignum( dmp1 )\n", result );
return 0;
}
// dmq1
result = sbn_bin2bignum( &dmq1Bn, handle, dmq1Ptr, dmq1Len );
if ( result != Status_OK )
{
printf( "error(%d) : sbn_bin2bignum( dmq1 )\n", result );
return 0;
}
// iqmp
result = sbn_bin2bignum( &iqmpBn, handle, iqmpPtr, iqmpLen );
if ( result != Status_OK )
{
printf( "error(%d) : sbn_bin2bignum( iqmp )\n", result );
return 0;
}
// e
result = sbn_bin2bignum( &eBn, handle, ePtr, eLen );
if ( result != Status_OK )
{
printf( "error(%d) : sbn_bin2bignum( e )\n", result );
return 0;
}
}
printf( "import ...\n" ); printf( "import ...\n" );

View File

@ -15,24 +15,30 @@
/* --------------------- */ /* --------------------- */
const NFast_MallocUpcalls my_malloc_upcalls = const NFast_MallocUpcalls my_hsm_malloc_upcalls =
{ {
my_malloc, my_realloc, my_free my_hsm_malloc, my_hsm_realloc, my_hsm_free
}; };
static void *my_malloc( size_t nbytes, /* --------------------- */
void *my_hsm_malloc( size_t nbytes,
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
{ {
return malloc( nbytes ); return malloc( nbytes );
} }
static void *my_realloc( void *ptr, size_t nbytes, /* --------------------- */
void *my_hsm_realloc( void *ptr, size_t nbytes,
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
{ {
return realloc( ptr, nbytes ); return realloc( ptr, nbytes );
} }
static void my_free( void *ptr, /* --------------------- */
void my_hsm_free( void *ptr,
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
{ {
free( ptr ); free( ptr );

View File

@ -11,7 +11,7 @@
extern "C" { extern "C" {
#endif #endif
extern NFast_MallocUpcalls my_hsm_malloc_upcalls; extern const NFast_MallocUpcalls my_hsm_malloc_upcalls;
void *my_hsm_malloc( size_t nbytes, void *my_hsm_malloc( size_t nbytes,
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ); struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx );

View File

@ -24,7 +24,7 @@
#include "nfastapp.h" #include "nfastapp.h"
#include "nfutil.h" #include "nfutil.h"
#include "mybignum.h" #include "my_hsm_bignum.h"
/* --------------------- */ /* --------------------- */