author | mikael |
Wed, 19 Sep 2018 09:24:40 -0700 | |
changeset 51802 | 15094d12a632 |
parent 51800 | bccd9966f1ed |
child 55332 | f492567244ab |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
2 | 1 |
/* |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, 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 |
||
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
460 |
void masterKeyDeriveParamToCKMasterKeyDeriveParam(JNIEnv *env, jobject jParam, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
461 |
jclass masterKeyDeriveParamClass, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
462 |
CK_VERSION_PTR* cKMasterKeyDeriveParamVersion, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
463 |
CK_SSL3_RANDOM_DATA* cKMasterKeyDeriveParamRandomInfo) { |
2 | 464 |
jfieldID fieldID; |
465 |
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
|
466 |
jobject jRandomInfo, jRIClientRandom, jRIServerRandom, jVersion; |
2 | 467 |
|
468 |
/* get RandomInfo */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
469 |
fieldID = (*env)->GetFieldID(env, masterKeyDeriveParamClass, "RandomInfo", |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
470 |
"Lsun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA;"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
471 |
if (fieldID == NULL) { return; } |
2 | 472 |
jRandomInfo = (*env)->GetObjectField(env, jParam, fieldID); |
473 |
||
474 |
/* 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
|
475 |
jSsl3RandomDataClass = (*env)->FindClass(env, CLASS_SSL3_RANDOM_DATA); |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
476 |
if (jSsl3RandomDataClass == NULL) { return; } |
2 | 477 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pClientRandom", "[B"); |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
478 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL 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 |
jRIClientRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 480 |
|
481 |
/* get pServerRandom and ulServerRandomLength out of RandomInfo */ |
|
482 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pServerRandom", "[B"); |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
483 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
484 |
jRIServerRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 485 |
|
486 |
/* get pVersion */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
487 |
fieldID = (*env)->GetFieldID(env, masterKeyDeriveParamClass, "pVersion", |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
488 |
"Lsun/security/pkcs11/wrapper/CK_VERSION;"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
489 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL 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 |
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
|
491 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
492 |
/* populate java values */ |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
493 |
*cKMasterKeyDeriveParamVersion = jVersionToCKVersionPtr(env, jVersion); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
494 |
if ((*env)->ExceptionCheck(env)) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
495 |
jByteArrayToCKByteArray(env, jRIClientRandom, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
496 |
&(cKMasterKeyDeriveParamRandomInfo->pClientRandom), |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
497 |
&(cKMasterKeyDeriveParamRandomInfo->ulClientRandomLen)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
498 |
if ((*env)->ExceptionCheck(env)) { |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
499 |
free(*cKMasterKeyDeriveParamVersion); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
500 |
return; |
2180
9994f4f08a59
6812738: SSL 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 |
} |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
502 |
jByteArrayToCKByteArray(env, jRIServerRandom, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
503 |
&(cKMasterKeyDeriveParamRandomInfo->pServerRandom), |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
504 |
&(cKMasterKeyDeriveParamRandomInfo->ulServerRandomLen)); |
2180
9994f4f08a59
6812738: SSL 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 |
if ((*env)->ExceptionCheck(env)) { |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
506 |
free(*cKMasterKeyDeriveParamVersion); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
507 |
free(cKMasterKeyDeriveParamRandomInfo->pClientRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
508 |
return; |
2180
9994f4f08a59
6812738: SSL 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 |
} |
2 | 510 |
} |
511 |
||
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
512 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
513 |
* converts the Java CK_SSL3_MASTER_KEY_DERIVE_PARAMS object to a |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
514 |
* CK_SSL3_MASTER_KEY_DERIVE_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
515 |
* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
516 |
* @param env - used to call JNI functions to get the Java classes and objects |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
517 |
* @param jParam - the Java CK_SSL3_MASTER_KEY_DERIVE_PARAMS object to convert |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
518 |
* @return - the new CK_SSL3_MASTER_KEY_DERIVE_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
519 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
520 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
521 |
jSsl3MasterKeyDeriveParamToCKSsl3MasterKeyDeriveParam(JNIEnv *env, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
522 |
jobject jParam) |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
523 |
{ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
524 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS ckParam; |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
525 |
jclass jSsl3MasterKeyDeriveParamsClass; |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
526 |
memset(&ckParam, 0, sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS)); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
527 |
jSsl3MasterKeyDeriveParamsClass = |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
528 |
(*env)->FindClass(env, CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
529 |
if (jSsl3MasterKeyDeriveParamsClass == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
530 |
masterKeyDeriveParamToCKMasterKeyDeriveParam(env, jParam, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
531 |
jSsl3MasterKeyDeriveParamsClass, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
532 |
&ckParam.pVersion, &ckParam.RandomInfo); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
533 |
return ckParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
534 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
535 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
536 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
537 |
* converts the Java CK_TLS12_MASTER_KEY_DERIVE_PARAMS object to a |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
538 |
* CK_TLS12_MASTER_KEY_DERIVE_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
539 |
* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
540 |
* @param env - used to call JNI functions to get the Java classes and objects |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
541 |
* @param jParam - the Java CK_TLS12_MASTER_KEY_DERIVE_PARAMS object to convert |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
542 |
* @return - the new CK_TLS12_MASTER_KEY_DERIVE_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
543 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
544 |
CK_TLS12_MASTER_KEY_DERIVE_PARAMS |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
545 |
jTls12MasterKeyDeriveParamToCKTls12MasterKeyDeriveParam(JNIEnv *env, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
546 |
jobject jParam) |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
547 |
{ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
548 |
CK_TLS12_MASTER_KEY_DERIVE_PARAMS ckParam; |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
549 |
jclass jTls12MasterKeyDeriveParamsClass; |
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
550 |
jfieldID fieldID; |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
551 |
memset(&ckParam, 0, sizeof(CK_TLS12_MASTER_KEY_DERIVE_PARAMS)); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
552 |
jTls12MasterKeyDeriveParamsClass = |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
553 |
(*env)->FindClass(env, CLASS_TLS12_MASTER_KEY_DERIVE_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
554 |
if (jTls12MasterKeyDeriveParamsClass == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
555 |
masterKeyDeriveParamToCKMasterKeyDeriveParam(env, jParam, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
556 |
jTls12MasterKeyDeriveParamsClass, &ckParam.pVersion, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
557 |
&ckParam.RandomInfo); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
558 |
fieldID = (*env)->GetFieldID(env, |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
559 |
jTls12MasterKeyDeriveParamsClass, "prfHashMechanism", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
560 |
if (fieldID != NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
561 |
jlong prfHashMechanism = |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
562 |
(*env)->GetLongField(env, jParam, fieldID); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
563 |
ckParam.prfHashMechanism = (CK_MECHANISM_TYPE)prfHashMechanism; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
564 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
565 |
return ckParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
566 |
} |
2 | 567 |
|
568 |
/* |
|
569 |
* converts the Java CK_TLS_PRF_PARAMS object to a CK_TLS_PRF_PARAMS structure |
|
570 |
*/ |
|
571 |
CK_TLS_PRF_PARAMS jTlsPrfParamsToCKTlsPrfParam(JNIEnv *env, jobject jParam) |
|
572 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
573 |
jclass jTlsPrfParamsClass; |
2 | 574 |
CK_TLS_PRF_PARAMS ckParam; |
575 |
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
|
576 |
jobject jSeed, jLabel, jOutput; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
577 |
memset(&ckParam, 0, 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
|
578 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
579 |
// TBD: what if jParam == NULL?! |
2 | 580 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
581 |
/* 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
|
582 |
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
|
583 |
if (jTlsPrfParamsClass == NULL) { return ckParam; } |
2 | 584 |
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
|
585 |
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
|
586 |
jSeed = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 587 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
588 |
/* get pLabel */ |
2 | 589 |
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
|
590 |
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
|
591 |
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
|
592 |
|
9994f4f08a59
6812738: SSL 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 |
/* 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
|
594 |
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
|
595 |
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
|
596 |
jOutput = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 597 |
|
2180
9994f4f08a59
6812738: SSL 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 |
/* 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
|
599 |
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
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
} |
2 | 606 |
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
|
607 |
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
|
608 |
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
|
609 |
free(ckParam.pLabel); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
610 |
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
|
611 |
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
|
612 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
613 |
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
|
614 |
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
|
615 |
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
|
616 |
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
|
617 |
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
|
618 |
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
|
619 |
} |
2 | 620 |
|
621 |
return ckParam ; |
|
622 |
} |
|
623 |
||
624 |
/* |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
625 |
* converts the Java CK_TLS_MAC_PARAMS object to a CK_TLS_MAC_PARAMS structure |
2 | 626 |
*/ |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
627 |
CK_TLS_MAC_PARAMS jTlsMacParamsToCKTlsMacParam(JNIEnv *env, jobject jParam) |
2 | 628 |
{ |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
629 |
jclass jTlsMacParamsClass; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
630 |
CK_TLS_MAC_PARAMS ckParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
631 |
jfieldID fieldID; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
632 |
jlong jPrfMechanism, jUlMacLength, jUlServerOrClient; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
633 |
memset(&ckParam, 0, sizeof(CK_TLS_MAC_PARAMS)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
634 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
635 |
jTlsMacParamsClass = (*env)->FindClass(env, CLASS_TLS_MAC_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
636 |
if (jTlsMacParamsClass == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
637 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
638 |
/* get prfMechanism */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
639 |
fieldID = (*env)->GetFieldID(env, jTlsMacParamsClass, "prfMechanism", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
640 |
if (fieldID == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
641 |
jPrfMechanism = (*env)->GetLongField(env, jParam, fieldID); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
642 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
643 |
/* get ulMacLength */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
644 |
fieldID = (*env)->GetFieldID(env, jTlsMacParamsClass, "ulMacLength", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
645 |
if (fieldID == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
646 |
jUlMacLength = (*env)->GetLongField(env, jParam, fieldID); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
647 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
648 |
/* get ulServerOrClient */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
649 |
fieldID = (*env)->GetFieldID(env, jTlsMacParamsClass, "ulServerOrClient", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
650 |
if (fieldID == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
651 |
jUlServerOrClient = (*env)->GetLongField(env, jParam, fieldID); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
652 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
653 |
/* populate java values */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
654 |
ckParam.prfMechanism = jLongToCKULong(jPrfMechanism); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
655 |
ckParam.ulMacLength = jLongToCKULong(jUlMacLength); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
656 |
ckParam.ulServerOrClient = jLongToCKULong(jUlServerOrClient); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
657 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
658 |
return ckParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
659 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
660 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
661 |
void keyMatParamToCKKeyMatParam(JNIEnv *env, jobject jParam, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
662 |
jclass jKeyMatParamClass, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
663 |
CK_ULONG* cKKeyMatParamUlMacSizeInBits, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
664 |
CK_ULONG* cKKeyMatParamUlKeySizeInBits, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
665 |
CK_ULONG* cKKeyMatParamUlIVSizeInBits, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
666 |
CK_BBOOL* cKKeyMatParamBIsExport, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
667 |
CK_SSL3_RANDOM_DATA* cKKeyMatParamRandomInfo, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
668 |
CK_SSL3_KEY_MAT_OUT_PTR* cKKeyMatParamPReturnedKeyMaterial) |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
669 |
{ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
670 |
jclass jSsl3RandomDataClass, jSsl3KeyMatOutClass; |
2 | 671 |
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
|
672 |
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
|
673 |
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
|
674 |
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
|
675 |
jobject jReturnedKeyMaterial, jRMIvClient, jRMIvServer; |
2 | 676 |
CK_ULONG ckTemp; |
677 |
||
678 |
/* get ulMacSizeInBits */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
679 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "ulMacSizeInBits", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
680 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL 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 |
jMacSizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 682 |
|
683 |
/* get ulKeySizeInBits */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
684 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "ulKeySizeInBits", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
685 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL 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 |
jKeySizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 687 |
|
688 |
/* get ulIVSizeInBits */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
689 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "ulIVSizeInBits", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
690 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL 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 |
jIVSizeInBits = (*env)->GetLongField(env, jParam, fieldID); |
2 | 692 |
|
693 |
/* get bIsExport */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
694 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "bIsExport", "Z"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
695 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
696 |
jIsExport = (*env)->GetBooleanField(env, jParam, fieldID); |
2 | 697 |
|
698 |
/* get RandomInfo */ |
|
699 |
jSsl3RandomDataClass = (*env)->FindClass(env, CLASS_SSL3_RANDOM_DATA); |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
700 |
if (jSsl3RandomDataClass == NULL) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
701 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "RandomInfo", |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
702 |
"Lsun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA;"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
703 |
if (fieldID == NULL) { return; } |
2 | 704 |
jRandomInfo = (*env)->GetObjectField(env, jParam, fieldID); |
705 |
||
706 |
/* get pClientRandom and ulClientRandomLength out of RandomInfo */ |
|
707 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pClientRandom", "[B"); |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
708 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
709 |
jRIClientRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 710 |
|
711 |
/* get pServerRandom and ulServerRandomLength out of RandomInfo */ |
|
712 |
fieldID = (*env)->GetFieldID(env, jSsl3RandomDataClass, "pServerRandom", "[B"); |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
713 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
714 |
jRIServerRandom = (*env)->GetObjectField(env, jRandomInfo, fieldID); |
2 | 715 |
|
716 |
/* get pReturnedKeyMaterial */ |
|
717 |
jSsl3KeyMatOutClass = (*env)->FindClass(env, CLASS_SSL3_KEY_MAT_OUT); |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
718 |
if (jSsl3KeyMatOutClass == NULL) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
719 |
fieldID = (*env)->GetFieldID(env, jKeyMatParamClass, "pReturnedKeyMaterial", |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
720 |
"Lsun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_OUT;"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
721 |
if (fieldID == NULL) { return; } |
2 | 722 |
jReturnedKeyMaterial = (*env)->GetObjectField(env, jParam, fieldID); |
723 |
||
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
724 |
/* 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
|
725 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatOutClass, "pIVClient", "[B"); |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
726 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
727 |
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
|
728 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
729 |
/* 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
|
730 |
fieldID = (*env)->GetFieldID(env, jSsl3KeyMatOutClass, "pIVServer", "[B"); |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
731 |
if (fieldID == NULL) { return; } |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
732 |
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
|
733 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
734 |
/* populate java values */ |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
735 |
*cKKeyMatParamUlMacSizeInBits = jLongToCKULong(jMacSizeInBits); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
736 |
*cKKeyMatParamUlKeySizeInBits = jLongToCKULong(jKeySizeInBits); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
737 |
*cKKeyMatParamUlIVSizeInBits = jLongToCKULong(jIVSizeInBits); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
738 |
*cKKeyMatParamBIsExport = jBooleanToCKBBool(jIsExport); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
739 |
jByteArrayToCKByteArray(env, jRIClientRandom, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
740 |
&(cKKeyMatParamRandomInfo->pClientRandom), |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
741 |
&(cKKeyMatParamRandomInfo->ulClientRandomLen)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
742 |
if ((*env)->ExceptionCheck(env)) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
743 |
jByteArrayToCKByteArray(env, jRIServerRandom, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
744 |
&(cKKeyMatParamRandomInfo->pServerRandom), |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
745 |
&(cKKeyMatParamRandomInfo->ulServerRandomLen)); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
746 |
if ((*env)->ExceptionCheck(env)) { |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
747 |
free(cKKeyMatParamRandomInfo->pClientRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
748 |
return; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
749 |
} |
2 | 750 |
/* allocate memory for pRetrunedKeyMaterial */ |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
751 |
*cKKeyMatParamPReturnedKeyMaterial = |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
752 |
(CK_SSL3_KEY_MAT_OUT_PTR)malloc(sizeof(CK_SSL3_KEY_MAT_OUT)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
753 |
if (*cKKeyMatParamPReturnedKeyMaterial == NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
754 |
free(cKKeyMatParamRandomInfo->pClientRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
755 |
free(cKKeyMatParamRandomInfo->pServerRandom); |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
756 |
throwOutOfMemoryError(env, 0); |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
757 |
return; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
758 |
} |
2 | 759 |
|
760 |
// the handles are output params only, no need to fetch them from Java |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
761 |
(*cKKeyMatParamPReturnedKeyMaterial)->hClientMacSecret = 0; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
762 |
(*cKKeyMatParamPReturnedKeyMaterial)->hServerMacSecret = 0; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
763 |
(*cKKeyMatParamPReturnedKeyMaterial)->hClientKey = 0; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
764 |
(*cKKeyMatParamPReturnedKeyMaterial)->hServerKey = 0; |
2 | 765 |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
766 |
jByteArrayToCKByteArray(env, jRMIvClient, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
767 |
&((*cKKeyMatParamPReturnedKeyMaterial)->pIVClient), &ckTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
768 |
if ((*env)->ExceptionCheck(env)) { |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
769 |
free(cKKeyMatParamRandomInfo->pClientRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
770 |
free(cKKeyMatParamRandomInfo->pServerRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
771 |
free((*cKKeyMatParamPReturnedKeyMaterial)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
772 |
return; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
773 |
} |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
774 |
jByteArrayToCKByteArray(env, jRMIvServer, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
775 |
&((*cKKeyMatParamPReturnedKeyMaterial)->pIVServer), &ckTemp); |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
776 |
if ((*env)->ExceptionCheck(env)) { |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
777 |
free(cKKeyMatParamRandomInfo->pClientRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
778 |
free(cKKeyMatParamRandomInfo->pServerRandom); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
779 |
free((*cKKeyMatParamPReturnedKeyMaterial)->pIVClient); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
780 |
free((*cKKeyMatParamPReturnedKeyMaterial)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
781 |
return; |
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
782 |
} |
2 | 783 |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
784 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
785 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
786 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
787 |
* converts the Java CK_SSL3_KEY_MAT_PARAMS object to a |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
788 |
* CK_SSL3_KEY_MAT_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
789 |
* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
790 |
* @param env - used to call JNI funktions to get the Java classes and objects |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
791 |
* @param jParam - the Java CK_SSL3_KEY_MAT_PARAMS object to convert |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
792 |
* @return - the new CK_SSL3_KEY_MAT_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
793 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
794 |
CK_SSL3_KEY_MAT_PARAMS |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
795 |
jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject jParam) |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
796 |
{ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
797 |
CK_SSL3_KEY_MAT_PARAMS ckParam; |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
798 |
jclass jSsl3KeyMatParamsClass; |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
799 |
memset(&ckParam, 0, sizeof(CK_SSL3_KEY_MAT_PARAMS)); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
800 |
jSsl3KeyMatParamsClass = (*env)->FindClass(env, |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
801 |
CLASS_SSL3_KEY_MAT_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
802 |
if (jSsl3KeyMatParamsClass == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
803 |
keyMatParamToCKKeyMatParam(env, jParam, jSsl3KeyMatParamsClass, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
804 |
&ckParam.ulMacSizeInBits, &ckParam.ulKeySizeInBits, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
805 |
&ckParam.ulIVSizeInBits, &ckParam.bIsExport, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
806 |
&ckParam.RandomInfo, &ckParam.pReturnedKeyMaterial); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
807 |
return ckParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
808 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
809 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
810 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
811 |
* converts the Java CK_TLS12_KEY_MAT_PARAMS object to a |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
812 |
* CK_TLS12_KEY_MAT_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
813 |
* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
814 |
* @param env - used to call JNI functions to get the Java classes and objects |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
815 |
* @param jParam - the Java CK_TLS12_KEY_MAT_PARAMS object to convert |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
816 |
* @return - the new CK_TLS12_KEY_MAT_PARAMS structure |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
817 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
818 |
CK_TLS12_KEY_MAT_PARAMS jTls12KeyMatParamToCKTls12KeyMatParam(JNIEnv *env, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
819 |
jobject jParam) |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
820 |
{ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
821 |
CK_TLS12_KEY_MAT_PARAMS ckParam; |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
822 |
jclass jTls12KeyMatParamsClass; |
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
823 |
jfieldID fieldID; |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
824 |
memset(&ckParam, 0, sizeof(CK_TLS12_KEY_MAT_PARAMS)); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
825 |
jTls12KeyMatParamsClass = (*env)->FindClass(env, |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
826 |
CLASS_TLS12_KEY_MAT_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
827 |
if (jTls12KeyMatParamsClass == NULL) { return ckParam; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
828 |
keyMatParamToCKKeyMatParam(env, jParam, jTls12KeyMatParamsClass, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
829 |
&ckParam.ulMacSizeInBits, &ckParam.ulKeySizeInBits, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
830 |
&ckParam.ulIVSizeInBits, &ckParam.bIsExport, |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
831 |
&ckParam.RandomInfo, &ckParam.pReturnedKeyMaterial); |
51802
15094d12a632
8210912: Build error in src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c after JDK-8029661
mikael
parents:
51800
diff
changeset
|
832 |
fieldID = (*env)->GetFieldID(env, jTls12KeyMatParamsClass, |
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
833 |
"prfHashMechanism", "J"); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
834 |
if (fieldID != NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
835 |
jlong prfHashMechanism = (*env)->GetLongField(env, jParam, fieldID); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
836 |
ckParam.prfHashMechanism = (CK_MECHANISM_TYPE)prfHashMechanism; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
837 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
838 |
return ckParam; |
2 | 839 |
} |
840 |
||
841 |
/* |
|
8542 | 842 |
* converts the Java CK_AES_CTR_PARAMS object to a CK_AES_CTR_PARAMS structure |
843 |
* |
|
844 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
845 |
* @param jParam - the Java CK_AES_CTR_PARAMS object to convert |
|
846 |
* @param ckpParam - pointer to the new CK_AES_CTR_PARAMS structure |
|
847 |
*/ |
|
848 |
void jAesCtrParamsToCKAesCtrParam(JNIEnv *env, jobject jParam, |
|
849 |
CK_AES_CTR_PARAMS_PTR ckpParam) { |
|
850 |
jclass jAesCtrParamsClass; |
|
851 |
jfieldID fieldID; |
|
852 |
jlong jCounterBits; |
|
853 |
jobject jCb; |
|
854 |
CK_BYTE_PTR ckBytes; |
|
855 |
CK_ULONG ckTemp; |
|
856 |
||
857 |
/* get ulCounterBits */ |
|
858 |
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS); |
|
859 |
if (jAesCtrParamsClass == NULL) { return; } |
|
860 |
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "ulCounterBits", "J"); |
|
861 |
if (fieldID == NULL) { return; } |
|
862 |
jCounterBits = (*env)->GetLongField(env, jParam, fieldID); |
|
863 |
||
864 |
/* get cb */ |
|
865 |
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "cb", "[B"); |
|
866 |
if (fieldID == NULL) { return; } |
|
867 |
jCb = (*env)->GetObjectField(env, jParam, fieldID); |
|
868 |
||
869 |
/* populate java values */ |
|
870 |
ckpParam->ulCounterBits = jLongToCKULong(jCounterBits); |
|
871 |
jByteArrayToCKByteArray(env, jCb, &ckBytes, &ckTemp); |
|
872 |
if ((*env)->ExceptionCheck(env)) { return; } |
|
873 |
if (ckTemp != 16) { |
|
874 |
TRACE1("ERROR: WRONG CTR IV LENGTH %d", ckTemp); |
|
875 |
} else { |
|
876 |
memcpy(ckpParam->cb, ckBytes, ckTemp); |
|
877 |
free(ckBytes); |
|
878 |
} |
|
879 |
} |
|
880 |
||
881 |
/* |
|
2 | 882 |
* converts a Java CK_MECHANISM object into a CK_MECHANISM structure |
883 |
* |
|
884 |
* @param env - used to call JNI funktions to get the values out of the Java object |
|
885 |
* @param jMechanism - the Java CK_MECHANISM object to convert |
|
886 |
* @return - the new CK_MECHANISM structure |
|
887 |
*/ |
|
888 |
void jMechanismToCKMechanism(JNIEnv *env, jobject jMechanism, CK_MECHANISM_PTR ckMechanismPtr) |
|
889 |
{ |
|
890 |
jlong jMechanismType = (*env)->GetLongField(env, jMechanism, mech_mechanismID); |
|
891 |
jobject jParameter = (*env)->GetObjectField(env, jMechanism, mech_pParameterID); |
|
892 |
||
893 |
(*ckMechanismPtr).mechanism = jLongToCKULong(jMechanismType); |
|
894 |
||
895 |
/* convert the specific Java mechanism parameter object to a pointer to a CK-type mechanism |
|
896 |
* structure |
|
897 |
*/ |
|
898 |
if (jParameter == NULL) { |
|
899 |
(*ckMechanismPtr).pParameter = NULL; |
|
900 |
(*ckMechanismPtr).ulParameterLen = 0; |
|
901 |
} else { |
|
902 |
jMechanismParameterToCKMechanismParameter(env, jParameter, &(*ckMechanismPtr).pParameter, &(*ckMechanismPtr).ulParameterLen); |
|
903 |
} |
|
904 |
} |
|
905 |
||
906 |
/* |
|
907 |
* the following functions convert Attribute and Mechanism value pointers |
|
908 |
* |
|
909 |
* jobject ckAttributeValueToJObject(JNIEnv *env, |
|
910 |
* const CK_ATTRIBUTE_PTR ckpAttribute); |
|
911 |
* |
|
912 |
* void jObjectToPrimitiveCKObjectPtrPtr(JNIEnv *env, |
|
913 |
* jobject jObject, |
|
914 |
* CK_VOID_PTR *ckpObjectPtr, |
|
915 |
* CK_ULONG *pLength); |
|
916 |
* |
|
917 |
* void jMechanismParameterToCKMechanismParameter(JNIEnv *env, |
|
918 |
* jobject jParam, |
|
919 |
* CK_VOID_PTR *ckpParamPtr, |
|
920 |
* CK_ULONG *ckpLength); |
|
921 |
* |
|
922 |
* These functions are used if a PKCS#11 mechanism or attribute structure gets |
|
923 |
* convertet to a Java attribute or mechanism object or vice versa. |
|
924 |
* |
|
925 |
* ckAttributeValueToJObject converts a PKCS#11 attribute value pointer to a Java |
|
926 |
* object depending on the type of the Attribute. A PKCS#11 attribute value can |
|
927 |
* be a CK_ULONG, CK_BYTE[], CK_CHAR[], big integer, CK_BBOOL, CK_UTF8CHAR[], |
|
928 |
* CK_DATE or CK_FLAGS that gets converted to a corresponding Java object. |
|
929 |
* |
|
930 |
* jObjectToPrimitiveCKObjectPtrPtr is used by jAttributeToCKAttributePtr for |
|
931 |
* converting the Java attribute value to a PKCS#11 attribute value pointer. |
|
932 |
* For now only primitive datatypes and arrays of primitive datatypes can get |
|
933 |
* converted. Otherwise this function throws a PKCS#11Exception with the |
|
934 |
* errorcode CKR_VENDOR_DEFINED. |
|
935 |
* |
|
936 |
* jMechanismParameterToCKMechanismParameter converts a Java mechanism parameter |
|
937 |
* to a PKCS#11 mechanism parameter. First this function determines what mechanism |
|
938 |
* parameter the Java object is, then it allocates the memory for the new PKCS#11 |
|
939 |
* structure and calls the corresponding function to convert the Java object to |
|
940 |
* a PKCS#11 mechanism parameter structure. |
|
941 |
*/ |
|
942 |
||
943 |
/* |
|
944 |
* converts the pValue of a CK_ATTRIBUTE structure into a Java Object by checking the type |
|
945 |
* of the attribute. |
|
946 |
* |
|
947 |
* @param env - used to call JNI funktions to create the new Java object |
|
948 |
* @param ckpAttribute - the pointer to the CK_ATTRIBUTE structure that contains the type |
|
949 |
* and the pValue to convert |
|
950 |
* @return - the new Java object of the CK-type pValue |
|
951 |
*/ |
|
952 |
jobject ckAttributeValueToJObject(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute) |
|
953 |
{ |
|
954 |
jint jValueLength; |
|
955 |
jobject jValueObject = NULL; |
|
956 |
||
957 |
jValueLength = ckULongToJInt(ckpAttribute->ulValueLen); |
|
958 |
||
959 |
if ((jValueLength <= 0) || (ckpAttribute->pValue == NULL)) { |
|
960 |
return NULL ; |
|
961 |
} |
|
962 |
||
963 |
switch(ckpAttribute->type) { |
|
964 |
case CKA_CLASS: |
|
965 |
/* value CK_OBJECT_CLASS, defacto a CK_ULONG */ |
|
966 |
case CKA_KEY_TYPE: |
|
967 |
/* value CK_KEY_TYPE, defacto a CK_ULONG */ |
|
968 |
case CKA_CERTIFICATE_TYPE: |
|
969 |
/* value CK_CERTIFICATE_TYPE, defacto a CK_ULONG */ |
|
970 |
case CKA_HW_FEATURE_TYPE: |
|
971 |
/* value CK_HW_FEATURE_TYPE, defacto a CK_ULONG */ |
|
972 |
case CKA_MODULUS_BITS: |
|
973 |
case CKA_VALUE_BITS: |
|
974 |
case CKA_VALUE_LEN: |
|
975 |
case CKA_KEY_GEN_MECHANISM: |
|
976 |
case CKA_PRIME_BITS: |
|
977 |
case CKA_SUB_PRIME_BITS: |
|
978 |
/* value CK_ULONG */ |
|
979 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
980 |
break; |
|
981 |
||
982 |
/* can be CK_BYTE[],CK_CHAR[] or big integer; defacto always CK_BYTE[] */ |
|
983 |
case CKA_VALUE: |
|
984 |
case CKA_OBJECT_ID: |
|
985 |
case CKA_SUBJECT: |
|
986 |
case CKA_ID: |
|
987 |
case CKA_ISSUER: |
|
988 |
case CKA_SERIAL_NUMBER: |
|
989 |
case CKA_OWNER: |
|
990 |
case CKA_AC_ISSUER: |
|
991 |
case CKA_ATTR_TYPES: |
|
992 |
case CKA_ECDSA_PARAMS: |
|
993 |
/* CKA_EC_PARAMS is the same, these two are equivalent */ |
|
994 |
case CKA_EC_POINT: |
|
995 |
case CKA_PRIVATE_EXPONENT: |
|
996 |
case CKA_PRIME_1: |
|
997 |
case CKA_PRIME_2: |
|
998 |
case CKA_EXPONENT_1: |
|
999 |
case CKA_EXPONENT_2: |
|
1000 |
case CKA_COEFFICIENT: |
|
1001 |
/* value CK_BYTE[] */ |
|
1002 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
1003 |
break; |
|
1004 |
||
1005 |
case CKA_RESET_ON_INIT: |
|
1006 |
case CKA_HAS_RESET: |
|
1007 |
case CKA_TOKEN: |
|
1008 |
case CKA_PRIVATE: |
|
1009 |
case CKA_MODIFIABLE: |
|
1010 |
case CKA_DERIVE: |
|
1011 |
case CKA_LOCAL: |
|
1012 |
case CKA_ENCRYPT: |
|
1013 |
case CKA_VERIFY: |
|
1014 |
case CKA_VERIFY_RECOVER: |
|
1015 |
case CKA_WRAP: |
|
1016 |
case CKA_SENSITIVE: |
|
1017 |
case CKA_SECONDARY_AUTH: |
|
1018 |
case CKA_DECRYPT: |
|
1019 |
case CKA_SIGN: |
|
1020 |
case CKA_SIGN_RECOVER: |
|
1021 |
case CKA_UNWRAP: |
|
1022 |
case CKA_EXTRACTABLE: |
|
1023 |
case CKA_ALWAYS_SENSITIVE: |
|
1024 |
case CKA_NEVER_EXTRACTABLE: |
|
1025 |
case CKA_TRUSTED: |
|
1026 |
/* value CK_BBOOL */ |
|
1027 |
jValueObject = ckBBoolPtrToJBooleanObject(env, (CK_BBOOL*) ckpAttribute->pValue); |
|
1028 |
break; |
|
1029 |
||
1030 |
case CKA_LABEL: |
|
1031 |
case CKA_APPLICATION: |
|
1032 |
/* value RFC 2279 (UTF-8) string */ |
|
1033 |
jValueObject = ckUTF8CharArrayToJCharArray(env, (CK_UTF8CHAR*) ckpAttribute->pValue, jValueLength); |
|
1034 |
break; |
|
1035 |
||
1036 |
case CKA_START_DATE: |
|
1037 |
case CKA_END_DATE: |
|
1038 |
/* value CK_DATE */ |
|
1039 |
jValueObject = ckDatePtrToJDateObject(env, (CK_DATE*) ckpAttribute->pValue); |
|
1040 |
break; |
|
1041 |
||
1042 |
case CKA_MODULUS: |
|
1043 |
case CKA_PUBLIC_EXPONENT: |
|
1044 |
case CKA_PRIME: |
|
1045 |
case CKA_SUBPRIME: |
|
1046 |
case CKA_BASE: |
|
1047 |
/* value big integer, i.e. CK_BYTE[] */ |
|
1048 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
1049 |
break; |
|
1050 |
||
1051 |
case CKA_AUTH_PIN_FLAGS: |
|
1052 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
1053 |
/* value FLAGS, defacto a CK_ULONG */ |
|
1054 |
break; |
|
1055 |
||
1056 |
case CKA_VENDOR_DEFINED: |
|
1057 |
/* we make a CK_BYTE[] out of this */ |
|
1058 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
1059 |
break; |
|
1060 |
||
1061 |
// Netscape trust attributes |
|
1062 |
case CKA_NETSCAPE_TRUST_SERVER_AUTH: |
|
1063 |
case CKA_NETSCAPE_TRUST_CLIENT_AUTH: |
|
1064 |
case CKA_NETSCAPE_TRUST_CODE_SIGNING: |
|
1065 |
case CKA_NETSCAPE_TRUST_EMAIL_PROTECTION: |
|
1066 |
/* value CK_ULONG */ |
|
1067 |
jValueObject = ckULongPtrToJLongObject(env, (CK_ULONG*) ckpAttribute->pValue); |
|
1068 |
break; |
|
1069 |
||
1070 |
default: |
|
1071 |
/* we make a CK_BYTE[] out of this */ |
|
1072 |
jValueObject = ckByteArrayToJByteArray(env, (CK_BYTE*) ckpAttribute->pValue, jValueLength); |
|
1073 |
break; |
|
1074 |
} |
|
1075 |
||
1076 |
return jValueObject ; |
|
1077 |
} |
|
1078 |
||
1079 |
/* |
|
1080 |
* the following functions convert a Java mechanism parameter object to a PKCS#11 |
|
1081 |
* mechanism parameter structure |
|
1082 |
* |
|
1083 |
* CK_<Param>_PARAMS j<Param>ParamToCK<Param>Param(JNIEnv *env, |
|
1084 |
* jobject jParam); |
|
1085 |
* |
|
1086 |
* These functions get a Java object, that must be the right Java mechanism |
|
1087 |
* object and they return the new PKCS#11 mechanism parameter structure. |
|
1088 |
* Every field of the Java object is retrieved, gets converted to a corresponding |
|
1089 |
* PKCS#11 type and is set in the new PKCS#11 structure. |
|
1090 |
*/ |
|
1091 |
||
1092 |
/* |
|
1093 |
* converts the given Java mechanism parameter to a CK mechanism parameter structure |
|
1094 |
* and store the length in bytes in the length variable. |
|
1095 |
* The memory of *ckpParamPtr has to be freed after use! |
|
1096 |
* |
|
1097 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1098 |
* @param jParam - the Java mechanism parameter object to convert |
|
1099 |
* @param ckpParamPtr - the reference of the new pointer to the new CK mechanism parameter |
|
1100 |
* structure |
|
1101 |
* @param ckpLength - the reference of the length in bytes of the new CK mechanism parameter |
|
1102 |
* structure |
|
1103 |
*/ |
|
1104 |
void jMechanismParameterToCKMechanismParameter(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength) |
|
1105 |
{ |
|
1106 |
if (jParam == NULL) { |
|
1107 |
*ckpParamPtr = NULL; |
|
1108 |
*ckpLength = 0; |
|
1109 |
} else if ((*env)->IsInstanceOf(env, jParam, jByteArrayClass)) { |
|
1110 |
jByteArrayToCKByteArray(env, jParam, (CK_BYTE_PTR *)ckpParamPtr, ckpLength); |
|
1111 |
} else if ((*env)->IsInstanceOf(env, jParam, jLongClass)) { |
|
1112 |
*ckpParamPtr = jLongObjectToCKULongPtr(env, jParam); |
|
1113 |
*ckpLength = sizeof(CK_ULONG); |
|
1114 |
} 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
|
1115 |
TRACE0("\nSLOW PATH jMechanismParameterToCKMechanismParameter\n"); |
2 | 1116 |
jMechanismParameterToCKMechanismParameterSlow(env, jParam, ckpParamPtr, ckpLength); |
1117 |
} |
|
1118 |
} |
|
1119 |
||
1120 |
void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength) |
|
1121 |
{ |
|
1122 |
/* get all Java mechanism parameter classes */ |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1123 |
jclass jVersionClass, jSsl3MasterKeyDeriveParamsClass; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1124 |
jclass jTls12MasterKeyDeriveParamsClass, jSsl3KeyMatParamsClass; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1125 |
jclass jTls12KeyMatParamsClass; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1126 |
jclass jTlsPrfParamsClass, jTlsMacParamsClass, jAesCtrParamsClass; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1127 |
jclass jRsaPkcsOaepParamsClass; |
8542 | 1128 |
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
|
1129 |
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
|
1130 |
jclass jX942Dh1DeriveParamsClass, jX942Dh2DeriveParamsClass; |
2 | 1131 |
TRACE0("\nDEBUG: jMechanismParameterToCKMechanismParameter"); |
1132 |
||
2180
9994f4f08a59
6812738: SSL 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 |
/* 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
|
1134 |
* 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
|
1135 |
*/ |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1136 |
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
|
1137 |
if (jVersionClass == NULL) { return; } |
2 | 1138 |
if ((*env)->IsInstanceOf(env, jParam, jVersionClass)) { |
1139 |
/* |
|
1140 |
* CK_VERSION used by CKM_SSL3_PRE_MASTER_KEY_GEN |
|
1141 |
*/ |
|
1142 |
CK_VERSION_PTR ckpParam; |
|
1143 |
||
1144 |
/* convert jParameter to CKParameter */ |
|
1145 |
ckpParam = jVersionToCKVersionPtr(env, jParam); |
|
1146 |
||
1147 |
/* get length and pointer of parameter */ |
|
1148 |
*ckpLength = sizeof(CK_VERSION); |
|
1149 |
*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
|
1150 |
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
|
1151 |
} |
2 | 1152 |
|
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1154 |
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
|
1155 |
if ((*env)->IsInstanceOf(env, jParam, jSsl3MasterKeyDeriveParamsClass)) { |
2 | 1156 |
/* |
1157 |
* CK_SSL3_MASTER_KEY_DERIVE_PARAMS |
|
1158 |
*/ |
|
1159 |
CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR ckpParam; |
|
1160 |
||
1161 |
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
|
1162 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1163 |
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
|
1164 |
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
|
1165 |
} |
2 | 1166 |
|
1167 |
/* convert jParameter to CKParameter */ |
|
1168 |
*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
|
1169 |
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
|
1170 |
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
|
1171 |
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
|
1172 |
} |
2 | 1173 |
|
1174 |
/* get length and pointer of parameter */ |
|
1175 |
*ckpLength = sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS); |
|
1176 |
*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
|
1177 |
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
|
1178 |
} |
2 | 1179 |
|
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1181 |
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
|
1182 |
if ((*env)->IsInstanceOf(env, jParam, jSsl3KeyMatParamsClass)) { |
2 | 1183 |
/* |
1184 |
* CK_SSL3_KEY_MAT_PARAMS |
|
1185 |
*/ |
|
1186 |
CK_SSL3_KEY_MAT_PARAMS_PTR ckpParam; |
|
1187 |
||
1188 |
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
|
1189 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1190 |
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
|
1191 |
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
|
1192 |
} |
2 | 1193 |
|
1194 |
/* convert jParameter to CKParameter */ |
|
1195 |
*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
|
1196 |
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
|
1197 |
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
|
1198 |
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
|
1199 |
} |
2 | 1200 |
|
1201 |
/* get length and pointer of parameter */ |
|
1202 |
*ckpLength = sizeof(CK_SSL3_KEY_MAT_PARAMS); |
|
1203 |
*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
|
1204 |
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
|
1205 |
} |
2 | 1206 |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1207 |
jTls12KeyMatParamsClass = (*env)->FindClass(env, CLASS_TLS12_KEY_MAT_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1208 |
if (jTls12KeyMatParamsClass == NULL) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1209 |
if ((*env)->IsInstanceOf(env, jParam, jTls12KeyMatParamsClass)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1210 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1211 |
* CK_TLS12_KEY_MAT_PARAMS |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1212 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1213 |
CK_TLS12_KEY_MAT_PARAMS_PTR ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1214 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1215 |
ckpParam = (CK_TLS12_KEY_MAT_PARAMS_PTR) malloc(sizeof(CK_TLS12_KEY_MAT_PARAMS)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1216 |
if (ckpParam == NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1217 |
throwOutOfMemoryError(env, 0); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1218 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1219 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1220 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1221 |
/* convert jParameter to CKParameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1222 |
*ckpParam = jTls12KeyMatParamToCKTls12KeyMatParam(env, jParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1223 |
if ((*env)->ExceptionCheck(env)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1224 |
free(ckpParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1225 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1226 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1227 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1228 |
/* get length and pointer of parameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1229 |
*ckpLength = sizeof(CK_TLS12_KEY_MAT_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1230 |
*ckpParamPtr = ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1231 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1232 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1233 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1234 |
jTls12MasterKeyDeriveParamsClass = |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1235 |
(*env)->FindClass(env, CLASS_TLS12_MASTER_KEY_DERIVE_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1236 |
if (jTls12MasterKeyDeriveParamsClass == NULL) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1237 |
if ((*env)->IsInstanceOf(env, jParam, jTls12MasterKeyDeriveParamsClass)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1238 |
/* |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1239 |
* CK_TLS12_MASTER_KEY_DERIVE_PARAMS |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1240 |
*/ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1241 |
CK_TLS12_MASTER_KEY_DERIVE_PARAMS_PTR ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1242 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1243 |
ckpParam = (CK_TLS12_MASTER_KEY_DERIVE_PARAMS_PTR)malloc( |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1244 |
sizeof(CK_TLS12_MASTER_KEY_DERIVE_PARAMS)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1245 |
if (ckpParam == NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1246 |
throwOutOfMemoryError(env, 0); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1247 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1248 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1249 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1250 |
/* convert jParameter to CKParameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1251 |
*ckpParam = jTls12MasterKeyDeriveParamToCKTls12MasterKeyDeriveParam(env, jParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1252 |
if ((*env)->ExceptionCheck(env)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1253 |
free(ckpParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1254 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1255 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1256 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1257 |
/* get length and pointer of parameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1258 |
*ckpLength = sizeof(CK_TLS12_MASTER_KEY_DERIVE_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1259 |
*ckpParamPtr = ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1260 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1261 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1262 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1263 |
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
|
1264 |
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
|
1265 |
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
|
1266 |
/* |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1267 |
* 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
|
1268 |
*/ |
2 | 1269 |
CK_TLS_PRF_PARAMS_PTR ckpParam; |
1270 |
||
1271 |
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
|
1272 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1273 |
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
|
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 |
/* convert jParameter to CKParameter */ |
2 | 1278 |
*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
|
1279 |
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
|
1280 |
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
|
1281 |
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
|
1282 |
} |
2 | 1283 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1284 |
/* get length and pointer of parameter */ |
2 | 1285 |
*ckpLength = sizeof(CK_TLS_PRF_PARAMS); |
1286 |
*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
|
1287 |
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
|
1288 |
} |
2 | 1289 |
|
51800
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1290 |
jTlsMacParamsClass = (*env)->FindClass(env, CLASS_TLS_MAC_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1291 |
if (jTlsMacParamsClass == NULL) { return; } |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1292 |
if ((*env)->IsInstanceOf(env, jParam, jTlsMacParamsClass)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1293 |
CK_TLS_MAC_PARAMS_PTR ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1294 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1295 |
ckpParam = (CK_TLS_MAC_PARAMS_PTR) malloc(sizeof(CK_TLS_MAC_PARAMS)); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1296 |
if (ckpParam == NULL) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1297 |
throwOutOfMemoryError(env, 0); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1298 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1299 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1300 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1301 |
/* convert jParameter to CKParameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1302 |
*ckpParam = jTlsMacParamsToCKTlsMacParam(env, jParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1303 |
if ((*env)->ExceptionCheck(env)) { |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1304 |
free(ckpParam); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1305 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1306 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1307 |
|
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1308 |
/* get length and pointer of parameter */ |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1309 |
*ckpLength = sizeof(CK_TLS_MAC_PARAMS); |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1310 |
*ckpParamPtr = ckpParam; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1311 |
return; |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1312 |
} |
bccd9966f1ed
8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents:
47216
diff
changeset
|
1313 |
|
8542 | 1314 |
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS); |
1315 |
if (jAesCtrParamsClass == NULL) { return; } |
|
1316 |
if ((*env)->IsInstanceOf(env, jParam, jAesCtrParamsClass)) { |
|
1317 |
/* |
|
1318 |
* CK_AES_CTR_PARAMS |
|
1319 |
*/ |
|
1320 |
CK_AES_CTR_PARAMS_PTR ckpParam; |
|
1321 |
||
1322 |
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS)); |
|
1323 |
if (ckpParam == NULL) { |
|
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1324 |
throwOutOfMemoryError(env, 0); |
8542 | 1325 |
return; |
1326 |
} |
|
1327 |
||
1328 |
/* convert jParameter to CKParameter */ |
|
1329 |
jAesCtrParamsToCKAesCtrParam(env, jParam, ckpParam); |
|
1330 |
if ((*env)->ExceptionCheck(env)) { |
|
1331 |
free(ckpParam); |
|
1332 |
return; |
|
1333 |
} |
|
1334 |
||
1335 |
/* get length and pointer of parameter */ |
|
1336 |
*ckpLength = sizeof(CK_AES_CTR_PARAMS); |
|
1337 |
*ckpParamPtr = ckpParam; |
|
1338 |
return; |
|
1339 |
} |
|
1340 |
||
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1341 |
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
|
1342 |
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
|
1343 |
if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsOaepParamsClass)) { |
2 | 1344 |
/* |
1345 |
* CK_RSA_PKCS_OAEP_PARAMS |
|
1346 |
*/ |
|
1347 |
CK_RSA_PKCS_OAEP_PARAMS_PTR ckpParam; |
|
1348 |
||
1349 |
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
|
1350 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1351 |
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
|
1352 |
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
|
1353 |
} |
2 | 1354 |
|
1355 |
/* convert jParameter to CKParameter */ |
|
1356 |
*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
|
1357 |
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
|
1358 |
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
|
1359 |
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
|
1360 |
} |
2 | 1361 |
|
1362 |
/* get length and pointer of parameter */ |
|
1363 |
*ckpLength = sizeof(CK_RSA_PKCS_OAEP_PARAMS); |
|
1364 |
*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
|
1365 |
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
|
1366 |
} |
2 | 1367 |
|
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1369 |
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
|
1370 |
if ((*env)->IsInstanceOf(env, jParam, jPbeParamsClass)) { |
2 | 1371 |
/* |
1372 |
* CK_PBE_PARAMS |
|
1373 |
*/ |
|
1374 |
CK_PBE_PARAMS_PTR ckpParam; |
|
1375 |
||
1376 |
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
|
1377 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1378 |
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
|
1379 |
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
|
1380 |
} |
2 | 1381 |
|
1382 |
/* convert jParameter to CKParameter */ |
|
1383 |
*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
|
1384 |
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
|
1385 |
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
|
1386 |
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
|
1387 |
} |
2 | 1388 |
|
1389 |
/* get length and pointer of parameter */ |
|
1390 |
*ckpLength = sizeof(CK_PBE_PARAMS); |
|
1391 |
*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
|
1392 |
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
|
1393 |
} |
2 | 1394 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1395 |
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
|
1396 |
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
|
1397 |
if ((*env)->IsInstanceOf(env, jParam, jPkcs5Pbkd2ParamsClass)) { |
2 | 1398 |
/* |
1399 |
* CK_PKCS5_PBKD2_PARAMS |
|
1400 |
*/ |
|
1401 |
CK_PKCS5_PBKD2_PARAMS_PTR ckpParam; |
|
1402 |
||
1403 |
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
|
1404 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1405 |
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
|
1406 |
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
|
1407 |
} |
2 | 1408 |
|
1409 |
/* convert jParameter to CKParameter */ |
|
1410 |
*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
|
1411 |
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
|
1412 |
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
|
1413 |
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
|
1414 |
} |
2 | 1415 |
|
1416 |
/* get length and pointer of parameter */ |
|
1417 |
*ckpLength = sizeof(CK_PKCS5_PBKD2_PARAMS); |
|
1418 |
*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
|
1419 |
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
|
1420 |
} |
2 | 1421 |
|
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1423 |
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
|
1424 |
if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsPssParamsClass)) { |
2 | 1425 |
/* |
1426 |
* CK_RSA_PKCS_PSS_PARAMS |
|
1427 |
*/ |
|
1428 |
CK_RSA_PKCS_PSS_PARAMS_PTR ckpParam; |
|
1429 |
||
1430 |
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
|
1431 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1432 |
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
|
1433 |
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
|
1434 |
} |
2 | 1435 |
|
1436 |
/* convert jParameter to CKParameter */ |
|
1437 |
*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
|
1438 |
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
|
1439 |
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
|
1440 |
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
|
1441 |
} |
2 | 1442 |
|
1443 |
/* get length and pointer of parameter */ |
|
1444 |
*ckpLength = sizeof(CK_RSA_PKCS_PSS_PARAMS); |
|
1445 |
*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
|
1446 |
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
|
1447 |
} |
2 | 1448 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1449 |
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
|
1450 |
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
|
1451 |
if ((*env)->IsInstanceOf(env, jParam, jEcdh1DeriveParamsClass)) { |
2 | 1452 |
/* |
1453 |
* CK_ECDH1_DERIVE_PARAMS |
|
1454 |
*/ |
|
1455 |
CK_ECDH1_DERIVE_PARAMS_PTR ckpParam; |
|
1456 |
||
1457 |
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
|
1458 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1459 |
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
|
1460 |
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
|
1461 |
} |
2 | 1462 |
|
1463 |
/* convert jParameter to CKParameter */ |
|
1464 |
*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
|
1465 |
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
|
1466 |
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
|
1467 |
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
|
1468 |
} |
2 | 1469 |
|
1470 |
/* get length and pointer of parameter */ |
|
1471 |
*ckpLength = sizeof(CK_ECDH1_DERIVE_PARAMS); |
|
1472 |
*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
|
1473 |
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
|
1474 |
} |
2 | 1475 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1476 |
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
|
1477 |
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
|
1478 |
if ((*env)->IsInstanceOf(env, jParam, jEcdh2DeriveParamsClass)) { |
2 | 1479 |
/* |
1480 |
* CK_ECDH2_DERIVE_PARAMS |
|
1481 |
*/ |
|
1482 |
CK_ECDH2_DERIVE_PARAMS_PTR ckpParam; |
|
1483 |
||
1484 |
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
|
1485 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1486 |
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
|
1487 |
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
|
1488 |
} |
2 | 1489 |
|
1490 |
/* convert jParameter to CKParameter */ |
|
1491 |
*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
|
1492 |
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
|
1493 |
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
|
1494 |
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
|
1495 |
} |
2 | 1496 |
|
1497 |
/* get length and pointer of parameter */ |
|
1498 |
*ckpLength = sizeof(CK_ECDH2_DERIVE_PARAMS); |
|
1499 |
*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
|
1500 |
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
|
1501 |
} |
2 | 1502 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1503 |
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
|
1504 |
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
|
1505 |
if ((*env)->IsInstanceOf(env, jParam, jX942Dh1DeriveParamsClass)) { |
2 | 1506 |
/* |
1507 |
* CK_X9_42_DH1_DERIVE_PARAMS |
|
1508 |
*/ |
|
1509 |
CK_X9_42_DH1_DERIVE_PARAMS_PTR ckpParam; |
|
1510 |
||
1511 |
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
|
1512 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1513 |
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
|
1514 |
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
|
1515 |
} |
2 | 1516 |
|
1517 |
/* convert jParameter to CKParameter */ |
|
1518 |
*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
|
1519 |
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
|
1520 |
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
|
1521 |
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
|
1522 |
} |
2 | 1523 |
|
1524 |
/* get length and pointer of parameter */ |
|
1525 |
*ckpLength = sizeof(CK_X9_42_DH1_DERIVE_PARAMS); |
|
1526 |
*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
|
1527 |
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
|
1528 |
} |
2 | 1529 |
|
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1531 |
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
|
1532 |
if ((*env)->IsInstanceOf(env, jParam, jX942Dh2DeriveParamsClass)) { |
2 | 1533 |
/* |
1534 |
* CK_X9_42_DH2_DERIVE_PARAMS |
|
1535 |
*/ |
|
1536 |
CK_X9_42_DH2_DERIVE_PARAMS_PTR ckpParam; |
|
1537 |
||
1538 |
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
|
1539 |
if (ckpParam == NULL) { |
10798
413b731e1818
7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents:
8542
diff
changeset
|
1540 |
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
|
1541 |
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
|
1542 |
} |
2 | 1543 |
|
1544 |
/* convert jParameter to CKParameter */ |
|
1545 |
*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
|
1546 |
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
|
1547 |
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
|
1548 |
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
|
1549 |
} |
2 | 1550 |
|
1551 |
/* get length and pointer of parameter */ |
|
1552 |
*ckpLength = sizeof(CK_X9_42_DH2_DERIVE_PARAMS); |
|
1553 |
*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
|
1554 |
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
|
1555 |
} |
2 | 1556 |
|
2180
9994f4f08a59
6812738: SSL 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 |
/* 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
|
1558 |
/* 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
|
1559 |
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
|
1560 |
/* *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
|
1561 |
/* *ckpLength = 1; */ |
2 | 1562 |
|
1563 |
TRACE0("FINISHED\n"); |
|
1564 |
} |
|
1565 |
||
1566 |
||
1567 |
/* the mechanism parameter convertion functions: */ |
|
1568 |
||
1569 |
/* |
|
1570 |
* converts the Java CK_RSA_PKCS_OAEP_PARAMS object to a CK_RSA_PKCS_OAEP_PARAMS structure |
|
1571 |
* |
|
1572 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1573 |
* @param jParam - the Java CK_RSA_PKCS_OAEP_PARAMS object to convert |
|
1574 |
* @return - the new CK_RSA_PKCS_OAEP_PARAMS structure |
|
1575 |
*/ |
|
1576 |
CK_RSA_PKCS_OAEP_PARAMS jRsaPkcsOaepParamToCKRsaPkcsOaepParam(JNIEnv *env, jobject jParam) |
|
1577 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1578 |
jclass jRsaPkcsOaepParamsClass; |
2 | 1579 |
CK_RSA_PKCS_OAEP_PARAMS ckParam; |
1580 |
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
|
1581 |
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
|
1582 |
jobject jSourceData; |
2 | 1583 |
CK_BYTE_PTR ckpByte; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
1584 |
memset(&ckParam, 0, sizeof(CK_RSA_PKCS_OAEP_PARAMS)); |
2 | 1585 |
|
1586 |
/* 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
|
1587 |
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
|
1588 |
if (jRsaPkcsOaepParamsClass == NULL) { return ckParam; } |
2 | 1589 |
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
|
1590 |
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
|
1591 |
jHashAlg = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1592 |
|
1593 |
/* get mgf */ |
|
1594 |
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
|
1595 |
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
|
1596 |
jMgf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1597 |
|
1598 |
/* get source */ |
|
1599 |
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
|
1600 |
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
|
1601 |
jSource = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1602 |
|
1603 |
/* get sourceData and sourceDataLength */ |
|
1604 |
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
|
1605 |
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
|
1606 |
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
|
1607 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1608 |
/* 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
|
1609 |
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
|
1610 |
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
|
1611 |
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
|
1612 |
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
|
1613 |
if ((*env)->ExceptionCheck(env)) { return ckParam; } |
2 | 1614 |
ckParam.pSourceData = (CK_VOID_PTR) ckpByte; |
1615 |
||
1616 |
return ckParam ; |
|
1617 |
} |
|
1618 |
||
1619 |
/* |
|
1620 |
* converts the Java CK_PBE_PARAMS object to a CK_PBE_PARAMS structure |
|
1621 |
* |
|
1622 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1623 |
* @param jParam - the Java CK_PBE_PARAMS object to convert |
|
1624 |
* @return - the new CK_PBE_PARAMS structure |
|
1625 |
*/ |
|
1626 |
CK_PBE_PARAMS jPbeParamToCKPbeParam(JNIEnv *env, jobject jParam) |
|
1627 |
{ |
|
2180
9994f4f08a59
6812738: SSL 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 |
jclass jPbeParamsClass; |
2 | 1629 |
CK_PBE_PARAMS ckParam; |
1630 |
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
|
1631 |
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
|
1632 |
jobject jInitVector, jPassword, jSalt; |
2 | 1633 |
CK_ULONG ckTemp; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
1634 |
memset(&ckParam, 0, sizeof(CK_PBE_PARAMS)); |
2 | 1635 |
|
1636 |
/* 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
|
1637 |
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
|
1638 |
if (jPbeParamsClass == NULL) { return ckParam; } |
2 | 1639 |
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
|
1640 |
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
|
1641 |
jInitVector = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1642 |
|
1643 |
/* get pPassword and ulPasswordLength */ |
|
1644 |
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
|
1645 |
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
|
1646 |
jPassword = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1647 |
|
1648 |
/* get pSalt and ulSaltLength */ |
|
1649 |
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
|
1650 |
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
|
1651 |
jSalt = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1652 |
|
1653 |
/* get ulIteration */ |
|
1654 |
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
|
1655 |
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
|
1656 |
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
|
1657 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1658 |
/* 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
|
1659 |
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
|
1660 |
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
|
1661 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
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
|
1665 |
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
|
1666 |
} |
9994f4f08a59
6812738: SSL 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 |
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
|
1668 |
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
|
1669 |
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
|
1670 |
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
|
1671 |
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
|
1672 |
} |
2 | 1673 |
|
1674 |
return ckParam ; |
|
1675 |
} |
|
1676 |
||
1677 |
/* |
|
1678 |
* Copy back the initialization vector from the native structure to the |
|
1679 |
* Java object. This is only used for CKM_PBE_* mechanisms and their |
|
1680 |
* CK_PBE_PARAMS parameters. |
|
1681 |
* |
|
1682 |
*/ |
|
1683 |
void copyBackPBEInitializationVector(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism) |
|
1684 |
{ |
|
2180
9994f4f08a59
6812738: SSL 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 |
jclass jMechanismClass, jPbeParamsClass; |
2 | 1686 |
CK_PBE_PARAMS *ckParam; |
1687 |
jfieldID fieldID; |
|
1688 |
CK_MECHANISM_TYPE ckMechanismType; |
|
1689 |
jlong jMechanismType; |
|
1690 |
jobject jParameter; |
|
1691 |
jobject jInitVector; |
|
1692 |
jint jInitVectorLength; |
|
1693 |
CK_CHAR_PTR initVector; |
|
1694 |
int i; |
|
1695 |
jchar* jInitVectorChars; |
|
1696 |
||
1697 |
/* 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
|
1698 |
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
|
1699 |
if (jMechanismClass == NULL) { return; } |
2 | 1700 |
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
|
1701 |
if (fieldID == NULL) { return; } |
2 | 1702 |
jMechanismType = (*env)->GetLongField(env, jMechanism, fieldID); |
1703 |
ckMechanismType = jLongToCKULong(jMechanismType); |
|
1704 |
if (ckMechanismType != ckMechanism->mechanism) { |
|
1705 |
/* we do not have maching types, this should not occur */ |
|
1706 |
return; |
|
1707 |
} |
|
1708 |
||
2180
9994f4f08a59
6812738: SSL 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 |
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
|
1710 |
if (jPbeParamsClass == NULL) { return; } |
2 | 1711 |
ckParam = (CK_PBE_PARAMS *) ckMechanism->pParameter; |
1712 |
if (ckParam != NULL_PTR) { |
|
1713 |
initVector = ckParam->pInitVector; |
|
1714 |
if (initVector != NULL_PTR) { |
|
1715 |
/* get pParameter */ |
|
1716 |
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
|
1717 |
if (fieldID == NULL) { return; } |
2 | 1718 |
jParameter = (*env)->GetObjectField(env, jMechanism, fieldID); |
1719 |
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
|
1720 |
if (fieldID == NULL) { return; } |
2 | 1721 |
jInitVector = (*env)->GetObjectField(env, jParameter, fieldID); |
1722 |
||
1723 |
if (jInitVector != NULL) { |
|
1724 |
jInitVectorLength = (*env)->GetArrayLength(env, jInitVector); |
|
1725 |
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
|
1726 |
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
|
1727 |
|
2 | 1728 |
/* copy the chars to the Java buffer */ |
1729 |
for (i=0; i < jInitVectorLength; i++) { |
|
1730 |
jInitVectorChars[i] = ckCharToJChar(initVector[i]); |
|
1731 |
} |
|
1732 |
/* copy back the Java buffer to the object */ |
|
1733 |
(*env)->ReleaseCharArrayElements(env, jInitVector, jInitVectorChars, 0); |
|
1734 |
} |
|
1735 |
} |
|
1736 |
} |
|
1737 |
} |
|
1738 |
||
1739 |
/* |
|
1740 |
* converts the Java CK_PKCS5_PBKD2_PARAMS object to a CK_PKCS5_PBKD2_PARAMS structure |
|
1741 |
* |
|
1742 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1743 |
* @param jParam - the Java CK_PKCS5_PBKD2_PARAMS object to convert |
|
1744 |
* @return - the new CK_PKCS5_PBKD2_PARAMS structure |
|
1745 |
*/ |
|
1746 |
CK_PKCS5_PBKD2_PARAMS jPkcs5Pbkd2ParamToCKPkcs5Pbkd2Param(JNIEnv *env, jobject jParam) |
|
1747 |
{ |
|
2180
9994f4f08a59
6812738: SSL 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 |
jclass jPkcs5Pbkd2ParamsClass; |
2 | 1749 |
CK_PKCS5_PBKD2_PARAMS ckParam; |
1750 |
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
|
1751 |
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
|
1752 |
jobject jSaltSourceData, jPrfData; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
1753 |
memset(&ckParam, 0, sizeof(CK_PKCS5_PBKD2_PARAMS)); |
2 | 1754 |
|
1755 |
/* 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
|
1756 |
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
|
1757 |
if (jPkcs5Pbkd2ParamsClass == NULL) { return ckParam; } |
2 | 1758 |
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
|
1759 |
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
|
1760 |
jSaltSource = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1761 |
|
1762 |
/* get pSaltSourceData */ |
|
1763 |
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
|
1764 |
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
|
1765 |
jSaltSourceData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1766 |
|
1767 |
/* get iterations */ |
|
1768 |
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
|
1769 |
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
|
1770 |
jIteration = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1771 |
|
1772 |
/* get prf */ |
|
1773 |
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
|
1774 |
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
|
1775 |
jPrf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1776 |
|
1777 |
/* get pPrfData and ulPrfDataLength in byte */ |
|
1778 |
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
|
1779 |
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
|
1780 |
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
|
1781 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1782 |
/* 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
|
1783 |
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
|
1784 |
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
|
1785 |
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
|
1786 |
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
|
1787 |
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
|
1788 |
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
|
1789 |
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
|
1790 |
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
|
1791 |
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
|
1792 |
} |
2 | 1793 |
|
1794 |
return ckParam ; |
|
1795 |
} |
|
1796 |
||
1797 |
/* |
|
1798 |
* converts the Java CK_RSA_PKCS_PSS_PARAMS object to a CK_RSA_PKCS_PSS_PARAMS structure |
|
1799 |
* |
|
1800 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1801 |
* @param jParam - the Java CK_RSA_PKCS_PSS_PARAMS object to convert |
|
1802 |
* @return - the new CK_RSA_PKCS_PSS_PARAMS structure |
|
1803 |
*/ |
|
1804 |
CK_RSA_PKCS_PSS_PARAMS jRsaPkcsPssParamToCKRsaPkcsPssParam(JNIEnv *env, jobject jParam) |
|
1805 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1806 |
jclass jRsaPkcsPssParamsClass; |
2 | 1807 |
CK_RSA_PKCS_PSS_PARAMS ckParam; |
1808 |
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
|
1809 |
jlong jHashAlg, jMgf, jSLen; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1810 |
memset(&ckParam, 0, sizeof(CK_RSA_PKCS_PSS_PARAMS)); |
2 | 1811 |
|
1812 |
/* 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
|
1813 |
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
|
1814 |
if (jRsaPkcsPssParamsClass == NULL) { return ckParam; } |
2 | 1815 |
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
|
1816 |
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
|
1817 |
jHashAlg = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1818 |
|
1819 |
/* get mgf */ |
|
1820 |
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
|
1821 |
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
|
1822 |
jMgf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1823 |
|
1824 |
/* get sLen */ |
|
1825 |
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
|
1826 |
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
|
1827 |
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
|
1828 |
|
9994f4f08a59
6812738: SSL 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 |
/* 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
|
1830 |
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
|
1831 |
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
|
1832 |
ckParam.sLen = jLongToCKULong(jSLen); |
2 | 1833 |
|
1834 |
return ckParam ; |
|
1835 |
} |
|
1836 |
||
1837 |
/* |
|
1838 |
* converts the Java CK_ECDH1_DERIVE_PARAMS object to a CK_ECDH1_DERIVE_PARAMS structure |
|
1839 |
* |
|
1840 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1841 |
* @param jParam - the Java CK_ECDH1_DERIVE_PARAMS object to convert |
|
1842 |
* @return - the new CK_ECDH1_DERIVE_PARAMS structure |
|
1843 |
*/ |
|
1844 |
CK_ECDH1_DERIVE_PARAMS jEcdh1DeriveParamToCKEcdh1DeriveParam(JNIEnv *env, jobject jParam) |
|
1845 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1846 |
jclass jEcdh1DeriveParamsClass; |
2 | 1847 |
CK_ECDH1_DERIVE_PARAMS ckParam; |
1848 |
jfieldID fieldID; |
|
1849 |
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
|
1850 |
jobject jSharedData, jPublicData; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1851 |
memset(&ckParam, 0, sizeof(CK_ECDH1_DERIVE_PARAMS)); |
2 | 1852 |
|
1853 |
/* 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
|
1854 |
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
|
1855 |
if (jEcdh1DeriveParamsClass == NULL) { return ckParam; } |
2 | 1856 |
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
|
1857 |
if (fieldID == NULL) { return ckParam; } |
2 | 1858 |
jLong = (*env)->GetLongField(env, jParam, fieldID); |
1859 |
ckParam.kdf = jLongToCKULong(jLong); |
|
1860 |
||
1861 |
/* get pSharedData and ulSharedDataLen */ |
|
1862 |
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
|
1863 |
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
|
1864 |
jSharedData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1865 |
|
1866 |
/* get pPublicData and ulPublicDataLen */ |
|
1867 |
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
|
1868 |
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
|
1869 |
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
|
1870 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1871 |
/* 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
|
1872 |
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
|
1873 |
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
|
1874 |
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
|
1875 |
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
|
1876 |
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
|
1877 |
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
|
1878 |
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
|
1879 |
} |
2 | 1880 |
|
1881 |
return ckParam ; |
|
1882 |
} |
|
1883 |
||
1884 |
/* |
|
1885 |
* converts the Java CK_ECDH2_DERIVE_PARAMS object to a CK_ECDH2_DERIVE_PARAMS structure |
|
1886 |
* |
|
1887 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1888 |
* @param jParam - the Java CK_ECDH2_DERIVE_PARAMS object to convert |
|
1889 |
* @return - the new CK_ECDH2_DERIVE_PARAMS structure |
|
1890 |
*/ |
|
1891 |
CK_ECDH2_DERIVE_PARAMS jEcdh2DeriveParamToCKEcdh2DeriveParam(JNIEnv *env, jobject jParam) |
|
1892 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1893 |
jclass jEcdh2DeriveParamsClass; |
2 | 1894 |
CK_ECDH2_DERIVE_PARAMS ckParam; |
1895 |
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
|
1896 |
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
|
1897 |
jobject jSharedData, jPublicData, jPublicData2; |
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
11356
diff
changeset
|
1898 |
memset(&ckParam, 0, sizeof(CK_ECDH2_DERIVE_PARAMS)); |
2 | 1899 |
|
1900 |
/* 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
|
1901 |
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
|
1902 |
if (jEcdh2DeriveParamsClass == NULL) { return ckParam; } |
2 | 1903 |
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
|
1904 |
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
|
1905 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1906 |
|
1907 |
/* get pSharedData and ulSharedDataLen */ |
|
1908 |
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
|
1909 |
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
|
1910 |
jSharedData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1911 |
|
1912 |
/* get pPublicData and ulPublicDataLen */ |
|
1913 |
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
|
1914 |
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
|
1915 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1916 |
|
1917 |
/* get ulPrivateDataLen */ |
|
1918 |
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
|
1919 |
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
|
1920 |
jPrivateDataLen = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1921 |
|
1922 |
/* get hPrivateData */ |
|
1923 |
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
|
1924 |
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
|
1925 |
jPrivateData = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1926 |
|
1927 |
/* get pPublicData2 and ulPublicDataLen2 */ |
|
1928 |
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
|
1929 |
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
|
1930 |
jPublicData2 = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1931 |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1932 |
/* 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
|
1933 |
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
|
1934 |
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
|
1935 |
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
|
1936 |
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
|
1937 |
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
|
1938 |
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
|
1939 |
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
|
1940 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1941 |
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
|
1942 |
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
|
1943 |
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
|
1944 |
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
|
1945 |
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
|
1946 |
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
|
1947 |
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
|
1948 |
} |
2 | 1949 |
return ckParam ; |
1950 |
} |
|
1951 |
||
1952 |
/* |
|
1953 |
* converts the Java CK_X9_42_DH1_DERIVE_PARAMS object to a CK_X9_42_DH1_DERIVE_PARAMS structure |
|
1954 |
* |
|
1955 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
1956 |
* @param jParam - the Java CK_X9_42_DH1_DERIVE_PARAMS object to convert |
|
1957 |
* @return - the new CK_X9_42_DH1_DERIVE_PARAMS structure |
|
1958 |
*/ |
|
1959 |
CK_X9_42_DH1_DERIVE_PARAMS jX942Dh1DeriveParamToCKX942Dh1DeriveParam(JNIEnv *env, jobject jParam) |
|
1960 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1961 |
jclass jX942Dh1DeriveParamsClass; |
2 | 1962 |
CK_X9_42_DH1_DERIVE_PARAMS ckParam; |
1963 |
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
|
1964 |
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
|
1965 |
jobject jOtherInfo, jPublicData; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
1966 |
memset(&ckParam, 0, sizeof(CK_X9_42_DH1_DERIVE_PARAMS)); |
2 | 1967 |
|
1968 |
/* 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
|
1969 |
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
|
1970 |
if (jX942Dh1DeriveParamsClass == NULL) { return ckParam; } |
2 | 1971 |
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
|
1972 |
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
|
1973 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 1974 |
|
1975 |
/* get pOtherInfo and ulOtherInfoLen */ |
|
1976 |
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
|
1977 |
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
|
1978 |
jOtherInfo = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 1979 |
|
1980 |
/* get pPublicData and ulPublicDataLen */ |
|
1981 |
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
|
1982 |
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
|
1983 |
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
|
1984 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
1985 |
/* 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
|
1986 |
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
|
1987 |
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
|
1988 |
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
|
1989 |
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
|
1990 |
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
|
1991 |
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
|
1992 |
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
|
1993 |
} |
2 | 1994 |
|
1995 |
return ckParam ; |
|
1996 |
} |
|
1997 |
||
1998 |
/* |
|
1999 |
* converts the Java CK_X9_42_DH2_DERIVE_PARAMS object to a CK_X9_42_DH2_DERIVE_PARAMS structure |
|
2000 |
* |
|
2001 |
* @param env - used to call JNI funktions to get the Java classes and objects |
|
2002 |
* @param jParam - the Java CK_X9_42_DH2_DERIVE_PARAMS object to convert |
|
2003 |
* @return - the new CK_X9_42_DH2_DERIVE_PARAMS structure |
|
2004 |
*/ |
|
2005 |
CK_X9_42_DH2_DERIVE_PARAMS jX942Dh2DeriveParamToCKX942Dh2DeriveParam(JNIEnv *env, jobject jParam) |
|
2006 |
{ |
|
2180
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
2007 |
jclass jX942Dh2DeriveParamsClass; |
2 | 2008 |
CK_X9_42_DH2_DERIVE_PARAMS ckParam; |
2009 |
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
|
2010 |
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
|
2011 |
jobject jOtherInfo, jPublicData, jPublicData2; |
32094
bebc489aace3
8132551: Initialize local varibales before returning them in p11_convert.c
simonis
parents:
25859
diff
changeset
|
2012 |
memset(&ckParam, 0, sizeof(CK_X9_42_DH2_DERIVE_PARAMS)); |
2 | 2013 |
|
2014 |
/* 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
|
2015 |
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
|
2016 |
if (jX942Dh2DeriveParamsClass == NULL) { return ckParam; } |
2 | 2017 |
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
|
2018 |
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
|
2019 |
jKdf = (*env)->GetLongField(env, jParam, fieldID); |
2 | 2020 |
|
2021 |
/* get pOtherInfo and ulOtherInfoLen */ |
|
2022 |
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
|
2023 |
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
|
2024 |
jOtherInfo = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 2025 |
|
2026 |
/* get pPublicData and ulPublicDataLen */ |
|
2027 |
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
|
2028 |
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
|
2029 |
jPublicData = (*env)->GetObjectField(env, jParam, fieldID); |
2 | 2030 |
|
2031 |
/* get ulPrivateDataLen */ |
|
2032 |
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
|
2033 |
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
|
2034 |
jPrivateDataLen = (*env)->GetLongField(env, jParam, fieldID); |
2 | 2035 |
|
2036 |
/* get hPrivateData */ |
|
2037 |
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
|
2038 |
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
|
2039 |
jPrivateData = (*env)->GetLongField(env, jParam, fieldID); |
2 | 2040 |
|
2041 |
/* get pPublicData2 and ulPublicDataLen2 */ |
|
2042 |
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
|
2043 |
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
|
2044 |
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
|
2045 |
|
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
2046 |
/* 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
|
2047 |
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
|
2048 |
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
|
2049 |
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
|
2050 |
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
|
2051 |
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
|
2052 |
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
|
2053 |
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
|
2054 |
} |
9994f4f08a59
6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents:
2
diff
changeset
|
2055 |
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
|
2056 |
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
|
2057 |
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
|
2058 |
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
|
2059 |
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
|
2060 |
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
|
2061 |
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
|
2062 |
} |
2 | 2063 |
|
2064 |
return ckParam ; |
|
2065 |
} |