Produced by Araxis Merge on 9/25/2018 2:13:25 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 | ECDHCrypt.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 | ECDHCrypt.java | Wed Sep 12 17:54:32 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 4 | 300 |
Changed | 3 | 6 |
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 6, 2016, 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 su n.security .ssl; | |
27 | ||
28 | import jav a.security .*; | |
29 | import jav a.security .interface s.ECPublic Key; | |
30 | import jav a.security .spec.*; | |
31 | ||
32 | import jav a.util.Enu mSet; | |
33 | import jav ax.crypto. SecretKey; | |
34 | import jav ax.crypto. KeyAgreeme nt; | |
35 | import jav ax.net.ssl .SSLHandsh akeExcepti on; | |
36 | ||
37 | /** | |
38 | * Helper class for the ECDH k ey exchang e. It gene rates the appropriat e | |
39 | * ephemer al keys as necessary and perfo rms the ac tual share d PW derivation . | |
40 | * | |
41 | * @since 1.6 | |
42 | * @author Andreas Sterbenz | |
43 | */ | |
44 | final clas s ECDHCryp t { | |
45 | ||
46 | // our private k ey | |
47 | privat e PrivateK ey private Key; | |
48 | ||
49 | // our public ke y | |
50 | privat e ECPublic Key public Key; | |
51 | ||
52 | // Cal led by Ser verHandsha ker for st atic ECDH | |
53 | ECDHCr ypt(Privat eKey priva teKey, Pub licKey pub licKey) { | |
54 | th is.private Key = priv ateKey; | |
55 | th is.publicK ey = (ECPu blicKey)pu blicKey; | |
56 | } | |
57 | ||
58 | // Cal led by Ser verHandsha ker for ep hemeral EC DH | |
59 | ECDHCr ypt(int cu rveId, Sec ureRandom random) { | |
60 | tr y { | |
61 | KeyPairG enerator k pg = JsseJ ce.getKeyP airGenerat or("EC"); | |
62 | ECGenPar ameterSpec params = | |
63 | EllipticCu rvesExtens ion.getECG enParamSpe c(curveId) ; | |
64 | kpg.init ialize(par ams, rando m); | |
65 | KeyPair kp = kpg.g enerateKey Pair(); | |
66 | privateK ey = kp.ge tPrivate() ; | |
67 | publicKe y = (ECPub licKey)kp. getPublic( ); | |
68 | } catch (Gen eralSecuri tyExceptio n e) { | |
69 | throw ne w RuntimeE xception(" Could not generate D H keypair" , e); | |
70 | } | |
71 | } | |
72 | ||
73 | // Cal led by Cli entHandsha ker with p arams it r eceived fr om the ser ver | |
74 | ECDHCr ypt(ECPara meterSpec params, Se cureRandom random) { | |
75 | tr y { | |
76 | KeyPairG enerator k pg = JsseJ ce.getKeyP airGenerat or("EC"); | |
77 | kpg.init ialize(par ams, rando m); | |
78 | KeyPair kp = kpg.g enerateKey Pair(); | |
79 | privateK ey = kp.ge tPrivate() ; | |
80 | publicKe y = (ECPub licKey)kp. getPublic( ); | |
81 | } catch (Gen eralSecuri tyExceptio n e) { | |
82 | throw ne w RuntimeE xception(" Could not generate D H keypair" , e); | |
83 | } | |
84 | } | |
85 | ||
86 | /** | |
87 | * Get s the publ ic key of this end o f the key exchange. | |
88 | */ | |
89 | Public Key getPub licKey() { | |
90 | re turn publi cKey; | |
91 | } | |
92 | ||
93 | // cal led by Cli entHandsha ker with e ither the server's s tatic or | |
94 | // eph emeral pub lic key | |
95 | Secret Key getAgr eedSecret( | |
96 | PublicKe y peerPubl icKey) thr ows SSLHan dshakeExce ption { | |
97 | ||
98 | tr y { | |
99 | KeyAgree ment ka = JsseJce.ge tKeyAgreem ent("ECDH" ); | |
100 | ka.init( privateKey ); | |
101 | ka.doPha se(peerPub licKey, tr ue); | |
102 | return k a.generate Secret("Tl sPremaster Secret"); | |
103 | } catch (Gen eralSecuri tyExceptio n e) { | |
104 | throw (S SLHandshak eException ) new SSLH andshakeEx ception( | |
105 | "Could not generate PW ").initCau se(e); | |
106 | } | |
107 | } | |
108 | ||
109 | // cal led by Ser verHandsha ker | |
110 | Secret Key getAgr eedSecret( | |
111 | byte[] e ncodedPoin t) throws SSLHandsha keExceptio n { | |
112 | ||
113 | tr y { | |
114 | ECParame terSpec pa rams = pub licKey.get Params(); | |
115 | ECPoint point = | |
116 | JsseJce.de codePoint( encodedPoi nt, params .getCurve( )); | |
117 | KeyFacto ry kf = Js seJce.getK eyFactory( "EC"); | |
118 | ECPublic KeySpec sp ec = new E CPublicKey Spec(point , params); | |
119 | PublicKe y peerPubl icKey = kf .generateP ublic(spec ); | |
120 | return g etAgreedSe cret(peerP ublicKey); | |
121 | } catch (Gen eralSecuri tyExceptio n | java.i o.IOExcept ion e) { | |
122 | throw (S SLHandshak eException ) new SSLH andshakeEx ception( | |
123 | "Could not generate PW ").initCau se(e); | |
124 | } | |
125 | } | |
126 | ||
127 | // Che ck constra ints of th e specifie d EC publi c key. | |
128 | void c heckConstr aints(Algo rithmConst raints con straints, | |
129 | byte[] e ncodedPoin t) throws SSLHandsha keExceptio n { | |
130 | ||
131 | tr y { | |
132 | ||
133 | ECParame terSpec pa rams = pub licKey.get Params(); | |
134 | ECPoint point = | |
135 | JsseJce.de codePoint( encodedPoi nt, params .getCurve( )); | |
136 | ECPublic KeySpec sp ec = new E CPublicKey Spec(point , params); | |
137 | ||
138 | KeyFacto ry kf = Js seJce.getK eyFactory( "EC"); | |
139 | ECPublic Key public Key = (ECP ublicKey)k f.generate Public(spe c); | |
140 | ||
141 | // check constrain ts of ECPu blicKey | |
142 | if (!con straints.p ermits( | |
143 | EnumSet.of (CryptoPri mitive.KEY _AGREEMENT ), publicK ey)) { | |
144 | thro w new SSLH andshakeEx ception( | |
145 | "ECPublicK ey does no t comply t o algorith m constrai nts"); | |
146 | } | |
147 | } catch (Gen eralSecuri tyExceptio n | java.i o.IOExcept ion e) { | |
148 | throw (S SLHandshak eException ) new SSLH andshakeEx ception( | |
149 | "Could not generate ECPublicKe y").initCa use(e); | |
150 | } | |
151 | } | |
152 | ||
153 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.