Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/provider/SunEntries.java
38830 views
1
/*
2
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.security.provider;
27
28
import java.io.*;
29
import java.net.*;
30
import java.util.Map;
31
import java.security.*;
32
import sun.security.action.GetPropertyAction;
33
34
/**
35
* Defines the entries of the SUN provider.
36
*
37
* Algorithms supported, and their names:
38
*
39
* - SHA is the message digest scheme described in FIPS 180-1.
40
* Aliases for SHA are SHA-1 and SHA1.
41
*
42
* - SHA1withDSA is the signature scheme described in FIPS 186.
43
* (SHA used in DSA is SHA-1: FIPS 186 with Change No 1.)
44
* Aliases for SHA1withDSA are DSA, DSS, SHA/DSA, SHA-1/DSA, SHA1/DSA,
45
* SHAwithDSA, DSAWithSHA1, and the object
46
* identifier strings "OID.1.3.14.3.2.13", "OID.1.3.14.3.2.27" and
47
* "OID.1.2.840.10040.4.3".
48
*
49
* - SHA-2 is a set of message digest schemes described in FIPS 180-2.
50
* SHA-2 family of hash functions includes SHA-224, SHA-256, SHA-384,
51
* and SHA-512.
52
*
53
* - SHA-224withDSA/SHA-256withDSA are the signature schemes
54
* described in FIPS 186-3. The associated object identifiers are
55
* "OID.2.16.840.1.101.3.4.3.1", and "OID.2.16.840.1.101.3.4.3.2".
56
57
* - DSA is the key generation scheme as described in FIPS 186.
58
* Aliases for DSA include the OID strings "OID.1.3.14.3.2.12"
59
* and "OID.1.2.840.10040.4.1".
60
*
61
* - MD5 is the message digest scheme described in RFC 1321.
62
* There are no aliases for MD5.
63
*
64
* - X.509 is the certificate factory type for X.509 certificates
65
* and CRLs. Aliases for X.509 are X509.
66
*
67
* - PKIX is the certification path validation algorithm described
68
* in RFC 5280. The ValidationAlgorithm attribute notes the
69
* specification that this provider implements.
70
*
71
* - LDAP is the CertStore type for LDAP repositories. The
72
* LDAPSchema attribute notes the specification defining the
73
* schema that this provider uses to find certificates and CRLs.
74
*
75
* - JavaPolicy is the default file-based Policy type.
76
*
77
* - JavaLoginConfig is the default file-based LoginModule Configuration type.
78
*/
79
80
final class SunEntries {
81
82
private static final boolean useLegacyDSA =
83
Boolean.parseBoolean(GetPropertyAction.privilegedGetProperty
84
("jdk.security.legacyDSAKeyPairGenerator"));
85
86
private SunEntries() {
87
// empty
88
}
89
90
static void putEntries(Map<Object, Object> map) {
91
92
/*
93
* SecureRandom
94
*
95
* Register these first to speed up "new SecureRandom()",
96
* which iterates through the list of algorithms
97
*/
98
// register the native PRNG, if available
99
// if user selected /dev/urandom, we put it before SHA1PRNG,
100
// otherwise after it
101
boolean nativeAvailable = NativePRNG.isAvailable();
102
boolean useNativePRNG = seedSource.equals(URL_DEV_URANDOM) ||
103
seedSource.equals(URL_DEV_RANDOM);
104
105
if (nativeAvailable && useNativePRNG) {
106
map.put("SecureRandom.NativePRNG",
107
"sun.security.provider.NativePRNG");
108
}
109
110
map.put("SecureRandom.SHA1PRNG",
111
"sun.security.provider.SecureRandom");
112
if (nativeAvailable && !useNativePRNG) {
113
map.put("SecureRandom.NativePRNG",
114
"sun.security.provider.NativePRNG");
115
}
116
117
if (NativePRNG.Blocking.isAvailable()) {
118
map.put("SecureRandom.NativePRNGBlocking",
119
"sun.security.provider.NativePRNG$Blocking");
120
}
121
122
if (NativePRNG.NonBlocking.isAvailable()) {
123
map.put("SecureRandom.NativePRNGNonBlocking",
124
"sun.security.provider.NativePRNG$NonBlocking");
125
}
126
127
/*
128
* Signature engines
129
*/
130
map.put("Signature.SHA1withDSA",
131
"sun.security.provider.DSA$SHA1withDSA");
132
map.put("Signature.NONEwithDSA", "sun.security.provider.DSA$RawDSA");
133
map.put("Alg.Alias.Signature.RawDSA", "NONEwithDSA");
134
map.put("Signature.SHA224withDSA",
135
"sun.security.provider.DSA$SHA224withDSA");
136
map.put("Signature.SHA256withDSA",
137
"sun.security.provider.DSA$SHA256withDSA");
138
139
String dsaKeyClasses = "java.security.interfaces.DSAPublicKey" +
140
"|java.security.interfaces.DSAPrivateKey";
141
map.put("Signature.SHA1withDSA SupportedKeyClasses", dsaKeyClasses);
142
map.put("Signature.NONEwithDSA SupportedKeyClasses", dsaKeyClasses);
143
map.put("Signature.SHA224withDSA SupportedKeyClasses", dsaKeyClasses);
144
map.put("Signature.SHA256withDSA SupportedKeyClasses", dsaKeyClasses);
145
146
map.put("Alg.Alias.Signature.DSA", "SHA1withDSA");
147
map.put("Alg.Alias.Signature.DSS", "SHA1withDSA");
148
map.put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
149
map.put("Alg.Alias.Signature.SHA-1/DSA", "SHA1withDSA");
150
map.put("Alg.Alias.Signature.SHA1/DSA", "SHA1withDSA");
151
map.put("Alg.Alias.Signature.SHAwithDSA", "SHA1withDSA");
152
map.put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
153
map.put("Alg.Alias.Signature.OID.1.2.840.10040.4.3",
154
"SHA1withDSA");
155
map.put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
156
map.put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA");
157
map.put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA1withDSA");
158
map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.1",
159
"SHA224withDSA");
160
map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.1", "SHA224withDSA");
161
map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.2",
162
"SHA256withDSA");
163
map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.2", "SHA256withDSA");
164
165
/*
166
* Key Pair Generator engines
167
*/
168
String dsaKPGImplClass = "sun.security.provider.DSAKeyPairGenerator$";
169
dsaKPGImplClass += (useLegacyDSA? "Legacy" : "Current");
170
map.put("KeyPairGenerator.DSA", dsaKPGImplClass);
171
map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
172
map.put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA");
173
map.put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA");
174
175
/*
176
* Digest engines
177
*/
178
map.put("MessageDigest.MD2", "sun.security.provider.MD2");
179
map.put("MessageDigest.MD5", "sun.security.provider.MD5");
180
map.put("MessageDigest.SHA", "sun.security.provider.SHA");
181
182
map.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
183
map.put("Alg.Alias.MessageDigest.SHA1", "SHA");
184
map.put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA");
185
map.put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA");
186
187
map.put("MessageDigest.SHA-224", "sun.security.provider.SHA2$SHA224");
188
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.4", "SHA-224");
189
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.4",
190
"SHA-224");
191
192
map.put("MessageDigest.SHA-256", "sun.security.provider.SHA2$SHA256");
193
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1", "SHA-256");
194
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.1",
195
"SHA-256");
196
map.put("MessageDigest.SHA-384", "sun.security.provider.SHA5$SHA384");
197
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2", "SHA-384");
198
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.2",
199
"SHA-384");
200
map.put("MessageDigest.SHA-512", "sun.security.provider.SHA5$SHA512");
201
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512");
202
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.3",
203
"SHA-512");
204
map.put("MessageDigest.SHA-512/224", "sun.security.provider.SHA5$SHA512_224");
205
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.5", "SHA-512/224");
206
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.5",
207
"SHA-512/224");
208
map.put("MessageDigest.SHA-512/256", "sun.security.provider.SHA5$SHA512_256");
209
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.6", "SHA-512/256");
210
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.6",
211
"SHA-512/256");
212
213
/*
214
* Algorithm Parameter Generator engines
215
*/
216
map.put("AlgorithmParameterGenerator.DSA",
217
"sun.security.provider.DSAParameterGenerator");
218
219
/*
220
* Algorithm Parameter engines
221
*/
222
map.put("AlgorithmParameters.DSA",
223
"sun.security.provider.DSAParameters");
224
map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.10040.4.1", "DSA");
225
map.put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
226
map.put("Alg.Alias.AlgorithmParameters.1.3.14.3.2.12", "DSA");
227
228
/*
229
* Key factories
230
*/
231
map.put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory");
232
map.put("Alg.Alias.KeyFactory.OID.1.2.840.10040.4.1", "DSA");
233
map.put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
234
map.put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
235
236
/*
237
* Certificates
238
*/
239
map.put("CertificateFactory.X.509",
240
"sun.security.provider.X509Factory");
241
map.put("Alg.Alias.CertificateFactory.X509", "X.509");
242
243
/*
244
* KeyStore
245
*/
246
map.put("KeyStore.JKS",
247
"sun.security.provider.JavaKeyStore$DualFormatJKS");
248
map.put("KeyStore.CaseExactJKS",
249
"sun.security.provider.JavaKeyStore$CaseExactJKS");
250
map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS");
251
252
/*
253
* Policy
254
*/
255
map.put("Policy.JavaPolicy", "sun.security.provider.PolicySpiFile");
256
257
/*
258
* Configuration
259
*/
260
map.put("Configuration.JavaLoginConfig",
261
"sun.security.provider.ConfigFile$Spi");
262
263
/*
264
* CertPathBuilder
265
*/
266
map.put("CertPathBuilder.PKIX",
267
"sun.security.provider.certpath.SunCertPathBuilder");
268
map.put("CertPathBuilder.PKIX ValidationAlgorithm",
269
"RFC5280");
270
271
/*
272
* CertPathValidator
273
*/
274
map.put("CertPathValidator.PKIX",
275
"sun.security.provider.certpath.PKIXCertPathValidator");
276
map.put("CertPathValidator.PKIX ValidationAlgorithm",
277
"RFC5280");
278
279
/*
280
* CertStores
281
*/
282
map.put("CertStore.LDAP",
283
"sun.security.provider.certpath.ldap.LDAPCertStore");
284
map.put("CertStore.LDAP LDAPSchema", "RFC2587");
285
map.put("CertStore.Collection",
286
"sun.security.provider.certpath.CollectionCertStore");
287
map.put("CertStore.com.sun.security.IndexedCollection",
288
"sun.security.provider.certpath.IndexedCollectionCertStore");
289
290
/*
291
* KeySize
292
*/
293
map.put("Signature.NONEwithDSA KeySize", "1024");
294
map.put("Signature.SHA1withDSA KeySize", "1024");
295
map.put("Signature.SHA224withDSA KeySize", "2048");
296
map.put("Signature.SHA256withDSA KeySize", "2048");
297
298
map.put("KeyPairGenerator.DSA KeySize", "2048");
299
map.put("AlgorithmParameterGenerator.DSA KeySize", "2048");
300
301
/*
302
* Implementation type: software or hardware
303
*/
304
map.put("Signature.SHA1withDSA ImplementedIn", "Software");
305
map.put("KeyPairGenerator.DSA ImplementedIn", "Software");
306
map.put("MessageDigest.MD5 ImplementedIn", "Software");
307
map.put("MessageDigest.SHA ImplementedIn", "Software");
308
map.put("AlgorithmParameterGenerator.DSA ImplementedIn",
309
"Software");
310
map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
311
map.put("KeyFactory.DSA ImplementedIn", "Software");
312
map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
313
map.put("CertificateFactory.X.509 ImplementedIn", "Software");
314
map.put("KeyStore.JKS ImplementedIn", "Software");
315
map.put("CertPathValidator.PKIX ImplementedIn", "Software");
316
map.put("CertPathBuilder.PKIX ImplementedIn", "Software");
317
map.put("CertStore.LDAP ImplementedIn", "Software");
318
map.put("CertStore.Collection ImplementedIn", "Software");
319
map.put("CertStore.com.sun.security.IndexedCollection ImplementedIn",
320
"Software");
321
322
}
323
324
// name of the *System* property, takes precedence over PROP_RNDSOURCE
325
private final static String PROP_EGD = "java.security.egd";
326
// name of the *Security* property
327
private final static String PROP_RNDSOURCE = "securerandom.source";
328
329
final static String URL_DEV_RANDOM = "file:/dev/random";
330
final static String URL_DEV_URANDOM = "file:/dev/urandom";
331
332
private static final String seedSource;
333
334
static {
335
seedSource = AccessController.doPrivileged(
336
new PrivilegedAction<String>() {
337
338
@Override
339
public String run() {
340
String egdSource = System.getProperty(PROP_EGD, "");
341
if (egdSource.length() != 0) {
342
return egdSource;
343
}
344
egdSource = Security.getProperty(PROP_RNDSOURCE);
345
if (egdSource == null) {
346
return "";
347
}
348
return egdSource;
349
}
350
});
351
}
352
353
static String getSeedSource() {
354
return seedSource;
355
}
356
357
/*
358
* Use a URI to access this File. Previous code used a URL
359
* which is less strict on syntax. If we encounter a
360
* URISyntaxException we make best efforts for backwards
361
* compatibility. e.g. space character in deviceName string.
362
*
363
* Method called within PrivilegedExceptionAction block.
364
*
365
* Moved from SeedGenerator to avoid initialization problems with
366
* signed providers.
367
*/
368
static File getDeviceFile(URL device) throws IOException {
369
try {
370
URI deviceURI = device.toURI();
371
if(deviceURI.isOpaque()) {
372
// File constructor does not accept opaque URI
373
URI localDir = new File(
374
System.getProperty("user.dir")).toURI();
375
String uriPath = localDir.toString() +
376
deviceURI.toString().substring(5);
377
return new File(URI.create(uriPath));
378
} else {
379
return new File(deviceURI);
380
}
381
} catch (URISyntaxException use) {
382
/*
383
* Make best effort to access this File.
384
* We can try using the URL path.
385
*/
386
return new File(device.getPath());
387
}
388
}
389
}
390
391