Produced by Araxis Merge on 9/25/2018 2:13:23 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\security\krb5\internal\crypto\dk | AesDkCrypto.java | Mon Jan 22 14:46:54 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\security\krb5\internal\crypto\dk | AesDkCrypto.java | Wed Sep 12 17:52:45 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 11 | 982 |
Changed | 10 | 20 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |
2 | * Copyrig ht (c) 200 4, 2008, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | /* | |
27 | */ | |
28 | ||
29 | package su n.security .krb5.inte rnal.crypt o.dk; | |
30 | ||
31 | import jav ax.crypto. Cipher; | |
32 | import jav ax.crypto. Mac; | |
33 | import jav ax.crypto. SecretKeyF actory; | |
34 | import jav ax.crypto. SecretKey; | |
35 | import jav ax.crypto. spec.Secre tKeySpec; | |
36 | import jav ax.crypto. spec.DESed eKeySpec; | |
37 | import jav ax.crypto. spec.IvPar ameterSpec ; | |
38 | import jav ax.crypto. spec.PBEKe ySpec; | |
39 | import jav a.security .spec.KeyS pec; | |
40 | import jav a.security .GeneralSe curityExce ption; | |
41 | import sun .security. krb5.KrbCr yptoExcept ion; | |
42 | import sun .security. krb5.Confo under; | |
43 | import sun .security. krb5.inter nal.crypto .KeyUsage; | |
44 | import jav a.util.Arr ays; | |
45 | ||
46 | /** | |
47 | * This cl ass provid es the imp lementatio n of AES E ncryption for Kerber os | |
48 | * as defi ned RFC 39 62. | |
49 | * http:// www.ietf.o rg/rfc/rfc 3962.txt | |
50 | * | |
51 | * Algorit hm profile described in [KCRYP TO]: | |
52 | * +------ ---------- ---------- ---------- ---------- ---------- ---------- --+ | |
53 | * | p rotocol ke y format 12 8- or 256- bit string | | |
54 | * | | | |
55 | * | stri ng-to-key function PB KDF2+DK wi th variabl e | | |
56 | * | iter ation coun t (see | | |
57 | * | abov e) | | |
58 | * | | | |
59 | * | defa ult string -to-key pa rameters 00 00 10 00 | | |
60 | * | | | |
61 | * | key-gene ration see d length ke y size | | |
62 | * | | | |
63 | * | rand om-to-key function id entity fun ction | | |
64 | * | | | |
65 | * | hash f unction, H SHA- 1 | | |
66 | * | | | |
67 | * | H MAC output size, h 12 octets (9 6 bits) | | |
68 | * | | | |
69 | * | mes sage block size, m 1 octet | | |
70 | * | | | |
71 | * | encr yption/dec ryption fu nctions, AE S in CBC-C TS mode | | |
72 | * | E an d D (cip her block size 16 | | |
73 | * | octe ts), with next to | | |
74 | * | last block as CBC-style | | |
75 | * | ivec | | |
76 | * +------ ---------- ---------- ---------- ---------- ---------- ---------- --+ | |
77 | * | |
78 | * Support s AES128 a nd AES256 | |
79 | * | |
80 | * @author Seema Mal kani | |
81 | */ | |
82 | ||
83 | public cla ss AesDkCr ypto exten ds DkCrypt o { | |
84 | ||
85 | privat e static f inal boole an debug = false; | |
86 | ||
87 | privat e static f inal int B LOCK_SIZE = 16; | |
88 | privat e static f inal int D EFAULT_ITE RATION_COU NT = 4096; | |
89 | privat e static f inal byte[ ] ZERO_IV = new byte [] { 0, 0, 0, 0, 0, 0, 0, 0, | |
90 | 0, 0, 0, 0, 0, 0, 0, 0 }; | |
91 | privat e static f inal int h ashSize = 96/8; | |
92 | privat e final in t keyLengt h; | |
93 | ||
94 | public AesDkCryp to(int len gth) { | |
95 | ke yLength = length; | |
96 | } | |
97 | ||
98 | protec ted int ge tKeySeedLe ngth() { | |
99 | re turn keyLe ngth; // bits; AES key mater ial | |
100 | } | |
101 | ||
102 | public byte[] st ringToKey( char[] pas sword, Str ing salt, byte[] s2k params) | |
103 | th rows Gener alSecurity Exception { | |
104 | ||
105 | by te[] saltU tf8 = null ; | |
106 | tr y { | |
107 | saltUtf8 = salt.ge tBytes("UT F-8"); | |
108 | return s tringToKey (password, saltUtf8, s2kparams ); | |
109 | } catch (Exc eption e) { | |
110 | return n ull; | |
111 | } finally { | |
112 | if (salt Utf8 != nu ll) { | |
113 | Arra ys.fill(sa ltUtf8, (b yte)0); | |
114 | } | |
115 | } | |
116 | } | |
117 | ||
118 | private by te[] strin gToKey(cha r[] PW , byte[] s alt, byte[ ] params) | |
119 | th rows Gener alSecurity Exception { | |
120 | ||
121 | in t iter_cou nt = DEFAU LT_ITERATI ON_COUNT; | |
122 | if (params ! = null) { | |
123 | if (para ms.length != 4) { | |
124 | thro w new Runt imeExcepti on("Invali d paramete r to strin gToKey"); | |
125 | } | |
126 | iter_cou nt = readB igEndian(p arams, 0, 4); | |
127 | } | |
128 | ||
129 | byte[] tmp Key = rand omToKey(PB KDF2( PW , salt, it er_count, | |
130 | getKeySeed Length())) ; | |
131 | by te[] resul t = dk(tmp Key, KERBE ROS_CONSTA NT); | |
132 | re turn resul t; | |
133 | } | |
134 | ||
135 | protec ted byte[] randomToK ey(byte[] in) { | |
136 | // simple id entity ope ration | |
137 | re turn in; | |
138 | } | |
139 | ||
140 | protec ted Cipher getCipher (byte[] ke y, byte[] ivec, int mode) | |
141 | th rows Gener alSecurity Exception { | |
142 | ||
143 | // IV | |
144 | if (ivec == null) { | |
145 | ivec = ZE RO_IV; | |
146 | } | |
147 | SecretKeyS pec PW Key = new SecretKeyS pec(key, " AES"); | |
148 | Ci pher ciphe r = Cipher .getInstan ce("AES/CB C/NoPaddin g"); | |
149 | Iv ParameterS pec encIv = new IvPa rameterSpe c(ivec, 0, ivec.leng th); | |
150 | cipher.ini t(mode, PW Key, encIv ); | |
151 | re turn ciphe r; | |
152 | } | |
153 | ||
154 | // get an instan ce of the AES Cipher in CTS mo de | |
155 | public int getCh ecksumLeng th() { | |
156 | re turn hashS ize; // b ytes | |
157 | } | |
158 | ||
159 | /** | |
160 | * Get the trunc ated HMAC | |
161 | */ | |
162 | protec ted byte[] getHmac(b yte[] key, byte[] ms g) | |
163 | th rows Gener alSecurity Exception { | |
164 | ||
165 | Se cretKey ke yKi = new SecretKeyS pec(key, " HMAC"); | |
166 | Ma c m = Mac. getInstanc e("HmacSHA 1"); | |
167 | m. init(keyKi ); | |
168 | ||
169 | // generate hash | |
170 | by te[] hash = m.doFina l(msg); | |
171 | ||
172 | // truncate hash | |
173 | by te[] outpu t = new by te[hashSiz e]; | |
174 | Sy stem.array copy(hash, 0, output , 0, hashS ize); | |
175 | re turn outpu t; | |
176 | } | |
177 | ||
178 | /** | |
179 | * Cal culate the checksum | |
180 | */ | |
181 | public byte[] ca lculateChe cksum(byte [] baseKey , int usag e, byte[] input, | |
182 | in t start, i nt len) th rows Gener alSecurity Exception { | |
183 | ||
184 | if (!KeyUsag e.isValid( usage)) { | |
185 | throw ne w GeneralS ecurityExc eption("In valid key usage numb er: " | |
186 | + usage); | |
187 | } | |
188 | ||
189 | // Derive ke ys | |
190 | by te[] const ant = new byte[5]; | |
191 | co nstant[0] = (byte) ( (usage>>24 )&0xff); | |
192 | co nstant[1] = (byte) ( (usage>>16 )&0xff); | |
193 | co nstant[2] = (byte) ( (usage>>8) &0xff); | |
194 | co nstant[3] = (byte) ( usage&0xff ); | |
195 | ||
196 | co nstant[4] = (byte) 0 x99; | |
197 | ||
198 | by te[] Kc = dk(baseKey , constant ); // Che cksum key | |
199 | if (debug) { | |
200 | System.e rr.println ("usage: " + usage); | |
201 | traceOut put("input ", input, start, Mat h.min(len, 32)); | |
202 | traceOut put("const ant", cons tant, 0, c onstant.le ngth); | |
203 | traceOut put("baseK ey", baseK ey, 0, bas eKey.lengt h); | |
204 | traceOut put("Kc", Kc, 0, Kc. length); | |
205 | } | |
206 | ||
207 | tr y { | |
208 | // Gener ate checks um | |
209 | // H1 = HMAC(Kc, i nput) | |
210 | byte[] h mac = getH mac(Kc, in put); | |
211 | if (debu g) { | |
212 | trac eOutput("h mac", hmac , 0, hmac. length); | |
213 | } | |
214 | if (hmac .length == getChecks umLength() ) { | |
215 | retu rn hmac; | |
216 | } else i f (hmac.le ngth > get ChecksumLe ngth()) { | |
217 | byte [] buf = n ew byte[ge tChecksumL ength()]; | |
218 | Syst em.arrayco py(hmac, 0 , buf, 0, buf.length ); | |
219 | retu rn buf; | |
220 | } else { | |
221 | thro w new Gene ralSecurit yException ("checksum size too short: " + | |
222 | hmac.l ength + "; expecting : " + get ChecksumLe ngth()); | |
223 | } | |
224 | } finally { | |
225 | Arrays.f ill(Kc, 0, Kc.length , (byte)0) ; | |
226 | } | |
227 | } | |
228 | ||
229 | /** | |
230 | * Per forms encr yption usi ng derived key; adds confounde r. | |
231 | */ | |
232 | public byte[] en crypt(byte [] baseKey , int usag e, | |
233 | by te[] ivec, byte[] ne w_ivec, by te[] plain text, int start, int len) | |
234 | th rows Gener alSecurity Exception, KrbCrypto Exception { | |
235 | ||
236 | if (!KeyUsag e.isValid( usage)) { | |
237 | throw ne w GeneralS ecurityExc eption("In valid key usage numb er: " | |
238 | + usage); | |
239 | } | |
240 | by te[] outpu t = encryp tCTS(baseK ey, usage, ivec, new _ivec, pla intext, | |
241 | start, len , true); | |
242 | re turn outpu t; | |
243 | } | |
244 | ||
245 | /** | |
246 | * Per forms encr yption usi ng derived key; does not add c onfounder. | |
247 | */ | |
248 | public byte[] en cryptRaw(b yte[] base Key, int u sage, | |
249 | by te[] ivec, byte[] pl aintext, i nt start, int len) | |
250 | th rows Gener alSecurity Exception, KrbCrypto Exception { | |
251 | ||
252 | if (!KeyUsag e.isValid( usage)) { | |
253 | throw ne w GeneralS ecurityExc eption("In valid key usage numb er: " | |
254 | + usage); | |
255 | } | |
256 | by te[] outpu t = encryp tCTS(baseK ey, usage, ivec, nul l, plainte xt, | |
257 | start, len , false); | |
258 | re turn outpu t; | |
259 | } | |
260 | ||
261 | /** | |
262 | * @pa ram baseKe y key from which key s are to b e derived using usag e | |
263 | * @pa ram cipher text E(Ke , conf | p laintext | padding, ivec) | H1 [1..h] | |
264 | */ | |
265 | public byte[] de crypt(byte [] baseKey , int usag e, byte[] ivec, | |
266 | by te[] ciphe rtext, int start, in t len) thr ows Genera lSecurityE xception { | |
267 | ||
268 | if (!KeyUsag e.isValid( usage)) { | |
269 | throw ne w GeneralS ecurityExc eption("In valid key usage numb er: " | |
270 | + usage); | |
271 | } | |
272 | by te[] outpu t = decryp tCTS(baseK ey, usage, ivec, cip hertext, | |
273 | start, len , true); | |
274 | re turn outpu t; | |
275 | } | |
276 | ||
277 | /** | |
278 | * Dec rypts data using spe cified key and initi al vector. | |
279 | * @pa ram baseKe y encrypti on key to use | |
280 | * @pa ram cipher text encr ypted data to be dec rypted | |
281 | * @pa ram usage ignored | |
282 | */ | |
283 | public byte[] de cryptRaw(b yte[] base Key, int u sage, byte [] ivec, | |
284 | by te[] ciphe rtext, int start, in t len) | |
285 | th rows Gener alSecurity Exception { | |
286 | ||
287 | if (!KeyUsag e.isValid( usage)) { | |
288 | throw ne w GeneralS ecurityExc eption("In valid key usage numb er: " | |
289 | + usage); | |
290 | } | |
291 | by te[] outpu t = decryp tCTS(baseK ey, usage, ivec, cip hertext, | |
292 | start, len , false); | |
293 | re turn outpu t; | |
294 | } | |
295 | ||
296 | /** | |
297 | * Enc rypt AES i n CBC-CTS mode using derived k eys. | |
298 | */ | |
299 | privat e byte[] e ncryptCTS( byte[] bas eKey, int usage, byt e[] ivec, | |
300 | by te[] new_i vec, byte[ ] plaintex t, int sta rt, int le n, | |
301 | bo olean conf ounder_exi sts) | |
302 | th rows Gener alSecurity Exception, KrbCrypto Exception { | |
303 | ||
304 | by te[] Ke = null; | |
305 | by te[] Ki = null; | |
306 | ||
307 | if (debug) { | |
308 | System.e rr.println ("usage: " + usage); | |
309 | if (ivec != null) { | |
310 | trac eOutput("o ld_state.i vec", ivec , 0, ivec. length); | |
311 | } | |
312 | traceOut put("plain text", pla intext, st art, Math. min(len, 3 2)); | |
313 | traceOut put("baseK ey", baseK ey, 0, bas eKey.lengt h); | |
314 | } | |
315 | ||
316 | tr y { | |
317 | // deriv e Encrypti on key | |
318 | byte[] c onstant = new byte[5 ]; | |
319 | constant [0] = (byt e) ((usage >>24)&0xff ); | |
320 | constant [1] = (byt e) ((usage >>16)&0xff ); | |
321 | constant [2] = (byt e) ((usage >>8)&0xff) ; | |
322 | constant [3] = (byt e) (usage& 0xff); | |
323 | constant [4] = (byt e) 0xaa; | |
324 | Ke = dk( baseKey, c onstant); // Encryp tion key | |
325 | ||
326 | byte[] t oBeEncrypt ed = null; | |
327 | if (conf ounder_exi sts) { | |
328 | byte [] confoun der = Conf ounder.byt es(BLOCK_S IZE); | |
329 | toBe Encrypted = new byte [confounde r.length + len]; | |
330 | Syst em.arrayco py(confoun der, 0, to BeEncrypte d, | |
331 | 0, confoun der.length ); | |
332 | Syst em.arrayco py(plainte xt, start, toBeEncry pted, | |
333 | confounder .length, l en); | |
334 | } else { | |
335 | toBe Encrypted = new byte [len]; | |
336 | Syst em.arrayco py(plainte xt, start, toBeEncry pted, 0, l en); | |
337 | } | |
338 | ||
339 | // encry ptedData + HMAC | |
340 | byte[] o utput = ne w byte[toB eEncrypted .length + hashSize]; | |
341 | ||
342 | // AES i n JCE | |
343 | Cipher c ipher = Ci pher.getIn stance("AE S/CTS/NoPa dding"); | |
344 | SecretKeyS pec PW Key = new SecretKeyS pec(Ke, "A ES"); | |
345 | IvParame terSpec en cIv = new IvParamete rSpec(ivec , 0, ivec. length); | |
346 | cipher.ini t(Cipher.E NCRYPT_MOD E, PW Key, encIv ); | |
347 | cipher.d oFinal(toB eEncrypted , 0, toBeE ncrypted.l ength, out put); | |
348 | ||
349 | // Deriv e integrit y key | |
350 | constant [4] = (byt e) 0x55; | |
351 | Ki = dk( baseKey, c onstant); | |
352 | if (debu g) { | |
353 | trac eOutput("c onstant", constant, 0, constan t.length); | |
354 | trac eOutput("K i", Ki, 0, Ke.length ); | |
355 | } | |
356 | ||
357 | // Gener ate checks um | |
358 | // H1 = HMAC(Ki, c onf | plai ntext | pa d) | |
359 | byte[] h mac = getH mac(Ki, to BeEncrypte d); | |
360 | ||
361 | // encry ptedData + HMAC | |
362 | System.a rraycopy(h mac, 0, ou tput, toBe Encrypted. length, | |
363 | hmac.len gth); | |
364 | return o utput; | |
365 | } finally { | |
366 | if (Ke ! = null) { | |
367 | Arra ys.fill(Ke , 0, Ke.le ngth, (byt e) 0); | |
368 | } | |
369 | if (Ki ! = null) { | |
370 | Arra ys.fill(Ki , 0, Ki.le ngth, (byt e) 0); | |
371 | } | |
372 | } | |
373 | } | |
374 | ||
375 | /** | |
376 | * Dec rypt AES i n CBC-CTS mode using derived k eys. | |
377 | */ | |
378 | privat e byte[] d ecryptCTS( byte[] bas eKey, int usage, byt e[] ivec, | |
379 | by te[] ciphe rtext, int start, in t len, boo lean confo under_exis ts) | |
380 | th rows Gener alSecurity Exception { | |
381 | ||
382 | by te[] Ke = null; | |
383 | by te[] Ki = null; | |
384 | ||
385 | tr y { | |
386 | // Deriv e encrypti on key | |
387 | byte[] c onstant = new byte[5 ]; | |
388 | constant [0] = (byt e) ((usage >>24)&0xff ); | |
389 | constant [1] = (byt e) ((usage >>16)&0xff ); | |
390 | constant [2] = (byt e) ((usage >>8)&0xff) ; | |
391 | constant [3] = (byt e) (usage& 0xff); | |
392 | ||
393 | constant [4] = (byt e) 0xaa; | |
394 | Ke = dk( baseKey, c onstant); // Encryp tion key | |
395 | ||
396 | if (debu g) { | |
397 | Syst em.err.pri ntln("usag e: " + usa ge); | |
398 | if ( ivec != nu ll) { | |
399 | traceOutpu t("old_sta te.ivec", ivec, 0, i vec.length ); | |
400 | } | |
401 | trac eOutput("c iphertext" , cipherte xt, start, Math.min( len, 32)); | |
402 | trac eOutput("c onstant", constant, 0, constan t.length); | |
403 | trac eOutput("b aseKey", b aseKey, 0, baseKey.l ength); | |
404 | trac eOutput("K e", Ke, 0, Ke.length ); | |
405 | } | |
406 | ||
407 | // Decry pt [confou nder | pla intext ] ( without ch ecksum) | |
408 | ||
409 | // AES i n JCE | |
410 | Cipher c ipher = Ci pher.getIn stance("AE S/CTS/NoPa dding"); | |
411 | SecretKeyS pec PW Key = new SecretKeyS pec(Ke, "A ES"); | |
412 | IvParame terSpec en cIv = new IvParamete rSpec(ivec , 0, ivec. length); | |
413 | cipher.ini t(Cipher.D ECRYPT_MOD E, PW Key, encIv ); | |
414 | byte[] p laintext = cipher.do Final(ciph ertext, st art, len-h ashSize); | |
415 | ||
416 | if (debu g) { | |
417 | trac eOutput("A ES PlainTe xt", plain text, 0, | |
418 | Math.min (plaintext .length, 3 2)); | |
419 | } | |
420 | ||
421 | // Deriv e integrit y key | |
422 | constant [4] = (byt e) 0x55; | |
423 | Ki = dk( baseKey, c onstant); // Integr ity key | |
424 | if (debu g) { | |
425 | trac eOutput("c onstant", constant, 0, constan t.length); | |
426 | trac eOutput("K i", Ki, 0, Ke.length ); | |
427 | } | |
428 | ||
429 | // Verif y checksum | |
430 | // H1 = HMAC(Ki, c onf | plai ntext | pa d) | |
431 | byte[] c alculatedH mac = getH mac(Ki, pl aintext); | |
432 | int hmac Offset = s tart + len - hashSiz e; | |
433 | if (debu g) { | |
434 | trac eOutput("c alculated Hmac", cal culatedHma c, | |
435 | 0, calcu latedHmac. length); | |
436 | trac eOutput("m essage Hma c", cipher text, hmac Offset, ha shSize); | |
437 | } | |
438 | boolean cksumFaile d = false; | |
439 | if (calc ulatedHmac .length >= hashSize) { | |
440 | for (int i = 0 ; i < hash Size; i++) { | |
441 | if (calcul atedHmac[i ] != ciphe rtext[hmac Offset+i]) { | |
442 | cksumF ailed = tr ue; | |
443 | if (de bug) { | |
444 | Sy stem.err.p rintln("Ch ecksum fai led !"); | |
445 | } | |
446 | break; | |
447 | } | |
448 | } | |
449 | } | |
450 | if (cksu mFailed) { | |
451 | thro w new Gene ralSecurit yException ("Checksum failed"); | |
452 | } | |
453 | ||
454 | if (conf ounder_exi sts) { | |
455 | // G et rid of confounder | |
456 | // [ confounde r | plaint ext ] | |
457 | byte [] output = new byte [plaintext .length - BLOCK_SIZE ]; | |
458 | Syst em.arrayco py(plainte xt, BLOCK_ SIZE, outp ut, | |
459 | 0, output. length); | |
460 | retu rn output; | |
461 | } else { | |
462 | retu rn plainte xt; | |
463 | } | |
464 | } finally { | |
465 | if (Ke ! = null) { | |
466 | Arra ys.fill(Ke , 0, Ke.le ngth, (byt e) 0); | |
467 | } | |
468 | if (Ki ! = null) { | |
469 | Arra ys.fill(Ki , 0, Ki.le ngth, (byt e) 0); | |
470 | } | |
471 | } | |
472 | } | |
473 | ||
474 | /* | |
475 | * Inv oke the PK CS#5 PBKDF 2 algorith m | |
476 | */ | |
477 | private st atic byte[ ] PBKDF2(c har[] PW , byte[] s alt, | |
478 | in t count, i nt keyLeng th) throws GeneralSe curityExce ption { | |
479 | ||
480 | PBEKeySpec keySpec = new PBEKe ySpec( PW , salt, co unt, keyLe ngth); | |
481 | Se cretKeyFac tory skf = | |
482 | Secr etKeyFacto ry.getInst ance("PBKD F2WithHmac SHA1"); | |
483 | Se cretKey ke y = skf.ge nerateSecr et(keySpec ); | |
484 | by te[] resul t = key.ge tEncoded() ; | |
485 | ||
486 | re turn resul t; | |
487 | } | |
488 | ||
489 | public static fi nal int re adBigEndia n(byte[] d ata, int p os, int si ze) { | |
490 | in t retVal = 0; | |
491 | in t shifter = (size-1) *8; | |
492 | wh ile (size > 0) { | |
493 | retVal + = (data[po s] & 0xff) << shifte r; | |
494 | shifter -= 8; | |
495 | pos++; | |
496 | size--; | |
497 | } | |
498 | re turn retVa l; | |
499 | } | |
500 | ||
501 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.