diff --git a/hsm_utils/Makefile b/hsm_utils/Makefile index 225a8f8..b088520 100644 --- a/hsm_utils/Makefile +++ b/hsm_utils/Makefile @@ -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) 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 diff --git a/hsm_utils/import_common_key.c b/hsm_utils/import_common_key.c index 53869bf..7a85235 100644 --- a/hsm_utils/import_common_key.c +++ b/hsm_utils/import_common_key.c @@ -11,10 +11,11 @@ #include "rqcard-applic.h" #include "rqcard-fips.h" -#include "ncthread-upcalls.h" +//#include "ncthread-upcalls.h" //#include "picky-upcalls.h" -#include "mybignum.h" +#include "my_hsm_bignum.h" +#include "my_hsm_alloc.h" #define MODULE_ID 1 #define DATA_LEN 256 // bytes diff --git a/hsm_utils/import_rsa_keypair.c b/hsm_utils/import_rsa_keypair.c index d2c2159..c1e75d4 100644 --- a/hsm_utils/import_rsa_keypair.c +++ b/hsm_utils/import_rsa_keypair.c @@ -358,55 +358,13 @@ int main( int argc, char *argv[] ) struct NFast_Bignum *dmq1Bn = NULL; struct NFast_Bignum *iqmpBn = 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 - result = sbn_bin2bignum( &qBn, handle, qPtr, qLen ); - if ( result != Status_OK ) - { - printf( "error(%d) : sbn_bin2bignum( q )\n", result ); - return 0; - } - - // 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; - } - } + + my_bin2bignum( &pBn, handle, pPtr, pLen ); + my_bin2bignum( &qBn, handle, qPtr, qLen ); + my_bin2bignum( &dmp1Bn, handle, dmp1Ptr, dmp1Len ); + my_bin2bignum( &dmq1Bn, handle, dmq1Ptr, dmq1Len ); + my_bin2bignum( &iqmpBn, handle, iqmpPtr, iqmpLen ); + my_bin2bignum( &eBn, handle, ePtr, eLen ); printf( "import ...\n" ); diff --git a/hsm_utils/my_hsm_alloc.c b/hsm_utils/my_hsm_alloc.c index 23470d6..abaaad2 100644 --- a/hsm_utils/my_hsm_alloc.c +++ b/hsm_utils/my_hsm_alloc.c @@ -15,25 +15,31 @@ /* --------------------- */ -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 ) { 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 ) { 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 ) { free( ptr ); -} \ No newline at end of file +} diff --git a/hsm_utils/my_hsm_alloc.h b/hsm_utils/my_hsm_alloc.h index 88bad9a..91a39ff 100644 --- a/hsm_utils/my_hsm_alloc.h +++ b/hsm_utils/my_hsm_alloc.h @@ -11,7 +11,7 @@ extern "C" { #endif -extern NFast_MallocUpcalls my_hsm_malloc_upcalls; +extern const NFast_MallocUpcalls my_hsm_malloc_upcalls; void *my_hsm_malloc( size_t nbytes, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ); diff --git a/hsm_utils/my_hsm_bignum.c b/hsm_utils/my_hsm_bignum.c index 1c1dcc2..dda52f6 100644 --- a/hsm_utils/my_hsm_bignum.c +++ b/hsm_utils/my_hsm_bignum.c @@ -24,7 +24,7 @@ #include "nfastapp.h" #include "nfutil.h" -#include "mybignum.h" +#include "my_hsm_bignum.h" /* --------------------- */