openCryptoki/openCryptoki-compile-fixes.patch

1535 lines
53 KiB
Diff

? openCryptoki-config.patch
? opencryptoki-compile-fixes.patch
? opencryptoki-include-fix.patch
? tmp.diff
Index: testcases/driver/driver.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/driver/driver.c,v
retrieving revision 1.6
diff -p -u -r1.6 driver.c
--- testcases/driver/driver.c 11 Jan 2006 19:36:15 -0000 1.6
+++ testcases/driver/driver.c 12 Jan 2006 09:56:32 -0000
@@ -74,7 +74,7 @@ void process_time(SYSTEMTIME t1, SYSTEMT
- printf("Time: %u msec\n", ms );
+ printf("Time: %ld msec\n", ms );
}
@@ -174,7 +174,7 @@ void process_ret_code( CK_RV rc )
//
void show_error( CK_BYTE *str, CK_RV rc )
{
- printf("%s returned: %d (0x%0x)", str, rc, rc );
+ printf("%s returned: %d (0x%0x)", str, (int)rc, (int)rc );
process_ret_code( rc );
printf("\n");
}
@@ -261,7 +261,7 @@ int main (int argc, char **argv)
for (i = 1; i < argc; i++) {
if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "--help") == 0) {
usage (argv [0]);
- return;
+ return -1;
}
else if (strcmp (argv[i], "-noskip") == 0)
skip_token_obj = FALSE;
@@ -275,16 +275,16 @@ int main (int argc, char **argv)
else {
printf ("Invalid argument passed as option: %s\n", argv [i]);
usage (argv [0]);
- return;
+ return -1;
}
}
- printf("Using slot #%d...\n\n", SLOT_ID );
+ printf("Using slot #%d...\n\n", (int)SLOT_ID );
printf("With option: no_init: %d, noskip: %d\n", no_init, skip_token_obj);
rc = do_GetFunctionList();
if (!rc)
- return;
+ return rc;
memset( &cinit_args, 0x0, sizeof(cinit_args) );
cinit_args.flags = CKF_OS_LOCKING_OK;
@@ -294,15 +294,15 @@ int main (int argc, char **argv)
funcs->C_Initialize( &cinit_args );
{
- CK_SESSION_HANDLE hsess;
+ CK_SESSION_HANDLE hsess = 0;
rc = funcs->C_GetFunctionStatus(hsess);
if (rc != CKR_FUNCTION_NOT_PARALLEL)
- return;
+ return rc;
rc = funcs->C_CancelFunction(hsess);
if (rc != CKR_FUNCTION_NOT_PARALLEL)
- return;
+ return rc;
}
@@ -313,25 +313,25 @@ int main (int argc, char **argv)
fprintf (stderr, "\tMisc Functions tests...\n");
rc = misc_functions();
if (!rc)
- return;
+ return rc;
fprintf (stderr, "\tSession Mgmt Functions tests...\n");
rc = sess_mgmt_functions();
if (!rc)
- return;
+ return rc;
fprintf (stderr, "\tObject Mgmt Functions tests...\n");
rc = obj_mgmt_functions();
if (!rc)
- return;
+ return rc;
rc = des_functions();
if (!rc)
- return;
+ return rc;
rc = des3_functions();
if (!rc)
- return;
+ return rc;
rc = aes_functions();
if (!rc) {
@@ -340,21 +340,21 @@ int main (int argc, char **argv)
rc = digest_functions();
if (!rc)
- return;
+ return rc;
rc = rsa_functions();
if (!rc)
- return;
+ return rc;
/* Begin code contributed by Corrent corp. */
rc = dh_functions();
if (!rc)
- return;
+ return rc;
/* End code contributed by Corrent corp. */
rc = ssl3_functions();
if (!rc)
- return;
+ return rc;
printf("------------------ Completed pass %d --------------------\n",i);
i++;
@@ -362,4 +362,6 @@ int main (int argc, char **argv)
}
funcs->C_Finalize( NULL );
+
+return 0;
}
Index: testcases/init_tok/init_tok.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/init_tok/init_tok.c,v
retrieving revision 1.6
diff -p -u -r1.6 init_tok.c
--- testcases/init_tok/init_tok.c 17 Jun 2005 15:35:19 -0000 1.6
+++ testcases/init_tok/init_tok.c 12 Jan 2006 09:56:33 -0000
@@ -686,7 +686,7 @@ int main( int argc, char **argv )
if (strcmp(argv[i], "-h") == 0) {
printf("usage: %s [-slot <num>] [-h]\n\n", argv[0] );
printf("By default, Slot #1 is used\n\n");
- return;
+ return -1;
}
}
@@ -705,6 +705,6 @@ int main( int argc, char **argv )
done:
rc = funcs->C_Finalize( NULL );
- if (rc != CKR_OK)
- return rc;
+
+ return rc;
}
Index: testcases/mkobj/mkobj.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/mkobj/mkobj.c,v
retrieving revision 1.6
diff -p -u -r1.6 mkobj.c
--- testcases/mkobj/mkobj.c 17 Jun 2005 15:35:19 -0000 1.6
+++ testcases/mkobj/mkobj.c 12 Jan 2006 09:56:33 -0000
@@ -705,6 +705,6 @@ int main( int argc, char **argv )
} while (++i < 1 );
rc = funcs->C_Finalize( NULL );
- if (rc != CKR_OK)
- return rc;
+
+ return rc;
}
Index: testcases/rsa_keygen/rsa_keygen.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/rsa_keygen/rsa_keygen.c,v
retrieving revision 1.6
diff -p -u -r1.6 rsa_keygen.c
--- testcases/rsa_keygen/rsa_keygen.c 17 Jun 2005 15:35:19 -0000 1.6
+++ testcases/rsa_keygen/rsa_keygen.c 12 Jan 2006 09:56:33 -0000
@@ -139,7 +139,7 @@ void process_time(SYSTEMTIME t1, SYSTEMT
- printf("Time: %u msec\n", ms );
+ printf("Time: %ld msec\n", ms );
}
@@ -239,7 +239,7 @@ void process_ret_code( CK_RV rc )
//
void show_error( CK_BYTE *str, CK_RV rc )
{
- printf("%s returned: %d (0x%0x)", str, rc, rc );
+ printf("%s returned: %d (0x%0x)", str, (int)rc, (int)rc );
process_ret_code( rc );
printf("\n");
}
@@ -332,11 +332,11 @@ int main( int argc, char **argv )
printf("By default, Slot #1 is used\n\n");
printf("By default we skip anything that creates or modifies\n");
printf("token objects to preserve flash lifetime.\n");
- return;
+ return -1;
}
}
- printf("Using slot #%d...\n\n", SLOT_ID );
+ printf("Using slot #%d...\n\n", (int)SLOT_ID );
rc = do_GetFunctionList();
if (!rc)
@@ -355,4 +355,6 @@ int main( int argc, char **argv )
return rc;
funcs->C_Finalize( NULL );
+
+ return 0;
}
Index: testcases/rsa_test/rsa_test.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/rsa_test/rsa_test.c,v
retrieving revision 1.6
diff -p -u -r1.6 rsa_test.c
--- testcases/rsa_test/rsa_test.c 17 Jun 2005 15:35:19 -0000 1.6
+++ testcases/rsa_test/rsa_test.c 12 Jan 2006 09:56:33 -0000
@@ -567,4 +567,6 @@ int main( int argc, char **argv )
return rc;
funcs->C_Finalize( NULL );
+
+ return 0;
}
Index: testcases/speed/speed.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/speed/speed.c,v
retrieving revision 1.6
diff -p -u -r1.6 speed.c
--- testcases/speed/speed.c 17 Jun 2005 15:35:19 -0000 1.6
+++ testcases/speed/speed.c 12 Jan 2006 09:56:33 -0000
@@ -1329,6 +1329,8 @@ int do_DummyFunction( void )
printf("Minimum: %d ms\n", min_time );
printf("Maximum: %d ms\n", max_time );
#endif
+
+ return 0;
}
Index: testcases/threadmkobj/threadmkobj.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/testcases/threadmkobj/threadmkobj.c,v
retrieving revision 1.5
diff -p -u -r1.5 threadmkobj.c
--- testcases/threadmkobj/threadmkobj.c 17 Jun 2005 15:35:20 -0000 1.5
+++ testcases/threadmkobj/threadmkobj.c 12 Jan 2006 09:56:33 -0000
@@ -192,7 +192,7 @@ CK_BYTE true = TRUE;
rc = funcs->C_Login( h_session, CKU_USER, user_pin, user_pin_len );
-
+ return rc;
}
// do_create_token_object()
@@ -313,7 +313,7 @@ main( int argc, char **argv )
if (strcmp(argv[i], "-h") == 0) {
printf("usage: %s [-slot <num>] [-h]\n\n", argv[0] );
printf("By default, Slot #1 is used\n\n");
- return;
+ return -1;
}
}
@@ -321,7 +321,7 @@ main( int argc, char **argv )
rc = do_GetFunctionList();
if (!rc)
- return;
+ return rc;
funcs->C_Initialize( NULL );
@@ -339,6 +339,6 @@ main( int argc, char **argv )
}
rc = funcs->C_Finalize( NULL );
- if (rc != CKR_OK)
- return;
+
+ return rc;
}
Index: usr/lib/pkcs11/api/api_interface.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/api/api_interface.c,v
retrieving revision 1.6
diff -p -u -r1.6 api_interface.c
--- usr/lib/pkcs11/api/api_interface.c 12 Aug 2005 19:54:51 -0000 1.6
+++ usr/lib/pkcs11/api/api_interface.c 12 Jan 2006 09:56:34 -0000
@@ -297,7 +297,7 @@
#include <stdio.h>
#include <syslog.h>
-
+#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -2555,13 +2555,13 @@ C_GetInfo ( CK_INFO_PTR pInfo )
shm = Anchor->SharedMemP;
- bzero(pInfo, sizeof(*pInfo));
+ memset(pInfo, 0, sizeof(*pInfo));
pInfo->cryptokiVersion = shm->ck_info.cryptokiVersion;
memset(pInfo->manufacturerID, '\0', 32);
- bcopy(&(shm->ck_info.manufacturerID),pInfo->manufacturerID,32);
+ memcpy(pInfo->manufacturerID,&(shm->ck_info.manufacturerID),32);
pInfo->flags = shm->ck_info.flags;
- bcopy(&(shm->ck_info.libraryDescription),pInfo->libraryDescription,32);
+ memcpy(pInfo->libraryDescription,&(shm->ck_info.libraryDescription),32);
pInfo->libraryVersion = shm->ck_info.libraryVersion;
return CKR_OK;
@@ -2586,7 +2586,7 @@ C_GetInfo ( CK_INFO_PTR pInfo )
}
shm = Anchor->SharedMemP;
- bcopy(&(shm->ck_info),pInfo,sizeof(CK_INFO));
+ memcpy(pInfo,&(shm->ck_info),sizeof(CK_INFO));
return CKR_OK;
} // end of C_GetInfo
@@ -2972,14 +2972,14 @@ C_GetSlotInfo ( CK_SLOT_ID slotID,
#ifdef __64BIT__
- bcopy((char *)&(sinfp->pk_slot),pInfo,sizeof(CK_SLOT_INFO));
+ memcpy(pInfo,(char *)&(sinfp->pk_slot),sizeof(CK_SLOT_INFO));
#else
- bcopy((char *)&(sinfp->pk_slot.slotDescription[0]),
- (char *)&(pInfo->slotDescription[0]),64);
- bcopy((char *)&(sinfp->pk_slot.manufacturerID[0]),
- (char *)&(pInfo->manufacturerID[0]),32);
+ memcpy((char *)&(pInfo->slotDescription[0]),
+ (char *)&(sinfp->pk_slot.slotDescription[0]),64);
+ memcpy((char *)&(pInfo->manufacturerID[0]),
+ (char *)&(sinfp->pk_slot.manufacturerID[0]),32);
pInfo->flags = sinfp->pk_slot.flags;
pInfo->hardwareVersion = sinfp->pk_slot.hardwareVersion;
@@ -3038,7 +3038,7 @@ C_GetSlotInfo ( CK_SLOT_ID slotID,
//LOGIT(LOG_DEBUG," %32s ",sinfp->pk_slot.slotDescription);
//LOGIT(LOG_DEBUG," %32s ",sinfp->pk_slot.manufacturerID);
- bcopy((char *)&(sinfp->pk_slot),pInfo,sizeof(CK_SLOT_INFO));
+ memcpy(pInfo,(char *)&(sinfp->pk_slot),sizeof(CK_SLOT_INFO));
return CKR_OK;
} // end of C_GetSlotInfo
@@ -3311,7 +3311,7 @@ C_Initialize ( CK_VOID_PTR pVoid )
return CKR_CRYPTOKI_ALREADY_INITIALIZED;
}
- bzero(slot_loaded,sizeof(int)*NUMBER_SLOTS_MANAGED); // Clear out the load list
+ memset(slot_loaded,0,sizeof(int)*NUMBER_SLOTS_MANAGED); // Clear out the load list
LOGIT(LOG_DEBUG,"Anchor allocated at %x",(char *)Anchor);
@@ -3424,7 +3424,7 @@ C_Initialize ( CK_VOID_PTR pVoid )
//if ( Shared Memory Mapped not Successful )
// Free allocated Memory
// Return CKR_HOST_MEMORY
- bzero((char *)Anchor,sizeof(API_Proc_Struct_t));
+ memset((char *)Anchor,0,sizeof(API_Proc_Struct_t));
pthread_mutex_init(&(Anchor->ProcMutex),NULL); // This is not shared across apps.
pthread_mutex_init(&(Anchor->SessListMutex),NULL); // This is not shared across apps.
pthread_mutex_init(&GlobMutex,NULL);
Index: usr/lib/pkcs11/api/apiproto.h
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/api/apiproto.h,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 apiproto.h
--- usr/lib/pkcs11/api/apiproto.h 18 Jan 2005 16:09:00 -0000 1.1.1.1
+++ usr/lib/pkcs11/api/apiproto.h 12 Jan 2006 09:56:34 -0000
@@ -308,6 +308,13 @@
void *attach_shared_memory();
void detach_shared_memory(char *);
+void loginit();
+void logterm();
+void st_err_log(int num, ...);
+
+int Valid_Session(Session_Struct_t *, ST_SESSION_T *);
+void RemoveFromSessionList(Session_Struct_t *);
+int decr_sess_counts(CK_SLOT_ID);
int API_Initialized();
void Terminate_All_Process_Sessions();
Index: usr/lib/pkcs11/api/apiutil.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/api/apiutil.c,v
retrieving revision 1.5
diff -p -u -r1.5 apiutil.c
--- usr/lib/pkcs11/api/apiutil.c 11 Oct 2005 19:04:23 -0000 1.5
+++ usr/lib/pkcs11/api/apiutil.c 12 Jan 2006 09:56:34 -0000
@@ -302,10 +302,13 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <dlfcn.h>
#include <errno.h>
#include <sys/syslog.h>
-
+#include <sys/types.h>
+#include <unistd.h>
+#include <alloca.h>
#include <sys/ipc.h>
#include "msg.h" //HACK
@@ -356,7 +359,7 @@ set_perm(int file)
#ifdef DEBUG
#define LOGIT logit
#else
-#define LOGIT
+#define LOGIT(x...)
#endif
#define SYSLOG
@@ -654,6 +657,7 @@ incr_sess_counts(slotID)
XProcUnLock(&(shm->slt_mutex));
+ return 0;
}
int
@@ -687,7 +691,7 @@ decr_sess_counts(slotID)
XProcUnLock(&(shm->slt_mutex));
-
+ return 0;
}
// Check if any sessions from other applicaitons exist on this particular
@@ -863,9 +867,9 @@ API_Register()
}
#ifdef PKCS64
- bzero((char *)procp,sizeof(Slot_Mgr_Proc_t_64));
+ memset((char *)procp,0,sizeof(Slot_Mgr_Proc_t_64));
#else
- bzero((char *)procp,sizeof(Slot_Mgr_Proc_t));
+ memset((char *)procp,0,sizeof(Slot_Mgr_Proc_t));
#endif
procp->inuse = TRUE;
procp->proc_id = getpid();
@@ -916,9 +920,9 @@ API_UnRegister()
procp = &(shm->proc_table[Anchor->MgrProcIndex]);
#ifdef PKCS64
- bzero((char *)procp,sizeof(Slot_Mgr_Proc_t_64));
+ memset((char *)procp,0,sizeof(Slot_Mgr_Proc_t_64));
#else
- bzero((char *)procp,sizeof(Slot_Mgr_Proc_t));
+ memset((char *)procp,0,sizeof(Slot_Mgr_Proc_t));
#endif
Anchor->MgrProcIndex=0;
@@ -1070,6 +1074,7 @@ int DL_Unload(sltp)
sltp->pSTfini = NULL;
sltp->pSTcloseall = NULL;
+ return TRUE;
}
int
Index: usr/lib/pkcs11/bcom_stdll/bcom_specific.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/bcom_stdll/bcom_specific.c,v
retrieving revision 1.2
diff -p -u -r1.2 bcom_specific.c
--- usr/lib/pkcs11/bcom_stdll/bcom_specific.c 1 Sep 2005 22:57:04 -0000 1.2
+++ usr/lib/pkcs11/bcom_stdll/bcom_specific.c 12 Jan 2006 09:56:37 -0000
@@ -428,7 +428,7 @@ CK_RV build_swapped_attribute(CK_ATTRIBU
if (! swapped_data) {
return CKR_DEVICE_ERROR;
}
- bzero(swapped_data, data_len);
+ memset(swapped_data, 0, data_len);
real_data_len = data_len;
pos = data_len -1;
@@ -483,10 +483,10 @@ int bcom_rsa_pub_new(BCOM_RSA_PUB_KEY_t
}
rsa_pub->n = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES*sizeof(unsigned char));
- bzero(rsa_pub->n, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_pub->n, 0, MAX_PUBLIC_KEY_BYTES);
rsa_pub->n_len = 0;
rsa_pub->e = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES*sizeof(unsigned char));
- bzero(rsa_pub->e, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_pub->e, 0, MAX_PUBLIC_KEY_BYTES);
rsa_pub->e_len = 0;
if (! (rsa_pub->n && rsa_pub->e)) {
@@ -578,24 +578,24 @@ int bcom_rsa_crt_new(BCOM_RSA_CRT_KEY_t
}
rsa_priv->n = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->n, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->n, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->d = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->d, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->d, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->d_len = 0;
rsa_priv->p = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->p, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->p, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->p_len = 0;
rsa_priv->q = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->q, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->q, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->q_len = 0;
rsa_priv->dp = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->dp, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->dp, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->dp_len = 0;
rsa_priv->dq = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->dq, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->dq, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->dq_len = 0;
rsa_priv->pinv = (U32_t *)malloc(MAX_PUBLIC_KEY_BYTES);
- bzero(rsa_priv->pinv, MAX_PUBLIC_KEY_BYTES);
+ memset(rsa_priv->pinv, 0, MAX_PUBLIC_KEY_BYTES);
rsa_priv->pinv_len = 0;
if (! (rsa_priv->p && rsa_priv->q && rsa_priv->dp && rsa_priv->dq && rsa_priv->pinv)) {
Index: usr/lib/pkcs11/common/loadsave.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/loadsave.c,v
retrieving revision 1.4
diff -p -u -r1.4 loadsave.c
--- usr/lib/pkcs11/common/loadsave.c 14 Dec 2005 19:14:16 -0000 1.4
+++ usr/lib/pkcs11/common/loadsave.c 12 Jan 2006 09:56:37 -0000
@@ -303,6 +303,8 @@
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/file.h>
+#include <unistd.h>
+#include <alloca.h>
#include <errno.h>
#include <pwd.h>
@@ -331,9 +333,11 @@ load_token_data()
FILE * fp;
CK_BYTE fname[2048];
TOKEN_DATA td;
+#if 0
CK_BYTE clear[3 * DES_BLOCK_SIZE]; // enough to hold a CBC-encrypted SHA hash
CK_BYTE cipher[3 * DES_BLOCK_SIZE];
CK_ULONG clear_len, cipher_len;
+#endif
CK_RV rc;
struct passwd *pw = NULL;
@@ -392,6 +396,7 @@ load_token_data()
goto out_unlock;
}
+#if 0
// memcpy( cipher, &td.user_pin_sha, 3*DES_BLOCK_SIZE );
// clear_len = cipher_len = 3 * DES_BLOCK_SIZE;
// rc = ckm_des3_cbc_decrypt( cipher, cipher_len, clear, &clear_len, "12345678", master_key );
@@ -407,6 +412,7 @@ load_token_data()
// return CKR_FUNCTION_FAILED;
//
// memcpy( &td.so_pin_sha, clear, clear_len );
+#endif
memcpy( nv_token_data, &td, sizeof(TOKEN_DATA) );
@@ -427,9 +433,11 @@ save_token_data()
{
FILE *fp;
TOKEN_DATA td;
+#if 0
CK_BYTE clear[3 * DES_BLOCK_SIZE];
CK_BYTE cipher[3 * DES_BLOCK_SIZE];
CK_ULONG clear_len, cipher_len;
+#endif
CK_RV rc;
CK_BYTE fname[2048];
struct passwd *pw = NULL;
@@ -477,7 +485,7 @@ save_token_data()
//
// memcpy( td.so_pin_sha, cipher, 3*DES_BLOCK_SIZE );
- fwrite( &td, sizeof(TOKEN_DATA), 1, fp );
+ (void)fwrite( &td, sizeof(TOKEN_DATA), 1, fp );
fclose(fp);
rc = CKR_OK;
@@ -526,7 +534,7 @@ save_token_object( OBJECT *obj )
if (fp) {
set_perm(fileno(fp));
while (!feof(fp)) {
- fgets((char *)line, 50, fp );
+ (void)fgets((char *)line, 50, fp );
if (!feof(fp)) {
line[ strlen((char *)line)-1 ] = 0;
if (strcmp((char *)line,(char *)( obj->name)) == 0) {
@@ -600,9 +608,9 @@ save_public_token_object( OBJECT *obj )
total_len = cleartxt_len + sizeof(CK_ULONG_32) + sizeof(CK_BBOOL);
- fwrite( &total_len, sizeof(CK_ULONG_32), 1, fp );
- fwrite( &flag, sizeof(CK_BBOOL), 1, fp );
- fwrite( cleartxt, cleartxt_len, 1, fp );
+ (void)fwrite( &total_len, sizeof(CK_ULONG_32), 1, fp );
+ (void)fwrite( &flag, sizeof(CK_BBOOL), 1, fp );
+ (void)fwrite( cleartxt, cleartxt_len, 1, fp );
fclose( fp );
free( cleartxt );
@@ -628,9 +636,8 @@ save_private_token_object( OBJECT *obj )
CK_BYTE * ptr = NULL;
CK_BYTE fname[100];
CK_BYTE hash_sha[SHA1_HASH_SIZE];
- CK_BYTE hash_md5[MD5_HASH_SIZE];
CK_BYTE des3_key[3 * DES_KEY_SIZE];
- CK_ULONG obj_data_len,cleartxt_len, ciphertxt_len, hash_len, tmp, tmp2;
+ CK_ULONG obj_data_len,cleartxt_len, ciphertxt_len;
CK_ULONG padded_len;
CK_BBOOL flag;
CK_RV rc;
@@ -704,7 +711,7 @@ save_private_token_object( OBJECT *obj )
initial_vector = (CK_BYTE *)alloca(strlen("10293847")+5);
if (initial_vector) {
- bcopy("10293847",initial_vector,strlen("10293847"));
+ memcpy(initial_vector,"10293847",strlen("10293847"));
rc = ckm_des3_cbc_encrypt( cleartxt, padded_len,
ciphertxt, &ciphertxt_len,
initial_vector, (char *) des3_key );
@@ -714,7 +721,7 @@ save_private_token_object( OBJECT *obj )
}
#else
- bcopy(cleartxt,ciphertxt,padded_len);
+ memcpy(ciphertxt,cleartxt,padded_len);
rc = CKR_OK;
#endif
if (rc != CKR_OK){
@@ -738,9 +745,9 @@ save_private_token_object( OBJECT *obj )
flag = TRUE;
- fwrite( &total_len, sizeof(CK_ULONG_32), 1, fp );
- fwrite( &flag, sizeof(CK_BBOOL), 1, fp );
- fwrite( ciphertxt, ciphertxt_len, 1, fp );
+ (void)fwrite( &total_len, sizeof(CK_ULONG_32), 1, fp );
+ (void)fwrite( &flag, sizeof(CK_BBOOL), 1, fp );
+ (void)fwrite( ciphertxt, ciphertxt_len, 1, fp );
fclose( fp );
@@ -786,7 +793,7 @@ load_public_token_objects( void )
return CKR_OK; // no token objects
while (!feof(fp1)) {
- fgets( (char *)tmp, 50, fp1 );
+ (void)fgets( (char *)tmp, 50, fp1 );
if (!feof(fp1)) {
tmp[ strlen((char *)tmp)-1 ] = 0;
@@ -798,8 +805,8 @@ load_public_token_objects( void )
if (!fp2)
continue;
- fread( &size, sizeof(CK_ULONG_32), 1, fp2 );
- fread( &priv, sizeof(CK_BBOOL), 1, fp2 );
+ (void)fread( &size, sizeof(CK_ULONG_32), 1, fp2 );
+ (void)fread( &priv, sizeof(CK_BBOOL), 1, fp2 );
if (priv == TRUE) {
fclose( fp2 );
continue;
@@ -815,7 +822,7 @@ load_public_token_objects( void )
return CKR_HOST_MEMORY;
}
- fread( buf, size, 1, fp2 );
+ (void)fread( buf, size, 1, fp2 );
// ... grab object mutex here.
MY_LockMutex(&obj_list_mutex);
@@ -839,7 +846,6 @@ load_private_token_objects( void )
FILE *fp1 = NULL, *fp2 = NULL;
CK_BYTE *buf = NULL;
CK_BYTE tmp[2048], fname[2048],iname[2048];
- CK_BYTE sha_hash[SHA1_HASH_SIZE], old_hash[SHA1_HASH_SIZE];
CK_BBOOL priv;
CK_ULONG_32 size;
CK_RV rc;
@@ -859,7 +865,7 @@ load_private_token_objects( void )
return CKR_OK; // no token objects
while (!feof(fp1)) {
- fgets((char *) tmp, 50, fp1 );
+ (void)fgets((char *) tmp, 50, fp1 );
if (!feof(fp1)) {
tmp[ strlen((char *)tmp)-1 ] = 0;
@@ -871,8 +877,8 @@ load_private_token_objects( void )
if (!fp2)
continue;
- fread( &size, sizeof(CK_ULONG_32), 1, fp2 );
- fread( &priv, sizeof(CK_BBOOL), 1, fp2 );
+ (void)fread( &size, sizeof(CK_ULONG_32), 1, fp2 );
+ (void)fread( &priv, sizeof(CK_BBOOL), 1, fp2 );
if (priv == FALSE) {
fclose( fp2 );
continue;
@@ -932,10 +938,7 @@ restore_private_token_object( CK_BYTE *
CK_BYTE * ptr = NULL;
CK_BYTE des3_key[3 * DES_KEY_SIZE];
CK_BYTE hash_sha[SHA1_HASH_SIZE];
- CK_MECHANISM mech;
- DIGEST_CONTEXT digest_ctx;
- ENCR_DECR_CONTEXT encr_ctx;
- CK_ULONG hash_len, cleartxt_len, obj_data_len;
+ CK_ULONG cleartxt_len, obj_data_len;
CK_RV rc;
// format for the object data:
@@ -968,7 +971,7 @@ restore_private_token_object( CK_BYTE *
initial_vector = (CK_BYTE *)alloca(strlen("10293847")+5);
if (initial_vector) {
- bcopy("10293847",initial_vector,strlen("10293847"));
+ memcpy(initial_vector,"10293847",strlen("10293847"));
rc = ckm_des3_cbc_decrypt( ciphertxt, len,
cleartxt, &len,
initial_vector, (char *) des3_key );
@@ -984,7 +987,7 @@ restore_private_token_object( CK_BYTE *
"10293847", des3_key );
#endif
#else
- bcopy(ciphertxt,cleartxt,len);
+ memcpy(cleartxt,ciphertxt,len);
rc = CKR_OK;
#endif
@@ -1098,7 +1101,7 @@ load_masterkey_so( void )
initial_vector = (CK_BYTE *)alloca(strlen("12345678")+5);
if (initial_vector) {
- bcopy("12345678",initial_vector,strlen("12345678"));
+ memcpy(initial_vector,"12345678",strlen("12345678"));
rc = ckm_des3_cbc_decrypt( cipher, cipher_len,
clear, &clear_len,
initial_vector, (char *) des3_key );
@@ -1112,7 +1115,7 @@ load_masterkey_so( void )
rc = ckm_des3_cbc_decrypt( cipher, cipher_len, clear, &clear_len, "12345678", des3_key );
#endif
#else
- bcopy(cipher,clear,cipher_len);
+ memcpy(clear,cipher,cipher_len);
rc = CKR_OK;
#endif
@@ -1208,7 +1211,7 @@ load_masterkey_user( void )
initial_vector = (CK_BYTE *)alloca(strlen("12345678")+5);
if (initial_vector) {
- bcopy("12345678",initial_vector,strlen("12345678"));
+ memcpy(initial_vector,"12345678",strlen("12345678"));
rc = ckm_des3_cbc_decrypt( cipher, cipher_len,
clear, &clear_len,
initial_vector, (char *) des3_key );
@@ -1221,7 +1224,7 @@ load_masterkey_user( void )
rc = ckm_des3_cbc_decrypt( cipher, cipher_len, clear, &clear_len, "12345678", des3_key );
#endif
#else
- bcopy(cipher,clear,cipher_len);
+ memcpy(clear,cipher,cipher_len);
rc = CKR_OK;
#endif
@@ -1300,7 +1303,7 @@ save_masterkey_so( void )
initial_vector = (CK_BYTE *)alloca(strlen("12345678"));
if (initial_vector) {
- bcopy("12345678",initial_vector,strlen("12345678"));
+ memcpy(initial_vector,"12345678",strlen("12345678"));
rc = ckm_des3_cbc_encrypt( cleartxt, padded_len,
ciphertxt, &ciphertxt_len,
initial_vector, (char *) des3_key );
@@ -1313,7 +1316,7 @@ save_masterkey_so( void )
rc = ckm_des3_cbc_encrypt( cleartxt, padded_len, ciphertxt, &ciphertxt_len, "12345678", des3_key );
#endif
#else
- bcopy(cleartxt,ciphertxt,padded_len);
+ memcpy(ciphertxt,cleartxt,padded_len);
rc = CKR_OK;
#endif
@@ -1396,7 +1399,7 @@ save_masterkey_user( void )
initial_vector = (CK_BYTE *)alloca(strlen("12345678")+5);
if (initial_vector) {
- bcopy("12345678",initial_vector,strlen("12345678"));
+ memcpy(initial_vector,"12345678",strlen("12345678"));
rc = ckm_des3_cbc_encrypt( cleartxt, padded_len,
ciphertxt, &ciphertxt_len,
initial_vector, (char *) des3_key );
@@ -1409,7 +1412,7 @@ save_masterkey_user( void )
rc = ckm_des3_cbc_encrypt( cleartxt, padded_len, ciphertxt, &ciphertxt_len, "12345678", des3_key );
#endif
#else
- bcopy(cleartxt,ciphertxt,padded_len);
+ memcpy(ciphertxt,cleartxt,padded_len);
rc = CKR_OK;
#endif
@@ -1563,7 +1566,7 @@ delete_token_object( OBJECT *obj )
set_perm(fileno(fp2));
while (!feof(fp1)) {
- fgets((char *)line, 50, fp1 );
+ (void)fgets((char *)line, 50, fp1 );
if (!feof(fp1)) {
line[ strlen((char *)line)-1 ] = 0;
if (strcmp((char *)line, (char *)obj->name) == 0)
@@ -1589,7 +1592,7 @@ delete_token_object( OBJECT *obj )
set_perm(fileno(fp2));
while (!feof(fp1)) {
- fgets((char *)line, 50, fp1 );
+ (void)fgets((char *)line, 50, fp1 );
if (!feof(fp1))
fprintf( fp2, "%s",(char *) line );
}
Index: usr/lib/pkcs11/common/mech_list.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/mech_list.c,v
retrieving revision 1.2
diff -p -u -r1.2 mech_list.c
--- usr/lib/pkcs11/common/mech_list.c 1 Sep 2005 22:57:04 -0000 1.2
+++ usr/lib/pkcs11/common/mech_list.c 12 Jan 2006 09:56:37 -0000
@@ -288,6 +288,8 @@
/* COPYRIGHT (c) International Business Machines Corp. 2005 */
+#include <stdlib.h>
+#include <string.h>
#include "pkcs11types.h"
#include "defs.h"
#include "host_defs.h"
Index: usr/lib/pkcs11/common/mech_ssl3.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/mech_ssl3.c,v
retrieving revision 1.2
diff -p -u -r1.2 mech_ssl3.c
--- usr/lib/pkcs11/common/mech_ssl3.c 24 Feb 2005 21:35:09 -0000 1.2
+++ usr/lib/pkcs11/common/mech_ssl3.c 12 Jan 2006 09:56:37 -0000
@@ -1486,7 +1486,7 @@ ssl3_key_and_mac_derive( SESSION
CK_BYTE key_block[(16*26) + (4*16)];
CK_ULONG i, key_material_loop_count;
CK_ULONG iv_len, MAC_len, write_len;
- CK_RV rc;
+ CK_RV rc = CKR_OK;
CK_BYTE * base_key_value = NULL;
CK_BBOOL base_sensitive;
@@ -2000,7 +2000,7 @@ ssl3_kmd_process_write_keys( SESSION
CK_ULONG i, cnt;
CK_ULONG true_vals[] = { CKA_ENCRYPT, CKA_DECRYPT, CKA_DERIVE };
CK_ULONG false_vals[] = { CKA_SIGN, CKA_VERIFY, CKA_WRAP, CKA_UNWRAP };
- CK_RV rc;
+ CK_RV rc = CKR_HOST_MEMORY;
// for the write keys, we want the following default values:
// CKA_ENCRYPT, CKA_DECRYPT, CKA_DERIVE = TRUE
@@ -2027,7 +2027,6 @@ ssl3_kmd_process_write_keys( SESSION
attr->ulValueLen = sizeof(CK_BBOOL);
attr->pValue = (CK_BBOOL *)malloc(sizeof(CK_BBOOL));
if (!attr->pValue) {
- rc = CKR_HOST_MEMORY;
st_err_log(0, __FILE__, __LINE__);
goto error;
}
@@ -2039,7 +2038,6 @@ ssl3_kmd_process_write_keys( SESSION
attr->ulValueLen = sizeof(CK_BBOOL);
attr->pValue = (CK_BBOOL *)malloc(sizeof(CK_BBOOL));
if (!attr->pValue) {
- rc = CKR_HOST_MEMORY;
st_err_log(0, __FILE__, __LINE__);
goto error;
}
@@ -2055,7 +2053,6 @@ ssl3_kmd_process_write_keys( SESSION
attr->ulValueLen = pTemplate[i].ulValueLen;
attr->pValue = (char *)malloc(attr->ulValueLen);
if (!attr->pValue) {
- rc = CKR_HOST_MEMORY;
st_err_log(0, __FILE__, __LINE__);
goto error;
}
Index: usr/lib/pkcs11/common/new_host.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/new_host.c,v
retrieving revision 1.15
diff -p -u -r1.15 new_host.c
--- usr/lib/pkcs11/common/new_host.c 1 Sep 2005 22:57:04 -0000 1.15
+++ usr/lib/pkcs11/common/new_host.c 12 Jan 2006 09:56:37 -0000
@@ -310,6 +310,7 @@
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
+#include <unistd.h>
#include "pkcs11types.h"
#include "stdll.h"
@@ -532,11 +533,11 @@ init_data_store(char *directory)
char *pkdir;
if ( (pkdir = getenv("PKCS_APP_STORE")) != NULL){
pk_dir = (char *) malloc(strlen(pkdir)+1024);
- bzero(pk_dir,strlen(pkdir)+1024);
+ memset(pk_dir,0,strlen(pkdir)+1024);
sprintf(pk_dir,"%s/%s",pkdir,SUB_DIR);
} else {
pk_dir = (char *)malloc(strlen(directory)+25);
- bzero(pk_dir,strlen(directory)+25);
+ memset(pk_dir,0,strlen(directory)+25);
sprintf(pk_dir,"%s",directory);
}
Index: usr/lib/pkcs11/common/obj_mgr.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/obj_mgr.c,v
retrieving revision 1.11
diff -p -u -r1.11 obj_mgr.c
--- usr/lib/pkcs11/common/obj_mgr.c 12 Dec 2005 17:44:37 -0000 1.11
+++ usr/lib/pkcs11/common/obj_mgr.c 12 Jan 2006 09:56:38 -0000
@@ -2217,17 +2217,17 @@ object_mgr_del_from_shm( OBJECT *obj )
if (count > 0) { // If we are not deleting the last element in the list
// Move up count number of elements effectively deleting the index
- bcopy((char *)&global_shm->priv_tok_objs[index+1],
- (char *)&global_shm->priv_tok_objs[index],
+ memcpy((char *)&global_shm->priv_tok_objs[index],
+ (char *)&global_shm->priv_tok_objs[index+1],
sizeof(TOK_OBJ_ENTRY) * count );
// We need to zero out the last entry... Since the memcopy
// does not zero it out...
- bzero((char *)&global_shm->priv_tok_objs[global_shm->num_priv_tok_obj+1],
- sizeof(TOK_OBJ_ENTRY));
+ memset((char *)&global_shm->priv_tok_objs[global_shm->num_priv_tok_obj+1],
+ 0,sizeof(TOK_OBJ_ENTRY));
}
else { // We are deleting the last element which is in num_priv_tok_obj
- bzero((char *)&global_shm->priv_tok_objs[global_shm->num_priv_tok_obj],
- sizeof(TOK_OBJ_ENTRY));
+ memset((char *)&global_shm->priv_tok_objs[global_shm->num_priv_tok_obj],
+ 0,sizeof(TOK_OBJ_ENTRY));
}
}
else {
@@ -2252,17 +2252,17 @@ object_mgr_del_from_shm( OBJECT *obj )
#endif
if (count > 0) {
- bcopy((char *)&global_shm->publ_tok_objs[index+1],
- (char *)&global_shm->publ_tok_objs[index],
+ memcpy((char *)&global_shm->publ_tok_objs[index],
+ (char *)&global_shm->publ_tok_objs[index+1],
sizeof(TOK_OBJ_ENTRY) * count);
// We need to zero out the last entry... Since the memcopy
// does not zero it out...
- bzero((char *)&global_shm->publ_tok_objs[global_shm->num_publ_tok_obj+1],
- sizeof(TOK_OBJ_ENTRY));
+ memset((char *)&global_shm->publ_tok_objs[global_shm->num_publ_tok_obj+1],
+ 0,sizeof(TOK_OBJ_ENTRY));
}
else {
- bzero((char *)&global_shm->publ_tok_objs[global_shm->num_publ_tok_obj],
- sizeof(TOK_OBJ_ENTRY));
+ memset((char *)&global_shm->publ_tok_objs[global_shm->num_publ_tok_obj],
+ 0,sizeof(TOK_OBJ_ENTRY));
}
}
@@ -2439,6 +2439,8 @@ object_mgr_update_from_shm( void )
{
object_mgr_update_publ_tok_obj_from_shm();
object_mgr_update_priv_tok_obj_from_shm();
+
+ return CKR_OK;
}
Index: usr/lib/pkcs11/common/sess_mgr.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/sess_mgr.c,v
retrieving revision 1.3
diff -p -u -r1.3 sess_mgr.c
--- usr/lib/pkcs11/common/sess_mgr.c 10 May 2005 18:51:59 -0000 1.3
+++ usr/lib/pkcs11/common/sess_mgr.c 12 Jan 2006 09:56:38 -0000
@@ -874,7 +874,7 @@ session_mgr_get_op_state( SESSION *ses
CK_ULONG *data_len )
{
OP_STATE_DATA *op_data = NULL;
- CK_ULONG op_data_len;
+ CK_ULONG op_data_len = 0;
CK_ULONG offset;
if (!sess){
Index: usr/lib/pkcs11/common/template.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/template.c,v
retrieving revision 1.2
diff -p -u -r1.2 template.c
--- usr/lib/pkcs11/common/template.c 24 Feb 2005 21:35:10 -0000 1.2
+++ usr/lib/pkcs11/common/template.c 12 Jan 2006 09:56:38 -0000
@@ -868,7 +868,7 @@ template_flatten( TEMPLATE * tmpl,
DL_NODE * node = NULL;
CK_BYTE * ptr = NULL;
CK_ULONG_32 long_len;
- CK_ATTRIBUTE_32 *attr_32;
+ CK_ATTRIBUTE_32 *attr_32 = NULL;
CK_ULONG Val;
CK_ULONG_32 Val_32;
CK_ULONG * pVal;
@@ -929,7 +929,7 @@ template_flatten( TEMPLATE * tmpl,
node = node->next;
}
- if (long_len != 4)
+ if (attr_32)
free(attr_32);
return CKR_OK;
Index: usr/lib/pkcs11/common/utility.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/common/utility.c,v
retrieving revision 1.6
diff -p -u -r1.6 utility.c
--- usr/lib/pkcs11/common/utility.c 12 Aug 2005 15:54:31 -0000 1.6
+++ usr/lib/pkcs11/common/utility.c 12 Jan 2006 09:56:38 -0000
@@ -299,7 +299,7 @@
#include <sys/ipc.h>
#include <errno.h>
#include <pwd.h>
-
+#include <unistd.h>
#include "pkcs11types.h"
#include "defs.h"
Index: usr/lib/pkcs11/ica_s390_stdll/ica_specific.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/ica_s390_stdll/ica_specific.c,v
retrieving revision 1.6
diff -p -u -r1.6 ica_specific.c
--- usr/lib/pkcs11/ica_s390_stdll/ica_specific.c 4 Jan 2006 15:05:50 -0000 1.6
+++ usr/lib/pkcs11/ica_s390_stdll/ica_specific.c 12 Jan 2006 09:56:38 -0000
@@ -292,6 +292,7 @@
#include <pthread.h>
#include <string.h> // for memcmp() et al
+#include <strings.h>
#include <stdlib.h>
#ifndef NOAES
@@ -439,7 +440,7 @@ token_specific_des_ecb(CK_BYTE * in_data
unsigned int temp = 0;
temp = (unsigned int) *out_data_len;
- bzero(&empty_iv,sizeof(empty_iv));
+ memset(&empty_iv,0,sizeof(empty_iv));
if ( encrypt) {
rc = icaDesEncrypt(adapter_handle, MODE_DES_ECB, (unsigned int)in_data_len, in_data,
&empty_iv, (ICA_KEY_DES_SINGLE *)key_value,
@@ -515,7 +516,7 @@ token_specific_tdes_ecb(CK_BYTE * in_dat
unsigned int temp;
temp = (unsigned int) *out_data_len;
- bzero(&empty_iv,sizeof(empty_iv));
+ memset(&empty_iv,0,sizeof(empty_iv));
if ( encrypt) {
rc = icaTDesEncrypt(adapter_handle, MODE_DES_ECB, (unsigned int)in_data_len, in_data,
&empty_iv,
@@ -1127,7 +1128,7 @@ rsa_convert_public_key( OBJECT * key_
if (publKey == NULL) {
return NULL;
}
- bzero(publKey, sizeof(ICA_KEY_RSA_MODEXPO));
+ memset(publKey, 0, sizeof(ICA_KEY_RSA_MODEXPO));
// Currently using definition of ICA_KEY_RSA_MODEXPO in NT spec v1.12
@@ -1142,9 +1143,9 @@ rsa_convert_public_key( OBJECT * key_
pkey = (CK_BYTE_PTR) publKey->keyRecord;
pkey += modulus->ulValueLen - pub_exp->ulValueLen;
- bcopy(pub_exp->pValue, pkey, pub_exp->ulValueLen);
+ memcpy(pkey, pub_exp->pValue, pub_exp->ulValueLen);
pkey += pub_exp->ulValueLen;
- bcopy(modulus->pValue, pkey, modulus->ulValueLen);
+ memcpy(pkey, modulus->pValue, modulus->ulValueLen);
return publKey;
}
@@ -1186,7 +1187,7 @@ rsa_convert_private_key(OBJECT *key_obj)
if (privKey == NULL) {
return NULL;
}
- bzero(privKey, sizeof(ICA_KEY_RSA_CRT));
+ memset(privKey, 0, sizeof(ICA_KEY_RSA_CRT));
// Currently using definition of ICA_KEY_RSA_CRT in NT spec v1.12
// (with nLength and nOffset removed per BEF's e-mail)
@@ -1210,19 +1211,19 @@ rsa_convert_private_key(OBJECT *key_obj)
privKey->qInvOffset = offset + qSize;
pkey = (CK_BYTE_PTR) privKey->keyRecord;
pkey += pSize - exp1->ulValueLen;
- bcopy(exp1->pValue, pkey, exp1->ulValueLen);
+ memcpy(pkey, exp1->pValue, exp1->ulValueLen);
// pkey += exp1->ulValueLen + qSize - exp2->ulValueLen;
pkey += exp1->ulValueLen;
- bcopy(exp2->pValue, pkey, exp2->ulValueLen);
+ memcpy(pkey, exp2->pValue, exp2->ulValueLen);
// pkey += exp2->ulValueLen + pSize - prime1->ulValueLen;
pkey += qSize + pSize - prime1->ulValueLen;
- bcopy(prime1->pValue, pkey, prime1->ulValueLen);
+ memcpy(pkey, prime1->pValue, prime1->ulValueLen);
// pkey += prime1->ulValueLen + qSize - prime2->ulValueLen;
pkey += prime1->ulValueLen;
- bcopy(prime2->pValue, pkey, prime2->ulValueLen);
+ memcpy(pkey, prime2->pValue, prime2->ulValueLen);
// pkey += prime2->ulValueLen + pSize - coeff->ulValueLen;
pkey += qSize + pSize - coeff->ulValueLen;
- bcopy(coeff->pValue, pkey, coeff->ulValueLen);
+ memcpy(pkey, coeff->pValue, coeff->ulValueLen);
return privKey;
// hex_dump_to_file("PRIVATEKEY",(char *)privKey,sizeof(ICA_KEY_RSA_CRT));
} else { // must be a non-CRT key
@@ -1233,7 +1234,7 @@ rsa_convert_private_key(OBJECT *key_obj)
if (privModKey == NULL) {
return NULL;
}
- bzero(privModKey, sizeof(ICA_KEY_RSA_MODEXPO));
+ memset(privModKey, 0, sizeof(ICA_KEY_RSA_MODEXPO));
// Currently using definition of ICA_KEY_RSA_MODEXPO in NT spec v1.12
@@ -1249,9 +1250,9 @@ rsa_convert_private_key(OBJECT *key_obj)
pkey = (CK_BYTE_PTR) privModKey->keyRecord;
pkey += modulus->ulValueLen - priv_exp->ulValueLen;
- bcopy(priv_exp->pValue, pkey, priv_exp->ulValueLen);
+ memcpy(pkey, priv_exp->pValue, priv_exp->ulValueLen);
pkey += priv_exp->ulValueLen;
- bcopy(modulus->pValue, pkey, modulus->ulValueLen);
+ memcpy(pkey, modulus->pValue, modulus->ulValueLen);
return privModKey;
}
Index: usr/lib/pkcs11/ica_stdll/ica_specific.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/ica_stdll/ica_specific.c,v
retrieving revision 1.7
diff -p -u -r1.7 ica_specific.c
--- usr/lib/pkcs11/ica_stdll/ica_specific.c 1 Sep 2005 22:57:05 -0000 1.7
+++ usr/lib/pkcs11/ica_stdll/ica_specific.c 12 Jan 2006 09:56:39 -0000
@@ -291,6 +291,7 @@
#include <pthread.h>
#include <string.h> // for memcmp() et al
+#include <strings.h>
#include <stdlib.h>
#ifndef NOAES
@@ -438,7 +439,7 @@ token_specific_des_ecb(CK_BYTE * in_data
CK_RV rc;
unsigned int _out_data_len = *out_data_len;
- bzero(&empty_iv,sizeof(empty_iv));
+ memset(&empty_iv,0,sizeof(empty_iv));
if ( encrypt) {
rc = icaDesEncrypt(adapter_handle, (unsigned int)MODE_DES_ECB, (unsigned int)in_data_len, in_data,
&empty_iv, (ICA_KEY_DES_SINGLE *)key_value,
@@ -513,7 +514,7 @@ token_specific_tdes_ecb(CK_BYTE * in_dat
unsigned int _out_data_len = *out_data_len;
- bzero(&empty_iv,sizeof(empty_iv));
+ memset(&empty_iv,0,sizeof(empty_iv));
if ( encrypt) {
rc = icaTDesEncrypt(adapter_handle, (unsigned int)MODE_DES_ECB,
(unsigned int)in_data_len, in_data,
@@ -617,7 +618,7 @@ rsa_convert_public_key( OBJECT * key_
if (publKey == NULL) {
return NULL;
}
- bzero(publKey, sizeof(ICA_KEY_RSA_MODEXPO));
+ memset(publKey, 0, sizeof(ICA_KEY_RSA_MODEXPO));
// Currently using definition of ICA_KEY_RSA_MODEXPO in NT spec v1.12
@@ -676,7 +677,7 @@ rsa_convert_private_key(OBJECT *key_obj)
if (privKey == NULL) {
return NULL;
}
- bzero(privKey, sizeof(ICA_KEY_RSA_CRT));
+ memset(privKey, 0, sizeof(ICA_KEY_RSA_CRT));
// Currently using definition of ICA_KEY_RSA_CRT in NT spec v1.12
// (with nLength and nOffset removed per BEF's e-mail)
@@ -723,7 +724,7 @@ rsa_convert_private_key(OBJECT *key_obj)
if (privModKey == NULL) {
return NULL;
}
- bzero(privModKey, sizeof(ICA_KEY_RSA_MODEXPO));
+ memset(privModKey, 0, sizeof(ICA_KEY_RSA_MODEXPO));
// Currently using definition of ICA_KEY_RSA_MODEXPO in NT spec v1.12
Index: usr/lib/pkcs11/leeds_stdll/host_api.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/leeds_stdll/host_api.c,v
retrieving revision 1.4
diff -p -u -r1.4 host_api.c
--- usr/lib/pkcs11/leeds_stdll/host_api.c 3 Nov 2005 19:38:00 -0000 1.4
+++ usr/lib/pkcs11/leeds_stdll/host_api.c 12 Jan 2006 09:56:42 -0000
@@ -838,7 +838,7 @@ copy_attribute_value(void *source, void
break;
default:
- bcopy(source,dest,attr->ulValueLen);
+ memcpy(dest,source,attr->ulValueLen);
break;
}
@@ -874,10 +874,10 @@ ModifyAttribute(type,val)
#ifdef PKCS64
tval = HTOCL((CK_ULONG_32)*val);
*val = tval;
- // bcopy(&tval,val,sizeof(CK_ULONG_32));
+ // memcpy(val,&tval,sizeof(CK_ULONG_32));
#else
tval = HTOCL((CK_ULONG)*val);
- bcopy(&tval,val,sizeof(CK_ULONG));
+ memcpy(val,&tval,sizeof(CK_ULONG));
#endif
default:
@@ -1254,7 +1254,7 @@ CK_RV communicate( CK_ULONG cmd_id, C
}
hst=*hs;
saddr.sin_family = AF_INET;
- bcopy(hs->h_addr,(char *)&saddr.sin_addr,hs->h_length);
+ memcpy((char *)&saddr.sin_addr,hs->h_addr,hs->h_length);
//saddr.sin_addr.s_addr = htonl(0x0933510c);
saddr.sin_port = htons(PORT);
@@ -1556,11 +1556,11 @@ CK_RV SC_Initialize( void **FunctionList
// Zero out the adapter handle array
// an adapter handle of 0 indicates that the particular adapter has
// NOT been initialized
- bzero((char *)adapter_handle,sizeof(sccAdapterHandle_t)*MAX_SLOT_ID);
+ memset((char *)adapter_handle,0,sizeof(sccAdapterHandle_t)*MAX_SLOT_ID);
initialized = TRUE;
initedpid = getpid();
SC_SetFunctionList();
- bzero((char *)correlator_init,PKW_MAX_DEVICES * sizeof(struct Cor_init));
+ memset((char *)correlator_init,0,PKW_MAX_DEVICES * sizeof(struct Cor_init));
{
int i;
@@ -1645,7 +1645,7 @@ rc = 0;
saddr.sin_family = AF_INET;
- bcopy(hs->h_addr,(char *)&saddr.sin_addr,hs->h_length);
+ memcpy((char *)&saddr.sin_addr,hs->h_addr,hs->h_length);
saddr.sin_port = htons(PORT);
if ( connect (adapter_handle[i],(struct sockaddr *)&saddr,sizeof(struct sockaddr_in)) < 0 ){
// XXX FIXME just bail for now.
@@ -3133,7 +3133,7 @@ CK_RV SC_CopyObject( ST_SESSION_HANDLE
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -3842,7 +3842,7 @@ CK_RV SC_SetAttributeValue( ST_SESSION_
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -3997,7 +3997,7 @@ CK_RV SC_FindObjectsInit( ST_SESSION_HAN
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -4457,7 +4457,7 @@ CK_RV SC_GenerateKey( ST_SESSION_HANDLE
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -5555,7 +5555,7 @@ CK_RV SC_UnwrapKey( ST_SESSION_HANDLE
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
@@ -6142,7 +6142,7 @@ CK_RV SC_GenerateKeyPair( ST_SESSION_HAN
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -6205,7 +6205,7 @@ CK_RV SC_GenerateKeyPair( ST_SESSION_HAN
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
@@ -7995,7 +7995,7 @@ CK_RV SC_DeriveKey( ST_SESSION_HANDLE
#if __64BIT__
copy_attribute_value(ps,pd,attr);
#else
- bcopy(ps,pd,attr->ulValueLen);
+ memcpy(pd,ps,attr->ulValueLen);
#endif
#if __64BIT__
Index: usr/lib/pkcs11/soft_stdll/soft_specific.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/soft_stdll/soft_specific.c,v
retrieving revision 1.3
diff -p -u -r1.3 soft_specific.c
--- usr/lib/pkcs11/soft_stdll/soft_specific.c 1 Sep 2005 22:57:05 -0000 1.3
+++ usr/lib/pkcs11/soft_stdll/soft_specific.c 12 Jan 2006 09:56:42 -0000
@@ -302,6 +302,7 @@
#include <pthread.h>
#include <string.h> // for memcmp() et al
#include <stdlib.h>
+#include <unistd.h>
#include "pkcs11types.h"
#include "defs.h"
@@ -395,6 +396,7 @@ token_specific_init(char * Correlator,CK
CK_RV
token_specific_final()
{
+ return CKR_OK;
}
Index: usr/lib/pkcs11/tpm_stdll/new_host.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/lib/pkcs11/tpm_stdll/new_host.c,v
retrieving revision 1.10
diff -p -u -r1.10 new_host.c
--- usr/lib/pkcs11/tpm_stdll/new_host.c 11 Aug 2005 20:52:59 -0000 1.10
+++ usr/lib/pkcs11/tpm_stdll/new_host.c 12 Jan 2006 09:56:42 -0000
@@ -305,12 +305,12 @@ init_data_store(char *directory)
if ( (pkdir = getenv("PKCS_APP_STORE")) != NULL) {
pk_dir = (char *) malloc(strlen(pkdir)+1024);
- bzero(pk_dir,strlen(pkdir)+1024);
+ memset(pk_dir,0,strlen(pkdir)+1024);
sprintf(pk_dir,"%s/%s",pkdir,SUB_DIR);
LogError("Using custom data store location: %s", pk_dir);
} else {
pk_dir = (char *)malloc(strlen(directory)+25);
- bzero(pk_dir,strlen(directory)+25);
+ memset(pk_dir,0,strlen(directory)+25);
sprintf(pk_dir,"%s",directory);
}
}
Index: usr/sbin/pkcsconf/pkcsconf.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/sbin/pkcsconf/pkcsconf.c,v
retrieving revision 1.5
diff -p -u -r1.5 pkcsconf.c
--- usr/sbin/pkcsconf/pkcsconf.c 11 Aug 2005 21:00:57 -0000 1.5
+++ usr/sbin/pkcsconf/pkcsconf.c 12 Jan 2006 09:56:42 -0000
@@ -588,17 +588,17 @@ done:
#endif
if (sopin) {
- bzero (sopin, strlen(sopin));
+ memset (sopin, 0, strlen(sopin));
free (sopin);
}
if (pin) {
- bzero (pin, strlen(pin));
+ memset (pin, 0, strlen(pin));
free (pin);
}
if (newpin) {
- bzero (newpin, strlen(newpin));
+ memset (newpin, 0, strlen(newpin));
free (newpin);
}
@@ -672,6 +672,8 @@ echo(int bool){
* displayed on the terminal is invalid */
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &term) != 0)
return -1;
+
+ return 0;
}
#if SHM
@@ -725,6 +727,8 @@ display_pkcs11_info(void){
printf(PKCSINIT_MSG(LIBVERSION, "\tLibrary Version %d.%d \n"),
CryptokiInfo.libraryVersion.major,
CryptokiInfo.libraryVersion.minor);
+
+ return 0;
}
CK_RV
@@ -1176,7 +1180,7 @@ init(void){
dllPtr = dlopen("/usr/lib/pkcs11/PKCS11_API.so64", RTLD_NOW); */
dllPtr = dlopen("libopencryptoki.so", RTLD_NOW);
if (!dllPtr) {
- printf(PKCSINIT_MSG(LOADERROR, "Error loading PKCS#11 library: 0x%X\n"), rc);
+ printf(PKCSINIT_MSG(LOADERROR, "Error loading PKCS#11 library;\n"));
printf(PKCSINIT_MSG(LOADERROR, "dlopen error: %s\n"), dlerror());
fflush(stdout);
return -1;
Index: usr/sbin/pkcsslotd/garbage_linux.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/sbin/pkcsslotd/garbage_linux.c,v
retrieving revision 1.3
diff -p -u -r1.3 garbage_linux.c
--- usr/sbin/pkcsslotd/garbage_linux.c 24 Feb 2005 21:35:10 -0000 1.3
+++ usr/sbin/pkcsslotd/garbage_linux.c 12 Jan 2006 09:56:42 -0000
@@ -917,7 +917,7 @@ BOOL IsValidProcessEntry ( pid_t pid, ti
p = (proc_t *)malloc(sizeof(proc_t));
#else
p = &procstore;
- bzero(p, sizeof(proc_t));
+ memset(p, 0, sizeof(proc_t));
#endif
if( !(valid = Stat2Proc( (int)pid, p )) )
Index: usr/sbin/pkcsslotd/no_odm.c
===================================================================
RCS file: /cvsroot/opencryptoki/opencryptoki/usr/sbin/pkcsslotd/no_odm.c,v
retrieving revision 1.5
diff -p -u -r1.5 no_odm.c
--- usr/sbin/pkcsslotd/no_odm.c 3 Jun 2005 16:07:39 -0000 1.5
+++ usr/sbin/pkcsslotd/no_odm.c 12 Jan 2006 09:56:42 -0000
@@ -502,7 +502,7 @@ BOOL ReadSlotInfoDB ( void ) {
#ifdef ALLOCATE
slot_entry = (char *)malloc(sizeof(char)*(PATH_MAX));
#else
- bzero(slot_entry,PATH_MAX);
+ memset(slot_entry,0,PATH_MAX);
#endif
fgets(slot_entry, PATH_MAX, fp);
@@ -523,7 +523,7 @@ BOOL ReadSlotInfoDB ( void ) {
// if( feof(fp) )
// break;
- bzero(&sinfo_struct,sizeof(sinfo_struct)); // for good measure zero it out before use each time
+ memset(&sinfo_struct,0,sizeof(sinfo_struct)); // for good measure zero it out before use each time
sinfo_struct.global_sessions = 0; // initializing to zero
element_num = Present;
@@ -746,7 +746,7 @@ BOOL ReadSlotInfoDB ( void ) {
/* WarnLog ( "***** ReadSlotInfoDB: %s: file not found (%s). Skipping DB entry.", sinfo[Index].dll_location, SysError(Err) ); */
}
else {
- fprintf(stderr, "\nReading Slot Info: %s: looking at %s, stat64() returned %s (%d; %#x)", sinfo_struct.dll_location, SysError(Err), Err, Err);
+ fprintf(stderr, "\nReading Slot Info: %s: stat64() returned %s (%d; %#x)", sinfo_struct.dll_location, SysError(Err), Err, Err);
/* DbgLog (DL0, "***** ReadSlotInfoDB: looking at %s, stat64() returned %s (%d; %#x)", sinfo[Index].dll_location, SysError(Err), Err, Err); */
}
memset( pSlot, '\0', sizeof(*pSlot) );
@@ -809,7 +809,7 @@ BOOL ReadSlotInfoDB ( void ) {
if( (sinfo_struct.dll_location != NULL) &&
(sinfo_struct.slot_init_fcn != NULL) ) {
- bcopy(&sinfo_struct,&sinfo[Index],sizeof(sinfo_struct)); // similar to sinfo[Index] = &sinfo_struct;
+ memcpy(&sinfo[Index],&sinfo_struct,sizeof(sinfo_struct)); // similar to sinfo[Index] = &sinfo_struct;
PrintSlotInfo( &(sinfo[Index]) );
Index++;