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