Produced by Araxis Merge on 9/25/2018 2:13:26 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\ssl | MAC.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\ssl | MAC.java | Wed Sep 12 17:54:43 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 334 |
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) 199 6, 2013, 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 | package su n.security .ssl; | |
28 | ||
29 | import jav a.security .InvalidKe yException ; | |
30 | import jav a.security .NoSuchAlg orithmExce ption; | |
31 | ||
32 | import jav a.nio.Byte Buffer; | |
33 | ||
34 | import jav ax.crypto. Mac; | |
35 | import jav ax.crypto. SecretKey; | |
36 | ||
37 | import sun .security. ssl.Cipher Suite.MacA lg; | |
38 | import sta tic sun.se curity.ssl .CipherSui te.*; | |
39 | ||
40 | /** | |
41 | * This cl ass comput es the "Me ssage Auth entication Code" (MA C) for eac h | |
42 | * SSL str eam and bl ock cipher message. This is es sentially a shared- PW | |
43 | * signatu re, used t o provide integrity protection for SSL m essages. The | |
44 | * MAC is actually o ne of seve ral keyed hashes, as associate d with the cipher | |
45 | * suite a nd protoco l version. (SSL v3.0 uses one construct, TLS uses another.) | |
46 | * | |
47 | * @author David Bro wnell | |
48 | * @author Andreas S terbenz | |
49 | */ | |
50 | final clas s MAC exte nds Authen ticator { | |
51 | ||
52 | final static MAC NULL = ne w MAC(); | |
53 | ||
54 | // Val ue of the null MAC i s fixed | |
55 | privat e static f inal byte nullMAC[] = new byte [0]; | |
56 | ||
57 | // int ernal iden tifier for the MAC a lgorithm | |
58 | privat e final Ma cAlg macAlg; | |
59 | ||
60 | // JCE Mac objec t | |
61 | privat e final Ma c mac; | |
62 | ||
63 | privat e MAC() { | |
64 | ma cAlg = M_N ULL; | |
65 | ma c = null; | |
66 | } | |
67 | ||
68 | /** | |
69 | * Set up, confi gured for the given SSL/TLS MA C type and version. | |
70 | */ | |
71 | MAC(Ma cAlg macAl g, Protoco lVersion p rotocolVer sion, Secr etKey key) | |
72 | throws N oSuchAlgor ithmExcept ion, Inval idKeyExcep tion { | |
73 | su per(protoc olVersion) ; | |
74 | th is.macAlg = macAlg; | |
75 | ||
76 | St ring algor ithm; | |
77 | bo olean tls = (protoco lVersion.v >= Protoc olVersion. TLS10.v); | |
78 | ||
79 | if (macAlg = = M_MD5) { | |
80 | algorith m = tls ? "HmacMD5" : "SslMacM D5"; | |
81 | } else if (m acAlg == M _SHA) { | |
82 | algorith m = tls ? "HmacSHA1" : "SslMac SHA1"; | |
83 | } else if (m acAlg == M _SHA256) { | |
84 | algorith m = "HmacS HA256"; // TLS 1. 2+ | |
85 | } else if (m acAlg == M _SHA384) { | |
86 | algorith m = "HmacS HA384"; // TLS 1. 2+ | |
87 | } else { | |
88 | throw ne w RuntimeE xception(" Unknown Ma c " + macA lg); | |
89 | } | |
90 | ||
91 | ma c = JsseJc e.getMac(a lgorithm); | |
92 | ma c.init(key ); | |
93 | } | |
94 | ||
95 | /** | |
96 | * Ret urns the l ength of t he MAC. | |
97 | */ | |
98 | int MA Clen() { | |
99 | re turn macAl g.size; | |
100 | } | |
101 | ||
102 | /** | |
103 | * Ret urns the h ash functi on block l ength of t he MAC alo rithm. | |
104 | */ | |
105 | int ha shBlockLen () { | |
106 | re turn macAl g.hashBloc kSize; | |
107 | } | |
108 | ||
109 | /** | |
110 | * Ret urns the h ash functi on minimal padding l ength of t he MAC alo rithm. | |
111 | */ | |
112 | int mi nimalPaddi ngLen() { | |
113 | re turn macAl g.minimalP addingSize ; | |
114 | } | |
115 | ||
116 | /** | |
117 | * Com putes and returns th e MAC for the data i n this byt e array. | |
118 | * | |
119 | * @pa ram type r ecord type | |
120 | * @pa ram buf co mpressed r ecord on w hich the M AC is comp uted | |
121 | * @pa ram offset start of compressed record da ta | |
122 | * @pa ram len th e size of the compre ssed recor d | |
123 | * @pa ram isSimu lated if t rue, simul ate the th e MAC comp utation | |
124 | */ | |
125 | final byte[] com pute(byte type, byte buf[], | |
126 | int offs et, int le n, boolean isSimulat ed) { | |
127 | if (macAlg.s ize == 0) { | |
128 | return n ullMAC; | |
129 | } | |
130 | ||
131 | if (!isSimul ated) { | |
132 | byte[] a dditional = acquireA uthenticat ionBytes(t ype, len); | |
133 | mac.upda te(additio nal); | |
134 | } | |
135 | ma c.update(b uf, offset , len); | |
136 | ||
137 | re turn mac.d oFinal(); | |
138 | } | |
139 | ||
140 | /** | |
141 | * Com pute and r eturns the MAC for t he remaini ng data | |
142 | * in this ByteB uffer. | |
143 | * | |
144 | * On return, th e bb posit ion == lim it, and li mit will | |
145 | * hav e not chan ged. | |
146 | * | |
147 | * @pa ram type r ecord type | |
148 | * @pa ram bb a B yteBuffer in which t he positio n and limi t | |
149 | * dema rcate the data to be MAC'd. | |
150 | * @pa ram isSimu lated if t rue, simul ate the th e MAC comp utation | |
151 | */ | |
152 | final byte[] com pute(byte type, Byte Buffer bb, boolean i sSimulated ) { | |
153 | if (macAlg.s ize == 0) { | |
154 | return n ullMAC; | |
155 | } | |
156 | ||
157 | if (!isSimul ated) { | |
158 | byte[] a dditional = | |
159 | acquireAut henticatio nBytes(typ e, bb.rema ining()); | |
160 | mac.upda te(additio nal); | |
161 | } | |
162 | ma c.update(b b); | |
163 | ||
164 | re turn mac.d oFinal(); | |
165 | } | |
166 | ||
167 | } | |
168 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.