author | jzavgren |
Wed, 07 Nov 2012 10:49:19 +0000 | |
changeset 14414 | f338be3ef659 |
parent 11356 | 898d37526be1 |
child 16012 | d10572eb1f48 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
8542 | 2 |
* Copyright (c) 2003, 2011, 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 |
/* |
|
49 |
* pkcs11wrapper.c |
|
50 |
* 18.05.2001 |
|
51 |
* |
|
52 |
* This is the implementation of the native functions of the Java to PKCS#11 interface. |
|
53 |
* All function use some helper functions to convert the JNI types to PKCS#11 types. |
|
54 |
* |
|
55 |
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> |
|
56 |
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> |
|
57 |
*/ |
|
58 |
||
59 |
||
60 |
#include "pkcs11wrapper.h" |
|
61 |
||
62 |
#include <stdio.h> |
|
63 |
#include <stdlib.h> |
|
64 |
#include <string.h> |
|
65 |
#include <assert.h> |
|
66 |
||
67 |
#include "sun_security_pkcs11_wrapper_PKCS11.h" |
|
68 |
||
69 |
/* declare file private functions */ |
|
70 |
||
71 |
void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength); |
|
72 |
||
73 |
||
74 |
/* |
|
75 |
* converts a pointer to a CK_DATE structure into a Java CK_DATE Object. |
|
76 |
* |
|
77 |
* @param env - used to call JNI funktions to create the new Java object |
|
78 |
* @param ckpValue - the pointer to the CK_DATE structure |
|
79 |
* @return - the new Java CK_DATE object |
|
80 |
*/ |
|
81 |
jobject ckDatePtrToJDateObject(JNIEnv *env, const CK_DATE *ckpDate) |
|
82 |
{ |
|
83 |
jclass jDateClass; |
|
84 |
jmethodID jCtrId; |
|
85 |
jobject jDateObject; |
|
86 |
jcharArray jYear; |
|
87 |
jcharArray jMonth; |
|
88 |
jcharArray jDay; |
|
89 |
||
90 |
/* load CK_DATE class */ |
|
91 |
jDateClass = (*env)->FindClass(env, CLASS_DATE); |
|
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
|
92 |
if (jDateClass == NULL) { return NULL; } |
2 | 93 |
|
94 |
/* load CK_DATE constructor */ |
|
95 |
jCtrId = (*env)->GetMethodID(env, jDateClass, "<init>", "([C[C[C)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
|
96 |
if (jCtrId == NULL) { return NULL; } |
2 | 97 |
|
98 |
/* prep all fields */ |
|
99 |
jYear = ckCharArrayToJCharArray(env, (CK_CHAR_PTR)(ckpDate->year), 4); |
|
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
|
100 |
if (jYear == NULL) { return NULL; } |
2 | 101 |
jMonth = ckCharArrayToJCharArray(env, (CK_CHAR_PTR)(ckpDate->month), 2); |
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
|
102 |
if (jMonth == NULL) { return NULL; } |
2 | 103 |
jDay = ckCharArrayToJCharArray(env, (CK_CHAR_PTR)(ckpDate->day), 2); |
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
|
104 |
if (jDay == NULL) { return NULL; } |
2 | 105 |
|
106 |
/* create new CK_DATE object */ |
|
107 |
jDateObject = |
|
108 |
(*env)->NewObject(env, jDateClass, jCtrId, jYear, jMonth, jDay); |
|
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
|
109 |
if (jDateObject == NULL) { return NULL; } |
2 | 110 |
|
111 |
/* free local references */ |
|
112 |
(*env)->DeleteLocalRef(env, jDateClass); |
|
113 |
(*env)->DeleteLocalRef(env, jYear); |
|
114 |
(*env)->DeleteLocalRef(env, jMonth); |
|
115 |
(*env)->DeleteLocalRef(env, jDay); |
|
116 |
||
117 |
return jDateObject ; |
|
118 |
} |
|
119 |
||
120 |
/* |
|
121 |
* converts a pointer to a CK_VERSION structure into a Java CK_VERSION Object. |
|
122 |
* |
|
123 |
* @param env - used to call JNI funktions to create the new Java object |
|
124 |
* @param ckpVersion - the pointer to the CK_VERSION structure |
|
125 |
* @return - the new Java CK_VERSION object |
|
126 |
*/ |
|
127 |
jobject ckVersionPtrToJVersion(JNIEnv *env, const CK_VERSION_PTR ckpVersion) |
|
128 |
{ |
|
129 |
jclass jVersionClass; |
|
130 |
jmethodID jCtrId; |
|
131 |
jobject jVersionObject; |
|
132 |
jint jMajor; |
|
133 |
jint jMinor; |
|
134 |
||
135 |
/* load CK_VERSION class */ |
|
136 |
jVersionClass = (*env)->FindClass(env, CLASS_VERSION); |
|
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
|
137 |
if (jVersionClass == NULL) { return NULL; } |
2 | 138 |
|
139 |
/* load CK_VERSION constructor */ |
|
140 |
jCtrId = (*env)->GetMethodID(env, jVersionClass, "<init>", "(II)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
|
141 |
if (jCtrId == NULL) { return NULL; } |
2 | 142 |
|
143 |
/* prep both fields */ |
|
144 |
jMajor = ckpVersion->major; |
|
145 |
jMinor = ckpVersion->minor; |
|
146 |
||
147 |
/* create new CK_VERSION object */ |
|
148 |
jVersionObject = |
|
149 |
(*env)->NewObject(env, jVersionClass, jCtrId, jMajor, jMinor); |
|
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
|
150 |
if (jVersionObject == NULL) { return NULL; } |
2 | 151 |
|
152 |
/* free local references */ |
|
153 |
(*env)->DeleteLocalRef(env, jVersionClass); |
|
154 |
||
155 |
return jVersionObject ; |
|
156 |
} |
|
157 |
||
158 |
/* |
|
159 |
* converts a pointer to a CK_SESSION_INFO structure into a Java CK_SESSION_INFO Object. |
|
160 |
* |
|
161 |
* @param env - used to call JNI funktions to create the new Java object |
|
162 |
* @param ckpSessionInfo - the pointer to the CK_SESSION_INFO structure |
|
163 |
* @return - the new Java CK_SESSION_INFO object |
|
164 |
*/ |
|
165 |
jobject ckSessionInfoPtrToJSessionInfo(JNIEnv *env, const CK_SESSION_INFO_PTR ckpSessionInfo) |
|
166 |
{ |
|
167 |
jclass jSessionInfoClass; |
|
168 |
jmethodID jCtrId; |
|
169 |
jobject jSessionInfoObject; |
|
170 |
jlong jSlotID; |
|
171 |
jlong jState; |
|
172 |
jlong jFlags; |
|
173 |
jlong jDeviceError; |
|
174 |
||
175 |
/* load CK_SESSION_INFO class */ |
|
176 |
jSessionInfoClass = (*env)->FindClass(env, CLASS_SESSION_INFO); |
|
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
|
177 |
if (jSessionInfoClass == NULL) { return NULL; } |
2 | 178 |
|
179 |
/* load CK_SESSION_INFO constructor */ |
|
180 |
jCtrId = (*env)->GetMethodID(env, jSessionInfoClass, "<init>", "(JJJJ)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
|
181 |
if (jCtrId == NULL) { return NULL; } |
2 | 182 |
|
183 |
/* prep all fields */ |
|
184 |
jSlotID = ckULongToJLong(ckpSessionInfo->slotID); |
|
185 |
jState = ckULongToJLong(ckpSessionInfo->state); |
|
186 |
jFlags = ckULongToJLong(ckpSessionInfo->flags); |
|
187 |
jDeviceError = ckULongToJLong(ckpSessionInfo->ulDeviceError); |
|
188 |
||
189 |
/* create new CK_SESSION_INFO object */ |
|
190 |
jSessionInfoObject = |
|
191 |
(*env)->NewObject(env, jSessionInfoClass, jCtrId, jSlotID, jState, |
|
192 |
jFlags, jDeviceError); |
|
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
|
193 |
if (jSessionInfoObject == NULL) { return NULL; } |
2 | 194 |
|
195 |
/* free local references */ |
|
196 |
(*env)->DeleteLocalRef(env, jSessionInfoClass); |
|
197 |
||
198 |
return jSessionInfoObject ; |
|
199 |
} |
|
200 |
||
201 |
/* |
|
202 |
* converts a pointer to a CK_ATTRIBUTE structure into a Java CK_ATTRIBUTE Object. |
|
203 |
* |
|
204 |
* @param env - used to call JNI funktions to create the new Java object |
|
205 |
* @param ckpAttribute - the pointer to the CK_ATTRIBUTE structure |
|
206 |
* @return - the new Java CK_ATTRIBUTE object |
|
207 |
*/ |
|
208 |
jobject ckAttributePtrToJAttribute(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute) |
|
209 |
{ |
|
210 |
jclass jAttributeClass; |
|
211 |
jmethodID jCtrId; |
|
212 |
jobject jAttributeObject; |
|
213 |
jlong jType; |
|
214 |
jobject jPValue = NULL; |
|
215 |
||
216 |
jAttributeClass = (*env)->FindClass(env, CLASS_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
|
217 |
if (jAttributeClass == NULL) { return NULL; } |
2 | 218 |
|
219 |
/* load CK_INFO constructor */ |
|
220 |
jCtrId = (*env)->GetMethodID(env, jAttributeClass, "<init>", "(JLjava/lang/Object;)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
|
221 |
if (jCtrId == NULL) { return NULL; } |
2 | 222 |
|
223 |
/* prep both fields */ |
|
224 |
jType = ckULongToJLong(ckpAttribute->type); |
|
225 |
jPValue = ckAttributeValueToJObject(env, ckpAttribute); |
|
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
|
226 |
if ((*env)->ExceptionCheck(env)) { return NULL; } |
2 | 227 |
|
228 |
/* create new CK_ATTRIBUTE object */ |
|
229 |
jAttributeObject = |
|
230 |
(*env)->NewObject(env, jAttributeClass, jCtrId, jType, jPValue); |
|
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
|
231 |
if (jAttributeObject == NULL) { return NULL; } |
2 | 232 |
|
233 |
/* free local references */ |
|
234 |
(*env)->DeleteLocalRef(env, jAttributeClass); |
|
235 |
(*env)->DeleteLocalRef(env, jPValue); |
|
236 |
||
237 |
return jAttributeObject; |
|
238 |
} |
|
239 |
||
240 |
||
241 |
/* |
|
242 |
* converts a Java CK_VERSION object into a pointer to a CK_VERSION structure |
|
243 |
* |
|
244 |
* @param env - used to call JNI funktions to get the values out of the Java object |
|
245 |
* @param jVersion - the Java CK_VERSION object to convert |
|
246 |
* @return - the pointer to the new CK_VERSION structure |
|
247 |
*/ |
|
248 |
CK_VERSION_PTR jVersionToCKVersionPtr(JNIEnv *env, jobject jVersion) |
|
249 |
{ |
|
250 |
CK_VERSION_PTR ckpVersion; |
|
251 |
jclass jVersionClass; |
|
252 |
jfieldID jFieldID; |
|
253 |
jbyte jMajor, jMinor; |
|
254 |
||
255 |
if (jVersion == NULL) { |
|
256 |
return NULL; |
|
257 |
} |
|
258 |
||
259 |
/* get CK_VERSION class */ |
|
260 |
jVersionClass = (*env)->GetObjectClass(env, jVersion); |
|
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
|
261 |
if (jVersionClass == NULL) { return NULL; } |
2 | 262 |
|
263 |
/* get Major */ |
|
264 |
jFieldID = (*env)->GetFieldID(env, jVersionClass, "major", "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
|
265 |
if (jFieldID == NULL) { return NULL; } |
2 | 266 |
jMajor = (*env)->GetByteField(env, jVersion, jFieldID); |
267 |
||
268 |
/* get Minor */ |
|
269 |
jFieldID = (*env)->GetFieldID(env, jVersionClass, "minor", "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
|
270 |
if (jFieldID == NULL) { return NULL; } |
2 | 271 |
jMinor = (*env)->GetByteField(env, jVersion, jFieldID); |
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 |
|
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 |
/* allocate memory for CK_VERSION pointer */ |
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
|
274 |
ckpVersion = (CK_VERSION_PTR) malloc(sizeof(CK_VERSION)); |
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 |
if (ckpVersion == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
} |
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 |
ckpVersion->major = jByteToCKByte(jMajor); |
2 | 280 |
ckpVersion->minor = jByteToCKByte(jMinor); |
281 |
||
282 |
return ckpVersion ; |
|
283 |
} |
|
284 |
||
285 |
||
286 |
/* |
|
287 |
* converts a Java CK_DATE object into a pointer to a CK_DATE structure |
|
288 |
* |
|
289 |
* @param env - used to call JNI funktions to get the values out of the Java object |
|
290 |
* @param jVersion - the Java CK_DATE object to convert |
|
291 |
* @return - the pointer to the new CK_DATE structure |
|
292 |
*/ |
|
293 |
CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate) |
|
294 |
{ |
|
295 |
CK_DATE * ckpDate; |
|
296 |
CK_ULONG ckLength; |
|
297 |
jclass jDateClass; |
|
298 |
jfieldID jFieldID; |
|
299 |
jobject jYear, jMonth, jDay; |
|
300 |
jchar *jTempChars; |
|
301 |
CK_ULONG i; |
|
302 |
||
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
|
303 |
if (jDate == 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
|
304 |
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
|
305 |
} |
2 | 306 |
|
307 |
/* get CK_DATE class */ |
|
308 |
jDateClass = (*env)->FindClass(env, CLASS_DATE); |
|
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
|
309 |
if (jDateClass == NULL) { return NULL; } |
2 | 310 |
|
311 |
/* get Year */ |
|
312 |
jFieldID = (*env)->GetFieldID(env, jDateClass, "year", "[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
|
313 |
if (jFieldID == NULL) { return NULL; } |
2 | 314 |
jYear = (*env)->GetObjectField(env, jDate, jFieldID); |
315 |
||
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
|
316 |
/* get Month */ |
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
|
317 |
jFieldID = (*env)->GetFieldID(env, jDateClass, "month", "[C"); |
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
|
318 |
if (jFieldID == NULL) { 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
|
319 |
jMonth = (*env)->GetObjectField(env, jDate, jFieldID); |
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
|
320 |
|
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
|
321 |
/* get Day */ |
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
|
322 |
jFieldID = (*env)->GetFieldID(env, jDateClass, "day", "[C"); |
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
|
323 |
if (jFieldID == NULL) { 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
|
324 |
jDay = (*env)->GetObjectField(env, jDate, jFieldID); |
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
|
325 |
|
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
|
326 |
/* allocate memory for CK_DATE pointer */ |
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
|
327 |
ckpDate = (CK_DATE *) malloc(sizeof(CK_DATE)); |
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
|
328 |
if (ckpDate == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
329 |
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
|
330 |
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
|
331 |
} |
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
|
332 |
|
2 | 333 |
if (jYear == NULL) { |
334 |
ckpDate->year[0] = 0; |
|
335 |
ckpDate->year[1] = 0; |
|
336 |
ckpDate->year[2] = 0; |
|
337 |
ckpDate->year[3] = 0; |
|
338 |
} else { |
|
339 |
ckLength = (*env)->GetArrayLength(env, jYear); |
|
340 |
jTempChars = (jchar*) malloc((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
|
341 |
if (jTempChars == 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
|
342 |
free(ckpDate); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
343 |
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
|
344 |
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
|
345 |
} |
2 | 346 |
(*env)->GetCharArrayRegion(env, jYear, 0, ckLength, jTempChars); |
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
|
347 |
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
|
348 |
free(ckpDate); |
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
|
349 |
free(jTempChars); |
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
|
350 |
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
|
351 |
} |
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
|
352 |
|
2 | 353 |
for (i = 0; (i < ckLength) && (i < 4) ; i++) { |
354 |
ckpDate->year[i] = jCharToCKChar(jTempChars[i]); |
|
355 |
} |
|
356 |
free(jTempChars); |
|
357 |
} |
|
358 |
||
359 |
if (jMonth == NULL) { |
|
360 |
ckpDate->month[0] = 0; |
|
361 |
ckpDate->month[1] = 0; |
|
362 |
} else { |
|
363 |
ckLength = (*env)->GetArrayLength(env, jMonth); |
|
364 |
jTempChars = (jchar*) malloc((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
|
365 |
if (jTempChars == 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
|
366 |
free(ckpDate); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
367 |
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
|
368 |
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
|
369 |
} |
2 | 370 |
(*env)->GetCharArrayRegion(env, jMonth, 0, ckLength, jTempChars); |
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
|
371 |
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
|
372 |
free(ckpDate); |
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
|
373 |
free(jTempChars); |
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
|
374 |
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
|
375 |
} |
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
|
376 |
|
11356 | 377 |
for (i = 0; (i < ckLength) && (i < 2) ; i++) { |
2 | 378 |
ckpDate->month[i] = jCharToCKChar(jTempChars[i]); |
379 |
} |
|
380 |
free(jTempChars); |
|
381 |
} |
|
382 |
||
383 |
if (jDay == NULL) { |
|
384 |
ckpDate->day[0] = 0; |
|
385 |
ckpDate->day[1] = 0; |
|
386 |
} else { |
|
387 |
ckLength = (*env)->GetArrayLength(env, jDay); |
|
388 |
jTempChars = (jchar*) malloc((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
|
389 |
if (jTempChars == 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
|
390 |
free(ckpDate); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
} |
2 | 394 |
(*env)->GetCharArrayRegion(env, jDay, 0, ckLength, jTempChars); |
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
|
395 |
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
|
396 |
free(ckpDate); |
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
|
397 |
free(jTempChars); |
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
|
398 |
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
|
399 |
} |
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
|
400 |
|
11356 | 401 |
for (i = 0; (i < ckLength) && (i < 2) ; i++) { |
2 | 402 |
ckpDate->day[i] = jCharToCKChar(jTempChars[i]); |
403 |
} |
|
404 |
free(jTempChars); |
|
405 |
} |
|
406 |
||
407 |
return ckpDate ; |
|
408 |
} |
|
409 |
||
410 |
||
411 |
/* |
|
412 |
* converts a Java CK_ATTRIBUTE object into a CK_ATTRIBUTE structure |
|
413 |
* |
|
414 |
* @param env - used to call JNI funktions to get the values out of the Java object |
|
415 |
* @param jAttribute - the Java CK_ATTRIBUTE object to convert |
|
416 |
* @return - the new CK_ATTRIBUTE structure |
|
417 |
*/ |
|
418 |
CK_ATTRIBUTE jAttributeToCKAttribute(JNIEnv *env, jobject jAttribute) |
|
419 |
{ |
|
420 |
CK_ATTRIBUTE ckAttribute; |
|
421 |
jclass jAttributeClass; |
|
422 |
jfieldID jFieldID; |
|
423 |
jlong jType; |
|
424 |
jobject jPValue; |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
425 |
memset(&ckAttribute, 0, sizeof(CK_ATTRIBUTE)); |
2 | 426 |
|
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
|
427 |
// TBD: what if jAttribute == 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
|
428 |
|
2 | 429 |
TRACE0("\nDEBUG: jAttributeToCKAttribute"); |
430 |
/* get CK_ATTRIBUTE class */ |
|
431 |
TRACE0(", getting attribute object class"); |
|
432 |
jAttributeClass = (*env)->GetObjectClass(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
|
433 |
if (jAttributeClass == NULL) { return ckAttribute; } |
2 | 434 |
|
435 |
/* get type */ |
|
436 |
TRACE0(", getting type field"); |
|
437 |
jFieldID = (*env)->GetFieldID(env, jAttributeClass, "type", "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
|
438 |
if (jFieldID == NULL) { return ckAttribute; } |
2 | 439 |
jType = (*env)->GetLongField(env, jAttribute, jFieldID); |
440 |
TRACE1(", type=0x%X", jType); |
|
441 |
||
442 |
/* get pValue */ |
|
443 |
TRACE0(", getting pValue field"); |
|
444 |
jFieldID = (*env)->GetFieldID(env, jAttributeClass, "pValue", "Ljava/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
|
445 |
if (jFieldID == NULL) { return ckAttribute; } |
2 | 446 |
jPValue = (*env)->GetObjectField(env, jAttribute, jFieldID); |
447 |
TRACE1(", pValue=%p", jPValue); |
|
448 |
||
449 |
ckAttribute.type = jLongToCKULong(jType); |
|
450 |
TRACE0(", converting pValue to primitive object"); |
|
451 |
||
452 |
/* convert the Java pValue object to a CK-type pValue pointer */ |
|
453 |
jObjectToPrimitiveCKObjectPtrPtr(env, jPValue, &(ckAttribute.pValue), &(ckAttribute.ulValueLen)); |
|
454 |
||
455 |
TRACE0("\nFINISHED\n"); |
|
456 |
||
457 |
return ckAttribute ; |
|
458 |
} |
|
459 |
||
460 |
/* |
|
461 |
* converts the Java CK_SSL3_MASTER_KEY_DERIVE_PARAMS object to a |
|
462 |
* CK_SSL3_MASTER_KEY_DERIVE_PARAMS structure |
|
463 |
* |
|
464 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
465 |
* @param jParam - the Java CK_SSL3_MASTER_KEY_DERIVE_PARAMS object to convert |
|
466 |
* @return - the new CK_SSL3_MASTER_KEY_DERIVE_PARAMS structure |
|
467 |
*/ |
|
468 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS jSsl3MasterKeyDeriveParamToCKSsl3MasterKeyDeriveParam(JNIEnv *env, jobject jParam) |
|
469 |
{ |
|
470 |
// XXX don't return structs |
|
471 |
// XXX prefetch class and field ids |
|
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
|
472 |
jclass jSsl3MasterKeyDeriveParamsClass; |
2 | 473 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS ckParam; |
474 |
jfieldID fieldID; |
|
475 |
jclass jSsl3RandomDataClass; |
|
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 |
jobject jRandomInfo, jRIClientRandom, jRIServerRandom, jVersion; |
2 | 477 |
|
478 |
/* get RandomInfo */ |
|
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 |
jSsl3MasterKeyDeriveParamsClass = (*env)->FindClass(env, CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS); |
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 |
if (jSsl3MasterKeyDeriveParamsClass == NULL) { return ckParam; } |
2 | 481 |
fieldID = (*env)->GetFieldID(env, jSsl3MasterKeyDeriveParamsClass, "RandomInfo", "Lsun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA;"); |
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
|
482 |
if (fieldID == NULL) { return ckParam; } |
2 | 483 |
jRandomInfo = (*env)->GetObjectField(env, jParam, fieldID); |
484 |
||
485 |
/* get pClientRandom and ulClientRandomLength out of RandomInfo */ |
|
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
|
486 |
jSsl3RandomDataClass = (*env)->FindClass(env, CLASS_SSL3_RANDOM_DATA); |
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
|
487 |
if (jSsl3RandomDataClass == NULL) { return ckParam; } |
2 | 488 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pClientRandom", "[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
|
489 |
if (fieldID == NULL) { return ckParam; } |
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
|
490 |
jRIClientRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 491 |
|
492 |
/* get pServerRandom and ulServerRandomLength out of RandomInfo */ |
|
493 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pServerRandom", "[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
|
494 |
if (fieldID == NULL) { return ckParam; } |
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
|
495 |
jRIServerRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 496 |
|
497 |
/* get pVersion */ |
|
498 |
fieldID = (*env)->GetFieldID(env, jSsl3MasterKeyDeriveParamsClass, "pVersion", "Lsun/security/pkcs11/wrapper/CK_VERSION;"); |
|
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
|
499 |
if (fieldID == NULL) { return ckParam; } |
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
|
500 |
jVersion = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
501 |
|
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
|
502 |
/* populate java values */ |
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
|
503 |
ckParam.pVersion = jVersionToCKVersionPtr(env, jVersion); |
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
|
504 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
505 |
jByteArrayToCKByteArray(env, jRIClientRandom, &(ckParam.RandomInfo.pClientRandom), &(ckParam.RandomInfo.ulClientRandomLen)); |
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
|
506 |
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
|
507 |
free(ckParam.pVersion); |
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
|
508 |
return ckParam; |
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 |
} |
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 |
jByteArrayToCKByteArray(env, jRIServerRandom, &(ckParam.RandomInfo.pServerRandom), &(ckParam.RandomInfo.ulServerRandomLen)); |
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
|
511 |
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
|
512 |
free(ckParam.pVersion); |
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(ckParam.RandomInfo.pClientRandom); |
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 ckParam; |
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 |
return ckParam ; |
|
518 |
} |
|
519 |
||
520 |
||
521 |
/* |
|
522 |
* converts the Java CK_TLS_PRF_PARAMS object to a CK_TLS_PRF_PARAMS structure |
|
523 |
*/ |
|
524 |
CK_TLS_PRF_PARAMS jTlsPrfParamsToCKTlsPrfParam(JNIEnv *env, jobject jParam) |
|
525 |
{ |
|
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
|
526 |
jclass jTlsPrfParamsClass; |
2 | 527 |
CK_TLS_PRF_PARAMS ckParam; |
528 |
jfieldID fieldID; |
|
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
|
529 |
jobject jSeed, jLabel, jOutput; |
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
|
530 |
|
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
|
531 |
// TBD: what if jParam == NULL?! |
2 | 532 |
|
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
|
533 |
/* get pSeed */ |
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
|
534 |
jTlsPrfParamsClass = (*env)->FindClass(env, CLASS_TLS_PRF_PARAMS); |
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
|
535 |
if (jTlsPrfParamsClass == NULL) { return ckParam; } |
2 | 536 |
fieldID = (*env)->GetFieldID(env, jTlsPrfParamsClass, "pSeed", "[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
|
537 |
if (fieldID == NULL) { return ckParam; } |
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
|
538 |
jSeed = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 539 |
|
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
|
540 |
/* get pLabel */ |
2 | 541 |
fieldID = (*env)->GetFieldID(env, jTlsPrfParamsClass, "pLabel", "[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
|
542 |
if (fieldID == NULL) { return ckParam; } |
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
|
543 |
jLabel = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
544 |
|
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
|
545 |
/* get pOutput */ |
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
|
546 |
fieldID = (*env)->GetFieldID(env, jTlsPrfParamsClass, "pOutput", "[B"); |
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
|
547 |
if (fieldID == NULL) { return ckParam; } |
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
|
548 |
jOutput = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 549 |
|
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
|
550 |
/* populate java values */ |
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
|
551 |
jByteArrayToCKByteArray(env, jSeed, &(ckParam.pSeed), &(ckParam.ulSeedLen)); |
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
|
552 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
553 |
jByteArrayToCKByteArray(env, jLabel, &(ckParam.pLabel), &(ckParam.ulLabelLen)); |
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 ((*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
|
555 |
free(ckParam.pSeed); |
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 ckParam; |
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 |
ckParam.pulOutputLen = 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
|
559 |
if (ckParam.pulOutputLen == 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
|
560 |
free(ckParam.pSeed); |
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 |
free(ckParam.pLabel); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
562 |
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
|
563 |
return ckParam; |
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
|
564 |
} |
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 |
jByteArrayToCKByteArray(env, jOutput, &(ckParam.pOutput), ckParam.pulOutputLen); |
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 |
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
|
567 |
free(ckParam.pSeed); |
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 |
free(ckParam.pLabel); |
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 |
free(ckParam.pulOutputLen); |
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
|
570 |
return ckParam; |
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
|
571 |
} |
2 | 572 |
|
573 |
return ckParam ; |
|
574 |
} |
|
575 |
||
576 |
/* |
|
577 |
* converts the Java CK_SSL3_KEY_MAT_PARAMS object to a CK_SSL3_KEY_MAT_PARAMS structure |
|
578 |
* |
|
579 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
580 |
* @param jParam - the Java CK_SSL3_KEY_MAT_PARAMS object to convert |
|
581 |
* @return - the new CK_SSL3_KEY_MAT_PARAMS structure |
|
582 |
*/ |
|
583 |
CK_SSL3_KEY_MAT_PARAMS jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject jParam) |
|
584 |
{ |
|
585 |
// XXX don't return structs |
|
586 |
// XXX prefetch class and field ids |
|
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
|
587 |
jclass jSsl3KeyMatParamsClass, jSsl3RandomDataClass, jSsl3KeyMatOutClass; |
2 | 588 |
CK_SSL3_KEY_MAT_PARAMS ckParam; |
589 |
jfieldID fieldID; |
|
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
|
590 |
jlong jMacSizeInBits, jKeySizeInBits, jIVSizeInBits; |
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
|
591 |
jboolean jIsExport; |
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
|
592 |
jobject jRandomInfo, jRIClientRandom, jRIServerRandom; |
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
|
593 |
jobject jReturnedKeyMaterial, jRMIvClient, jRMIvServer; |
2 | 594 |
CK_ULONG ckTemp; |
595 |
||
596 |
/* get ulMacSizeInBits */ |
|
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
|
597 |
jSsl3KeyMatParamsClass = (*env)->FindClass(env, CLASS_SSL3_KEY_MAT_PARAMS); |
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 |
if (jSsl3KeyMatParamsClass == NULL) { return ckParam; } |
2 | 599 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "ulMacSizeInBits", "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
|
600 |
if (fieldID == NULL) { return ckParam; } |
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 |
jMacSizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 602 |
|
603 |
/* get ulKeySizeInBits */ |
|
604 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "ulKeySizeInBits", "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
|
605 |
if (fieldID == NULL) { return ckParam; } |
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
|
606 |
jKeySizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 607 |
|
608 |
/* get ulIVSizeInBits */ |
|
609 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "ulIVSizeInBits", "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
|
610 |
if (fieldID == NULL) { return ckParam; } |
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 |
jIVSizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 612 |
|
613 |
/* get bIsExport */ |
|
614 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "bIsExport", "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
|
615 |
if (fieldID == NULL) { return ckParam; } |
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
|
616 |
jIsExport = (*env)->GetBooleanField(env, jParam, fieldID); |
2 | 617 |
|
618 |
/* get RandomInfo */ |
|
619 |
jSsl3RandomDataClass = (*env)->FindClass(env, CLASS_SSL3_RANDOM_DATA); |
|
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
|
620 |
if (jSsl3RandomDataClass == NULL) { return ckParam; } |
2 | 621 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "RandomInfo", "Lsun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA;"); |
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
|
622 |
if (fieldID == NULL) { return ckParam; } |
2 | 623 |
jRandomInfo = (*env)->GetObjectField(env, jParam, fieldID); |
624 |
||
625 |
/* get pClientRandom and ulClientRandomLength out of RandomInfo */ |
|
626 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pClientRandom", "[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
|
627 |
if (fieldID == NULL) { return ckParam; } |
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
|
628 |
jRIClientRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 629 |
|
630 |
/* get pServerRandom and ulServerRandomLength out of RandomInfo */ |
|
631 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pServerRandom", "[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
|
632 |
if (fieldID == NULL) { return ckParam; } |
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
|
633 |
jRIServerRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 634 |
|
635 |
/* get pReturnedKeyMaterial */ |
|
636 |
jSsl3KeyMatOutClass = (*env)->FindClass(env, CLASS_SSL3_KEY_MAT_OUT); |
|
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
|
637 |
if (jSsl3KeyMatOutClass == NULL) { return ckParam; } |
2 | 638 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatParamsClass, "pReturnedKeyMaterial", "Lsun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_OUT;"); |
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
|
639 |
if (fieldID == NULL) { return ckParam; } |
2 | 640 |
jReturnedKeyMaterial = (*env)->GetObjectField(env, jParam, fieldID); |
641 |
||
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
|
642 |
/* get pIVClient out of pReturnedKeyMaterial */ |
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 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatOutClass, "pIVClient", "[B"); |
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 |
if (fieldID == NULL) { return ckParam; } |
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 |
jRMIvClient = (*env)->GetObjectField(env, jReturnedKeyMaterial, fieldID); |
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 |
/* get pIVServer out of pReturnedKeyMaterial */ |
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
|
648 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatOutClass, "pIVServer", "[B"); |
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 (fieldID == NULL) { return ckParam; } |
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 |
jRMIvServer = (*env)->GetObjectField(env, jReturnedKeyMaterial, fieldID); |
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
|
651 |
|
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 |
/* populate java values */ |
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 |
ckParam.ulMacSizeInBits = jLongToCKULong(jMacSizeInBits); |
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
|
654 |
ckParam.ulKeySizeInBits = jLongToCKULong(jKeySizeInBits); |
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
|
655 |
ckParam.ulIVSizeInBits = jLongToCKULong(jIVSizeInBits); |
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
|
656 |
ckParam.bIsExport = jBooleanToCKBBool(jIsExport); |
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
|
657 |
jByteArrayToCKByteArray(env, jRIClientRandom, &(ckParam.RandomInfo.pClientRandom), &(ckParam.RandomInfo.ulClientRandomLen)); |
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
|
658 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
659 |
jByteArrayToCKByteArray(env, jRIServerRandom, &(ckParam.RandomInfo.pServerRandom), &(ckParam.RandomInfo.ulServerRandomLen)); |
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
|
660 |
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
|
661 |
free(ckParam.RandomInfo.pClientRandom); |
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
|
662 |
return ckParam; |
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
|
663 |
} |
2 | 664 |
/* allocate memory for pRetrunedKeyMaterial */ |
665 |
ckParam.pReturnedKeyMaterial = (CK_SSL3_KEY_MAT_OUT_PTR) malloc(sizeof(CK_SSL3_KEY_MAT_OUT)); |
|
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
|
666 |
if (ckParam.pReturnedKeyMaterial == 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
|
667 |
free(ckParam.RandomInfo.pClientRandom); |
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
|
668 |
free(ckParam.RandomInfo.pServerRandom); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
669 |
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
|
670 |
return ckParam; |
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
|
671 |
} |
2 | 672 |
|
673 |
// the handles are output params only, no need to fetch them from Java |
|
674 |
ckParam.pReturnedKeyMaterial->hClientMacSecret = 0; |
|
675 |
ckParam.pReturnedKeyMaterial->hServerMacSecret = 0; |
|
676 |
ckParam.pReturnedKeyMaterial->hClientKey = 0; |
|
677 |
ckParam.pReturnedKeyMaterial->hServerKey = 0; |
|
678 |
||
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
|
679 |
jByteArrayToCKByteArray(env, jRMIvClient, &(ckParam.pReturnedKeyMaterial->pIVClient), &ckTemp); |
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 ((*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
|
681 |
free(ckParam.RandomInfo.pClientRandom); |
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
|
682 |
free(ckParam.RandomInfo.pServerRandom); |
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
|
683 |
free(ckParam.pReturnedKeyMaterial); |
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 |
return ckParam; |
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 |
} |
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
|
686 |
jByteArrayToCKByteArray(env, jRMIvServer, &(ckParam.pReturnedKeyMaterial->pIVServer), &ckTemp); |
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 |
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
|
688 |
free(ckParam.RandomInfo.pClientRandom); |
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
|
689 |
free(ckParam.RandomInfo.pServerRandom); |
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
|
690 |
free(ckParam.pReturnedKeyMaterial); |
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
|
691 |
free(ckParam.pReturnedKeyMaterial->pIVClient); |
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
|
692 |
return ckParam; |
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
|
693 |
} |
2 | 694 |
|
695 |
return ckParam ; |
|
696 |
} |
|
697 |
||
698 |
/* |
|
8542 | 699 |
* converts the Java CK_AES_CTR_PARAMS object to a CK_AES_CTR_PARAMS structure |
700 |
* |
|
701 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
702 |
* @param jParam - the Java CK_AES_CTR_PARAMS object to convert |
|
703 |
* @param ckpParam - pointer to the new CK_AES_CTR_PARAMS structure |
|
704 |
*/ |
|
705 |
void jAesCtrParamsToCKAesCtrParam(JNIEnv *env, jobject jParam, |
|
706 |
CK_AES_CTR_PARAMS_PTR ckpParam) { |
|
707 |
jclass jAesCtrParamsClass; |
|
708 |
jfieldID fieldID; |
|
709 |
jlong jCounterBits; |
|
710 |
jobject jCb; |
|
711 |
CK_BYTE_PTR ckBytes; |
|
712 |
CK_ULONG ckTemp; |
|
713 |
||
714 |
/* get ulCounterBits */ |
|
715 |
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS); |
|
716 |
if (jAesCtrParamsClass == NULL) { return; } |
|
717 |
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "ulCounterBits", "J"); |
|
718 |
if (fieldID == NULL) { return; } |
|
719 |
jCounterBits = (*env)->GetLongField(env, jParam, fieldID); |
|
720 |
||
721 |
/* get cb */ |
|
722 |
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "cb", "[B"); |
|
723 |
if (fieldID == NULL) { return; } |
|
724 |
jCb = (*env)->GetObjectField(env, jParam, fieldID); |
|
725 |
||
726 |
/* populate java values */ |
|
727 |
ckpParam->ulCounterBits = jLongToCKULong(jCounterBits); |
|
728 |
jByteArrayToCKByteArray(env, jCb, &ckBytes, &ckTemp); |
|
729 |
if ((*env)->ExceptionCheck(env)) { return; } |
|
730 |
if (ckTemp != 16) { |
|
731 |
TRACE1("ERROR: WRONG CTR IV LENGTH %d", ckTemp); |
|
732 |
} else { |
|
733 |
memcpy(ckpParam->cb, ckBytes, ckTemp); |
|
734 |
free(ckBytes); |
|
735 |
} |
|
736 |
} |
|
737 |
||
738 |
/* |
|
2 | 739 |
* converts a Java CK_MECHANISM object into a CK_MECHANISM structure |
740 |
* |
|
741 |
* @param env - used to call JNI funktions to get the values out of the Java object |
|
742 |
* @param jMechanism - the Java CK_MECHANISM object to convert |
|
743 |
* @return - the new CK_MECHANISM structure |
|
744 |
*/ |
|
745 |
void jMechanismToCKMechanism(JNIEnv *env, jobject jMechanism, CK_MECHANISM_PTR ckMechanismPtr) |
|
746 |
{ |
|
747 |
jlong jMechanismType = (*env)->GetLongField(env, jMechanism, mech_mechanismID); |
|
748 |
jobject jParameter = (*env)->GetObjectField(env, jMechanism, mech_pParameterID); |
|
749 |
||
750 |
(*ckMechanismPtr).mechanism = jLongToCKULong(jMechanismType); |
|
751 |
||
752 |
/* convert the specific Java mechanism parameter object to a pointer to a CK-type mechanism |
|
753 |
* structure |
|
754 |
*/ |
|
755 |
if (jParameter == NULL) { |
|
756 |
(*ckMechanismPtr).pParameter = NULL; |
|
757 |
(*ckMechanismPtr).ulParameterLen = 0; |
|
758 |
} else { |
|
759 |
jMechanismParameterToCKMechanismParameter(env, jParameter, &(*ckMechanismPtr).pParameter, &(*ckMechanismPtr).ulParameterLen); |
|
760 |
} |
|
761 |
} |
|
762 |
||
763 |
/* |
|
764 |
* the following functions convert Attribute and Mechanism value pointers |
|
765 |
* |
|
766 |
* jobject ckAttributeValueToJObject(JNIEnv *env, |
|
767 |
* const CK_ATTRIBUTE_PTR ckpAttribute); |
|
768 |
* |
|
769 |
* void jObjectToPrimitiveCKObjectPtrPtr(JNIEnv *env, |
|
770 |
* jobject jObject, |
|
771 |
* CK_VOID_PTR *ckpObjectPtr, |
|
772 |
* CK_ULONG *pLength); |
|
773 |
* |
|
774 |
* void jMechanismParameterToCKMechanismParameter(JNIEnv *env, |
|
775 |
* jobject jParam, |
|
776 |
* CK_VOID_PTR *ckpParamPtr, |
|
777 |
* CK_ULONG *ckpLength); |
|
778 |
* |
|
779 |
* These functions are used if a PKCS#11 mechanism or attribute structure gets |
|
780 |
* convertet to a Java attribute or mechanism object or vice versa. |
|
781 |
* |
|
782 |
* ckAttributeValueToJObject converts a PKCS#11 attribute value pointer to a Java |
|
783 |
* object depending on the type of the Attribute. A PKCS#11 attribute value can |
|
784 |
* be a CK_ULONG, CK_BYTE[], CK_CHAR[], big integer, CK_BBOOL, CK_UTF8CHAR[], |
|
785 |
* CK_DATE or CK_FLAGS that gets converted to a corresponding Java object. |
|
786 |
* |
|
787 |
* jObjectToPrimitiveCKObjectPtrPtr is used by jAttributeToCKAttributePtr for |
|
788 |
* converting the Java attribute value to a PKCS#11 attribute value pointer. |
|
789 |
* For now only primitive datatypes and arrays of primitive datatypes can get |
|
790 |
* converted. Otherwise this function throws a PKCS#11Exception with the |
|
791 |
* errorcode CKR_VENDOR_DEFINED. |
|
792 |
* |
|
793 |
* jMechanismParameterToCKMechanismParameter converts a Java mechanism parameter |
|
794 |
* to a PKCS#11 mechanism parameter. First this function determines what mechanism |
|
795 |
* parameter the Java object is, then it allocates the memory for the new PKCS#11 |
|
796 |
* structure and calls the corresponding function to convert the Java object to |
|
797 |
* a PKCS#11 mechanism parameter structure. |
|
798 |
*/ |
|
799 |
||
800 |
/* |
|
801 |
* converts the pValue of a CK_ATTRIBUTE structure into a Java Object by checking the type |
|
802 |
* of the attribute. |
|
803 |
* |
|
804 |
* @param env - used to call JNI funktions to create the new Java object |
|
805 |
* @param ckpAttribute - the pointer to the CK_ATTRIBUTE structure that contains the type |
|
806 |
* and the pValue to convert |
|
807 |
* @return - the new Java object of the CK-type pValue |
|
808 |
*/ |
|
809 |
jobject ckAttributeValueToJObject(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute) |
|
810 |
{ |
|
811 |
jint jValueLength; |
|
812 |
jobject jValueObject = NULL; |
|
813 |
||
814 |
jValueLength = ckULongToJInt(ckpAttribute->ulValueLen); |
|
815 |
||
816 |
if ((jValueLength <= 0) || (ckpAttribute->pValue == NULL)) { |
|
817 |
return NULL ; |
|
818 |
} |
|
819 |
||
820 |
switch(ckpAttribute->type) { |
|
821 |
case CKA_CLASS: |
|
822 |
/* value CK_OBJECT_CLASS, defacto a CK_ULONG */ |
|
823 |
case CKA_KEY_TYPE: |
|
824 |
/* value CK_KEY_TYPE, defacto a CK_ULONG */ |
|
825 |
case CKA_CERTIFICATE_TYPE: |
|
826 |
/* value CK_CERTIFICATE_TYPE, defacto a CK_ULONG */ |
|
827 |
case CKA_HW_FEATURE_TYPE: |
|
828 |
/* value CK_HW_FEATURE_TYPE, defacto a CK_ULONG */ |
|
829 |
case CKA_MODULUS_BITS: |
|
830 |
case CKA_VALUE_BITS: |
|
831 |
case CKA_VALUE_LEN: |
|
832 |
case CKA_KEY_GEN_MECHANISM: |
|
833 |
case CKA_PRIME_BITS: |
|
834 |
case CKA_SUB_PRIME_BITS: |
|
835 |
/* value CK_ULONG */ |
|
836 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
837 |
break; |
|
838 |
||
839 |
/* can be CK_BYTE[],CK_CHAR[] or big integer; defacto always CK_BYTE[] */ |
|
840 |
case CKA_VALUE: |
|
841 |
case CKA_OBJECT_ID: |
|
842 |
case CKA_SUBJECT: |
|
843 |
case CKA_ID: |
|
844 |
case CKA_ISSUER: |
|
845 |
case CKA_SERIAL_NUMBER: |
|
846 |
case CKA_OWNER: |
|
847 |
case CKA_AC_ISSUER: |
|
848 |
case CKA_ATTR_TYPES: |
|
849 |
case CKA_ECDSA_PARAMS: |
|
850 |
/* CKA_EC_PARAMS is the same, these two are equivalent */ |
|
851 |
case CKA_EC_POINT: |
|
852 |
case CKA_PRIVATE_EXPONENT: |
|
853 |
case CKA_PRIME_1: |
|
854 |
case CKA_PRIME_2: |
|
855 |
case CKA_EXPONENT_1: |
|
856 |
case CKA_EXPONENT_2: |
|
857 |
case CKA_COEFFICIENT: |
|
858 |
/* value CK_BYTE[] */ |
|
859 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
860 |
break; |
|
861 |
||
862 |
case CKA_RESET_ON_INIT: |
|
863 |
case CKA_HAS_RESET: |
|
864 |
case CKA_TOKEN: |
|
865 |
case CKA_PRIVATE: |
|
866 |
case CKA_MODIFIABLE: |
|
867 |
case CKA_DERIVE: |
|
868 |
case CKA_LOCAL: |
|
869 |
case CKA_ENCRYPT: |
|
870 |
case CKA_VERIFY: |
|
871 |
case CKA_VERIFY_RECOVER: |
|
872 |
case CKA_WRAP: |
|
873 |
case CKA_SENSITIVE: |
|
874 |
case CKA_SECONDARY_AUTH: |
|
875 |
case CKA_DECRYPT: |
|
876 |
case CKA_SIGN: |
|
877 |
case CKA_SIGN_RECOVER: |
|
878 |
case CKA_UNWRAP: |
|
879 |
case CKA_EXTRACTABLE: |
|
880 |
case CKA_ALWAYS_SENSITIVE: |
|
881 |
case CKA_NEVER_EXTRACTABLE: |
|
882 |
case CKA_TRUSTED: |
|
883 |
/* value CK_BBOOL */ |
|
884 |
jValueObject = ckBBoolPtrToJBooleanObject(env, (CK_BBOOL*) ckpAttribute->pValue); |
|
885 |
break; |
|
886 |
||
887 |
case CKA_LABEL: |
|
888 |
case CKA_APPLICATION: |
|
889 |
/* value RFC 2279 (UTF-8) string */ |
|
890 |
jValueObject = ckUTF8CharArrayToJCharArray(env, (CK_UTF8CHAR*) ckpAttribute->pValue, jValueLength); |
|
891 |
break; |
|
892 |
||
893 |
case CKA_START_DATE: |
|
894 |
case CKA_END_DATE: |
|
895 |
/* value CK_DATE */ |
|
896 |
jValueObject = ckDatePtrToJDateObject(env, (CK_DATE*) ckpAttribute->pValue); |
|
897 |
break; |
|
898 |
||
899 |
case CKA_MODULUS: |
|
900 |
case CKA_PUBLIC_EXPONENT: |
|
901 |
case CKA_PRIME: |
|
902 |
case CKA_SUBPRIME: |
|
903 |
case CKA_BASE: |
|
904 |
/* value big integer, i.e. CK_BYTE[] */ |
|
905 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
906 |
break; |
|
907 |
||
908 |
case CKA_AUTH_PIN_FLAGS: |
|
909 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
910 |
/* value FLAGS, defacto a CK_ULONG */ |
|
911 |
break; |
|
912 |
||
913 |
case CKA_VENDOR_DEFINED: |
|
914 |
/* we make a CK_BYTE[] out of this */ |
|
915 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
916 |
break; |
|
917 |
||
918 |
// Netscape trust attributes |
|
919 |
case CKA_NETSCAPE_TRUST_SERVER_AUTH: |
|
920 |
case CKA_NETSCAPE_TRUST_CLIENT_AUTH: |
|
921 |
case CKA_NETSCAPE_TRUST_CODE_SIGNING: |
|
922 |
case CKA_NETSCAPE_TRUST_EMAIL_PROTECTION: |
|
923 |
/* value CK_ULONG */ |
|
924 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
925 |
break; |
|
926 |
||
927 |
default: |
|
928 |
/* we make a CK_BYTE[] out of this */ |
|
929 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
930 |
break; |
|
931 |
} |
|
932 |
||
933 |
return jValueObject ; |
|
934 |
} |
|
935 |
||
936 |
/* |
|
937 |
* the following functions convert a Java mechanism parameter object to a PKCS#11 |
|
938 |
* mechanism parameter structure |
|
939 |
* |
|
940 |
* CK_<Param>_PARAMS j<Param>ParamToCK<Param>Param(JNIEnv *env, |
|
941 |
* jobject jParam); |
|
942 |
* |
|
943 |
* These functions get a Java object, that must be the right Java mechanism |
|
944 |
* object and they return the new PKCS#11 mechanism parameter structure. |
|
945 |
* Every field of the Java object is retrieved, gets converted to a corresponding |
|
946 |
* PKCS#11 type and is set in the new PKCS#11 structure. |
|
947 |
*/ |
|
948 |
||
949 |
/* |
|
950 |
* converts the given Java mechanism parameter to a CK mechanism parameter structure |
|
951 |
* and store the length in bytes in the length variable. |
|
952 |
* The memory of *ckpParamPtr has to be freed after use! |
|
953 |
* |
|
954 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
955 |
* @param jParam - the Java mechanism parameter object to convert |
|
956 |
* @param ckpParamPtr - the reference of the new pointer to the new CK mechanism parameter |
|
957 |
* structure |
|
958 |
* @param ckpLength - the reference of the length in bytes of the new CK mechanism parameter |
|
959 |
* structure |
|
960 |
*/ |
|
961 |
void jMechanismParameterToCKMechanismParameter(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength) |
|
962 |
{ |
|
963 |
if (jParam == NULL) { |
|
964 |
*ckpParamPtr = NULL; |
|
965 |
*ckpLength = 0; |
|
966 |
} else if ((*env)->IsInstanceOf(env, jParam, jByteArrayClass)) { |
|
967 |
jByteArrayToCKByteArray(env, jParam, (CK_BYTE_PTR *)ckpParamPtr, ckpLength); |
|
968 |
} else if ((*env)->IsInstanceOf(env, jParam, jLongClass)) { |
|
969 |
*ckpParamPtr = jLongObjectToCKULongPtr(env, jParam); |
|
970 |
*ckpLength = sizeof(CK_ULONG); |
|
971 |
} else { |
|
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
|
972 |
TRACE0("\nSLOW PATH jMechanismParameterToCKMechanismParameter\n"); |
2 | 973 |
jMechanismParameterToCKMechanismParameterSlow(env, jParam, ckpParamPtr, ckpLength); |
974 |
} |
|
975 |
} |
|
976 |
||
977 |
void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength) |
|
978 |
{ |
|
979 |
/* get all Java mechanism parameter classes */ |
|
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
|
980 |
jclass jVersionClass, jSsl3MasterKeyDeriveParamsClass, jSsl3KeyMatParamsClass; |
8542 | 981 |
jclass jTlsPrfParamsClass, jAesCtrParamsClass, jRsaPkcsOaepParamsClass; |
982 |
jclass jPbeParamsClass, jPkcs5Pbkd2ParamsClass, jRsaPkcsPssParamsClass; |
|
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 |
jclass jEcdh1DeriveParamsClass, jEcdh2DeriveParamsClass; |
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
|
984 |
jclass jX942Dh1DeriveParamsClass, jX942Dh2DeriveParamsClass; |
2 | 985 |
TRACE0("\nDEBUG: jMechanismParameterToCKMechanismParameter"); |
986 |
||
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
|
987 |
/* most common cases, i.e. NULL/byte[]/long, are already handled by |
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 |
* jMechanismParameterToCKMechanismParameter before calling this method. |
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
|
989 |
*/ |
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 |
jVersionClass = (*env)->FindClass(env, CLASS_VERSION); |
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 |
if (jVersionClass == NULL) { return; } |
2 | 992 |
if ((*env)->IsInstanceOf(env, jParam, jVersionClass)) { |
993 |
/* |
|
994 |
* CK_VERSION used by CKM_SSL3_PRE_MASTER_KEY_GEN |
|
995 |
*/ |
|
996 |
CK_VERSION_PTR ckpParam; |
|
997 |
||
998 |
/* convert jParameter to CKParameter */ |
|
999 |
ckpParam = jVersionToCKVersionPtr(env, jParam); |
|
1000 |
||
1001 |
/* get length and pointer of parameter */ |
|
1002 |
*ckpLength = sizeof(CK_VERSION); |
|
1003 |
*ckpParamPtr = ckpParam; |
|
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
|
1004 |
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
|
1005 |
} |
2 | 1006 |
|
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
|
1007 |
jSsl3MasterKeyDeriveParamsClass = (*env)->FindClass(env, CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS); |
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
|
1008 |
if (jSsl3MasterKeyDeriveParamsClass == 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
|
1009 |
if ((*env)->IsInstanceOf(env, jParam, jSsl3MasterKeyDeriveParamsClass)) { |
2 | 1010 |
/* |
1011 |
* CK_SSL3_MASTER_KEY_DERIVE_PARAMS |
|
1012 |
*/ |
|
1013 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR ckpParam; |
|
1014 |
||
1015 |
ckpParam = (CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR) malloc(sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS)); |
|
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
|
1016 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1017 |
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
|
1018 |
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
|
1019 |
} |
2 | 1020 |
|
1021 |
/* convert jParameter to CKParameter */ |
|
1022 |
*ckpParam = jSsl3MasterKeyDeriveParamToCKSsl3MasterKeyDeriveParam(env, jParam); |
|
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
|
1023 |
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
|
1024 |
free(ckpParam); |
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
|
1025 |
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
|
1026 |
} |
2 | 1027 |
|
1028 |
/* get length and pointer of parameter */ |
|
1029 |
*ckpLength = sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS); |
|
1030 |
*ckpParamPtr = ckpParam; |
|
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
|
1031 |
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
|
1032 |
} |
2 | 1033 |
|
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
|
1034 |
jSsl3KeyMatParamsClass = (*env)->FindClass(env, CLASS_SSL3_KEY_MAT_PARAMS); |
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
|
1035 |
if (jSsl3KeyMatParamsClass == 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
|
1036 |
if ((*env)->IsInstanceOf(env, jParam, jSsl3KeyMatParamsClass)) { |
2 | 1037 |
/* |
1038 |
* CK_SSL3_KEY_MAT_PARAMS |
|
1039 |
*/ |
|
1040 |
CK_SSL3_KEY_MAT_PARAMS_PTR ckpParam; |
|
1041 |
||
1042 |
ckpParam = (CK_SSL3_KEY_MAT_PARAMS_PTR) malloc(sizeof(CK_SSL3_KEY_MAT_PARAMS)); |
|
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 (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1044 |
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
|
1045 |
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
|
1046 |
} |
2 | 1047 |
|
1048 |
/* convert jParameter to CKParameter */ |
|
1049 |
*ckpParam = jSsl3KeyMatParamToCKSsl3KeyMatParam(env, jParam); |
|
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
|
1050 |
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
|
1051 |
free(ckpParam); |
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
|
1052 |
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
|
1053 |
} |
2 | 1054 |
|
1055 |
/* get length and pointer of parameter */ |
|
1056 |
*ckpLength = sizeof(CK_SSL3_KEY_MAT_PARAMS); |
|
1057 |
*ckpParamPtr = ckpParam; |
|
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
|
1058 |
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
|
1059 |
} |
2 | 1060 |
|
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
|
1061 |
jTlsPrfParamsClass = (*env)->FindClass(env, CLASS_TLS_PRF_PARAMS); |
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
|
1062 |
if (jTlsPrfParamsClass == 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
|
1063 |
if ((*env)->IsInstanceOf(env, jParam, jTlsPrfParamsClass)) { |
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
|
1064 |
/* |
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
|
1065 |
* CK_TLS_PRF_PARAMS |
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
|
1066 |
*/ |
2 | 1067 |
CK_TLS_PRF_PARAMS_PTR ckpParam; |
1068 |
||
1069 |
ckpParam = (CK_TLS_PRF_PARAMS_PTR) malloc(sizeof(CK_TLS_PRF_PARAMS)); |
|
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
|
1070 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1071 |
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
|
1072 |
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
|
1073 |
} |
2 | 1074 |
|
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
|
1075 |
/* convert jParameter to CKParameter */ |
2 | 1076 |
*ckpParam = jTlsPrfParamsToCKTlsPrfParam(env, jParam); |
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
|
1077 |
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
|
1078 |
free(ckpParam); |
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 |
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
|
1080 |
} |
2 | 1081 |
|
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
|
1082 |
/* get length and pointer of parameter */ |
2 | 1083 |
*ckpLength = sizeof(CK_TLS_PRF_PARAMS); |
1084 |
*ckpParamPtr = ckpParam; |
|
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
|
1085 |
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
|
1086 |
} |
2 | 1087 |
|
8542 | 1088 |
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS); |
1089 |
if (jAesCtrParamsClass == NULL) { return; } |
|
1090 |
if ((*env)->IsInstanceOf(env, jParam, jAesCtrParamsClass)) { |
|
1091 |
/* |
|
1092 |
* CK_AES_CTR_PARAMS |
|
1093 |
*/ |
|
1094 |
CK_AES_CTR_PARAMS_PTR ckpParam; |
|
1095 |
||
1096 |
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS)); |
|
1097 |
if (ckpParam == NULL) { |
|
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1098 |
throwOutOfMemoryError(env, 0); |
8542 | 1099 |
return; |
1100 |
} |
|
1101 |
||
1102 |
/* convert jParameter to CKParameter */ |
|
1103 |
jAesCtrParamsToCKAesCtrParam(env, jParam, ckpParam); |
|
1104 |
if ((*env)->ExceptionCheck(env)) { |
|
1105 |
free(ckpParam); |
|
1106 |
return; |
|
1107 |
} |
|
1108 |
||
1109 |
/* get length and pointer of parameter */ |
|
1110 |
*ckpLength = sizeof(CK_AES_CTR_PARAMS); |
|
1111 |
*ckpParamPtr = ckpParam; |
|
1112 |
return; |
|
1113 |
} |
|
1114 |
||
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 |
jRsaPkcsOaepParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_OAEP_PARAMS); |
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
|
1116 |
if (jRsaPkcsOaepParamsClass == 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
|
1117 |
if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsOaepParamsClass)) { |
2 | 1118 |
/* |
1119 |
* CK_RSA_PKCS_OAEP_PARAMS |
|
1120 |
*/ |
|
1121 |
CK_RSA_PKCS_OAEP_PARAMS_PTR ckpParam; |
|
1122 |
||
1123 |
ckpParam = (CK_RSA_PKCS_OAEP_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_OAEP_PARAMS)); |
|
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 (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1125 |
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
|
1126 |
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
|
1127 |
} |
2 | 1128 |
|
1129 |
/* convert jParameter to CKParameter */ |
|
1130 |
*ckpParam = jRsaPkcsOaepParamToCKRsaPkcsOaepParam(env, jParam); |
|
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
|
1131 |
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
|
1132 |
free(ckpParam); |
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
|
1133 |
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
|
1134 |
} |
2 | 1135 |
|
1136 |
/* get length and pointer of parameter */ |
|
1137 |
*ckpLength = sizeof(CK_RSA_PKCS_OAEP_PARAMS); |
|
1138 |
*ckpParamPtr = ckpParam; |
|
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
|
1139 |
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
|
1140 |
} |
2 | 1141 |
|
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
|
1142 |
jPbeParamsClass = (*env)->FindClass(env, CLASS_PBE_PARAMS); |
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
|
1143 |
if (jPbeParamsClass == 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
|
1144 |
if ((*env)->IsInstanceOf(env, jParam, jPbeParamsClass)) { |
2 | 1145 |
/* |
1146 |
* CK_PBE_PARAMS |
|
1147 |
*/ |
|
1148 |
CK_PBE_PARAMS_PTR ckpParam; |
|
1149 |
||
1150 |
ckpParam = (CK_PBE_PARAMS_PTR) malloc(sizeof(CK_PBE_PARAMS)); |
|
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
|
1151 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1152 |
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
|
1153 |
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
|
1154 |
} |
2 | 1155 |
|
1156 |
/* convert jParameter to CKParameter */ |
|
1157 |
*ckpParam = jPbeParamToCKPbeParam(env, jParam); |
|
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
|
1158 |
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
|
1159 |
free(ckpParam); |
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
|
1160 |
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
|
1161 |
} |
2 | 1162 |
|
1163 |
/* get length and pointer of parameter */ |
|
1164 |
*ckpLength = sizeof(CK_PBE_PARAMS); |
|
1165 |
*ckpParamPtr = ckpParam; |
|
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
|
1166 |
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
|
1167 |
} |
2 | 1168 |
|
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
|
1169 |
jPkcs5Pbkd2ParamsClass = (*env)->FindClass(env, CLASS_PKCS5_PBKD2_PARAMS); |
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
|
1170 |
if (jPkcs5Pbkd2ParamsClass == 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
|
1171 |
if ((*env)->IsInstanceOf(env, jParam, jPkcs5Pbkd2ParamsClass)) { |
2 | 1172 |
/* |
1173 |
* CK_PKCS5_PBKD2_PARAMS |
|
1174 |
*/ |
|
1175 |
CK_PKCS5_PBKD2_PARAMS_PTR ckpParam; |
|
1176 |
||
1177 |
ckpParam = (CK_PKCS5_PBKD2_PARAMS_PTR) malloc(sizeof(CK_PKCS5_PBKD2_PARAMS)); |
|
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
|
1178 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1179 |
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
|
1180 |
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
|
1181 |
} |
2 | 1182 |
|
1183 |
/* convert jParameter to CKParameter */ |
|
1184 |
*ckpParam = jPkcs5Pbkd2ParamToCKPkcs5Pbkd2Param(env, jParam); |
|
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)->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
|
1186 |
free(ckpParam); |
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
|
1187 |
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
|
1188 |
} |
2 | 1189 |
|
1190 |
/* get length and pointer of parameter */ |
|
1191 |
*ckpLength = sizeof(CK_PKCS5_PBKD2_PARAMS); |
|
1192 |
*ckpParamPtr = ckpParam; |
|
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
|
1193 |
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
|
1194 |
} |
2 | 1195 |
|
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
|
1196 |
jRsaPkcsPssParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_PSS_PARAMS); |
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 |
if (jRsaPkcsPssParamsClass == 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
|
1198 |
if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsPssParamsClass)) { |
2 | 1199 |
/* |
1200 |
* CK_RSA_PKCS_PSS_PARAMS |
|
1201 |
*/ |
|
1202 |
CK_RSA_PKCS_PSS_PARAMS_PTR ckpParam; |
|
1203 |
||
1204 |
ckpParam = (CK_RSA_PKCS_PSS_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_PSS_PARAMS)); |
|
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
|
1205 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1206 |
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
|
1207 |
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
|
1208 |
} |
2 | 1209 |
|
1210 |
/* convert jParameter to CKParameter */ |
|
1211 |
*ckpParam = jRsaPkcsPssParamToCKRsaPkcsPssParam(env, jParam); |
|
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
|
1212 |
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
|
1213 |
free(ckpParam); |
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 |
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
|
1215 |
} |
2 | 1216 |
|
1217 |
/* get length and pointer of parameter */ |
|
1218 |
*ckpLength = sizeof(CK_RSA_PKCS_PSS_PARAMS); |
|
1219 |
*ckpParamPtr = ckpParam; |
|
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 |
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
|
1221 |
} |
2 | 1222 |
|
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
|
1223 |
jEcdh1DeriveParamsClass = (*env)->FindClass(env, CLASS_ECDH1_DERIVE_PARAMS); |
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 |
if (jEcdh1DeriveParamsClass == 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
|
1225 |
if ((*env)->IsInstanceOf(env, jParam, jEcdh1DeriveParamsClass)) { |
2 | 1226 |
/* |
1227 |
* CK_ECDH1_DERIVE_PARAMS |
|
1228 |
*/ |
|
1229 |
CK_ECDH1_DERIVE_PARAMS_PTR ckpParam; |
|
1230 |
||
1231 |
ckpParam = (CK_ECDH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH1_DERIVE_PARAMS)); |
|
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
|
1232 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1233 |
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
|
1234 |
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
|
1235 |
} |
2 | 1236 |
|
1237 |
/* convert jParameter to CKParameter */ |
|
1238 |
*ckpParam = jEcdh1DeriveParamToCKEcdh1DeriveParam(env, jParam); |
|
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
|
1239 |
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
|
1240 |
free(ckpParam); |
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 |
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
|
1242 |
} |
2 | 1243 |
|
1244 |
/* get length and pointer of parameter */ |
|
1245 |
*ckpLength = sizeof(CK_ECDH1_DERIVE_PARAMS); |
|
1246 |
*ckpParamPtr = ckpParam; |
|
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
|
1247 |
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
|
1248 |
} |
2 | 1249 |
|
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
|
1250 |
jEcdh2DeriveParamsClass = (*env)->FindClass(env, CLASS_ECDH2_DERIVE_PARAMS); |
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 |
if (jEcdh2DeriveParamsClass == 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
|
1252 |
if ((*env)->IsInstanceOf(env, jParam, jEcdh2DeriveParamsClass)) { |
2 | 1253 |
/* |
1254 |
* CK_ECDH2_DERIVE_PARAMS |
|
1255 |
*/ |
|
1256 |
CK_ECDH2_DERIVE_PARAMS_PTR ckpParam; |
|
1257 |
||
1258 |
ckpParam = (CK_ECDH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH2_DERIVE_PARAMS)); |
|
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
|
1259 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1260 |
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
|
1261 |
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
|
1262 |
} |
2 | 1263 |
|
1264 |
/* convert jParameter to CKParameter */ |
|
1265 |
*ckpParam = jEcdh2DeriveParamToCKEcdh2DeriveParam(env, jParam); |
|
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
|
1266 |
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
|
1267 |
free(ckpParam); |
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
|
1268 |
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
|
1269 |
} |
2 | 1270 |
|
1271 |
/* get length and pointer of parameter */ |
|
1272 |
*ckpLength = sizeof(CK_ECDH2_DERIVE_PARAMS); |
|
1273 |
*ckpParamPtr = ckpParam; |
|
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
|
1274 |
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
|
1275 |
} |
2 | 1276 |
|
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
|
1277 |
jX942Dh1DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH1_DERIVE_PARAMS); |
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
|
1278 |
if (jX942Dh1DeriveParamsClass == 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
|
1279 |
if ((*env)->IsInstanceOf(env, jParam, jX942Dh1DeriveParamsClass)) { |
2 | 1280 |
/* |
1281 |
* CK_X9_42_DH1_DERIVE_PARAMS |
|
1282 |
*/ |
|
1283 |
CK_X9_42_DH1_DERIVE_PARAMS_PTR ckpParam; |
|
1284 |
||
1285 |
ckpParam = (CK_X9_42_DH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH1_DERIVE_PARAMS)); |
|
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
|
1286 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1287 |
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
|
1288 |
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
|
1289 |
} |
2 | 1290 |
|
1291 |
/* convert jParameter to CKParameter */ |
|
1292 |
*ckpParam = jX942Dh1DeriveParamToCKX942Dh1DeriveParam(env, jParam); |
|
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
|
1293 |
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
|
1294 |
free(ckpParam); |
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
|
1295 |
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
|
1296 |
} |
2 | 1297 |
|
1298 |
/* get length and pointer of parameter */ |
|
1299 |
*ckpLength = sizeof(CK_X9_42_DH1_DERIVE_PARAMS); |
|
1300 |
*ckpParamPtr = ckpParam; |
|
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
|
1301 |
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
|
1302 |
} |
2 | 1303 |
|
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
|
1304 |
jX942Dh2DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH2_DERIVE_PARAMS); |
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
|
1305 |
if (jX942Dh2DeriveParamsClass == 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
|
1306 |
if ((*env)->IsInstanceOf(env, jParam, jX942Dh2DeriveParamsClass)) { |
2 | 1307 |
/* |
1308 |
* CK_X9_42_DH2_DERIVE_PARAMS |
|
1309 |
*/ |
|
1310 |
CK_X9_42_DH2_DERIVE_PARAMS_PTR ckpParam; |
|
1311 |
||
1312 |
ckpParam = (CK_X9_42_DH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH2_DERIVE_PARAMS)); |
|
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
|
1313 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1314 |
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
|
1315 |
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
|
1316 |
} |
2 | 1317 |
|
1318 |
/* convert jParameter to CKParameter */ |
|
1319 |
*ckpParam = jX942Dh2DeriveParamToCKX942Dh2DeriveParam(env, jParam); |
|
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
|
1320 |
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
|
1321 |
free(ckpParam); |
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
|
1322 |
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
|
1323 |
} |
2 | 1324 |
|
1325 |
/* get length and pointer of parameter */ |
|
1326 |
*ckpLength = sizeof(CK_X9_42_DH2_DERIVE_PARAMS); |
|
1327 |
*ckpParamPtr = ckpParam; |
|
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
|
1328 |
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
|
1329 |
} |
2 | 1330 |
|
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
|
1331 |
/* if everything faild up to here */ |
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
|
1332 |
/* try if the parameter is a primitive Java 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
|
1333 |
jObjectToPrimitiveCKObjectPtrPtr(env, jParam, ckpParamPtr, ckpLength); |
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
|
1334 |
/* *ckpParamPtr = jObjectToCKVoidPtr(jParam); */ |
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
|
1335 |
/* *ckpLength = 1; */ |
2 | 1336 |
|
1337 |
TRACE0("FINISHED\n"); |
|
1338 |
} |
|
1339 |
||
1340 |
||
1341 |
/* the mechanism parameter convertion functions: */ |
|
1342 |
||
1343 |
/* |
|
1344 |
* converts the Java CK_RSA_PKCS_OAEP_PARAMS object to a CK_RSA_PKCS_OAEP_PARAMS structure |
|
1345 |
* |
|
1346 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1347 |
* @param jParam - the Java CK_RSA_PKCS_OAEP_PARAMS object to convert |
|
1348 |
* @return - the new CK_RSA_PKCS_OAEP_PARAMS structure |
|
1349 |
*/ |
|
1350 |
CK_RSA_PKCS_OAEP_PARAMS jRsaPkcsOaepParamToCKRsaPkcsOaepParam(JNIEnv *env, jobject jParam) |
|
1351 |
{ |
|
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
|
1352 |
jclass jRsaPkcsOaepParamsClass; |
2 | 1353 |
CK_RSA_PKCS_OAEP_PARAMS ckParam; |
1354 |
jfieldID fieldID; |
|
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
|
1355 |
jlong jHashAlg, jMgf, jSource; |
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
|
1356 |
jobject jSourceData; |
2 | 1357 |
CK_BYTE_PTR ckpByte; |
1358 |
||
1359 |
/* get hashAlg */ |
|
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
|
1360 |
jRsaPkcsOaepParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_OAEP_PARAMS); |
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
|
1361 |
if (jRsaPkcsOaepParamsClass == NULL) { return ckParam; } |
2 | 1362 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsOaepParamsClass, "hashAlg", "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
|
1363 |
if (fieldID == NULL) { return ckParam; } |
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
|
1364 |
jHashAlg = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1365 |
|
1366 |
/* get mgf */ |
|
1367 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsOaepParamsClass, "mgf", "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
|
1368 |
if (fieldID == NULL) { return ckParam; } |
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
|
1369 |
jMgf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1370 |
|
1371 |
/* get source */ |
|
1372 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsOaepParamsClass, "source", "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
|
1373 |
if (fieldID == NULL) { return ckParam; } |
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
|
1374 |
jSource = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1375 |
|
1376 |
/* get sourceData and sourceDataLength */ |
|
1377 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsOaepParamsClass, "pSourceData", "[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
|
1378 |
if (fieldID == NULL) { return ckParam; } |
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
|
1379 |
jSourceData = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
1380 |
|
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
|
1381 |
/* populate java values */ |
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
|
1382 |
ckParam.hashAlg = jLongToCKULong(jHashAlg); |
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
|
1383 |
ckParam.mgf = jLongToCKULong(jMgf); |
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
|
1384 |
ckParam.source = jLongToCKULong(jSource); |
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
|
1385 |
jByteArrayToCKByteArray(env, jSourceData, & ckpByte, &(ckParam.ulSourceDataLen)); |
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
|
1386 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
2 | 1387 |
ckParam.pSourceData = (CK_VOID_PTR) ckpByte; |
1388 |
||
1389 |
return ckParam ; |
|
1390 |
} |
|
1391 |
||
1392 |
/* |
|
1393 |
* converts the Java CK_PBE_PARAMS object to a CK_PBE_PARAMS structure |
|
1394 |
* |
|
1395 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1396 |
* @param jParam - the Java CK_PBE_PARAMS object to convert |
|
1397 |
* @return - the new CK_PBE_PARAMS structure |
|
1398 |
*/ |
|
1399 |
CK_PBE_PARAMS jPbeParamToCKPbeParam(JNIEnv *env, jobject jParam) |
|
1400 |
{ |
|
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
|
1401 |
jclass jPbeParamsClass; |
2 | 1402 |
CK_PBE_PARAMS ckParam; |
1403 |
jfieldID fieldID; |
|
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
|
1404 |
jlong jIteration; |
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
|
1405 |
jobject jInitVector, jPassword, jSalt; |
2 | 1406 |
CK_ULONG ckTemp; |
1407 |
||
1408 |
/* get pInitVector */ |
|
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
|
1409 |
jPbeParamsClass = (*env)->FindClass(env, CLASS_PBE_PARAMS); |
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
|
1410 |
if (jPbeParamsClass == NULL) { return ckParam; } |
2 | 1411 |
fieldID = (*env)->GetFieldID(env, jPbeParamsClass, "pInitVector", "[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
|
1412 |
if (fieldID == NULL) { return ckParam; } |
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
|
1413 |
jInitVector = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1414 |
|
1415 |
/* get pPassword and ulPasswordLength */ |
|
1416 |
fieldID = (*env)->GetFieldID(env, jPbeParamsClass, "pPassword", "[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
|
1417 |
if (fieldID == NULL) { return ckParam; } |
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
|
1418 |
jPassword = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1419 |
|
1420 |
/* get pSalt and ulSaltLength */ |
|
1421 |
fieldID = (*env)->GetFieldID(env, jPbeParamsClass, "pSalt", "[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
|
1422 |
if (fieldID == NULL) { return ckParam; } |
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
|
1423 |
jSalt = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1424 |
|
1425 |
/* get ulIteration */ |
|
1426 |
fieldID = (*env)->GetFieldID(env, jPbeParamsClass, "ulIteration", "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
|
1427 |
if (fieldID == NULL) { return ckParam; } |
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
|
1428 |
jIteration = (*env)->GetLongField(env, jParam, fieldID); |
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
|
1429 |
|
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
|
1430 |
/* populate java values */ |
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
|
1431 |
ckParam.ulIteration = jLongToCKULong(jIteration); |
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
|
1432 |
jCharArrayToCKCharArray(env, jInitVector, &(ckParam.pInitVector), &ckTemp); |
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
|
1433 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1434 |
jCharArrayToCKCharArray(env, jPassword, &(ckParam.pPassword), &(ckParam.ulPasswordLen)); |
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
|
1435 |
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
|
1436 |
free(ckParam.pInitVector); |
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
|
1437 |
return ckParam; |
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
|
1438 |
} |
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
|
1439 |
jCharArrayToCKCharArray(env, jSalt, &(ckParam.pSalt), &(ckParam.ulSaltLen)); |
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
|
1440 |
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
|
1441 |
free(ckParam.pInitVector); |
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
|
1442 |
free(ckParam.pPassword); |
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
|
1443 |
return ckParam; |
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
|
1444 |
} |
2 | 1445 |
|
1446 |
return ckParam ; |
|
1447 |
} |
|
1448 |
||
1449 |
/* |
|
1450 |
* Copy back the initialization vector from the native structure to the |
|
1451 |
* Java object. This is only used for CKM_PBE_* mechanisms and their |
|
1452 |
* CK_PBE_PARAMS parameters. |
|
1453 |
* |
|
1454 |
*/ |
|
1455 |
void copyBackPBEInitializationVector(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism) |
|
1456 |
{ |
|
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
|
1457 |
jclass jMechanismClass, jPbeParamsClass; |
2 | 1458 |
CK_PBE_PARAMS *ckParam; |
1459 |
jfieldID fieldID; |
|
1460 |
CK_MECHANISM_TYPE ckMechanismType; |
|
1461 |
jlong jMechanismType; |
|
1462 |
jobject jParameter; |
|
1463 |
jobject jInitVector; |
|
1464 |
jint jInitVectorLength; |
|
1465 |
CK_CHAR_PTR initVector; |
|
1466 |
int i; |
|
1467 |
jchar* jInitVectorChars; |
|
1468 |
||
1469 |
/* get mechanism */ |
|
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
|
1470 |
jMechanismClass = (*env)->FindClass(env, CLASS_MECHANISM); |
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
|
1471 |
if (jMechanismClass == NULL) { return; } |
2 | 1472 |
fieldID = (*env)->GetFieldID(env, jMechanismClass, "mechanism", "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
|
1473 |
if (fieldID == NULL) { return; } |
2 | 1474 |
jMechanismType = (*env)->GetLongField(env, jMechanism, fieldID); |
1475 |
ckMechanismType = jLongToCKULong(jMechanismType); |
|
1476 |
if (ckMechanismType != ckMechanism->mechanism) { |
|
1477 |
/* we do not have maching types, this should not occur */ |
|
1478 |
return; |
|
1479 |
} |
|
1480 |
||
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
|
1481 |
jPbeParamsClass = (*env)->FindClass(env, CLASS_PBE_PARAMS); |
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
|
1482 |
if (jPbeParamsClass == NULL) { return; } |
2 | 1483 |
ckParam = (CK_PBE_PARAMS *) ckMechanism->pParameter; |
1484 |
if (ckParam != NULL_PTR) { |
|
1485 |
initVector = ckParam->pInitVector; |
|
1486 |
if (initVector != NULL_PTR) { |
|
1487 |
/* get pParameter */ |
|
1488 |
fieldID = (*env)->GetFieldID(env, jMechanismClass, "pParameter", "Ljava/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
|
1489 |
if (fieldID == NULL) { return; } |
2 | 1490 |
jParameter = (*env)->GetObjectField(env, jMechanism, fieldID); |
1491 |
fieldID = (*env)->GetFieldID(env, jPbeParamsClass, "pInitVektor", "[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
|
1492 |
if (fieldID == NULL) { return; } |
2 | 1493 |
jInitVector = (*env)->GetObjectField(env, jParameter, fieldID); |
1494 |
||
1495 |
if (jInitVector != NULL) { |
|
1496 |
jInitVectorLength = (*env)->GetArrayLength(env, jInitVector); |
|
1497 |
jInitVectorChars = (*env)->GetCharArrayElements(env, jInitVector, 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
|
1498 |
if (jInitVectorChars == 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
|
1499 |
|
2 | 1500 |
/* copy the chars to the Java buffer */ |
1501 |
for (i=0; i < jInitVectorLength; i++) { |
|
1502 |
jInitVectorChars[i] = ckCharToJChar(initVector[i]); |
|
1503 |
} |
|
1504 |
/* copy back the Java buffer to the object */ |
|
1505 |
(*env)->ReleaseCharArrayElements(env, jInitVector, jInitVectorChars, 0); |
|
1506 |
} |
|
1507 |
} |
|
1508 |
} |
|
1509 |
} |
|
1510 |
||
1511 |
/* |
|
1512 |
* converts the Java CK_PKCS5_PBKD2_PARAMS object to a CK_PKCS5_PBKD2_PARAMS structure |
|
1513 |
* |
|
1514 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1515 |
* @param jParam - the Java CK_PKCS5_PBKD2_PARAMS object to convert |
|
1516 |
* @return - the new CK_PKCS5_PBKD2_PARAMS structure |
|
1517 |
*/ |
|
1518 |
CK_PKCS5_PBKD2_PARAMS jPkcs5Pbkd2ParamToCKPkcs5Pbkd2Param(JNIEnv *env, jobject jParam) |
|
1519 |
{ |
|
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
|
1520 |
jclass jPkcs5Pbkd2ParamsClass; |
2 | 1521 |
CK_PKCS5_PBKD2_PARAMS ckParam; |
1522 |
jfieldID fieldID; |
|
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
|
1523 |
jlong jSaltSource, jIteration, jPrf; |
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
|
1524 |
jobject jSaltSourceData, jPrfData; |
2 | 1525 |
|
1526 |
/* get saltSource */ |
|
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
|
1527 |
jPkcs5Pbkd2ParamsClass = (*env)->FindClass(env, CLASS_PKCS5_PBKD2_PARAMS); |
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
|
1528 |
if (jPkcs5Pbkd2ParamsClass == NULL) { return ckParam; } |
2 | 1529 |
fieldID = (*env)->GetFieldID(env, jPkcs5Pbkd2ParamsClass, "saltSource", "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
|
1530 |
if (fieldID == NULL) { return ckParam; } |
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
|
1531 |
jSaltSource = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1532 |
|
1533 |
/* get pSaltSourceData */ |
|
1534 |
fieldID = (*env)->GetFieldID(env, jPkcs5Pbkd2ParamsClass, "pSaltSourceData", "[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
|
1535 |
if (fieldID == NULL) { return ckParam; } |
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
|
1536 |
jSaltSourceData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1537 |
|
1538 |
/* get iterations */ |
|
1539 |
fieldID = (*env)->GetFieldID(env, jPkcs5Pbkd2ParamsClass, "iterations", "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
|
1540 |
if (fieldID == NULL) { return ckParam; } |
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
|
1541 |
jIteration = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1542 |
|
1543 |
/* get prf */ |
|
1544 |
fieldID = (*env)->GetFieldID(env, jPkcs5Pbkd2ParamsClass, "prf", "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
|
1545 |
if (fieldID == NULL) { return ckParam; } |
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
|
1546 |
jPrf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1547 |
|
1548 |
/* get pPrfData and ulPrfDataLength in byte */ |
|
1549 |
fieldID = (*env)->GetFieldID(env, jPkcs5Pbkd2ParamsClass, "pPrfData", "[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
|
1550 |
if (fieldID == NULL) { return ckParam; } |
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
|
1551 |
jPrfData = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
1552 |
|
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
|
1553 |
/* populate java values */ |
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
|
1554 |
ckParam.saltSource = jLongToCKULong(jSaltSource); |
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
|
1555 |
jByteArrayToCKByteArray(env, jSaltSourceData, (CK_BYTE_PTR *) &(ckParam.pSaltSourceData), &(ckParam.ulSaltSourceDataLen)); |
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
|
1556 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1557 |
ckParam.iterations = jLongToCKULong(jIteration); |
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
|
1558 |
ckParam.prf = jLongToCKULong(jPrf); |
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
|
1559 |
jByteArrayToCKByteArray(env, jPrfData, (CK_BYTE_PTR *) &(ckParam.pPrfData), &(ckParam.ulPrfDataLen)); |
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
|
1560 |
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
|
1561 |
free(ckParam.pSaltSourceData); |
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
|
1562 |
return ckParam; |
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
|
1563 |
} |
2 | 1564 |
|
1565 |
return ckParam ; |
|
1566 |
} |
|
1567 |
||
1568 |
/* |
|
1569 |
* converts the Java CK_RSA_PKCS_PSS_PARAMS object to a CK_RSA_PKCS_PSS_PARAMS structure |
|
1570 |
* |
|
1571 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1572 |
* @param jParam - the Java CK_RSA_PKCS_PSS_PARAMS object to convert |
|
1573 |
* @return - the new CK_RSA_PKCS_PSS_PARAMS structure |
|
1574 |
*/ |
|
1575 |
CK_RSA_PKCS_PSS_PARAMS jRsaPkcsPssParamToCKRsaPkcsPssParam(JNIEnv *env, jobject jParam) |
|
1576 |
{ |
|
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
|
1577 |
jclass jRsaPkcsPssParamsClass; |
2 | 1578 |
CK_RSA_PKCS_PSS_PARAMS ckParam; |
1579 |
jfieldID fieldID; |
|
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
|
1580 |
jlong jHashAlg, jMgf, jSLen; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1581 |
memset(&ckParam, 0, sizeof(CK_RSA_PKCS_PSS_PARAMS)); |
2 | 1582 |
|
1583 |
/* get hashAlg */ |
|
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
|
1584 |
jRsaPkcsPssParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_PSS_PARAMS); |
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
|
1585 |
if (jRsaPkcsPssParamsClass == NULL) { return ckParam; } |
2 | 1586 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsPssParamsClass, "hashAlg", "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
|
1587 |
if (fieldID == NULL) { return ckParam; } |
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
|
1588 |
jHashAlg = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1589 |
|
1590 |
/* get mgf */ |
|
1591 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsPssParamsClass, "mgf", "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
|
1592 |
if (fieldID == NULL) { return ckParam; } |
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
|
1593 |
jMgf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1594 |
|
1595 |
/* get sLen */ |
|
1596 |
fieldID = (*env)->GetFieldID(env, jRsaPkcsPssParamsClass, "sLen", "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
|
1597 |
if (fieldID == NULL) { return ckParam; } |
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
|
1598 |
jSLen = (*env)->GetLongField(env, jParam, fieldID); |
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
|
1599 |
|
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
|
1600 |
/* populate java values */ |
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
|
1601 |
ckParam.hashAlg = jLongToCKULong(jHashAlg); |
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
|
1602 |
ckParam.mgf = jLongToCKULong(jMgf); |
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
|
1603 |
ckParam.sLen = jLongToCKULong(jSLen); |
2 | 1604 |
|
1605 |
return ckParam ; |
|
1606 |
} |
|
1607 |
||
1608 |
/* |
|
1609 |
* converts the Java CK_ECDH1_DERIVE_PARAMS object to a CK_ECDH1_DERIVE_PARAMS structure |
|
1610 |
* |
|
1611 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1612 |
* @param jParam - the Java CK_ECDH1_DERIVE_PARAMS object to convert |
|
1613 |
* @return - the new CK_ECDH1_DERIVE_PARAMS structure |
|
1614 |
*/ |
|
1615 |
CK_ECDH1_DERIVE_PARAMS jEcdh1DeriveParamToCKEcdh1DeriveParam(JNIEnv *env, jobject jParam) |
|
1616 |
{ |
|
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
|
1617 |
jclass jEcdh1DeriveParamsClass; |
2 | 1618 |
CK_ECDH1_DERIVE_PARAMS ckParam; |
1619 |
jfieldID fieldID; |
|
1620 |
jlong 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
|
1621 |
jobject jSharedData, jPublicData; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1622 |
memset(&ckParam, 0, sizeof(CK_ECDH1_DERIVE_PARAMS)); |
2 | 1623 |
|
1624 |
/* get kdf */ |
|
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
|
1625 |
jEcdh1DeriveParamsClass = (*env)->FindClass(env, CLASS_ECDH1_DERIVE_PARAMS); |
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
|
1626 |
if (jEcdh1DeriveParamsClass == NULL) { return ckParam; } |
2 | 1627 |
fieldID = (*env)->GetFieldID(env, jEcdh1DeriveParamsClass, "kdf", "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
|
1628 |
if (fieldID == NULL) { return ckParam; } |
2 | 1629 |
jLong = (*env)->GetLongField(env, jParam, fieldID); |
1630 |
ckParam.kdf = jLongToCKULong(jLong); |
|
1631 |
||
1632 |
/* get pSharedData and ulSharedDataLen */ |
|
1633 |
fieldID = (*env)->GetFieldID(env, jEcdh1DeriveParamsClass, "pSharedData", "[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
|
1634 |
if (fieldID == NULL) { return ckParam; } |
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
|
1635 |
jSharedData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1636 |
|
1637 |
/* get pPublicData and ulPublicDataLen */ |
|
1638 |
fieldID = (*env)->GetFieldID(env, jEcdh1DeriveParamsClass, "pPublicData", "[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
|
1639 |
if (fieldID == NULL) { return ckParam; } |
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
|
1640 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
1641 |
|
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
|
1642 |
/* populate java values */ |
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
|
1643 |
ckParam.kdf = jLongToCKULong(jLong); |
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
|
1644 |
jByteArrayToCKByteArray(env, jSharedData, &(ckParam.pSharedData), &(ckParam.ulSharedDataLen)); |
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
|
1645 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1646 |
jByteArrayToCKByteArray(env, jPublicData, &(ckParam.pPublicData), &(ckParam.ulPublicDataLen)); |
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
|
1647 |
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
|
1648 |
free(ckParam.pSharedData); |
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
|
1649 |
return ckParam; |
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
|
1650 |
} |
2 | 1651 |
|
1652 |
return ckParam ; |
|
1653 |
} |
|
1654 |
||
1655 |
/* |
|
1656 |
* converts the Java CK_ECDH2_DERIVE_PARAMS object to a CK_ECDH2_DERIVE_PARAMS structure |
|
1657 |
* |
|
1658 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1659 |
* @param jParam - the Java CK_ECDH2_DERIVE_PARAMS object to convert |
|
1660 |
* @return - the new CK_ECDH2_DERIVE_PARAMS structure |
|
1661 |
*/ |
|
1662 |
CK_ECDH2_DERIVE_PARAMS jEcdh2DeriveParamToCKEcdh2DeriveParam(JNIEnv *env, jobject jParam) |
|
1663 |
{ |
|
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
|
1664 |
jclass jEcdh2DeriveParamsClass; |
2 | 1665 |
CK_ECDH2_DERIVE_PARAMS ckParam; |
1666 |
jfieldID fieldID; |
|
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
|
1667 |
jlong jKdf, jPrivateDataLen, jPrivateData; |
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
|
1668 |
jobject jSharedData, jPublicData, jPublicData2; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1669 |
memset(&ckParam, 0, sizeof(CK_ECDH2_DERIVE_PARAMS)); |
2 | 1670 |
|
1671 |
/* get kdf */ |
|
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
|
1672 |
jEcdh2DeriveParamsClass = (*env)->FindClass(env, CLASS_ECDH2_DERIVE_PARAMS); |
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
|
1673 |
if (jEcdh2DeriveParamsClass == NULL) { return ckParam; } |
2 | 1674 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "kdf", "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
|
1675 |
if (fieldID == NULL) { return ckParam; } |
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
|
1676 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1677 |
|
1678 |
/* get pSharedData and ulSharedDataLen */ |
|
1679 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "pSharedData", "[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
|
1680 |
if (fieldID == NULL) { return ckParam; } |
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
|
1681 |
jSharedData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1682 |
|
1683 |
/* get pPublicData and ulPublicDataLen */ |
|
1684 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "pPublicData", "[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
|
1685 |
if (fieldID == NULL) { return ckParam; } |
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
|
1686 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1687 |
|
1688 |
/* get ulPrivateDataLen */ |
|
1689 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "ulPrivateDataLen", "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
|
1690 |
if (fieldID == NULL) { return ckParam; } |
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
|
1691 |
jPrivateDataLen = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1692 |
|
1693 |
/* get hPrivateData */ |
|
1694 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "hPrivateData", "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
|
1695 |
if (fieldID == NULL) { return ckParam; } |
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
|
1696 |
jPrivateData = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1697 |
|
1698 |
/* get pPublicData2 and ulPublicDataLen2 */ |
|
1699 |
fieldID = (*env)->GetFieldID(env, jEcdh2DeriveParamsClass, "pPublicData2", "[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
|
1700 |
if (fieldID == NULL) { return ckParam; } |
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
|
1701 |
jPublicData2 = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1702 |
|
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
|
1703 |
/* populate java values */ |
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
|
1704 |
ckParam.kdf = jLongToCKULong(jKdf); |
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
|
1705 |
jByteArrayToCKByteArray(env, jSharedData, &(ckParam.pSharedData), &(ckParam.ulSharedDataLen)); |
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
|
1706 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1707 |
jByteArrayToCKByteArray(env, jPublicData, &(ckParam.pPublicData), &(ckParam.ulPublicDataLen)); |
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
|
1708 |
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
|
1709 |
free(ckParam.pSharedData); |
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
|
1710 |
return ckParam; |
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
|
1711 |
} |
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
|
1712 |
ckParam.ulPrivateDataLen = jLongToCKULong(jPrivateDataLen); |
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
|
1713 |
ckParam.hPrivateData = jLongToCKULong(jPrivateData); |
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
|
1714 |
jByteArrayToCKByteArray(env, jPublicData2, &(ckParam.pPublicData2), &(ckParam.ulPublicDataLen2)); |
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
|
1715 |
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
|
1716 |
free(ckParam.pSharedData); |
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
|
1717 |
free(ckParam.pPublicData); |
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
|
1718 |
return ckParam; |
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
|
1719 |
} |
2 | 1720 |
return ckParam ; |
1721 |
} |
|
1722 |
||
1723 |
/* |
|
1724 |
* converts the Java CK_X9_42_DH1_DERIVE_PARAMS object to a CK_X9_42_DH1_DERIVE_PARAMS structure |
|
1725 |
* |
|
1726 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1727 |
* @param jParam - the Java CK_X9_42_DH1_DERIVE_PARAMS object to convert |
|
1728 |
* @return - the new CK_X9_42_DH1_DERIVE_PARAMS structure |
|
1729 |
*/ |
|
1730 |
CK_X9_42_DH1_DERIVE_PARAMS jX942Dh1DeriveParamToCKX942Dh1DeriveParam(JNIEnv *env, jobject jParam) |
|
1731 |
{ |
|
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
|
1732 |
jclass jX942Dh1DeriveParamsClass; |
2 | 1733 |
CK_X9_42_DH1_DERIVE_PARAMS ckParam; |
1734 |
jfieldID fieldID; |
|
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
|
1735 |
jlong jKdf; |
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
|
1736 |
jobject jOtherInfo, jPublicData; |
2 | 1737 |
|
1738 |
/* get kdf */ |
|
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
|
1739 |
jX942Dh1DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH1_DERIVE_PARAMS); |
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
|
1740 |
if (jX942Dh1DeriveParamsClass == NULL) { return ckParam; } |
2 | 1741 |
fieldID = (*env)->GetFieldID(env, jX942Dh1DeriveParamsClass, "kdf", "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
|
1742 |
if (fieldID == NULL) { return ckParam; } |
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
|
1743 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1744 |
|
1745 |
/* get pOtherInfo and ulOtherInfoLen */ |
|
1746 |
fieldID = (*env)->GetFieldID(env, jX942Dh1DeriveParamsClass, "pOtherInfo", "[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
|
1747 |
if (fieldID == NULL) { return ckParam; } |
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
|
1748 |
jOtherInfo = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1749 |
|
1750 |
/* get pPublicData and ulPublicDataLen */ |
|
1751 |
fieldID = (*env)->GetFieldID(env, jX942Dh1DeriveParamsClass, "pPublicData", "[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
|
1752 |
if (fieldID == NULL) { return ckParam; } |
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
|
1753 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
1754 |
|
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
|
1755 |
/* populate java values */ |
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
|
1756 |
ckParam.kdf = jLongToCKULong(jKdf); |
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
|
1757 |
jByteArrayToCKByteArray(env, jOtherInfo, &(ckParam.pOtherInfo), &(ckParam.ulOtherInfoLen)); |
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
|
1758 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1759 |
jByteArrayToCKByteArray(env, jPublicData, &(ckParam.pPublicData), &(ckParam.ulPublicDataLen)); |
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
|
1760 |
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
|
1761 |
free(ckParam.pOtherInfo); |
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
|
1762 |
return ckParam; |
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
|
1763 |
} |
2 | 1764 |
|
1765 |
return ckParam ; |
|
1766 |
} |
|
1767 |
||
1768 |
/* |
|
1769 |
* converts the Java CK_X9_42_DH2_DERIVE_PARAMS object to a CK_X9_42_DH2_DERIVE_PARAMS structure |
|
1770 |
* |
|
1771 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1772 |
* @param jParam - the Java CK_X9_42_DH2_DERIVE_PARAMS object to convert |
|
1773 |
* @return - the new CK_X9_42_DH2_DERIVE_PARAMS structure |
|
1774 |
*/ |
|
1775 |
CK_X9_42_DH2_DERIVE_PARAMS jX942Dh2DeriveParamToCKX942Dh2DeriveParam(JNIEnv *env, jobject jParam) |
|
1776 |
{ |
|
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
|
1777 |
jclass jX942Dh2DeriveParamsClass; |
2 | 1778 |
CK_X9_42_DH2_DERIVE_PARAMS ckParam; |
1779 |
jfieldID fieldID; |
|
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
|
1780 |
jlong jKdf, jPrivateDataLen, jPrivateData; |
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
|
1781 |
jobject jOtherInfo, jPublicData, jPublicData2; |
2 | 1782 |
|
1783 |
/* get kdf */ |
|
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
|
1784 |
jX942Dh2DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH2_DERIVE_PARAMS); |
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
|
1785 |
if (jX942Dh2DeriveParamsClass == NULL) { return ckParam; } |
2 | 1786 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "kdf", "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
|
1787 |
if (fieldID == NULL) { return ckParam; } |
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
|
1788 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1789 |
|
1790 |
/* get pOtherInfo and ulOtherInfoLen */ |
|
1791 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "pOtherInfo", "[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
|
1792 |
if (fieldID == NULL) { return ckParam; } |
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
|
1793 |
jOtherInfo = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1794 |
|
1795 |
/* get pPublicData and ulPublicDataLen */ |
|
1796 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "pPublicData", "[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
|
1797 |
if (fieldID == NULL) { return ckParam; } |
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
|
1798 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1799 |
|
1800 |
/* get ulPrivateDataLen */ |
|
1801 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "ulPrivateDataLen", "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
|
1802 |
if (fieldID == NULL) { return ckParam; } |
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
|
1803 |
jPrivateDataLen = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1804 |
|
1805 |
/* get hPrivateData */ |
|
1806 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "hPrivateData", "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
|
1807 |
if (fieldID == NULL) { return ckParam; } |
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
|
1808 |
jPrivateData = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1809 |
|
1810 |
/* get pPublicData2 and ulPublicDataLen2 */ |
|
1811 |
fieldID = (*env)->GetFieldID(env, jX942Dh2DeriveParamsClass, "pPublicData2", "[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
|
1812 |
if (fieldID == NULL) { return ckParam; } |
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
|
1813 |
jPublicData2 = (*env)->GetObjectField(env, jParam, fieldID); |
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
|
1814 |
|
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
|
1815 |
/* populate java values */ |
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
|
1816 |
ckParam.kdf = jLongToCKULong(jKdf); |
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
|
1817 |
jByteArrayToCKByteArray(env, jOtherInfo, &(ckParam.pOtherInfo), &(ckParam.ulOtherInfoLen)); |
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
|
1818 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
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
|
1819 |
jByteArrayToCKByteArray(env, jPublicData, &(ckParam.pPublicData), &(ckParam.ulPublicDataLen)); |
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
|
1820 |
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
|
1821 |
free(ckParam.pOtherInfo); |
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
|
1822 |
return ckParam; |
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
|
1823 |
} |
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
|
1824 |
ckParam.ulPrivateDataLen = jLongToCKULong(jPrivateDataLen); |
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
|
1825 |
ckParam.hPrivateData = jLongToCKULong(jPrivateData); |
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
|
1826 |
jByteArrayToCKByteArray(env, jPublicData2, &(ckParam.pPublicData2), &(ckParam.ulPublicDataLen2)); |
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
|
1827 |
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
|
1828 |
free(ckParam.pOtherInfo); |
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
|
1829 |
free(ckParam.pPublicData); |
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
|
1830 |
return ckParam; |
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
|
1831 |
} |
2 | 1832 |
|
1833 |
return ckParam ; |
|
1834 |
} |