author | mbaesken |
Mon, 23 Sep 2019 17:02:08 +0200 | |
changeset 58281 | 49836127542b |
parent 57737 | 6bbb4af131e3 |
child 58489 | 2faeaa5933a6 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
*/ |
4 |
||
5 |
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. |
|
6 |
* |
|
7 |
* Redistribution and use in source and binary forms, with or without |
|
8 |
* modification, are permitted provided that the following conditions are met: |
|
9 |
* |
|
10 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
11 |
* this list of conditions and the following disclaimer. |
|
12 |
* |
|
13 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
14 |
* this list of conditions and the following disclaimer in the documentation |
|
15 |
* and/or other materials provided with the distribution. |
|
16 |
* |
|
17 |
* 3. The end-user documentation included with the redistribution, if any, must |
|
18 |
* include the following acknowledgment: |
|
19 |
* |
|
20 |
* "This product includes software developed by IAIK of Graz University of |
|
21 |
* Technology." |
|
22 |
* |
|
23 |
* Alternately, this acknowledgment may appear in the software itself, if |
|
24 |
* and wherever such third-party acknowledgments normally appear. |
|
25 |
* |
|
26 |
* 4. The names "Graz University of Technology" and "IAIK of Graz University of |
|
27 |
* Technology" must not be used to endorse or promote products derived from |
|
28 |
* this software without prior written permission. |
|
29 |
* |
|
30 |
* 5. Products derived from this software may not be called |
|
31 |
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior |
|
32 |
* written permission of Graz University of Technology. |
|
33 |
* |
|
34 |
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
|
35 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
36 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
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 |
/* declare file private functions */ |
|
56 |
||
57 |
ModuleData * getModuleEntry(JNIEnv *env, jobject pkcs11Implementation); |
|
58 |
int isModulePresent(JNIEnv *env, jobject pkcs11Implementation); |
|
59 |
void removeAllModuleEntries(JNIEnv *env); |
|
60 |
||
61 |
||
62 |
/* ************************************************************************** */ |
|
63 |
/* Functions for keeping track of currently active and loaded modules */ |
|
64 |
/* ************************************************************************** */ |
|
65 |
||
66 |
||
67 |
/* |
|
68 |
* Create a new object for locking. |
|
69 |
*/ |
|
70 |
jobject createLockObject(JNIEnv *env) { |
|
71 |
jclass jObjectClass; |
|
72 |
jobject jLockObject; |
|
73 |
jmethodID jConstructor; |
|
74 |
||
75 |
jObjectClass = (*env)->FindClass(env, "java/lang/Object"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
76 |
if (jObjectClass == NULL) { return NULL; } |
2 | 77 |
jConstructor = (*env)->GetMethodID(env, jObjectClass, "<init>", "()V"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
78 |
if (jConstructor == NULL) { return NULL; } |
2 | 79 |
jLockObject = (*env)->NewObject(env, jObjectClass, jConstructor); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
80 |
if (jLockObject == NULL) { return NULL; } |
2 | 81 |
jLockObject = (*env)->NewGlobalRef(env, jLockObject); |
82 |
||
83 |
return jLockObject ; |
|
84 |
} |
|
85 |
||
86 |
/* |
|
87 |
* Create a new object for locking. |
|
88 |
*/ |
|
89 |
void destroyLockObject(JNIEnv *env, jobject jLockObject) { |
|
90 |
if (jLockObject != NULL) { |
|
91 |
(*env)->DeleteGlobalRef(env, jLockObject); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
/* |
|
96 |
* Add the given pkcs11Implementation object to the list of present modules. |
|
97 |
* Attach the given data to the entry. If the given pkcs11Implementation is |
|
98 |
* already in the lsit, just override its old module data with the new one. |
|
99 |
* None of the arguments can be NULL. If one of the arguments is NULL, this |
|
100 |
* function does nothing. |
|
101 |
*/ |
|
102 |
void putModuleEntry(JNIEnv *env, jobject pkcs11Implementation, ModuleData *moduleData) { |
|
103 |
if (pkcs11Implementation == NULL_PTR) { |
|
104 |
return ; |
|
105 |
} |
|
106 |
if (moduleData == NULL) { |
|
107 |
return ; |
|
108 |
} |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
14342
diff
changeset
|
109 |
(*env)->SetLongField(env, pkcs11Implementation, pNativeDataID, ptr_to_jlong(moduleData)); |
2 | 110 |
} |
111 |
||
112 |
||
113 |
/* |
|
114 |
* Get the module data of the entry for the given pkcs11Implementation. Returns |
|
115 |
* NULL, if the pkcs11Implementation is not in the list. |
|
116 |
*/ |
|
117 |
ModuleData * getModuleEntry(JNIEnv *env, jobject pkcs11Implementation) { |
|
118 |
jlong jData; |
|
119 |
if (pkcs11Implementation == NULL) { |
|
120 |
return NULL; |
|
121 |
} |
|
122 |
jData = (*env)->GetLongField(env, pkcs11Implementation, pNativeDataID); |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
14342
diff
changeset
|
123 |
return (ModuleData*)jlong_to_ptr(jData); |
2 | 124 |
} |
125 |
||
126 |
CK_FUNCTION_LIST_PTR getFunctionList(JNIEnv *env, jobject pkcs11Implementation) { |
|
127 |
ModuleData *moduleData; |
|
128 |
CK_FUNCTION_LIST_PTR ckpFunctions; |
|
129 |
||
130 |
moduleData = getModuleEntry(env, pkcs11Implementation); |
|
131 |
if (moduleData == NULL) { |
|
132 |
throwDisconnectedRuntimeException(env); |
|
133 |
return NULL; |
|
134 |
} |
|
135 |
ckpFunctions = moduleData->ckFunctionListPtr; |
|
136 |
return ckpFunctions; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
/* |
|
141 |
* Returns 1, if the given pkcs11Implementation is in the list. |
|
142 |
* 0, otherwise. |
|
143 |
*/ |
|
144 |
int isModulePresent(JNIEnv *env, jobject pkcs11Implementation) { |
|
145 |
int present; |
|
146 |
||
147 |
ModuleData *moduleData = getModuleEntry(env, pkcs11Implementation); |
|
148 |
||
149 |
present = (moduleData != NULL) ? 1 : 0; |
|
150 |
||
151 |
return present ; |
|
152 |
} |
|
153 |
||
154 |
||
155 |
/* |
|
156 |
* Removes the entry for the given pkcs11Implementation from the list. Returns |
|
157 |
* the module's data, after the node was removed. If this function returns NULL |
|
158 |
* the pkcs11Implementation was not in the list. |
|
159 |
*/ |
|
160 |
ModuleData * removeModuleEntry(JNIEnv *env, jobject pkcs11Implementation) { |
|
161 |
ModuleData *moduleData = getModuleEntry(env, pkcs11Implementation); |
|
162 |
if (moduleData == NULL) { |
|
163 |
return NULL; |
|
164 |
} |
|
165 |
(*env)->SetLongField(env, pkcs11Implementation, pNativeDataID, 0); |
|
166 |
return moduleData; |
|
167 |
} |
|
168 |
||
169 |
/* |
|
170 |
* Removes all present entries from the list of modules and frees all |
|
171 |
* associated resources. This function is used for clean-up. |
|
172 |
*/ |
|
173 |
void removeAllModuleEntries(JNIEnv *env) { |
|
174 |
/* XXX empty */ |
|
175 |
} |
|
176 |
||
177 |
/* ************************************************************************** */ |
|
178 |
/* Below there follow the helper functions to support conversions between */ |
|
179 |
/* Java and Cryptoki types */ |
|
180 |
/* ************************************************************************** */ |
|
181 |
||
182 |
/* |
|
183 |
* function to convert a PKCS#11 return value into a PKCS#11Exception |
|
184 |
* |
|
185 |
* This function generates a PKCS#11Exception with the returnValue as the errorcode |
|
186 |
* if the returnValue is not CKR_OK. The functin returns 0, if the returnValue is |
|
187 |
* CKR_OK. Otherwise, it returns the returnValue as a jLong. |
|
188 |
* |
|
189 |
* @param env - used to call JNI funktions and to get the Exception class |
|
190 |
* @param returnValue - of the PKCS#11 function |
|
191 |
*/ |
|
192 |
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue) |
|
193 |
{ |
|
194 |
jclass jPKCS11ExceptionClass; |
|
195 |
jmethodID jConstructor; |
|
196 |
jthrowable jPKCS11Exception; |
|
3321
fed33393bc52
6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents:
2180
diff
changeset
|
197 |
jlong jErrorCode = 0L; |
2 | 198 |
|
3321
fed33393bc52
6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents:
2180
diff
changeset
|
199 |
if (returnValue != CKR_OK) { |
fed33393bc52
6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents:
2180
diff
changeset
|
200 |
jErrorCode = ckULongToJLong(returnValue); |
2 | 201 |
jPKCS11ExceptionClass = (*env)->FindClass(env, CLASS_PKCS11EXCEPTION); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
202 |
if (jPKCS11ExceptionClass != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
203 |
jConstructor = (*env)->GetMethodID(env, jPKCS11ExceptionClass, "<init>", "(J)V"); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
204 |
if (jConstructor != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
205 |
jPKCS11Exception = (jthrowable) (*env)->NewObject(env, jPKCS11ExceptionClass, jConstructor, jErrorCode); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
206 |
if (jPKCS11Exception != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
207 |
(*env)->Throw(env, jPKCS11Exception); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
208 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
209 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
210 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
211 |
(*env)->DeleteLocalRef(env, jPKCS11ExceptionClass); |
2 | 212 |
} |
3321
fed33393bc52
6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents:
2180
diff
changeset
|
213 |
return jErrorCode ; |
2 | 214 |
} |
215 |
||
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
216 |
|
2 | 217 |
/* |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
218 |
* Throws a Java Exception by name |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
219 |
*/ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
220 |
void throwByName(JNIEnv *env, const char *name, const char *msg) |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
221 |
{ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
222 |
jclass cls = (*env)->FindClass(env, name); |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
223 |
|
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
224 |
if (cls != 0) /* Otherwise an exception has already been thrown */ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
225 |
(*env)->ThrowNew(env, cls, msg); |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
226 |
} |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
227 |
|
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
228 |
/* |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
229 |
* Throws java.lang.OutOfMemoryError |
2 | 230 |
*/ |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
231 |
void throwOutOfMemoryError(JNIEnv *env, const char *msg) |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
232 |
{ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
233 |
throwByName(env, "java/lang/OutOfMemoryError", msg); |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
234 |
} |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
235 |
|
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
236 |
/* |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
237 |
* Throws java.lang.NullPointerException |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
238 |
*/ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
239 |
void throwNullPointerException(JNIEnv *env, const char *msg) |
2 | 240 |
{ |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
241 |
throwByName(env, "java/lang/NullPointerException", msg); |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
242 |
} |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
243 |
|
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
244 |
/* |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
245 |
* Throws java.io.IOException |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
246 |
*/ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
247 |
void throwIOException(JNIEnv *env, const char *msg) |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
248 |
{ |
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
249 |
throwByName(env, "java/io/IOException", msg); |
2 | 250 |
} |
251 |
||
252 |
/* |
|
253 |
* This function simply throws a PKCS#11RuntimeException with the given |
|
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
254 |
* string as its message. |
2 | 255 |
* |
256 |
* @param env Used to call JNI funktions and to get the Exception class. |
|
257 |
* @param jmessage The message string of the Exception object. |
|
258 |
*/ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
259 |
void throwPKCS11RuntimeException(JNIEnv *env, const char *message) |
2 | 260 |
{ |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
261 |
throwByName(env, CLASS_PKCS11RUNTIMEEXCEPTION, message); |
2 | 262 |
} |
263 |
||
264 |
/* |
|
265 |
* This function simply throws a PKCS#11RuntimeException. The message says that |
|
266 |
* the object is not connected to the module. |
|
267 |
* |
|
268 |
* @param env Used to call JNI funktions and to get the Exception class. |
|
269 |
*/ |
|
270 |
void throwDisconnectedRuntimeException(JNIEnv *env) |
|
271 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
272 |
throwPKCS11RuntimeException(env, "This object is not connected to a module."); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
273 |
} |
2 | 274 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
275 |
/* This function frees the specified CK_ATTRIBUTE array. |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
276 |
* |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
277 |
* @param attrPtr pointer to the to-be-freed CK_ATTRIBUTE array. |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
278 |
* @param len the length of the array |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
279 |
*/ |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
280 |
void freeCKAttributeArray(CK_ATTRIBUTE_PTR attrPtr, int len) { |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
281 |
if (attrPtr != NULL) { |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
282 |
int i; |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
283 |
for (i=0; i<len; i++) { |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
284 |
if (attrPtr[i].pValue != NULL_PTR) { |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
285 |
free(attrPtr[i].pValue); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
286 |
} |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
287 |
} |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
288 |
free(attrPtr); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
289 |
} |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
290 |
} |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
291 |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
292 |
/* This function frees the specified CK_MECHANISM_PTR pointer and its |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
293 |
* pParameter including mechanism-specific memory allocations. |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
294 |
* |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
295 |
* @param mechPtr pointer to the to-be-freed CK_MECHANISM structure. |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
296 |
*/ |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
297 |
void freeCKMechanismPtr(CK_MECHANISM_PTR mechPtr) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
298 |
void *tmp; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
299 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS *sslMkdTmp; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
300 |
CK_SSL3_KEY_MAT_PARAMS* sslKmTmp; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
301 |
CK_TLS12_MASTER_KEY_DERIVE_PARAMS *tlsMkdTmp; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
302 |
CK_TLS12_KEY_MAT_PARAMS* tlsKmTmp; |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
303 |
|
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
304 |
if (mechPtr != NULL) { |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
305 |
TRACE2("DEBUG: free mech %lX (mech id = 0x%lX)\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
306 |
ptr_to_jlong(mechPtr), mechPtr->mechanism); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
307 |
if (mechPtr->pParameter != NULL) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
308 |
switch (mechPtr->mechanism) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
309 |
case CKM_AES_GCM: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
310 |
tmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
311 |
TRACE1("\t=> free GCM_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
312 |
ptr_to_jlong(tmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
313 |
free(((CK_GCM_PARAMS*)tmp)->pIv); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
314 |
free(((CK_GCM_PARAMS*)tmp)->pAAD); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
315 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
316 |
case CKM_AES_CCM: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
317 |
tmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
318 |
TRACE1("\t=> free CK_CCM_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
319 |
ptr_to_jlong(tmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
320 |
free(((CK_CCM_PARAMS*)tmp)->pNonce); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
321 |
free(((CK_CCM_PARAMS*)tmp)->pAAD); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
322 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
323 |
case CKM_TLS_PRF: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
324 |
case CKM_NSS_TLS_PRF_GENERAL: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
325 |
tmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
326 |
TRACE1("\t=> free CK_TLS_PRF_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
327 |
ptr_to_jlong(tmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
328 |
free(((CK_TLS_PRF_PARAMS*)tmp)->pSeed); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
329 |
free(((CK_TLS_PRF_PARAMS*)tmp)->pLabel); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
330 |
free(((CK_TLS_PRF_PARAMS*)tmp)->pulOutputLen); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
331 |
free(((CK_TLS_PRF_PARAMS*)tmp)->pOutput); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
332 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
333 |
case CKM_SSL3_MASTER_KEY_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
334 |
case CKM_TLS_MASTER_KEY_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
335 |
case CKM_SSL3_MASTER_KEY_DERIVE_DH: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
336 |
case CKM_TLS_MASTER_KEY_DERIVE_DH: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
337 |
sslMkdTmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
338 |
TRACE1("\t=> free CK_SSL3_MASTER_KEY_DERIVE_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
339 |
ptr_to_jlong(sslMkdTmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
340 |
free(sslMkdTmp->RandomInfo.pClientRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
341 |
free(sslMkdTmp->RandomInfo.pServerRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
342 |
free(sslMkdTmp->pVersion); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
343 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
344 |
case CKM_SSL3_KEY_AND_MAC_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
345 |
case CKM_TLS_KEY_AND_MAC_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
346 |
sslKmTmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
347 |
TRACE1("\t=> free CK_SSL3_KEY_MAT_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
348 |
ptr_to_jlong(sslKmTmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
349 |
free(sslKmTmp->RandomInfo.pClientRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
350 |
free(sslKmTmp->RandomInfo.pServerRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
351 |
if (sslKmTmp->pReturnedKeyMaterial != NULL) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
352 |
free(sslKmTmp->pReturnedKeyMaterial->pIVClient); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
353 |
free(sslKmTmp->pReturnedKeyMaterial->pIVServer); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
354 |
free(sslKmTmp->pReturnedKeyMaterial); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
355 |
} |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
356 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
357 |
case CKM_TLS12_MASTER_KEY_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
358 |
case CKM_TLS12_MASTER_KEY_DERIVE_DH: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
359 |
tlsMkdTmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
360 |
TRACE1("\t=> CK_TLS12_MASTER_KEY_DERIVE_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
361 |
ptr_to_jlong(tlsMkdTmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
362 |
free(tlsMkdTmp->RandomInfo.pClientRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
363 |
free(tlsMkdTmp->RandomInfo.pServerRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
364 |
free(tlsMkdTmp->pVersion); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
365 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
366 |
case CKM_TLS12_KEY_AND_MAC_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
367 |
tlsKmTmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
368 |
TRACE1("\t=> free CK_TLS12_KEY_MAT_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
369 |
ptr_to_jlong(tlsKmTmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
370 |
free(tlsKmTmp->RandomInfo.pClientRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
371 |
free(tlsKmTmp->RandomInfo.pServerRandom); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
372 |
if (tlsKmTmp->pReturnedKeyMaterial != NULL) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
373 |
free(tlsKmTmp->pReturnedKeyMaterial->pIVClient); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
374 |
free(tlsKmTmp->pReturnedKeyMaterial->pIVServer); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
375 |
free(tlsKmTmp->pReturnedKeyMaterial); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
376 |
} |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
377 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
378 |
case CKM_ECDH1_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
379 |
case CKM_ECDH1_COFACTOR_DERIVE: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
380 |
tmp = mechPtr->pParameter; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
381 |
TRACE1("\t=> free CK_ECDH1_DERIVE_PARAMS %lX\n", |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
382 |
ptr_to_jlong(tmp)); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
383 |
free(((CK_ECDH1_DERIVE_PARAMS *)tmp)->pSharedData); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
384 |
free(((CK_ECDH1_DERIVE_PARAMS *)tmp)->pPublicData); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
385 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
386 |
case CKM_TLS_MAC: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
387 |
case CKM_AES_CTR: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
388 |
case CKM_RSA_PKCS_PSS: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
389 |
case CKM_CAMELLIA_CTR: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
390 |
TRACE0("\t=> NO OP\n"); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
391 |
// params do not contain pointers |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
392 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
393 |
default: |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
394 |
// currently unsupported mechs by SunPKCS11 provider |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
395 |
// CKM_RSA_PKCS_OAEP, CKM_ECMQV_DERIVE, |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
396 |
// CKM_X9_42_*, CKM_KEA_DERIVE, CKM_RC2_*, CKM_RC5_*, |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
397 |
// CKM_SKIPJACK_*, CKM_KEY_WRAP_SET_OAEP, CKM_PKCS5_PBKD2, |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
398 |
// PBE mechs, WTLS mechs, CMS mechs, |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
399 |
// CKM_EXTRACT_KEY_FROM_KEY, CKM_OTP, CKM_KIP, |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
400 |
// CKM_DSA_PARAMETER_GEN?, CKM_GOSTR3410_* |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
401 |
// CK_any_CBC_ENCRYPT_DATA? |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
402 |
TRACE0("\t=> ERROR UNSUPPORTED CK PARAMS\n"); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
403 |
break; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
404 |
} |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
405 |
free(mechPtr->pParameter); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
406 |
} else { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
407 |
TRACE0("DEBUG => Parameter NULL\n"); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
408 |
} |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
409 |
free(mechPtr); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
410 |
} |
2 | 411 |
} |
412 |
||
413 |
/* |
|
414 |
* the following functions convert Java arrays to PKCS#11 array pointers and |
|
415 |
* their array length and vice versa |
|
416 |
* |
|
417 |
* void j<Type>ArrayToCK<Type>Array(JNIEnv *env, |
|
418 |
* const j<Type>Array jArray, |
|
419 |
* CK_<Type>_PTR *ckpArray, |
|
420 |
* CK_ULONG_PTR ckLength); |
|
421 |
* |
|
422 |
* j<Type>Array ck<Type>ArrayToJ<Type>Array(JNIEnv *env, |
|
423 |
* const CK_<Type>_PTR ckpArray, |
|
424 |
* CK_ULONG ckLength); |
|
425 |
* |
|
426 |
* PKCS#11 arrays consist always of a pointer to the beginning of the array and |
|
427 |
* the array length whereas Java arrays carry their array length. |
|
428 |
* |
|
429 |
* The Functions to convert a Java array to a PKCS#11 array are void functions. |
|
430 |
* Their arguments are the Java array object to convert, the reference to the |
|
431 |
* array pointer, where the new PKCS#11 array should be stored and the reference |
|
432 |
* to the array length where the PKCS#11 array length should be stored. These two |
|
433 |
* references must not be NULL_PTR. |
|
434 |
* |
|
435 |
* The functions first obtain the array length of the Java array and then allocate |
|
436 |
* the memory for the PKCS#11 array and set the array length. Then each element |
|
437 |
* gets converted depending on their type. After use the allocated memory of the |
|
438 |
* PKCS#11 array has to be explicitly freed. |
|
439 |
* |
|
440 |
* The Functions to convert a PKCS#11 array to a Java array get the PKCS#11 array |
|
441 |
* pointer and the array length and they return the new Java array object. The |
|
442 |
* Java array does not need to get freed after use. |
|
443 |
*/ |
|
444 |
||
445 |
/* |
|
446 |
* converts a jbooleanArray to a CK_BBOOL array. The allocated memory has to be freed after use! |
|
447 |
* |
|
448 |
* @param env - used to call JNI funktions to get the array informtaion |
|
449 |
* @param jArray - the Java array to convert |
|
450 |
* @param ckpArray - the reference, where the pointer to the new CK_BBOOL array will be stored |
|
451 |
* @param ckpLength - the reference, where the array length will be stored |
|
452 |
*/ |
|
453 |
void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBOOL **ckpArray, CK_ULONG_PTR ckpLength) |
|
454 |
{ |
|
455 |
jboolean* jpTemp; |
|
456 |
CK_ULONG i; |
|
457 |
||
458 |
if(jArray == NULL) { |
|
459 |
*ckpArray = NULL_PTR; |
|
460 |
*ckpLength = 0L; |
|
461 |
return; |
|
462 |
} |
|
463 |
*ckpLength = (*env)->GetArrayLength(env, jArray); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
464 |
jpTemp = (jboolean*) calloc(*ckpLength, sizeof(jboolean)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
465 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
466 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
467 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
468 |
} |
2 | 469 |
(*env)->GetBooleanArrayRegion(env, jArray, 0, *ckpLength, jpTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
470 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
471 |
free(jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
472 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
473 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
474 |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
475 |
*ckpArray = (CK_BBOOL*) calloc (*ckpLength, sizeof(CK_BBOOL)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
476 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
477 |
free(jpTemp); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
478 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
479 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
480 |
} |
2 | 481 |
for (i=0; i<(*ckpLength); i++) { |
482 |
(*ckpArray)[i] = jBooleanToCKBBool(jpTemp[i]); |
|
483 |
} |
|
484 |
free(jpTemp); |
|
485 |
} |
|
486 |
||
487 |
/* |
|
488 |
* converts a jbyteArray to a CK_BYTE array. The allocated memory has to be freed after use! |
|
489 |
* |
|
490 |
* @param env - used to call JNI funktions to get the array informtaion |
|
491 |
* @param jArray - the Java array to convert |
|
492 |
* @param ckpArray - the reference, where the pointer to the new CK_BYTE array will be stored |
|
493 |
* @param ckpLength - the reference, where the array length will be stored |
|
494 |
*/ |
|
495 |
void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
496 |
{ |
|
497 |
jbyte* jpTemp; |
|
498 |
CK_ULONG i; |
|
499 |
||
500 |
if(jArray == NULL) { |
|
501 |
*ckpArray = NULL_PTR; |
|
502 |
*ckpLength = 0L; |
|
503 |
return; |
|
504 |
} |
|
505 |
*ckpLength = (*env)->GetArrayLength(env, jArray); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
506 |
jpTemp = (jbyte*) calloc(*ckpLength, sizeof(jbyte)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
507 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
508 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
509 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
510 |
} |
2 | 511 |
(*env)->GetByteArrayRegion(env, jArray, 0, *ckpLength, jpTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
512 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
513 |
free(jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
514 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
515 |
} |
2 | 516 |
|
517 |
/* if CK_BYTE is the same size as jbyte, we save an additional copy */ |
|
518 |
if (sizeof(CK_BYTE) == sizeof(jbyte)) { |
|
519 |
*ckpArray = (CK_BYTE_PTR) jpTemp; |
|
520 |
} else { |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
521 |
*ckpArray = (CK_BYTE_PTR) calloc (*ckpLength, sizeof(CK_BYTE)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
522 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
523 |
free(jpTemp); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
524 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
525 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
526 |
} |
2 | 527 |
for (i=0; i<(*ckpLength); i++) { |
528 |
(*ckpArray)[i] = jByteToCKByte(jpTemp[i]); |
|
529 |
} |
|
530 |
free(jpTemp); |
|
531 |
} |
|
532 |
} |
|
533 |
||
534 |
/* |
|
535 |
* converts a jlongArray to a CK_ULONG array. The allocated memory has to be freed after use! |
|
536 |
* |
|
537 |
* @param env - used to call JNI funktions to get the array informtaion |
|
538 |
* @param jArray - the Java array to convert |
|
539 |
* @param ckpArray - the reference, where the pointer to the new CK_ULONG array will be stored |
|
540 |
* @param ckpLength - the reference, where the array length will be stored |
|
541 |
*/ |
|
542 |
void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
543 |
{ |
|
544 |
jlong* jTemp; |
|
545 |
CK_ULONG i; |
|
546 |
||
547 |
if(jArray == NULL) { |
|
548 |
*ckpArray = NULL_PTR; |
|
549 |
*ckpLength = 0L; |
|
550 |
return; |
|
551 |
} |
|
552 |
*ckpLength = (*env)->GetArrayLength(env, jArray); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
553 |
jTemp = (jlong*) calloc(*ckpLength, sizeof(jlong)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
554 |
if (jTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
555 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
556 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
557 |
} |
2 | 558 |
(*env)->GetLongArrayRegion(env, jArray, 0, *ckpLength, jTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
559 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
560 |
free(jTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
561 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
562 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
563 |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
564 |
*ckpArray = (CK_ULONG_PTR) calloc(*ckpLength, sizeof(CK_ULONG)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
565 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
566 |
free(jTemp); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
567 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
568 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
569 |
} |
2 | 570 |
for (i=0; i<(*ckpLength); i++) { |
571 |
(*ckpArray)[i] = jLongToCKULong(jTemp[i]); |
|
572 |
} |
|
573 |
free(jTemp); |
|
574 |
} |
|
575 |
||
576 |
/* |
|
577 |
* converts a jcharArray to a CK_CHAR array. The allocated memory has to be freed after use! |
|
578 |
* |
|
579 |
* @param env - used to call JNI funktions to get the array informtaion |
|
580 |
* @param jArray - the Java array to convert |
|
581 |
* @param ckpArray - the reference, where the pointer to the new CK_CHAR array will be stored |
|
582 |
* @param ckpLength - the reference, where the array length will be stored |
|
583 |
*/ |
|
584 |
void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
585 |
{ |
|
586 |
jchar* jpTemp; |
|
587 |
CK_ULONG i; |
|
588 |
||
589 |
if(jArray == NULL) { |
|
590 |
*ckpArray = NULL_PTR; |
|
591 |
*ckpLength = 0L; |
|
592 |
return; |
|
593 |
} |
|
594 |
*ckpLength = (*env)->GetArrayLength(env, jArray); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
595 |
jpTemp = (jchar*) calloc(*ckpLength, sizeof(jchar)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
596 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
597 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
598 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
599 |
} |
2 | 600 |
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jpTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
601 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
602 |
free(jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
603 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
604 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
605 |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
606 |
*ckpArray = (CK_CHAR_PTR) calloc (*ckpLength, sizeof(CK_CHAR)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
607 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
608 |
free(jpTemp); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
609 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
610 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
611 |
} |
2 | 612 |
for (i=0; i<(*ckpLength); i++) { |
613 |
(*ckpArray)[i] = jCharToCKChar(jpTemp[i]); |
|
614 |
} |
|
615 |
free(jpTemp); |
|
616 |
} |
|
617 |
||
618 |
/* |
|
619 |
* converts a jcharArray to a CK_UTF8CHAR array. The allocated memory has to be freed after use! |
|
620 |
* |
|
621 |
* @param env - used to call JNI funktions to get the array informtaion |
|
622 |
* @param jArray - the Java array to convert |
|
623 |
* @param ckpArray - the reference, where the pointer to the new CK_UTF8CHAR array will be stored |
|
624 |
* @param ckpLength - the reference, where the array length will be stored |
|
625 |
*/ |
|
626 |
void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
627 |
{ |
|
628 |
jchar* jTemp; |
|
629 |
CK_ULONG i; |
|
630 |
||
631 |
if(jArray == NULL) { |
|
632 |
*ckpArray = NULL_PTR; |
|
633 |
*ckpLength = 0L; |
|
634 |
return; |
|
635 |
} |
|
636 |
*ckpLength = (*env)->GetArrayLength(env, jArray); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
637 |
jTemp = (jchar*) calloc(*ckpLength, sizeof(jchar)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
638 |
if (jTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
639 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
640 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
641 |
} |
2 | 642 |
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
643 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
644 |
free(jTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
645 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
646 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
647 |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
648 |
*ckpArray = (CK_UTF8CHAR_PTR) calloc(*ckpLength, sizeof(CK_UTF8CHAR)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
649 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
650 |
free(jTemp); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
651 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
652 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
653 |
} |
2 | 654 |
for (i=0; i<(*ckpLength); i++) { |
655 |
(*ckpArray)[i] = jCharToCKUTF8Char(jTemp[i]); |
|
656 |
} |
|
657 |
free(jTemp); |
|
658 |
} |
|
659 |
||
660 |
/* |
|
661 |
* converts a jstring to a CK_CHAR array. The allocated memory has to be freed after use! |
|
662 |
* |
|
663 |
* @param env - used to call JNI funktions to get the array informtaion |
|
664 |
* @param jArray - the Java array to convert |
|
665 |
* @param ckpArray - the reference, where the pointer to the new CK_CHAR array will be stored |
|
666 |
* @param ckpLength - the reference, where the array length will be stored |
|
667 |
*/ |
|
668 |
void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
669 |
{ |
|
670 |
const char* pCharArray; |
|
671 |
jboolean isCopy; |
|
672 |
||
673 |
if(jArray == NULL) { |
|
674 |
*ckpArray = NULL_PTR; |
|
675 |
*ckpLength = 0L; |
|
676 |
return; |
|
677 |
} |
|
678 |
||
679 |
pCharArray = (*env)->GetStringUTFChars(env, jArray, &isCopy); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
680 |
if (pCharArray == NULL) { return; } |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
681 |
|
40563
4bff68330f39
8074838: Resolve disabled warnings for libj2pkcs11
ascarpino
parents:
39142
diff
changeset
|
682 |
*ckpLength = (CK_ULONG) strlen(pCharArray); |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
683 |
*ckpArray = (CK_UTF8CHAR_PTR) calloc(*ckpLength + 1, sizeof(CK_UTF8CHAR)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
684 |
if (*ckpArray == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
685 |
(*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
686 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
687 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
688 |
} |
2 | 689 |
strcpy((char*)*ckpArray, pCharArray); |
690 |
(*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray); |
|
691 |
} |
|
692 |
||
693 |
/* |
|
694 |
* converts a jobjectArray with Java Attributes to a CK_ATTRIBUTE array. The allocated memory |
|
695 |
* has to be freed after use! |
|
696 |
* |
|
697 |
* @param env - used to call JNI funktions to get the array informtaion |
|
698 |
* @param jArray - the Java Attribute array (template) to convert |
|
699 |
* @param ckpArray - the reference, where the pointer to the new CK_ATTRIBUTE array will be |
|
700 |
* stored |
|
701 |
* @param ckpLength - the reference, where the array length will be stored |
|
702 |
*/ |
|
703 |
void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jArray, CK_ATTRIBUTE_PTR *ckpArray, CK_ULONG_PTR ckpLength) |
|
704 |
{ |
|
705 |
CK_ULONG i; |
|
706 |
jlong jLength; |
|
707 |
jobject jAttribute; |
|
708 |
||
709 |
TRACE0("\nDEBUG: jAttributeArrayToCKAttributeArray"); |
|
710 |
if (jArray == NULL) { |
|
711 |
*ckpArray = NULL_PTR; |
|
712 |
*ckpLength = 0L; |
|
713 |
return; |
|
714 |
} |
|
715 |
jLength = (*env)->GetArrayLength(env, jArray); |
|
716 |
*ckpLength = jLongToCKULong(jLength); |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
717 |
*ckpArray = (CK_ATTRIBUTE_PTR) calloc(*ckpLength, sizeof(CK_ATTRIBUTE)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
718 |
if (*ckpArray == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
719 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
720 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
721 |
} |
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
722 |
TRACE1(", converting %lld attributes", (long long int) jLength); |
2 | 723 |
for (i=0; i<(*ckpLength); i++) { |
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
724 |
TRACE1(", getting %lu. attribute", i); |
2 | 725 |
jAttribute = (*env)->GetObjectArrayElement(env, jArray, i); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
726 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
727 |
freeCKAttributeArray(*ckpArray, i); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
728 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
729 |
} |
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
730 |
TRACE1(", jAttribute , converting %lu. attribute", i); |
2 | 731 |
(*ckpArray)[i] = jAttributeToCKAttribute(env, jAttribute); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
732 |
if ((*env)->ExceptionCheck(env)) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
733 |
freeCKAttributeArray(*ckpArray, i); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
734 |
return; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
735 |
} |
2 | 736 |
} |
737 |
TRACE0("FINISHED\n"); |
|
738 |
} |
|
739 |
||
740 |
/* |
|
741 |
* converts a CK_BYTE array and its length to a jbyteArray. |
|
742 |
* |
|
743 |
* @param env - used to call JNI funktions to create the new Java array |
|
744 |
* @param ckpArray - the pointer to the CK_BYTE array to convert |
|
745 |
* @param ckpLength - the length of the array to convert |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
746 |
* @return - the new Java byte array or NULL if error occurred |
2 | 747 |
*/ |
748 |
jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength) |
|
749 |
{ |
|
750 |
CK_ULONG i; |
|
751 |
jbyte* jpTemp; |
|
752 |
jbyteArray jArray; |
|
753 |
||
754 |
/* if CK_BYTE is the same size as jbyte, we save an additional copy */ |
|
755 |
if (sizeof(CK_BYTE) == sizeof(jbyte)) { |
|
756 |
jpTemp = (jbyte*) ckpArray; |
|
757 |
} else { |
|
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
758 |
jpTemp = (jbyte*) calloc(ckLength, sizeof(jbyte)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
759 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
760 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
761 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
762 |
} |
2 | 763 |
for (i=0; i<ckLength; i++) { |
764 |
jpTemp[i] = ckByteToJByte(ckpArray[i]); |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
jArray = (*env)->NewByteArray(env, ckULongToJSize(ckLength)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
769 |
if (jArray != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
770 |
(*env)->SetByteArrayRegion(env, jArray, 0, ckULongToJSize(ckLength), jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
771 |
} |
2 | 772 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
773 |
if (sizeof(CK_BYTE) != sizeof(jbyte)) { free(jpTemp); } |
2 | 774 |
|
775 |
return jArray ; |
|
776 |
} |
|
777 |
||
778 |
/* |
|
779 |
* converts a CK_ULONG array and its length to a jlongArray. |
|
780 |
* |
|
781 |
* @param env - used to call JNI funktions to create the new Java array |
|
782 |
* @param ckpArray - the pointer to the CK_ULONG array to convert |
|
783 |
* @param ckpLength - the length of the array to convert |
|
784 |
* @return - the new Java long array |
|
785 |
*/ |
|
786 |
jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK_ULONG ckLength) |
|
787 |
{ |
|
788 |
CK_ULONG i; |
|
789 |
jlong* jpTemp; |
|
790 |
jlongArray jArray; |
|
791 |
||
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
792 |
jpTemp = (jlong*) calloc(ckLength, sizeof(jlong)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
793 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
794 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
795 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
796 |
} |
2 | 797 |
for (i=0; i<ckLength; i++) { |
798 |
jpTemp[i] = ckLongToJLong(ckpArray[i]); |
|
799 |
} |
|
800 |
jArray = (*env)->NewLongArray(env, ckULongToJSize(ckLength)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
801 |
if (jArray != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
802 |
(*env)->SetLongArrayRegion(env, jArray, 0, ckULongToJSize(ckLength), jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
803 |
} |
2 | 804 |
free(jpTemp); |
805 |
||
806 |
return jArray ; |
|
807 |
} |
|
808 |
||
809 |
/* |
|
810 |
* converts a CK_CHAR array and its length to a jcharArray. |
|
811 |
* |
|
812 |
* @param env - used to call JNI funktions to create the new Java array |
|
813 |
* @param ckpArray - the pointer to the CK_CHAR array to convert |
|
814 |
* @param ckpLength - the length of the array to convert |
|
815 |
* @return - the new Java char array |
|
816 |
*/ |
|
817 |
jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_ULONG ckLength) |
|
818 |
{ |
|
819 |
CK_ULONG i; |
|
820 |
jchar* jpTemp; |
|
821 |
jcharArray jArray; |
|
822 |
||
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
823 |
jpTemp = (jchar*) calloc(ckLength, sizeof(jchar)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
824 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
825 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
826 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
827 |
} |
2 | 828 |
for (i=0; i<ckLength; i++) { |
829 |
jpTemp[i] = ckCharToJChar(ckpArray[i]); |
|
830 |
} |
|
831 |
jArray = (*env)->NewCharArray(env, ckULongToJSize(ckLength)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
832 |
if (jArray != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
833 |
(*env)->SetCharArrayRegion(env, jArray, 0, ckULongToJSize(ckLength), jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
834 |
} |
2 | 835 |
free(jpTemp); |
836 |
||
837 |
return jArray ; |
|
838 |
} |
|
839 |
||
840 |
/* |
|
841 |
* converts a CK_UTF8CHAR array and its length to a jcharArray. |
|
842 |
* |
|
843 |
* @param env - used to call JNI funktions to create the new Java array |
|
844 |
* @param ckpArray - the pointer to the CK_UTF8CHAR array to convert |
|
845 |
* @param ckpLength - the length of the array to convert |
|
846 |
* @return - the new Java char array |
|
847 |
*/ |
|
848 |
jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArray, CK_ULONG ckLength) |
|
849 |
{ |
|
850 |
CK_ULONG i; |
|
851 |
jchar* jpTemp; |
|
852 |
jcharArray jArray; |
|
853 |
||
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
854 |
jpTemp = (jchar*) calloc(ckLength, sizeof(jchar)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
855 |
if (jpTemp == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
856 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
857 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
858 |
} |
2 | 859 |
for (i=0; i<ckLength; i++) { |
860 |
jpTemp[i] = ckUTF8CharToJChar(ckpArray[i]); |
|
861 |
} |
|
862 |
jArray = (*env)->NewCharArray(env, ckULongToJSize(ckLength)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
863 |
if (jArray != NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
864 |
(*env)->SetCharArrayRegion(env, jArray, 0, ckULongToJSize(ckLength), jpTemp); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
865 |
} |
2 | 866 |
free(jpTemp); |
867 |
||
868 |
return jArray ; |
|
869 |
} |
|
870 |
||
871 |
/* |
|
872 |
* the following functions convert Java objects to PKCS#11 pointers and the |
|
873 |
* length in bytes and vice versa |
|
874 |
* |
|
875 |
* CK_<Type>_PTR j<Object>ToCK<Type>Ptr(JNIEnv *env, jobject jObject); |
|
876 |
* |
|
877 |
* jobject ck<Type>PtrToJ<Object>(JNIEnv *env, const CK_<Type>_PTR ckpValue); |
|
878 |
* |
|
879 |
* The functions that convert a Java object to a PKCS#11 pointer first allocate |
|
880 |
* the memory for the PKCS#11 pointer. Then they set each element corresponding |
|
881 |
* to the fields in the Java object to convert. After use the allocated memory of |
|
882 |
* the PKCS#11 pointer has to be explicitly freed. |
|
883 |
* |
|
884 |
* The functions to convert a PKCS#11 pointer to a Java object create a new Java |
|
885 |
* object first and than they set all fields in the object depending on the values |
|
886 |
* of the type or structure where the PKCS#11 pointer points to. |
|
887 |
*/ |
|
888 |
||
889 |
/* |
|
890 |
* converts a CK_BBOOL pointer to a Java boolean Object. |
|
891 |
* |
|
892 |
* @param env - used to call JNI funktions to create the new Java object |
|
893 |
* @param ckpValue - the pointer to the CK_BBOOL value |
|
894 |
* @return - the new Java boolean object with the boolean value |
|
895 |
*/ |
|
896 |
jobject ckBBoolPtrToJBooleanObject(JNIEnv *env, const CK_BBOOL *ckpValue) |
|
897 |
{ |
|
898 |
jclass jValueObjectClass; |
|
899 |
jmethodID jConstructor; |
|
900 |
jobject jValueObject; |
|
901 |
jboolean jValue; |
|
902 |
||
903 |
jValueObjectClass = (*env)->FindClass(env, "java/lang/Boolean"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
904 |
if (jValueObjectClass == NULL) { return NULL; } |
2 | 905 |
jConstructor = (*env)->GetMethodID(env, jValueObjectClass, "<init>", "(Z)V"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
906 |
if (jConstructor == NULL) { return NULL; } |
2 | 907 |
jValue = ckBBoolToJBoolean(*ckpValue); |
908 |
jValueObject = (*env)->NewObject(env, jValueObjectClass, jConstructor, jValue); |
|
909 |
||
910 |
return jValueObject ; |
|
911 |
} |
|
912 |
||
913 |
/* |
|
914 |
* converts a CK_ULONG pointer to a Java long Object. |
|
915 |
* |
|
916 |
* @param env - used to call JNI funktions to create the new Java object |
|
917 |
* @param ckpValue - the pointer to the CK_ULONG value |
|
918 |
* @return - the new Java long object with the long value |
|
919 |
*/ |
|
920 |
jobject ckULongPtrToJLongObject(JNIEnv *env, const CK_ULONG_PTR ckpValue) |
|
921 |
{ |
|
922 |
jclass jValueObjectClass; |
|
923 |
jmethodID jConstructor; |
|
924 |
jobject jValueObject; |
|
925 |
jlong jValue; |
|
926 |
||
927 |
jValueObjectClass = (*env)->FindClass(env, "java/lang/Long"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
928 |
if (jValueObjectClass == NULL) { return NULL; } |
2 | 929 |
jConstructor = (*env)->GetMethodID(env, jValueObjectClass, "<init>", "(J)V"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
930 |
if (jConstructor == NULL) { return NULL; } |
2 | 931 |
jValue = ckULongToJLong(*ckpValue); |
932 |
jValueObject = (*env)->NewObject(env, jValueObjectClass, jConstructor, jValue); |
|
933 |
||
934 |
return jValueObject ; |
|
935 |
} |
|
936 |
||
937 |
/* |
|
938 |
* converts a Java boolean object into a pointer to a CK_BBOOL value. The memory has to be |
|
939 |
* freed after use! |
|
940 |
* |
|
941 |
* @param env - used to call JNI funktions to get the value out of the Java object |
|
942 |
* @param jObject - the "java/lang/Boolean" object to convert |
|
943 |
* @return - the pointer to the new CK_BBOOL value |
|
944 |
*/ |
|
945 |
CK_BBOOL* jBooleanObjectToCKBBoolPtr(JNIEnv *env, jobject jObject) |
|
946 |
{ |
|
947 |
jclass jObjectClass; |
|
948 |
jmethodID jValueMethod; |
|
949 |
jboolean jValue; |
|
950 |
CK_BBOOL *ckpValue; |
|
951 |
||
952 |
jObjectClass = (*env)->FindClass(env, "java/lang/Boolean"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
953 |
if (jObjectClass == NULL) { return NULL; } |
2 | 954 |
jValueMethod = (*env)->GetMethodID(env, jObjectClass, "booleanValue", "()Z"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
955 |
if (jValueMethod == NULL) { return NULL; } |
2 | 956 |
jValue = (*env)->CallBooleanMethod(env, jObject, jValueMethod); |
957 |
ckpValue = (CK_BBOOL *) malloc(sizeof(CK_BBOOL)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
958 |
if (ckpValue == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
959 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
960 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
961 |
} |
2 | 962 |
*ckpValue = jBooleanToCKBBool(jValue); |
963 |
||
964 |
return ckpValue ; |
|
965 |
} |
|
966 |
||
967 |
/* |
|
968 |
* converts a Java byte object into a pointer to a CK_BYTE value. The memory has to be |
|
969 |
* freed after use! |
|
970 |
* |
|
971 |
* @param env - used to call JNI funktions to get the value out of the Java object |
|
972 |
* @param jObject - the "java/lang/Byte" object to convert |
|
973 |
* @return - the pointer to the new CK_BYTE value |
|
974 |
*/ |
|
975 |
CK_BYTE_PTR jByteObjectToCKBytePtr(JNIEnv *env, jobject jObject) |
|
976 |
{ |
|
977 |
jclass jObjectClass; |
|
978 |
jmethodID jValueMethod; |
|
979 |
jbyte jValue; |
|
980 |
CK_BYTE_PTR ckpValue; |
|
981 |
||
982 |
jObjectClass = (*env)->FindClass(env, "java/lang/Byte"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
983 |
if (jObjectClass == NULL) { return NULL; } |
2 | 984 |
jValueMethod = (*env)->GetMethodID(env, jObjectClass, "byteValue", "()B"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
985 |
if (jValueMethod == NULL) { return NULL; } |
2 | 986 |
jValue = (*env)->CallByteMethod(env, jObject, jValueMethod); |
987 |
ckpValue = (CK_BYTE_PTR) malloc(sizeof(CK_BYTE)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
988 |
if (ckpValue == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
989 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
990 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
991 |
} |
2 | 992 |
*ckpValue = jByteToCKByte(jValue); |
993 |
return ckpValue ; |
|
994 |
} |
|
995 |
||
996 |
/* |
|
997 |
* converts a Java integer object into a pointer to a CK_ULONG value. The memory has to be |
|
998 |
* freed after use! |
|
999 |
* |
|
1000 |
* @param env - used to call JNI funktions to get the value out of the Java object |
|
1001 |
* @param jObject - the "java/lang/Integer" object to convert |
|
1002 |
* @return - the pointer to the new CK_ULONG value |
|
1003 |
*/ |
|
1004 |
CK_ULONG* jIntegerObjectToCKULongPtr(JNIEnv *env, jobject jObject) |
|
1005 |
{ |
|
1006 |
jclass jObjectClass; |
|
1007 |
jmethodID jValueMethod; |
|
1008 |
jint jValue; |
|
1009 |
CK_ULONG *ckpValue; |
|
1010 |
||
1011 |
jObjectClass = (*env)->FindClass(env, "java/lang/Integer"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1012 |
if (jObjectClass == NULL) { return NULL; } |
2 | 1013 |
jValueMethod = (*env)->GetMethodID(env, jObjectClass, "intValue", "()I"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1014 |
if (jValueMethod == NULL) { return NULL; } |
2 | 1015 |
jValue = (*env)->CallIntMethod(env, jObject, jValueMethod); |
1016 |
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1017 |
if (ckpValue == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
1018 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1019 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1020 |
} |
2 | 1021 |
*ckpValue = jLongToCKLong(jValue); |
1022 |
return ckpValue ; |
|
1023 |
} |
|
1024 |
||
1025 |
/* |
|
1026 |
* converts a Java long object into a pointer to a CK_ULONG value. The memory has to be |
|
1027 |
* freed after use! |
|
1028 |
* |
|
1029 |
* @param env - used to call JNI funktions to get the value out of the Java object |
|
1030 |
* @param jObject - the "java/lang/Long" object to convert |
|
1031 |
* @return - the pointer to the new CK_ULONG value |
|
1032 |
*/ |
|
1033 |
CK_ULONG* jLongObjectToCKULongPtr(JNIEnv *env, jobject jObject) |
|
1034 |
{ |
|
1035 |
jclass jObjectClass; |
|
1036 |
jmethodID jValueMethod; |
|
1037 |
jlong jValue; |
|
1038 |
CK_ULONG *ckpValue; |
|
1039 |
||
1040 |
jObjectClass = (*env)->FindClass(env, "java/lang/Long"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1041 |
if (jObjectClass == NULL) { return NULL; } |
2 | 1042 |
jValueMethod = (*env)->GetMethodID(env, jObjectClass, "longValue", "()J"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1043 |
if (jValueMethod == NULL) { return NULL; } |
2 | 1044 |
jValue = (*env)->CallLongMethod(env, jObject, jValueMethod); |
1045 |
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1046 |
if (ckpValue == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
1047 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1048 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1049 |
} |
2 | 1050 |
*ckpValue = jLongToCKULong(jValue); |
1051 |
||
1052 |
return ckpValue ; |
|
1053 |
} |
|
1054 |
||
1055 |
/* |
|
1056 |
* converts a Java char object into a pointer to a CK_CHAR value. The memory has to be |
|
1057 |
* freed after use! |
|
1058 |
* |
|
1059 |
* @param env - used to call JNI funktions to get the value out of the Java object |
|
1060 |
* @param jObject - the "java/lang/Char" object to convert |
|
1061 |
* @return - the pointer to the new CK_CHAR value |
|
1062 |
*/ |
|
1063 |
CK_CHAR_PTR jCharObjectToCKCharPtr(JNIEnv *env, jobject jObject) |
|
1064 |
{ |
|
1065 |
jclass jObjectClass; |
|
1066 |
jmethodID jValueMethod; |
|
1067 |
jchar jValue; |
|
1068 |
CK_CHAR_PTR ckpValue; |
|
1069 |
||
1070 |
jObjectClass = (*env)->FindClass(env, "java/lang/Char"); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1071 |
if (jObjectClass == NULL) { return NULL; } |
2 | 1072 |
jValueMethod = (*env)->GetMethodID(env, jObjectClass, "charValue", "()C"); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1073 |
if (jValueMethod == NULL) { return NULL; } |
2 | 1074 |
jValue = (*env)->CallCharMethod(env, jObject, jValueMethod); |
1075 |
ckpValue = (CK_CHAR_PTR) malloc(sizeof(CK_CHAR)); |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1076 |
if (ckpValue == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
1077 |
throwOutOfMemoryError(env, 0); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1078 |
return NULL; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1079 |
} |
2 | 1080 |
*ckpValue = jCharToCKChar(jValue); |
1081 |
||
1082 |
return ckpValue ; |
|
1083 |
} |
|
1084 |
||
1085 |
/* |
|
1086 |
* converts a Java object into a pointer to CK-type or a CK-structure with the length in Bytes. |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1087 |
* The memory of the returned pointer MUST BE FREED BY CALLER! |
2 | 1088 |
* |
1089 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1090 |
* @param jObject - the Java object to convert |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1091 |
* @param ckpLength - pointer to the length (bytes) of the newly-allocated CK-value or CK-structure |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1092 |
* @return ckpObject - pointer to the newly-allocated CK-value or CK-structure |
2 | 1093 |
*/ |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1094 |
CK_VOID_PTR jObjectToPrimitiveCKObjectPtr(JNIEnv *env, jobject jObject, CK_ULONG *ckpLength) |
2 | 1095 |
{ |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1096 |
jclass jLongClass, jBooleanClass, jByteArrayClass, jCharArrayClass; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1097 |
jclass jByteClass, jDateClass, jCharacterClass, jIntegerClass; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1098 |
jclass jBooleanArrayClass, jIntArrayClass, jLongArrayClass; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1099 |
jclass jStringClass; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1100 |
jclass jObjectClass, jClassClass; |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1101 |
CK_VOID_PTR ckpObject; |
2 | 1102 |
jmethodID jMethod; |
1103 |
jobject jClassObject; |
|
1104 |
jstring jClassNameString; |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1105 |
char *classNameString, *exceptionMsgPrefix, *exceptionMsg; |
2 | 1106 |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1107 |
TRACE0("\nDEBUG: jObjectToPrimitiveCKObjectPtr"); |
2 | 1108 |
if (jObject == NULL) { |
1109 |
*ckpLength = 0; |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1110 |
return NULL; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1111 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1112 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1113 |
jLongClass = (*env)->FindClass(env, "java/lang/Long"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1114 |
if (jLongClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1115 |
if ((*env)->IsInstanceOf(env, jObject, jLongClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1116 |
ckpObject = jLongObjectToCKULongPtr(env, jObject); |
2 | 1117 |
*ckpLength = sizeof(CK_ULONG); |
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
1118 |
TRACE1("<converted long value %lu>", *((CK_ULONG *) ckpObject)); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1119 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1120 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1121 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1122 |
jBooleanClass = (*env)->FindClass(env, "java/lang/Boolean"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1123 |
if (jBooleanClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1124 |
if ((*env)->IsInstanceOf(env, jObject, jBooleanClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1125 |
ckpObject = jBooleanObjectToCKBBoolPtr(env, jObject); |
2 | 1126 |
*ckpLength = sizeof(CK_BBOOL); |
1127 |
TRACE0(" <converted boolean value "); |
|
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
1128 |
TRACE0((*((CK_BBOOL *) ckpObject) == TRUE) ? "TRUE>" : "FALSE>"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1129 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1130 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1131 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1132 |
jByteArrayClass = (*env)->FindClass(env, "[B"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1133 |
if (jByteArrayClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1134 |
if ((*env)->IsInstanceOf(env, jObject, jByteArrayClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1135 |
jByteArrayToCKByteArray(env, jObject, (CK_BYTE_PTR*) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1136 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1137 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1138 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1139 |
jCharArrayClass = (*env)->FindClass(env, "[C"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1140 |
if (jCharArrayClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1141 |
if ((*env)->IsInstanceOf(env, jObject, jCharArrayClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1142 |
jCharArrayToCKUTF8CharArray(env, jObject, (CK_UTF8CHAR_PTR*) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1143 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1144 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1145 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1146 |
jByteClass = (*env)->FindClass(env, "java/lang/Byte"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1147 |
if (jByteClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1148 |
if ((*env)->IsInstanceOf(env, jObject, jByteClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1149 |
ckpObject = jByteObjectToCKBytePtr(env, jObject); |
2 | 1150 |
*ckpLength = sizeof(CK_BYTE); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1151 |
TRACE1("<converted byte value %X>", *((CK_BYTE *) ckpObject)); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1152 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1153 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1154 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1155 |
jDateClass = (*env)->FindClass(env, CLASS_DATE); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1156 |
if (jDateClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1157 |
if ((*env)->IsInstanceOf(env, jObject, jDateClass)) { |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1158 |
ckpObject = jDateObjectToCKDatePtr(env, jObject); |
2 | 1159 |
*ckpLength = sizeof(CK_DATE); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1160 |
TRACE3("<converted date value %.4s-%.2s-%.2s>", ((CK_DATE *) ckpObject)->year, |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1161 |
((CK_DATE *) ckpObject)->month, ((CK_DATE *) ckpObject)->day); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1162 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1163 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1164 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1165 |
jCharacterClass = (*env)->FindClass(env, "java/lang/Character"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1166 |
if (jCharacterClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1167 |
if ((*env)->IsInstanceOf(env, jObject, jCharacterClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1168 |
ckpObject = jCharObjectToCKCharPtr(env, jObject); |
2 | 1169 |
*ckpLength = sizeof(CK_UTF8CHAR); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1170 |
TRACE1("<converted char value %c>", *((CK_CHAR *) ckpObject)); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1171 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1172 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1173 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1174 |
jIntegerClass = (*env)->FindClass(env, "java/lang/Integer"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1175 |
if (jIntegerClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1176 |
if ((*env)->IsInstanceOf(env, jObject, jIntegerClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1177 |
ckpObject = jIntegerObjectToCKULongPtr(env, jObject); |
2 | 1178 |
*ckpLength = sizeof(CK_ULONG); |
58281
49836127542b
8231222: fix pkcs11 P11_DEBUG guarded native traces
mbaesken
parents:
57737
diff
changeset
|
1179 |
TRACE1("<converted integer value %lu>", *((CK_ULONG *) ckpObject)); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1180 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1181 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1182 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1183 |
jBooleanArrayClass = (*env)->FindClass(env, "[Z"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1184 |
if (jBooleanArrayClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1185 |
if ((*env)->IsInstanceOf(env, jObject, jBooleanArrayClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1186 |
jBooleanArrayToCKBBoolArray(env, jObject, (CK_BBOOL**) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1187 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1188 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1189 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1190 |
jIntArrayClass = (*env)->FindClass(env, "[I"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1191 |
if (jIntArrayClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1192 |
if ((*env)->IsInstanceOf(env, jObject, jIntArrayClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1193 |
jLongArrayToCKULongArray(env, jObject, (CK_ULONG_PTR*) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1194 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1195 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1196 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1197 |
jLongArrayClass = (*env)->FindClass(env, "[J"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1198 |
if (jLongArrayClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1199 |
if ((*env)->IsInstanceOf(env, jObject, jLongArrayClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1200 |
jLongArrayToCKULongArray(env, jObject, (CK_ULONG_PTR*) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1201 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1202 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1203 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1204 |
jStringClass = (*env)->FindClass(env, "java/lang/String"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1205 |
if (jStringClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1206 |
if ((*env)->IsInstanceOf(env, jObject, jStringClass)) { |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1207 |
jStringToCKUTF8CharArray(env, jObject, (CK_UTF8CHAR_PTR*) &ckpObject, ckpLength); |
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1208 |
return ckpObject; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1209 |
} |
2 | 1210 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1211 |
/* type of jObject unknown, throw PKCS11RuntimeException */ |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1212 |
jObjectClass = (*env)->FindClass(env, "java/lang/Object"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1213 |
if (jObjectClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1214 |
jMethod = (*env)->GetMethodID(env, jObjectClass, "getClass", "()Ljava/lang/Class;"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1215 |
if (jMethod == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1216 |
jClassObject = (*env)->CallObjectMethod(env, jObject, jMethod); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1217 |
assert(jClassObject != 0); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1218 |
jClassClass = (*env)->FindClass(env, "java/lang/Class"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1219 |
if (jClassClass == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1220 |
jMethod = (*env)->GetMethodID(env, jClassClass, "getName", "()Ljava/lang/String;"); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1221 |
if (jMethod == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1222 |
jClassNameString = (jstring) |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1223 |
(*env)->CallObjectMethod(env, jClassObject, jMethod); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1224 |
assert(jClassNameString != 0); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1225 |
classNameString = (char*) |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1226 |
(*env)->GetStringUTFChars(env, jClassNameString, NULL); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1227 |
if (classNameString == NULL) { return NULL; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1228 |
exceptionMsgPrefix = "Java object of this class cannot be converted to native PKCS#11 type: "; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1229 |
exceptionMsg = (char *) |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1230 |
malloc(strlen(exceptionMsgPrefix) + strlen(classNameString) + 1); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1231 |
if (exceptionMsg == NULL) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1232 |
(*env)->ReleaseStringUTFChars(env, jClassNameString, classNameString); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
5506
diff
changeset
|
1233 |
throwOutOfMemoryError(env, 0); |
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1234 |
return NULL; |
2 | 1235 |
} |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1236 |
strcpy(exceptionMsg, exceptionMsgPrefix); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1237 |
strcat(exceptionMsg, classNameString); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1238 |
(*env)->ReleaseStringUTFChars(env, jClassNameString, classNameString); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1239 |
throwPKCS11RuntimeException(env, exceptionMsg); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1240 |
free(exceptionMsg); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1241 |
*ckpLength = 0; |
2 | 1242 |
|
1243 |
TRACE0("FINISHED\n"); |
|
55332
f492567244ab
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents:
47216
diff
changeset
|
1244 |
return NULL; |
2 | 1245 |
} |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1246 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1247 |
#ifdef P11_MEMORYDEBUG |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1248 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1249 |
#undef malloc |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1250 |
#undef calloc |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1251 |
#undef free |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1252 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1253 |
void *p11malloc(size_t c, char *file, int line) { |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1254 |
void *p = malloc(c); |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1255 |
fprintf(stdout, "malloc\t%08lX\t%lX\t%s:%d\n", ptr_to_jlong(p), c, file, line); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1256 |
fflush(stdout); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1257 |
return p; |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1258 |
} |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1259 |
|
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1260 |
void *p11calloc(size_t c, size_t s, char *file, int line) { |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1261 |
void *p = calloc(c, s); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1262 |
fprintf(stdout, "calloc\t%08lX\t%lX\t%lX\t%s:%d\n", ptr_to_jlong(p), c, s, file, line); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1263 |
fflush(stdout); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1264 |
return p; |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1265 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1266 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1267 |
void p11free(void *p, char *file, int line) { |
57737
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1268 |
fprintf(stdout, "free\t%08lX\t\t%s:%d\n", ptr_to_jlong(p), file, line); |
6bbb4af131e3
8228835: Memory leak in PKCS11 provider when using AES GCM
valeriep
parents:
55332
diff
changeset
|
1269 |
fflush(stdout); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1270 |
free(p); |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1271 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1272 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1273 |
#endif |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1274 |
|
39142
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1275 |
// prints a message to stdout if debug output is enabled |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1276 |
void printDebug(const char *format, ...) { |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1277 |
if (debug == JNI_TRUE) { |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1278 |
va_list args; |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1279 |
fprintf(stdout, "sunpkcs11: "); |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1280 |
va_start(args, format); |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1281 |
vfprintf(stdout, format, args); |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1282 |
va_end(args); |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1283 |
fflush(stdout); |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1284 |
} |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1285 |
} |
bf48a9f13cf2
8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents:
25859
diff
changeset
|
1286 |