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 | SslMacCore.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 | SslMacCore.java | Wed Sep 12 16:22:44 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 12 | 504 |
Changed | 11 | 24 |
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, 2009, 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.nio.Byte Buffer; | |
29 | ||
30 | import jav ax.crypto. MacSpi; | |
31 | import jav ax.crypto. SecretKey; | |
32 | import jav a.security .*; | |
33 | import jav a.security .spec.Algo rithmParam eterSpec; | |
34 | ||
35 | import sta tic com.su n.crypto.p rovider.Tl sPrfGenera tor.genPad ; | |
36 | ||
37 | /** | |
38 | * This fi le contain s the code for the S slMacMD5 a nd SslMacS HA1 implem entations. | |
39 | * The SSL 3.0 MAC i s a variat ion of the HMAC algo rithm. | |
40 | * | |
41 | * Note th at we don' t implemen t Cloneabl e as that is not nee ded for SS L. | |
42 | * | |
43 | * @author Andreas Sterbenz | |
44 | * @since 1.6 | |
45 | */ | |
46 | final clas s SslMacCo re { | |
47 | ||
48 | privat e final Me ssageDiges t md; | |
49 | privat e final by te[] pad1, pad2; | |
50 | ||
51 | privat e boolean first; // Is t his the fi rst data t o be proce ssed? | |
52 | private by te[] PW ; | |
53 | ||
54 | /** | |
55 | * Sta ndard cons tructor, c reates a n ew SslMacC ore instan ce instant iating | |
56 | * a M essageDige st of the specified name. | |
57 | */ | |
58 | SslMac Core(Strin g digestAl gorithm, b yte[] pad1 , byte[] p ad2) | |
59 | throws N oSuchAlgor ithmExcept ion { | |
60 | md = Message Digest.get Instance(d igestAlgor ithm); | |
61 | th is.pad1 = pad1; | |
62 | th is.pad2 = pad2; | |
63 | fi rst = true ; | |
64 | } | |
65 | ||
66 | /** | |
67 | * Ret urns the l ength of t he Mac in bytes. | |
68 | * | |
69 | * @re turn the M ac length in bytes. | |
70 | */ | |
71 | int ge tDigestLen gth() { | |
72 | re turn md.ge tDigestLen gth(); | |
73 | } | |
74 | ||
75 | /** | |
76 | * Initiali zes the Ma c with the given PW key and al gorithm pa rameters. | |
77 | * | |
78 | * @param k ey the PW key. | |
79 | * @pa ram params the algor ithm param eters. | |
80 | * | |
81 | * @ex ception In validKeyEx ception if the given key is in appropriat e for | |
82 | * ini tializing this MAC. | |
83 | * @ex ception In validAlgor ithmParame terExcepti on if the given algo rithm | |
84 | * par ameters ar e inapprop riate for this MAC. | |
85 | */ | |
86 | void i nit(Key ke y, Algorit hmParamete rSpec para ms) | |
87 | throws I nvalidKeyE xception, InvalidAlg orithmPara meterExcep tion { | |
88 | ||
89 | if (params ! = null) { | |
90 | throw ne w InvalidA lgorithmPa rameterExc eption | |
91 | ("Ss lMac does not use pa rameters") ; | |
92 | } | |
93 | ||
94 | if (!(key in stanceof S ecretKey)) { | |
95 | throw ne w InvalidK eyExceptio n("Secret key expect ed"); | |
96 | } | |
97 | ||
98 | PW = key.getE ncoded(); | |
99 | if ( PW == null || PW .length == 0) { | |
100 | throw ne w InvalidK eyExceptio n("Missing key data" ); | |
101 | } | |
102 | ||
103 | re set(); | |
104 | } | |
105 | ||
106 | /** | |
107 | * Pro cesses the given byt e. | |
108 | * | |
109 | * @pa ram input the input byte to be processed . | |
110 | */ | |
111 | void u pdate(byte input) { | |
112 | if (first == true) { | |
113 | // compu te digest for 1st pa ss; start with inner pad | |
114 | md.update( PW ); | |
115 | md.updat e(pad1); | |
116 | first = false; | |
117 | } | |
118 | ||
119 | // add the p assed byte to the in ner digest | |
120 | md .update(in put); | |
121 | } | |
122 | ||
123 | /** | |
124 | * Pro cesses the first <co de>len</co de> bytes in <code>i nput</code >, | |
125 | * sta rting at < code>offse t</code>. | |
126 | * | |
127 | * @pa ram input the input buffer. | |
128 | * @pa ram offset the offse t in <code >input</co de> where the input starts. | |
129 | * @pa ram len th e number o f bytes to process. | |
130 | */ | |
131 | void u pdate(byte input[], int offset , int len) { | |
132 | if (first == true) { | |
133 | // compu te digest for 1st pa ss; start with inner pad | |
134 | md.update( PW ); | |
135 | md.updat e(pad1); | |
136 | first = false; | |
137 | } | |
138 | ||
139 | // add the s elected pa rt of an a rray of by tes to the inner dig est | |
140 | md .update(in put, offse t, len); | |
141 | } | |
142 | ||
143 | void u pdate(Byte Buffer inp ut) { | |
144 | if (first == true) { | |
145 | // compu te digest for 1st pa ss; start with inner pad | |
146 | md.update( PW ); | |
147 | md.updat e(pad1); | |
148 | first = false; | |
149 | } | |
150 | ||
151 | md .update(in put); | |
152 | } | |
153 | ||
154 | /** | |
155 | * Com pletes the Mac compu tation and resets th e Mac for further us e, | |
156 | * maintain ing the PW key that t he Mac was initializ ed with. | |
157 | * | |
158 | * @re turn the M ac result. | |
159 | */ | |
160 | byte[] doFinal() { | |
161 | if (first == true) { | |
162 | // compu te digest for 1st pa ss; start with inner pad | |
163 | md.update( PW ); | |
164 | md.updat e(pad1); | |
165 | } else { | |
166 | first = true; | |
167 | } | |
168 | ||
169 | tr y { | |
170 | // finis h the inne r digest | |
171 | byte[] t mp = md.di gest(); | |
172 | ||
173 | // compu te digest for 2nd pa ss; start with outer pad | |
174 | md.update( PW ); | |
175 | md.updat e(pad2); | |
176 | // add r esult of 1 st hash | |
177 | md.updat e(tmp); | |
178 | ||
179 | md.diges t(tmp, 0, tmp.length ); | |
180 | return t mp; | |
181 | } catch (Dig estExcepti on e) { | |
182 | // shoul d never oc cur | |
183 | throw ne w Provider Exception( e); | |
184 | } | |
185 | } | |
186 | ||
187 | /** | |
188 | * Resets t he Mac for further u se, mainta ining the PW key that t he | |
189 | * Mac was initi alized wit h. | |
190 | */ | |
191 | void r eset() { | |
192 | if (first == false) { | |
193 | md.reset (); | |
194 | first = true; | |
195 | } | |
196 | } | |
197 | ||
198 | // nes ted static class for the SslMa cMD5 imple mentation | |
199 | public static fi nal class SslMacMD5 extends Ma cSpi { | |
200 | pr ivate fina l SslMacCo re core; | |
201 | pu blic SslMa cMD5() thr ows NoSuch AlgorithmE xception { | |
202 | core = n ew SslMacC ore("MD5", md5Pad1, md5Pad2); | |
203 | } | |
204 | pr otected in t engineGe tMacLength () { | |
205 | return c ore.getDig estLength( ); | |
206 | } | |
207 | pr otected vo id engineI nit(Key ke y, Algorit hmParamete rSpec para ms) | |
208 | thro ws Invalid KeyExcepti on, Invali dAlgorithm ParameterE xception { | |
209 | core.ini t(key, par ams); | |
210 | } | |
211 | pr otected vo id engineU pdate(byte input) { | |
212 | core.upd ate(input) ; | |
213 | } | |
214 | pr otected vo id engineU pdate(byte input[], int offset , int len) { | |
215 | core.upd ate(input, offset, l en); | |
216 | } | |
217 | pr otected vo id engineU pdate(Byte Buffer inp ut) { | |
218 | core.upd ate(input) ; | |
219 | } | |
220 | pr otected by te[] engin eDoFinal() { | |
221 | return c ore.doFina l(); | |
222 | } | |
223 | pr otected vo id engineR eset() { | |
224 | core.res et(); | |
225 | } | |
226 | ||
227 | st atic final byte[] md 5Pad1 = ge nPad((byte )0x36, 48) ; | |
228 | st atic final byte[] md 5Pad2 = ge nPad((byte )0x5c, 48) ; | |
229 | } | |
230 | ||
231 | // nes ted static class for the SslMa cMD5 imple mentation | |
232 | public static fi nal class SslMacSHA1 extends M acSpi { | |
233 | pr ivate fina l SslMacCo re core; | |
234 | pu blic SslMa cSHA1() th rows NoSuc hAlgorithm Exception { | |
235 | core = n ew SslMacC ore("SHA", shaPad1, shaPad2); | |
236 | } | |
237 | pr otected in t engineGe tMacLength () { | |
238 | return c ore.getDig estLength( ); | |
239 | } | |
240 | pr otected vo id engineI nit(Key ke y, Algorit hmParamete rSpec para ms) | |
241 | thro ws Invalid KeyExcepti on, Invali dAlgorithm ParameterE xception { | |
242 | core.ini t(key, par ams); | |
243 | } | |
244 | pr otected vo id engineU pdate(byte input) { | |
245 | core.upd ate(input) ; | |
246 | } | |
247 | pr otected vo id engineU pdate(byte input[], int offset , int len) { | |
248 | core.upd ate(input, offset, l en); | |
249 | } | |
250 | pr otected vo id engineU pdate(Byte Buffer inp ut) { | |
251 | core.upd ate(input) ; | |
252 | } | |
253 | pr otected by te[] engin eDoFinal() { | |
254 | return c ore.doFina l(); | |
255 | } | |
256 | pr otected vo id engineR eset() { | |
257 | core.res et(); | |
258 | } | |
259 | ||
260 | st atic final byte[] sh aPad1 = ge nPad((byte )0x36, 40) ; | |
261 | st atic final byte[] sh aPad2 = ge nPad((byte )0x5c, 40) ; | |
262 | } | |
263 | ||
264 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.