37 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE 38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 42 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 45 * POSSIBILITY OF SUCH DAMAGE. 46 */ 47 48 #include "pkcs11wrapper.h" 49 50 #include <stdio.h> 51 #include <stdlib.h> 52 #include <string.h> 53 #include <assert.h> 54 55 #include "sun_security_pkcs11_wrapper_PKCS11.h" 56 57 #ifdef P11_ENABLE_C_GENERATEKEY 58 /* 59 * Class: sun_security_pkcs11_wrapper_PKCS11 60 * Method: C_GenerateKey 61 * Signature: (JLsun/security/pkcs11/wrapper/CK_MECHANISM;[Lsun/security/pkcs11/wrapper/CK_ATTRIBUTE;)J 62 * Parametermapping: *PKCS11* 63 * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 64 * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 65 * @param jobjectArray jTemplate CK_ATTRIBUTE_PTR pTemplate 66 * CK_ULONG ulCount 67 * @return jlong jKeyHandle CK_OBJECT_HANDLE_PTR phKey 68 */ 69 JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateKey 70 (JNIEnv *env, jobject obj, jlong jSessionHandle, jobject jMechanism, jobjectArray jTemplate) 71 { 72 CK_SESSION_HANDLE ckSessionHandle; 73 CK_MECHANISM ckMechanism; 74 CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR; 75 CK_ULONG ckAttributesLength; 76 CK_OBJECT_HANDLE ckKeyHandle = 0; | 37 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE 38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 42 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 45 * POSSIBILITY OF SUCH DAMAGE. 46 */ 47 48 #include "pkcs11wrapper.h" 49 50 #include <stdio.h> 51 #include <stdlib.h> 52 #include <string.h> 53 #include <assert.h> 54 55 #include "sun_security_pkcs11_wrapper_PKCS11.h" 56 57 #ifdef P11_ENABLE_GETNATIVEKEYINFO 58 59 #define CK_ATTRIBUTES_TEMPLATE_LENGTH (CK_ULONG)61U 60 61 static CK_ATTRIBUTE ckpAttributesTemplate[CK_ATTRIBUTES_TEMPLATE_LENGTH] = { 62 {CKA_CLASS, 0, 0}, 63 {CKA_TOKEN, 0, 0}, 64 {CKA_PRIVATE, 0, 0}, 65 {CKA_LABEL, 0, 0}, 66 {CKA_APPLICATION, 0, 0}, 67 {CKA_VALUE, 0, 0}, 68 {CKA_OBJECT_ID, 0, 0}, 69 {CKA_CERTIFICATE_TYPE, 0, 0}, 70 {CKA_ISSUER, 0, 0}, 71 {CKA_SERIAL_NUMBER, 0, 0}, 72 {CKA_AC_ISSUER, 0, 0}, 73 {CKA_OWNER, 0, 0}, 74 {CKA_ATTR_TYPES, 0, 0}, 75 {CKA_TRUSTED, 0, 0}, 76 {CKA_KEY_TYPE, 0, 0}, 77 {CKA_SUBJECT, 0, 0}, 78 {CKA_ID, 0, 0}, 79 {CKA_SENSITIVE, 0, 0}, 80 {CKA_ENCRYPT, 0, 0}, 81 {CKA_DECRYPT, 0, 0}, 82 {CKA_WRAP, 0, 0}, 83 {CKA_UNWRAP, 0, 0}, 84 {CKA_SIGN, 0, 0}, 85 {CKA_SIGN_RECOVER, 0, 0}, 86 {CKA_VERIFY, 0, 0}, 87 {CKA_VERIFY_RECOVER, 0, 0}, 88 {CKA_DERIVE, 0, 0}, 89 {CKA_START_DATE, 0, 0}, 90 {CKA_END_DATE, 0, 0}, 91 {CKA_MODULUS, 0, 0}, 92 {CKA_MODULUS_BITS, 0, 0}, 93 {CKA_PUBLIC_EXPONENT, 0, 0}, 94 {CKA_PRIVATE_EXPONENT, 0, 0}, 95 {CKA_PRIME_1, 0, 0}, 96 {CKA_PRIME_2, 0, 0}, 97 {CKA_EXPONENT_1, 0, 0}, 98 {CKA_EXPONENT_2, 0, 0}, 99 {CKA_COEFFICIENT, 0, 0}, 100 {CKA_PRIME, 0, 0}, 101 {CKA_SUBPRIME, 0, 0}, 102 {CKA_BASE, 0, 0}, 103 {CKA_PRIME_BITS, 0, 0}, 104 {CKA_SUB_PRIME_BITS, 0, 0}, 105 {CKA_VALUE_BITS, 0, 0}, 106 {CKA_VALUE_LEN, 0, 0}, 107 {CKA_EXTRACTABLE, 0, 0}, 108 {CKA_LOCAL, 0, 0}, 109 {CKA_NEVER_EXTRACTABLE, 0, 0}, 110 {CKA_ALWAYS_SENSITIVE, 0, 0}, 111 {CKA_KEY_GEN_MECHANISM, 0, 0}, 112 {CKA_MODIFIABLE, 0, 0}, 113 {CKA_ECDSA_PARAMS, 0, 0}, 114 {CKA_EC_PARAMS, 0, 0}, 115 {CKA_EC_POINT, 0, 0}, 116 {CKA_SECONDARY_AUTH, 0, 0}, 117 {CKA_AUTH_PIN_FLAGS, 0, 0}, 118 {CKA_HW_FEATURE_TYPE, 0, 0}, 119 {CKA_RESET_ON_INIT, 0, 0}, 120 {CKA_HAS_RESET, 0, 0}, 121 {CKA_VENDOR_DEFINED, 0, 0}, 122 {CKA_NETSCAPE_DB, 0, 0}, 123 }; 124 125 /* 126 * Class: sun_security_pkcs11_wrapper_PKCS11 127 * Method: getNativeKeyInfo 128 * Signature: (JJJ)[B 129 * Parametermapping: *PKCS11* 130 * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 131 * @param jlong jKeyHandle CK_OBJECT_HANDLE hObject 132 * @param jlong jWrappingKeyHandle CK_OBJECT_HANDLE hObject 133 * @return jbyteArray jNativeKeyInfo - 134 */ 135 JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_getNativeKeyInfo 136 (JNIEnv *env, jobject obj, jlong jSessionHandle, jlong jKeyHandle, jlong jWrappingKeyHandle) 137 { 138 jbyteArray returnValue = NULL; 139 CK_SESSION_HANDLE ckSessionHandle = jLongToCKULong(jSessionHandle); 140 CK_OBJECT_HANDLE ckObjectHandle = jLongToCKULong(jKeyHandle); 141 CK_ATTRIBUTE_PTR ckpAttributes = NULL; 142 CK_RV rv; 143 jbyteArray nativeKeyInfoArray = NULL; 144 jbyteArray nativeKeyInfoWrappedKeyArray = NULL; 145 jbyte* nativeKeyInfoArrayRaw = NULL; 146 jbyte* nativeKeyInfoWrappedKeyArrayRaw = NULL; 147 unsigned int sensitiveAttributePosition = (unsigned int)-1; 148 unsigned int i = 0U, totalDataSize = 0U, attributesCount = 0U; 149 unsigned int totalCkAttributesSize = 0U, totalNativeKeyInfoArraySize = 0U; 150 unsigned long* wrappedKeySizePtr = NULL; 151 jbyte* nativeKeyInfoArrayRawCkAttributes = NULL; 152 jbyte* nativeKeyInfoArrayRawCkAttributesPtr = NULL; 153 jbyte* nativeKeyInfoArrayRawDataPtr = NULL; 154 CK_MECHANISM ckMechanism = {0x0}; 155 char iv[16] = {0x0}; 156 CK_ULONG ckWrappedKeyLength = 0U; 157 unsigned long* wrappedKeySizeWrappedKeyArrayPtr = NULL; 158 CK_BYTE_PTR wrappedKeyBufferPtr = NULL; 159 CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); 160 161 if (ckpFunctions == NULL) { goto cleanup; } 162 163 ckpAttributes = (CK_ATTRIBUTE_PTR) malloc(CK_ATTRIBUTES_TEMPLATE_LENGTH * sizeof(CK_ATTRIBUTE)); 164 if (ckpAttributes == NULL) { 165 throwOutOfMemoryError(env, 0); 166 goto cleanup; 167 } 168 memcpy(ckpAttributes, ckpAttributesTemplate, CK_ATTRIBUTES_TEMPLATE_LENGTH * sizeof(CK_ATTRIBUTE)); 169 170 // Get sizes for value buffers 171 (*ckpFunctions->C_GetAttributeValue)(ckSessionHandle, ckObjectHandle, 172 ckpAttributes, CK_ATTRIBUTES_TEMPLATE_LENGTH); 173 174 for (i = 0; i < CK_ATTRIBUTES_TEMPLATE_LENGTH; i++) { 175 if ((ckpAttributes+i)->ulValueLen != (unsigned long)-1) { 176 totalDataSize += (ckpAttributes+i)->ulValueLen; 177 if ((ckpAttributes+i)->type == CKA_SENSITIVE) { 178 sensitiveAttributePosition = attributesCount; 179 } 180 attributesCount++; 181 } 182 } 183 184 // Allocate a single buffer to hold valid attributes and attribute's values 185 // Buffer structure: [ attributes-size, [ ... attributes ... ], values-size, [ ... values ... ], 186 // wrapped-key-size, [ ... wrapped-key ... ] ] 187 // * sizes are expressed in bytes and data type is unsigned long 188 totalCkAttributesSize = attributesCount * sizeof(CK_ATTRIBUTE); 189 totalNativeKeyInfoArraySize = totalCkAttributesSize + sizeof(unsigned long) * 3 + totalDataSize; 190 191 nativeKeyInfoArray = (*env)->NewByteArray(env, totalNativeKeyInfoArraySize); 192 if (nativeKeyInfoArray == NULL) { 193 goto cleanup; 194 } 195 196 nativeKeyInfoArrayRaw = (*env)->GetByteArrayElements(env, nativeKeyInfoArray, NULL); 197 if (nativeKeyInfoArrayRaw == NULL) { 198 goto cleanup; 199 } 200 201 wrappedKeySizePtr = (unsigned long*)(nativeKeyInfoArrayRaw + sizeof(unsigned long)*2 202 + totalCkAttributesSize + totalDataSize); 203 (*(unsigned long*)nativeKeyInfoArrayRaw) = totalCkAttributesSize; 204 (*(unsigned long*)(nativeKeyInfoArrayRaw + sizeof(unsigned long) + totalCkAttributesSize)) = totalDataSize; 205 *wrappedKeySizePtr = 0; 206 207 nativeKeyInfoArrayRawCkAttributes = nativeKeyInfoArrayRaw + sizeof(unsigned long); 208 nativeKeyInfoArrayRawCkAttributesPtr = nativeKeyInfoArrayRawCkAttributes; 209 nativeKeyInfoArrayRawDataPtr = nativeKeyInfoArrayRaw + totalCkAttributesSize + sizeof(unsigned long) * 2; 210 211 for (i = 0; i < CK_ATTRIBUTES_TEMPLATE_LENGTH; i++) { 212 if ((ckpAttributes+i)->ulValueLen != (unsigned long)-1) { 213 (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).type = (ckpAttributes+i)->type; 214 if ((ckpAttributes+i)->ulValueLen != 0) { 215 (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).pValue = nativeKeyInfoArrayRawDataPtr; 216 } else { 217 (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).pValue = 0; 218 } 219 (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).ulValueLen = (ckpAttributes+i)->ulValueLen; 220 nativeKeyInfoArrayRawDataPtr += (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).ulValueLen; 221 nativeKeyInfoArrayRawCkAttributesPtr += sizeof(CK_ATTRIBUTE); 222 } 223 } 224 225 // Get attribute's values 226 rv = (*ckpFunctions->C_GetAttributeValue)(ckSessionHandle, ckObjectHandle, 227 (CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributes, attributesCount); 228 if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { 229 goto cleanup; 230 } 231 232 if ((sensitiveAttributePosition != (unsigned int)-1) && 233 *(CK_BBOOL*)(((CK_ATTRIBUTE_PTR)(((CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributes) 234 +sensitiveAttributePosition))->pValue) == CK_TRUE) { 235 // Key is sensitive. Need to extract it wrapped. 236 if (jWrappingKeyHandle != -1) { 237 ckMechanism.mechanism = CKM_AES_CBC_PAD; 238 ckMechanism.pParameter = &iv; 239 ckMechanism.ulParameterLen = 16; 240 rv = (*ckpFunctions->C_WrapKey)(ckSessionHandle, &ckMechanism, jLongToCKULong(jWrappingKeyHandle), 241 ckObjectHandle, NULL_PTR, &ckWrappedKeyLength); 242 if (ckWrappedKeyLength != 0) { 243 // Allocate space for getting the wrapped key 244 nativeKeyInfoWrappedKeyArray = (*env)->NewByteArray(env, 245 totalNativeKeyInfoArraySize + ckWrappedKeyLength); 246 if (nativeKeyInfoWrappedKeyArray == NULL) { 247 goto cleanup; 248 } 249 nativeKeyInfoWrappedKeyArrayRaw = (*env)->GetByteArrayElements(env, nativeKeyInfoWrappedKeyArray, NULL); 250 if (nativeKeyInfoWrappedKeyArrayRaw == NULL) { 251 goto cleanup; 252 } 253 memcpy(nativeKeyInfoWrappedKeyArrayRaw, nativeKeyInfoArrayRaw, totalNativeKeyInfoArraySize); 254 wrappedKeySizeWrappedKeyArrayPtr = (unsigned long*)(nativeKeyInfoWrappedKeyArrayRaw + 255 sizeof(unsigned long)*2 + totalCkAttributesSize + totalDataSize); 256 *wrappedKeySizeWrappedKeyArrayPtr = (unsigned long)ckWrappedKeyLength; 257 wrappedKeyBufferPtr = (unsigned char*)wrappedKeySizeWrappedKeyArrayPtr + sizeof(unsigned long); 258 rv = (*ckpFunctions->C_WrapKey)(ckSessionHandle, &ckMechanism, jLongToCKULong(jWrappingKeyHandle), 259 ckObjectHandle, wrappedKeyBufferPtr, &ckWrappedKeyLength); 260 if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { 261 goto cleanup; 262 } 263 *wrappedKeySizeWrappedKeyArrayPtr = (unsigned long)ckWrappedKeyLength; 264 } else { 265 goto cleanup; 266 } 267 } else { 268 goto cleanup; 269 } 270 returnValue = nativeKeyInfoWrappedKeyArray; 271 } else { 272 returnValue = nativeKeyInfoArray; 273 } 274 275 cleanup: 276 if (ckpAttributes != NULL) { 277 free(ckpAttributes); 278 } 279 280 if (nativeKeyInfoArrayRaw != NULL) { 281 (*env)->ReleaseByteArrayElements(env, nativeKeyInfoArray, nativeKeyInfoArrayRaw, 0); 282 } 283 284 if (nativeKeyInfoWrappedKeyArrayRaw != NULL) { 285 (*env)->ReleaseByteArrayElements(env, nativeKeyInfoWrappedKeyArray, nativeKeyInfoWrappedKeyArrayRaw, 0); 286 } 287 288 if (nativeKeyInfoArray != NULL && returnValue != nativeKeyInfoArray) { 289 (*env)->DeleteLocalRef(env, nativeKeyInfoArray); 290 } 291 292 if (nativeKeyInfoWrappedKeyArray != NULL && returnValue != nativeKeyInfoWrappedKeyArray) { 293 (*env)->DeleteLocalRef(env, nativeKeyInfoWrappedKeyArray); 294 } 295 296 return returnValue; 297 } 298 #endif 299 300 #ifdef P11_ENABLE_CREATENATIVEKEY 301 /* 302 * Class: sun_security_pkcs11_wrapper_PKCS11 303 * Method: createNativeKey 304 * Signature: (J[BJ)J 305 * Parametermapping: *PKCS11* 306 * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 307 * @param jbyteArray jNativeKeyInfo - 308 * @param jlong jWrappingKeyHandle CK_OBJECT_HANDLE hObject 309 * @return jlong jKeyHandle CK_OBJECT_HANDLE hObject 310 */ 311 JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_createNativeKey 312 (JNIEnv *env, jobject obj, jlong jSessionHandle, jbyteArray jNativeKeyInfo, jlong jWrappingKeyHandle) 313 { 314 CK_OBJECT_HANDLE ckObjectHandle; 315 CK_RV rv; 316 CK_SESSION_HANDLE ckSessionHandle = jLongToCKULong(jSessionHandle); 317 jbyte* nativeKeyInfoArrayRaw = NULL; 318 jlong jObjectHandle = 0L; 319 unsigned long totalCkAttributesSize = 0UL, nativeKeyInfoCkAttributesCount = 0UL; 320 jbyte* nativeKeyInfoArrayRawCkAttributes = NULL; 321 jbyte* nativeKeyInfoArrayRawCkAttributesPtr = NULL; 322 jbyte* nativeKeyInfoArrayRawDataPtr = NULL; 323 unsigned long totalDataSize = 0UL; 324 unsigned long* wrappedKeySizePtr = NULL; 325 unsigned int i = 0U; 326 CK_MECHANISM ckMechanism = {0x0}; 327 char iv[16] = {0x0}; 328 CK_ULONG ckWrappedKeyLength = 0UL; 329 CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); 330 331 if (ckpFunctions == NULL) { goto cleanup; } 332 333 nativeKeyInfoArrayRaw = (*env)->GetByteArrayElements(env, jNativeKeyInfo, NULL); 334 if (nativeKeyInfoArrayRaw == NULL) { 335 goto cleanup; 336 } 337 338 totalCkAttributesSize = *(unsigned long*)nativeKeyInfoArrayRaw; 339 nativeKeyInfoCkAttributesCount = totalCkAttributesSize/sizeof(CK_ATTRIBUTE); 340 nativeKeyInfoArrayRawCkAttributes = nativeKeyInfoArrayRaw + sizeof(unsigned long); 341 nativeKeyInfoArrayRawCkAttributesPtr = nativeKeyInfoArrayRawCkAttributes; 342 nativeKeyInfoArrayRawDataPtr = nativeKeyInfoArrayRaw + totalCkAttributesSize + sizeof(unsigned long) * 2; 343 totalDataSize = *(unsigned long*)(nativeKeyInfoArrayRaw + totalCkAttributesSize + sizeof(unsigned long)); 344 wrappedKeySizePtr = (unsigned long*)(nativeKeyInfoArrayRaw + sizeof(unsigned long)*2 345 + totalCkAttributesSize + totalDataSize); 346 347 for (i = 0; i < nativeKeyInfoCkAttributesCount; i++) { 348 if ((*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).ulValueLen > 0) { 349 (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).pValue = nativeKeyInfoArrayRawDataPtr; 350 } 351 nativeKeyInfoArrayRawDataPtr += (*(CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributesPtr).ulValueLen; 352 nativeKeyInfoArrayRawCkAttributesPtr += sizeof(CK_ATTRIBUTE); 353 } 354 355 if (*wrappedKeySizePtr == 0) { 356 // Not a wrapped key 357 rv = (*ckpFunctions->C_CreateObject)(ckSessionHandle, (CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributes, 358 jLongToCKULong(nativeKeyInfoCkAttributesCount), &ckObjectHandle); 359 } else { 360 // Wrapped key 361 ckMechanism.mechanism = CKM_AES_CBC_PAD; 362 ckMechanism.pParameter = &iv; 363 ckMechanism.ulParameterLen = 16; 364 rv = (*ckpFunctions->C_UnwrapKey)(ckSessionHandle, &ckMechanism, jLongToCKULong(jWrappingKeyHandle), 365 (CK_BYTE_PTR)(wrappedKeySizePtr + 1), *wrappedKeySizePtr, (CK_ATTRIBUTE_PTR)nativeKeyInfoArrayRawCkAttributes, 366 jLongToCKULong(nativeKeyInfoCkAttributesCount), &ckObjectHandle); 367 } 368 if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { 369 goto cleanup; 370 } 371 372 jObjectHandle = ckULongToJLong(ckObjectHandle); 373 374 cleanup: 375 376 if (nativeKeyInfoArrayRaw != NULL) { 377 (*env)->ReleaseByteArrayElements(env, jNativeKeyInfo, nativeKeyInfoArrayRaw, JNI_ABORT); 378 } 379 380 return jObjectHandle; 381 } 382 #endif 383 384 #ifdef P11_ENABLE_C_GENERATEKEY 385 /* 386 * Class: sun_security_pkcs11_wrapper_PKCS11 387 * Method: C_GenerateKey 388 * Signature: (JLsun/security/pkcs11/wrapper/CK_MECHANISM;[Lsun/security/pkcs11/wrapper/CK_ATTRIBUTE;)J 389 * Parametermapping: *PKCS11* 390 * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 391 * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 392 * @param jobjectArray jTemplate CK_ATTRIBUTE_PTR pTemplate 393 * CK_ULONG ulCount 394 * @return jlong jKeyHandle CK_OBJECT_HANDLE_PTR phKey 395 */ 396 JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateKey 397 (JNIEnv *env, jobject obj, jlong jSessionHandle, jobject jMechanism, jobjectArray jTemplate) 398 { 399 CK_SESSION_HANDLE ckSessionHandle; 400 CK_MECHANISM ckMechanism; 401 CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR; 402 CK_ULONG ckAttributesLength; 403 CK_OBJECT_HANDLE ckKeyHandle = 0; |