Produced by Araxis Merge on 9/25/2018 2:13:01 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 | ConstructKeys.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 | ConstructKeys.java | Wed Sep 12 16:22:18 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 5 | 368 |
Changed | 4 | 8 |
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 9, 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 | package co m.sun.cryp to.provide r; | |
27 | ||
28 | import jav a.security .Key; | |
29 | import jav a.security .PublicKey ; | |
30 | import jav a.security .PrivateKe y; | |
31 | import jav a.security .KeyFactor y; | |
32 | import jav a.security .InvalidKe yException ; | |
33 | import jav a.security .NoSuchAlg orithmExce ption; | |
34 | import jav a.security .spec.PKCS 8EncodedKe ySpec; | |
35 | import jav a.security .spec.X509 EncodedKey Spec; | |
36 | import jav a.security .spec.Inva lidKeySpec Exception; | |
37 | ||
38 | import jav ax.crypto. SecretKey; | |
39 | import jav ax.crypto. Cipher; | |
40 | import jav ax.crypto. spec.Secre tKeySpec; | |
41 | ||
42 | /** | |
43 | * This cl ass is a h elper clas s which co nstruct ke y objects | |
44 | * from en coded keys . | |
45 | * | |
46 | * @author Sharon Li u | |
47 | * | |
48 | */ | |
49 | ||
50 | final clas s Construc tKeys { | |
51 | /** | |
52 | * Con struct a p ublic key from its e ncoding. | |
53 | * | |
54 | * @pa ram encode dKey the e ncoding of a public key. | |
55 | * | |
56 | * @pa ram encode dKeyAlgori thm the al gorithm th e encodedK ey is for. | |
57 | * | |
58 | * @re turn a pub lic key co nstructed from the e ncodedKey. | |
59 | */ | |
60 | privat e static f inal Publi cKey const ructPublic Key(byte[] encodedKe y, | |
61 | Stri ng encoded KeyAlgorit hm) | |
62 | th rows Inval idKeyExcep tion, NoSu chAlgorith mException | |
63 | { | |
64 | Pu blicKey ke y = null; | |
65 | ||
66 | tr y { | |
67 | KeyFacto ry keyFact ory = | |
68 | KeyF actory.get Instance(e ncodedKeyA lgorithm, | |
69 | SunJCE.get Instance() ); | |
70 | X509Enco dedKeySpec keySpec = new X509E ncodedKeyS pec(encode dKey); | |
71 | key = ke yFactory.g eneratePub lic(keySpe c); | |
72 | } catch (NoS uchAlgorit hmExceptio n nsae) { | |
73 | // Try t o see whet her there is another | |
74 | // provi der which supports t his algori thm | |
75 | try { | |
76 | KeyF actory key Factory = | |
77 | KeyFactory .getInstan ce(encoded KeyAlgorit hm); | |
78 | X509 EncodedKey Spec keySp ec = | |
79 | new X509En codedKeySp ec(encoded Key); | |
80 | key = keyFacto ry.generat ePublic(ke ySpec); | |
81 | } catch (NoSuchAlg orithmExce ption nsae 2) { | |
82 | thro w new NoSu chAlgorith mException ("No insta lled provi ders " + | |
83 | "can crea te keys fo r the " + | |
84 | encodedKe yAlgorithm + | |
85 | "algorith m"); | |
86 | } catch (InvalidKe ySpecExcep tion ikse2 ) { | |
87 | Inva lidKeyExce ption ike = | |
88 | new Invali dKeyExcept ion("Canno t construc t public k ey"); | |
89 | ike. initCause( ikse2); | |
90 | thro w ike; | |
91 | } | |
92 | } catch (Inv alidKeySpe cException ikse) { | |
93 | InvalidK eyExceptio n ike = | |
94 | new InvalidKey Exception( "Cannot co nstruct pu blic key") ; | |
95 | ike.init Cause(ikse ); | |
96 | throw ik e; | |
97 | } | |
98 | ||
99 | re turn key; | |
100 | } | |
101 | ||
102 | /** | |
103 | * Con struct a p rivate key from its encoding. | |
104 | * | |
105 | * @pa ram encode dKey the e ncoding of a private key. | |
106 | * | |
107 | * @pa ram encode dKeyAlgori thm the al gorithm th e wrapped key is for . | |
108 | * | |
109 | * @re turn a pri vate key c onstructed from the encodedKey . | |
110 | */ | |
111 | privat e static f inal Priva teKey cons tructPriva teKey(byte [] encoded Key, | |
112 | St ring encod edKeyAlgor ithm) | |
113 | th rows Inval idKeyExcep tion, NoSu chAlgorith mException | |
114 | { | |
115 | Pr ivateKey k ey = null; | |
116 | ||
117 | tr y { | |
118 | KeyFacto ry keyFact ory = | |
119 | KeyF actory.get Instance(e ncodedKeyA lgorithm, | |
120 | SunJCE.get Instance() ); | |
121 | PKCS8Enc odedKeySpe c keySpec = new PKCS 8EncodedKe ySpec(enco dedKey); | |
122 | return k eyFactory. generatePr ivate(keyS pec); | |
123 | } catch (NoS uchAlgorit hmExceptio n nsae) { | |
124 | // Try t o see whet her there is another | |
125 | // provi der which supports t his algori thm | |
126 | try { | |
127 | KeyF actory key Factory = | |
128 | KeyFactory .getInstan ce(encoded KeyAlgorit hm); | |
129 | PKCS 8EncodedKe ySpec keyS pec = | |
130 | new PKCS8E ncodedKeyS pec(encode dKey); | |
131 | key = keyFacto ry.generat ePrivate(k eySpec); | |
132 | } catch (NoSuchAlg orithmExce ption nsae 2) { | |
133 | thro w new NoSu chAlgorith mException ("No insta lled provi ders " + | |
134 | "can crea te keys fo r the " + | |
135 | encodedKe yAlgorithm + | |
136 | "algorith m"); | |
137 | } catch (InvalidKe ySpecExcep tion ikse2 ) { | |
138 | Inva lidKeyExce ption ike = | |
139 | new Invali dKeyExcept ion("Canno t construc t private key"); | |
140 | ike. initCause( ikse2); | |
141 | thro w ike; | |
142 | } | |
143 | } catch (Inv alidKeySpe cException ikse) { | |
144 | InvalidK eyExceptio n ike = | |
145 | new InvalidKey Exception( "Cannot co nstruct pr ivate key" ); | |
146 | ike.init Cause(ikse ); | |
147 | throw ik e; | |
148 | } | |
149 | ||
150 | re turn key; | |
151 | } | |
152 | ||
153 | /** | |
154 | * Construc t a PW key from i ts encodin g. | |
155 | * | |
156 | * @param e ncodedKey the encodi ng of a PW key. | |
157 | * | |
158 | * @param e ncodedKeyA lgorithm t he algorit hm the PW key is for . | |
159 | * | |
160 | * @return a PW key constr ucted from the encod edKey. | |
161 | */ | |
162 | privat e static f inal Secre tKey const ructSecret Key(byte[] encodedKe y, | |
163 | Stri ng encoded KeyAlgorit hm) | |
164 | { | |
165 | re turn (new SecretKeyS pec(encode dKey, enco dedKeyAlgo rithm)); | |
166 | } | |
167 | ||
168 | static final Key construct Key(byte[] encoding, String ke yAlgorithm , | |
169 | int ke yType) | |
170 | th rows Inval idKeyExcep tion, NoSu chAlgorith mException { | |
171 | Ke y result = null; | |
172 | sw itch (keyT ype) { | |
173 | ca se Cipher. SECRET_KEY : | |
174 | result = Construct Keys.const ructSecret Key(encodi ng, | |
175 | keyAlg orithm); | |
176 | break; | |
177 | ca se Cipher. PRIVATE_KE Y: | |
178 | result = Construct Keys.const ructPrivat eKey(encod ing, | |
179 | keyAl gorithm); | |
180 | break; | |
181 | ca se Cipher. PUBLIC_KEY : | |
182 | result = Construct Keys.const ructPublic Key(encodi ng, | |
183 | keyAlg orithm); | |
184 | break; | |
185 | } | |
186 | re turn resul t; | |
187 | } | |
188 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.