This commit is contained in:
Xueming Shen 2009-07-24 11:22:29 -07:00
commit 2ce8e7fb86
6 changed files with 17 additions and 27 deletions

View File

@ -337,7 +337,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSlotList
CK_ULONG ckTokenNumber;
CK_SLOT_ID_PTR ckpSlotList;
CK_BBOOL ckTokenPresent;
jlongArray jSlotList;
jlongArray jSlotList = NULL;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -637,7 +637,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetMechanismList
CK_SLOT_ID ckSlotID;
CK_ULONG ckMechanismNumber;
CK_MECHANISM_TYPE_PTR ckpMechanismList;
jlongArray jMechanismList;
jlongArray jMechanismList = NULL;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);

View File

@ -73,9 +73,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateKey
CK_MECHANISM ckMechanism;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_OBJECT_HANDLE ckKeyHandle;
CK_OBJECT_HANDLE ckKeyHandle = 0;
jlong jKeyHandle = 0L;
CK_ULONG i;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -151,8 +150,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
CK_OBJECT_HANDLE_PTR ckpPublicKeyHandle; /* pointer to Public Key */
CK_OBJECT_HANDLE_PTR ckpPrivateKeyHandle; /* pointer to Private Key */
CK_OBJECT_HANDLE_PTR ckpKeyHandles; /* pointer to array with Public and Private Key */
jlongArray jKeyHandles;
CK_ULONG i;
jlongArray jKeyHandles = NULL;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -299,9 +297,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1UnwrapKey
CK_ULONG ckWrappedKeyLength;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_OBJECT_HANDLE ckKeyHandle;
CK_OBJECT_HANDLE ckKeyHandle = 0;
jlong jKeyHandle = 0L;
CK_ULONG i;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -478,8 +475,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DeriveKey
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_OBJECT_HANDLE ckKeyHandle = 0;
jlong jKeyHandle;
CK_ULONG i;
jlong jKeyHandle = 0L;
CK_RV rv;
CK_OBJECT_HANDLE_PTR phKey = &ckKeyHandle;

View File

@ -72,8 +72,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CreateObject
CK_OBJECT_HANDLE ckObjectHandle;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
jlong jObjectHandle;
CK_ULONG i;
jlong jObjectHandle = 0L;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -114,8 +113,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CopyObject
CK_OBJECT_HANDLE ckNewObjectHandle;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
jlong jNewObjectHandle;
CK_ULONG i;
jlong jNewObjectHandle = 0L;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -180,7 +178,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetObjectSize
CK_SESSION_HANDLE ckSessionHandle;
CK_OBJECT_HANDLE ckObjectHandle;
CK_ULONG ckObjectSize;
jlong jObjectSize;
jlong jObjectSize = 0L;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -217,7 +215,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetAttributeVa
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_ULONG ckBufferLength;
CK_ULONG i, j;
CK_ULONG i;
jobject jAttribute;
CK_RV rv;
@ -307,7 +305,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetAttributeVa
CK_OBJECT_HANDLE ckObjectHandle;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_ULONG i;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -342,7 +339,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObjectsIni
CK_SESSION_HANDLE ckSessionHandle;
CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
CK_ULONG ckAttributesLength;
CK_ULONG i;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@ -385,7 +381,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObje
CK_ULONG ckMaxObjectLength;
CK_OBJECT_HANDLE_PTR ckpObjectHandleArray;
CK_ULONG ckActualObjectCount;
jlongArray jObjectHandleArray;
jlongArray jObjectHandleArray = NULL;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
if (ckpFunctions == NULL) { return NULL; }

View File

@ -110,7 +110,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
CK_BYTE_PTR ckpSignature;
CK_ULONG ckDataLength;
CK_ULONG ckSignatureLength = 0;
jbyteArray jSignature;
jbyteArray jSignature = NULL;
CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);

View File

@ -194,16 +194,14 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
jclass jPKCS11ExceptionClass;
jmethodID jConstructor;
jthrowable jPKCS11Exception;
jlong jErrorCode;
jlong jErrorCode = 0L;
if (returnValue == CKR_OK) {
return 0L ;
} else {
if (returnValue != CKR_OK) {
jErrorCode = ckULongToJLong(returnValue);
jPKCS11ExceptionClass = (*env)->FindClass(env, CLASS_PKCS11EXCEPTION);
if (jPKCS11ExceptionClass != NULL) {
jConstructor = (*env)->GetMethodID(env, jPKCS11ExceptionClass, "<init>", "(J)V");
if (jConstructor != NULL) {
jErrorCode = ckULongToJLong(returnValue);
jPKCS11Exception = (jthrowable) (*env)->NewObject(env, jPKCS11ExceptionClass, jConstructor, jErrorCode);
if (jPKCS11Exception != NULL) {
(*env)->Throw(env, jPKCS11Exception);
@ -211,8 +209,8 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
}
}
(*env)->DeleteLocalRef(env, jPKCS11ExceptionClass);
return jErrorCode ;
}
return jErrorCode ;
}
/*

View File

@ -300,7 +300,7 @@ void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jAArray, CK_ATT
/* funktions to convert a CK-type array and the array length to a Java array */
jcharArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK_ULONG ckLength);
jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_ULONG length);
jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArray, CK_ULONG ckLength);