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 | DESKeyFactory.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 | DESKeyFactory.java | Wed Sep 12 16:22:21 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 330 |
Changed | 2 | 4 |
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 7, 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 ax.crypto. SecretKey; | |
29 | import jav ax.crypto. SecretKeyF actorySpi; | |
30 | import jav ax.crypto. spec.DESKe ySpec; | |
31 | import jav a.security .InvalidKe yException ; | |
32 | import jav a.security .spec.KeyS pec; | |
33 | import jav a.security .spec.Inva lidKeySpec Exception; | |
34 | import jav ax.crypto. spec.Secre tKeySpec; | |
35 | ||
36 | /** | |
37 | * This cl ass implem ents the D ES key fac tory of th e Sun prov ider. | |
38 | * | |
39 | * @author Jan Luehe | |
40 | * | |
41 | */ | |
42 | ||
43 | public fin al class D ESKeyFacto ry extends SecretKey FactorySpi { | |
44 | ||
45 | /** | |
46 | * Emp ty constru ctor | |
47 | */ | |
48 | public DESKeyFac tory() { | |
49 | } | |
50 | ||
51 | /** | |
52 | * Gen erates a < code>Secre tKey</code > object f rom the pr ovided key | |
53 | * spe cification (key mate rial). | |
54 | * | |
55 | * @param k eySpec the specifica tion (key material) of the PW key | |
56 | * | |
57 | * @return the PW key | |
58 | * | |
59 | * @ex ception In validKeySp ecExceptio n if the g iven key s pecificati on | |
60 | * is inappropri ate for th is key fac tory to pr oduce a pu blic key. | |
61 | */ | |
62 | protec ted Secret Key engine GenerateSe cret(KeySp ec keySpec ) | |
63 | th rows Inval idKeySpecE xception { | |
64 | ||
65 | tr y { | |
66 | if (keyS pec instan ceof DESKe ySpec) { | |
67 | retu rn new DES Key(((DESK eySpec)key Spec).getK ey()); | |
68 | } | |
69 | ||
70 | if (keyS pec instan ceof Secre tKeySpec) { | |
71 | retu rn new DES Key(((Secr etKeySpec) keySpec).g etEncoded( )); | |
72 | } | |
73 | ||
74 | throw ne w InvalidK eySpecExce ption( | |
75 | "Inappropr iate key s pecificati on"); | |
76 | ||
77 | } catch (Inv alidKeyExc eption e) { | |
78 | throw ne w InvalidK eySpecExce ption(e.ge tMessage() ); | |
79 | } | |
80 | } | |
81 | ||
82 | /** | |
83 | * Ret urns a spe cification (key mate rial) of t he given k ey | |
84 | * in the reques ted format . | |
85 | * | |
86 | * @pa ram key th e key | |
87 | * | |
88 | * @pa ram keySpe c the requ ested form at in whic h the key material s hall be | |
89 | * ret urned | |
90 | * | |
91 | * @re turn the u nderlying key specif ication (k ey materia l) in the | |
92 | * req uested for mat | |
93 | * | |
94 | * @ex ception In validKeySp ecExceptio n if the r equested k ey specifi cation is | |
95 | * ina ppropriate for the g iven key, or the giv en key can not be pro cessed | |
96 | * (e. g., the gi ven key ha s an unrec ognized al gorithm or format). | |
97 | */ | |
98 | protec ted KeySpe c engineGe tKeySpec(S ecretKey k ey, Class< ?> keySpec ) | |
99 | th rows Inval idKeySpecE xception { | |
100 | ||
101 | tr y { | |
102 | ||
103 | if ((key instanceo f SecretKe y) | |
104 | && ( key.getAlg orithm().e qualsIgnor eCase("DES ")) | |
105 | && ( key.getFor mat().equa lsIgnoreCa se("RAW")) ) { | |
106 | ||
107 | // C heck if re quested ke y spec is amongst th e valid on es | |
108 | if ( (keySpec ! = null) && | |
109 | DESKeySpec .class.isA ssignableF rom(keySpe c)) { | |
110 | return new DESKeySpe c(key.getE ncoded()); | |
111 | ||
112 | } el se { | |
113 | throw new InvalidKey SpecExcept ion | |
114 | ("Inap propriate key specif ication"); | |
115 | } | |
116 | ||
117 | } else { | |
118 | thro w new Inva lidKeySpec Exception | |
119 | ("Inapprop riate key format/alg orithm"); | |
120 | } | |
121 | ||
122 | } catch (Inv alidKeyExc eption e) { | |
123 | throw ne w InvalidK eySpecExce ption("Sec ret key ha s wrong si ze"); | |
124 | } | |
125 | } | |
126 | ||
127 | /** | |
128 | * Tra nslates a <code>Secr etKey</cod e> object, whose pro vider may be | |
129 | * unk nown or po tentially untrusted, into a co rrespondin g | |
130 | * <co de>SecretK ey</code> object of this key f actory. | |
131 | * | |
132 | * @pa ram key th e key whos e provider is unknow n or untru sted | |
133 | * | |
134 | * @re turn the t ranslated key | |
135 | * | |
136 | * @ex ception In validKeyEx ception if the given key canno t be proce ssed by | |
137 | * thi s key fact ory. | |
138 | */ | |
139 | protec ted Secret Key engine TranslateK ey(SecretK ey key) | |
140 | th rows Inval idKeyExcep tion { | |
141 | ||
142 | tr y { | |
143 | ||
144 | if ((key != null) && | |
145 | (key .getAlgori thm().equa lsIgnoreCa se("DES")) && | |
146 | (key .getFormat ().equalsI gnoreCase( "RAW"))) { | |
147 | ||
148 | // C heck if ke y originat es from th is factory | |
149 | if ( key instan ceof com.s un.crypto. provider.D ESKey) { | |
150 | return key ; | |
151 | } | |
152 | // C onvert key to spec | |
153 | DESK eySpec des KeySpec | |
154 | = (DESKeyS pec)engine GetKeySpec (key, DESK eySpec.cla ss); | |
155 | // C reate key from spec, and retur n it | |
156 | retu rn engineG enerateSec ret(desKey Spec); | |
157 | ||
158 | } else { | |
159 | thro w new Inva lidKeyExce ption | |
160 | ("Inapprop riate key format/alg orithm"); | |
161 | } | |
162 | ||
163 | } catch (Inv alidKeySpe cException e) { | |
164 | throw ne w InvalidK eyExceptio n("Cannot translate key"); | |
165 | } | |
166 | } | |
167 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.