Check-in [8aec474c2b]
Overview
Comment:CACKey 0.5.20

Updated CACKey to not require pReserved to be set to NULL

Fixed bug where Sign and Decrypt operations would not terminate correctly

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | 0.5.20
Files: files | file ages | folders
SHA1:8aec474c2b8989788daea0a28c047fb0e344d60a
User & Date: rkeene on 2010-10-10 09:10:13
Other Links: manifest | tags
Context
2010-10-15
09:53
Added mostly-compiling Win32 support

Added local copy of RSA PKCS#11 check-in: ec1f93c869 user: rkeene tags: trunk

2010-10-10
09:10
CACKey 0.5.20

Updated CACKey to not require pReserved to be set to NULL

Fixed bug where Sign and Decrypt operations would not terminate correctly check-in: 8aec474c2b user: rkeene tags: trunk, 0.5.20

2010-08-02
16:05
CACKey 0.5.19 check-in: 25c710f288 user: rkeene tags: trunk, 0.5.19
Changes

Modified cackey.c from [8363ed8d3c] to [195b1c0ba3].

  3175   3175   		if (args->CreateMutex == NULL || args->DestroyMutex == NULL || args->LockMutex == NULL || args->UnlockMutex == NULL) {
  3176   3176   			if (args->CreateMutex != NULL || args->DestroyMutex != NULL || args->LockMutex != NULL || args->UnlockMutex != NULL) {
  3177   3177   				CACKEY_DEBUG_PRINTF("Error. Some, but not All threading primitives provided.");
  3178   3178   
  3179   3179   				return(CKR_ARGUMENTS_BAD);
  3180   3180   			}
  3181   3181   		}
  3182         -
  3183         -		if (args->pReserved != NULL) {
  3184         -			CACKEY_DEBUG_PRINTF("Error. pReserved is not NULL.");
  3185         -
  3186         -			return(CKR_ARGUMENTS_BAD);
  3187         -		}
  3188   3182   	} else {
  3189   3183   		cackey_args.CreateMutex = NULL;
  3190   3184   		cackey_args.DestroyMutex = NULL;
  3191   3185   		cackey_args.LockMutex = NULL;
  3192   3186   		cackey_args.UnlockMutex = NULL;
  3193   3187   		cackey_args.flags = 0;
  3194   3188   	}
................................................................................
  4974   4968   
  4975   4969   	return(CKR_OK);
  4976   4970   }
  4977   4971   
  4978   4972   CK_DEFINE_FUNCTION(CK_RV, C_Decrypt)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedData, CK_ULONG ulEncryptedDataLen, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen) {
  4979   4973   	CK_ULONG datalen_update, datalen_final;
  4980   4974   	CK_RV decrypt_ret;
         4975  +	int mutex_retval;
  4981   4976   
  4982   4977   	CACKEY_DEBUG_PRINTF("Called.");
  4983   4978   
  4984   4979   	if (!cackey_initialized) {
  4985   4980   		CACKEY_DEBUG_PRINTF("Error.  Not initialized.");
  4986   4981   
  4987   4982   		return(CKR_CRYPTOKI_NOT_INITIALIZED);
................................................................................
  4994   4989   	}
  4995   4990   
  4996   4991   	datalen_update = *pulDataLen;
  4997   4992   
  4998   4993   	decrypt_ret = C_DecryptUpdate(hSession, pEncryptedData, ulEncryptedDataLen, pData, &datalen_update);
  4999   4994   	if (decrypt_ret != CKR_OK) {
  5000   4995   		CACKEY_DEBUG_PRINTF("Error.  DecryptUpdate() returned failure (rv = %lu).", (unsigned long) decrypt_ret);
         4996  +
         4997  +		if (decrypt_ret != CKR_BUFFER_TOO_SMALL) {
         4998  +			/* Terminate decryption operation */
         4999  +
         5000  +			mutex_retval = cackey_mutex_lock(cackey_biglock);
         5001  +			if (mutex_retval != 0) {
         5002  +				CACKEY_DEBUG_PRINTF("Error.  Locking failed.");
         5003  +
         5004  +				return(CKR_GENERAL_ERROR);
         5005  +			}
         5006  +
         5007  +			if (!cackey_sessions[hSession].active) {
         5008  +				cackey_mutex_unlock(cackey_biglock);
         5009  +
         5010  +				CACKEY_DEBUG_PRINTF("Error.  Session not active.");
         5011  +		
         5012  +				return(CKR_SESSION_HANDLE_INVALID);
         5013  +			}
         5014  +
         5015  +			if (!cackey_sessions[hSession].decrypt_active) {
         5016  +				cackey_mutex_unlock(cackey_biglock);
         5017  +
         5018  +				CACKEY_DEBUG_PRINTF("Error.  Decrypt not active.");
         5019  +		
         5020  +				return(CKR_OPERATION_NOT_INITIALIZED);
         5021  +			}
         5022  +
         5023  +			cackey_sessions[hSession].decrypt_active = 0;
         5024  +
         5025  +			mutex_retval = cackey_mutex_unlock(cackey_biglock);
         5026  +			if (mutex_retval != 0) {
         5027  +				CACKEY_DEBUG_PRINTF("Error.  Unlocking failed.");
         5028  +
         5029  +				return(CKR_GENERAL_ERROR);
         5030  +			}
         5031  +		}
  5001   5032   
  5002   5033   		return(decrypt_ret);
  5003   5034   	}
  5004   5035   
  5005   5036   	if (pData) {
  5006   5037   		pData += datalen_update;
  5007   5038   	}
................................................................................
  5371   5402   
  5372   5403   	return(CKR_OK);
  5373   5404   }
  5374   5405   
  5375   5406   CK_DEFINE_FUNCTION(CK_RV, C_Sign)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen) {
  5376   5407   	unsigned long start_sign_bufused;
  5377   5408   	CK_RV sign_ret;
         5409  +	int mutex_retval;
  5378   5410   
  5379   5411   	CACKEY_DEBUG_PRINTF("Called.");
  5380   5412   
  5381   5413   	if (!cackey_initialized) {
  5382   5414   		CACKEY_DEBUG_PRINTF("Error.  Not initialized.");
  5383   5415   
  5384   5416   		return(CKR_CRYPTOKI_NOT_INITIALIZED);
................................................................................
  5391   5423   	}
  5392   5424   
  5393   5425   	start_sign_bufused = cackey_sessions[hSession].sign_bufused;
  5394   5426   
  5395   5427   	sign_ret = C_SignUpdate(hSession, pData, ulDataLen);
  5396   5428   	if (sign_ret != CKR_OK) {
  5397   5429   		CACKEY_DEBUG_PRINTF("Error.  SignUpdate() returned failure (rv = %lu).", (unsigned long) sign_ret);
         5430  +
         5431  +		if (sign_ret != CKR_BUFFER_TOO_SMALL) {
         5432  +			mutex_retval = cackey_mutex_lock(cackey_biglock);
         5433  +			if (mutex_retval != 0) {
         5434  +				CACKEY_DEBUG_PRINTF("Error.  Locking failed.");
         5435  +
         5436  +				return(CKR_GENERAL_ERROR);
         5437  +			}
         5438  +
         5439  +			if (!cackey_sessions[hSession].active) {
         5440  +				cackey_mutex_unlock(cackey_biglock);
         5441  +
         5442  +				CACKEY_DEBUG_PRINTF("Error.  Session not active.");
         5443  +		
         5444  +				return(CKR_SESSION_HANDLE_INVALID);
         5445  +			}
         5446  +
         5447  +			if (!cackey_sessions[hSession].sign_active) {
         5448  +				cackey_mutex_unlock(cackey_biglock);
         5449  +
         5450  +				CACKEY_DEBUG_PRINTF("Error.  Sign not active.");
         5451  +		
         5452  +				return(CKR_OPERATION_NOT_INITIALIZED);
         5453  +			}
         5454  +
         5455  +			cackey_sessions[hSession].sign_active = 0;
         5456  +
         5457  +			mutex_retval = cackey_mutex_unlock(cackey_biglock);
         5458  +			if (mutex_retval != 0) {
         5459  +				CACKEY_DEBUG_PRINTF("Error.  Unlocking failed.");
         5460  +
         5461  +				return(CKR_GENERAL_ERROR);
         5462  +			}
         5463  +		}
  5398   5464   
  5399   5465   		return(sign_ret);
  5400   5466   	}
  5401   5467   
  5402   5468   	sign_ret = C_SignFinal(hSession, pSignature, pulSignatureLen);
  5403   5469   	if (sign_ret != CKR_OK) {
  5404   5470   		if (sign_ret == CKR_BUFFER_TOO_SMALL) {

Modified configure.ac from [db7e56c702] to [10bd60e28c].

     1         -AC_INIT(cackey, 0.5.19) 
            1  +AC_INIT(cackey, 0.5.20) 
     2      2   AC_CONFIG_HEADERS(config.h)
     3      3   
     4      4   dnl Locate standard tools
     5      5   AC_PROG_CC
     6      6   AC_PROG_MAKE_SET
     7      7   AC_PROG_INSTALL
     8      8   AC_AIX

Modified pkcs11/pkcs11t.h from [3e84a5b712] to [3048f0f5fd].

  1021   1021    * C_Initialize */
  1022   1022   typedef struct CK_C_INITIALIZE_ARGS {
  1023   1023     CK_CREATEMUTEX CreateMutex;
  1024   1024     CK_DESTROYMUTEX DestroyMutex;
  1025   1025     CK_LOCKMUTEX LockMutex;
  1026   1026     CK_UNLOCKMUTEX UnlockMutex;
  1027   1027     CK_FLAGS flags;
  1028         -  CK_VOID_PTR LibraryParameters;
  1029   1028     CK_VOID_PTR pReserved;
  1030   1029   } CK_C_INITIALIZE_ARGS;
  1031   1030   
  1032   1031   /* flags: bit flags that provide capabilities of the slot
  1033   1032    *      Bit Flag                           Mask       Meaning
  1034   1033    */
  1035   1034   #define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001

Modified test.c from [5989078539] to [24213eb4b1].

   121    121   
   122    122   	initargs.CreateMutex = NULL;
   123    123   	initargs.DestroyMutex = NULL;
   124    124   	initargs.LockMutex = NULL;
   125    125   	initargs.UnlockMutex = NULL;
   126    126   	initargs.flags = CKF_OS_LOCKING_OK;
   127    127   	initargs.pReserved = NULL;
   128         -	initargs.LibraryParameters = NULL;
   129    128   
   130    129   	chk_rv = C_Initialize(&initargs);
   131    130   	if (chk_rv != CKR_OK) {
   132    131   		initargs.CreateMutex = NULL;
   133    132   		initargs.DestroyMutex = NULL;
   134    133   		initargs.LockMutex = NULL;
   135    134   		initargs.UnlockMutex = NULL;