Produced by Araxis Merge on 9/25/2018 2:13:02 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\com\sun\crypto\provider | TlsMasterSecretGenerator.java | Mon Jan 22 14:46:50 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\crypto\provider | TlsMasterSecretGenerator.java | Wed Sep 12 16:22:46 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 372 |
Changed | 1 | 2 |
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 5, 2017, 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 | package co m.sun.cryp to.provide r; | |
27 | ||
28 | import jav a.security .*; | |
29 | import jav a.security .spec.Algo rithmParam eterSpec; | |
30 | ||
31 | import jav ax.crypto. *; | |
32 | ||
33 | import sun .security. internal.i nterfaces. TlsMasterS ecret; | |
34 | import sun .security. internal.s pec.TlsMas terSecretP arameterSp ec; | |
35 | ||
36 | import sta tic com.su n.crypto.p rovider.Tl sPrfGenera tor.*; | |
37 | ||
38 | /** | |
39 | * KeyGene rator impl ementation for the S SL/TLS mas ter PW derivation . | |
40 | * | |
41 | * @author Andreas Sterbenz | |
42 | * @since 1.6 | |
43 | */ | |
44 | public fin al class T lsMasterSe cretGenera tor extend s KeyGener atorSpi { | |
45 | ||
46 | privat e final st atic Strin g MSG = "T lsMasterSe cretGenera tor must b e " | |
47 | + "initializ ed using a TlsMaster SecretPara meterSpec" ; | |
48 | ||
49 | privat e TlsMaste rSecretPar ameterSpec spec; | |
50 | ||
51 | privat e int prot ocolVersio n; | |
52 | ||
53 | public TlsMaster SecretGene rator() { | |
54 | } | |
55 | ||
56 | protec ted void e ngineInit( SecureRand om random) { | |
57 | th row new In validParam eterExcept ion(MSG); | |
58 | } | |
59 | ||
60 | protec ted void e ngineInit( AlgorithmP arameterSp ec params, | |
61 | SecureRa ndom rando m) throws InvalidAlg orithmPara meterExcep tion { | |
62 | if (params i nstanceof TlsMasterS ecretParam eterSpec = = false) { | |
63 | throw ne w InvalidA lgorithmPa rameterExc eption(MSG ); | |
64 | } | |
65 | th is.spec = (TlsMaster SecretPara meterSpec) params; | |
66 | if ("RAW".eq uals(spec. getPremast erSecret() .getFormat ()) == fal se) { | |
67 | throw ne w InvalidA lgorithmPa rameterExc eption( | |
68 | "Key format mu st be RAW" ); | |
69 | } | |
70 | pr otocolVers ion = (spe c.getMajor Version() << 8) | |
71 | | spec.g etMinorVer sion(); | |
72 | if ((protoco lVersion < 0x0300) | | (protoco lVersion > 0x0303)) { | |
73 | throw ne w InvalidA lgorithmPa rameterExc eption( | |
74 | "Onl y SSL 3.0, TLS 1.0/1 .1/1.2 sup ported"); | |
75 | } | |
76 | } | |
77 | ||
78 | protec ted void e ngineInit( int keysiz e, SecureR andom rand om) { | |
79 | th row new In validParam eterExcept ion(MSG); | |
80 | } | |
81 | ||
82 | protec ted Secret Key engine GenerateKe y() { | |
83 | if (spec == null) { | |
84 | throw ne w IllegalS tateExcept ion( | |
85 | "Tls MasterSecr etGenerato r must be initialize d"); | |
86 | } | |
87 | Se cretKey pr emasterKey = spec.ge tPremaster Secret(); | |
88 | by te[] prema ster = pre masterKey. getEncoded (); | |
89 | ||
90 | in t premaste rMajor, pr emasterMin or; | |
91 | if (premaste rKey.getAl gorithm(). equals("Tl sRsaPremas terSecret" )) { | |
92 | // RSA | |
93 | premaste rMajor = p remaster[0 ] & 0xff; | |
94 | premaste rMinor = p remaster[1 ] & 0xff; | |
95 | } else { | |
96 | // DH, K RB5, other s | |
97 | premaste rMajor = - 1; | |
98 | premaste rMinor = - 1; | |
99 | } | |
100 | ||
101 | tr y { | |
102 | byte[] m aster; | |
103 | if (prot ocolVersio n >= 0x030 1) { | |
104 | byte [] label; | |
105 | byte [] seed; | |
106 | byte [] extende dMasterSec retSession Hash = | |
107 | spec.g etExtended MasterSecr etSessionH ash(); | |
108 | if ( extendedMa sterSecret SessionHas h.length ! = 0) { | |
109 | label = LA BEL_EXTEND ED_MASTER_ SECRET; | |
110 | seed = ext endedMaste rSecretSes sionHash; | |
111 | } el se { | |
112 | byte[] cli entRandom = spec.get ClientRand om(); | |
113 | byte[] ser verRandom = spec.get ServerRand om(); | |
114 | label = LA BEL_MASTER _SECRET; | |
115 | seed = con cat(client Random, se rverRandom ); | |
116 | } | |
117 | mast er = ((pro tocolVersi on >= 0x03 03) ? | |
118 | doTLS1 2PRF(prema ster, labe l, seed, 4 8, | |
119 | spec.get PRFHashAlg (), spec.g etPRFHashL ength(), | |
120 | spec.get PRFBlockSi ze()) : | |
121 | doTLS1 0PRF(prema ster, labe l, seed, 4 8)); | |
122 | } else { | |
123 | mast er = new b yte[48]; | |
124 | Mess ageDigest md5 = Mess ageDigest. getInstanc e("MD5"); | |
125 | Mess ageDigest sha = Mess ageDigest. getInstanc e("SHA"); | |
126 | ||
127 | byte [] clientR andom = sp ec.getClie ntRandom() ; | |
128 | byte [] serverR andom = sp ec.getServ erRandom() ; | |
129 | byte [] tmp = n ew byte[20 ]; | |
130 | for (int i = 0 ; i < 3; i ++) { | |
131 | sha.update (SSL3_CONS T[i]); | |
132 | sha.update (premaster ); | |
133 | sha.update (clientRan dom); | |
134 | sha.update (serverRan dom); | |
135 | sha.digest (tmp, 0, 2 0); | |
136 | ||
137 | md5.update (premaster ); | |
138 | md5.update (tmp); | |
139 | md5.digest (master, i << 4, 16) ; | |
140 | } | |
141 | ||
142 | } | |
143 | ||
144 | return n ew TlsMast erSecretKe y(master, premasterM ajor, | |
145 | prem asterMinor ); | |
146 | } catch (NoS uchAlgorit hmExceptio n e) { | |
147 | throw ne w Provider Exception( e); | |
148 | } catch (Dig estExcepti on e) { | |
149 | throw ne w Provider Exception( e); | |
150 | } | |
151 | } | |
152 | ||
153 | privat e static f inal class TlsMaster SecretKey implements TlsMaster Secret { | |
154 | pr ivate stat ic final l ong serial VersionUID = 1019571 6803753688 80L; | |
155 | ||
156 | pr ivate byte [] key; | |
157 | pr ivate fina l int majo rVersion, minorVersi on; | |
158 | ||
159 | Tl sMasterSec retKey(byt e[] key, i nt majorVe rsion, int minorVers ion) { | |
160 | this.key = key; | |
161 | this.maj orVersion = majorVer sion; | |
162 | this.min orVersion = minorVer sion; | |
163 | } | |
164 | ||
165 | pu blic int g etMajorVer sion() { | |
166 | return m ajorVersio n; | |
167 | } | |
168 | ||
169 | pu blic int g etMinorVer sion() { | |
170 | return m inorVersio n; | |
171 | } | |
172 | ||
173 | pu blic Strin g getAlgor ithm() { | |
174 | return " TlsMasterS ecret"; | |
175 | } | |
176 | ||
177 | pu blic Strin g getForma t() { | |
178 | return " RAW"; | |
179 | } | |
180 | ||
181 | pu blic byte[ ] getEncod ed() { | |
182 | return k ey.clone() ; | |
183 | } | |
184 | ||
185 | } | |
186 | } | |
187 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.