jdk/src/java.base/share/classes/sun/security/provider/SunEntries.java
author juh
Tue, 07 Oct 2014 22:23:19 -0700
changeset 26967 c182469301ee
parent 25859 3317bb8137f4
child 28243 47080f9ae750
permissions -rw-r--r--
8037550: Update RFC references in javadoc to RFC 5280 Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
26967
c182469301ee 8037550: Update RFC references in javadoc to RFC 5280
juh
parents: 25859
diff changeset
     2
 * Copyright (c) 1996, 2014, 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
 * - LDAP is the CertStore type for LDAP repositories. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *   LDAPSchema attribute notes the specification defining the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *   schema that this provider uses to find certificates and CRLs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * - JavaPolicy is the default file-based Policy type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * - JavaLoginConfig is the default file-based LoginModule Configuration type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
final class SunEntries {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private SunEntries() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        // empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    static void putEntries(Map<Object, Object> map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
         * SecureRandom
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * Register these first to speed up "new SecureRandom()",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         * which iterates through the list of algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        // register the native PRNG, if available
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // if user selected /dev/urandom, we put it before SHA1PRNG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        // otherwise after it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        boolean nativeAvailable = NativePRNG.isAvailable();
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
    97
        boolean useNativePRNG = seedSource.equals(URL_DEV_URANDOM) ||
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
    98
            seedSource.equals(URL_DEV_RANDOM);
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
    99
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   100
        if (nativeAvailable && useNativePRNG) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            map.put("SecureRandom.NativePRNG",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                "sun.security.provider.NativePRNG");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        map.put("SecureRandom.SHA1PRNG",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
             "sun.security.provider.SecureRandom");
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   106
        if (nativeAvailable && !useNativePRNG) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            map.put("SecureRandom.NativePRNG",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                "sun.security.provider.NativePRNG");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   111
        if (NativePRNG.Blocking.isAvailable()) {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   112
            map.put("SecureRandom.NativePRNGBlocking",
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   113
                "sun.security.provider.NativePRNG$Blocking");
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
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   116
        if (NativePRNG.NonBlocking.isAvailable()) {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   117
            map.put("SecureRandom.NativePRNGNonBlocking",
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   118
                "sun.security.provider.NativePRNG$NonBlocking");
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   119
        }
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   120
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
         * Signature engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
         */
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   124
        map.put("Signature.SHA1withDSA",
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   125
                "sun.security.provider.DSA$SHA1withDSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        map.put("Signature.NONEwithDSA", "sun.security.provider.DSA$RawDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        map.put("Alg.Alias.Signature.RawDSA", "NONEwithDSA");
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   128
        map.put("Signature.SHA224withDSA",
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   129
                "sun.security.provider.DSA$SHA224withDSA");
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   130
        map.put("Signature.SHA256withDSA",
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   131
                "sun.security.provider.DSA$SHA256withDSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        String dsaKeyClasses = "java.security.interfaces.DSAPublicKey" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                "|java.security.interfaces.DSAPrivateKey";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        map.put("Signature.SHA1withDSA SupportedKeyClasses", dsaKeyClasses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        map.put("Signature.NONEwithDSA SupportedKeyClasses", dsaKeyClasses);
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   137
        map.put("Signature.SHA224withDSA SupportedKeyClasses", dsaKeyClasses);
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   138
        map.put("Signature.SHA256withDSA SupportedKeyClasses", dsaKeyClasses);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        map.put("Alg.Alias.Signature.DSA", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        map.put("Alg.Alias.Signature.DSS", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        map.put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        map.put("Alg.Alias.Signature.SHA-1/DSA", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        map.put("Alg.Alias.Signature.SHA1/DSA", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        map.put("Alg.Alias.Signature.SHAwithDSA", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        map.put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        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
   148
                "SHA1withDSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        map.put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        map.put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        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
   152
        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
   153
                "SHA224withDSA");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   154
        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
   155
        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
   156
                "SHA256withDSA");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   157
        map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.2", "SHA256withDSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
         *  Key Pair Generator engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        map.put("KeyPairGenerator.DSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            "sun.security.provider.DSAKeyPairGenerator");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        map.put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        map.put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
         * Digest engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        map.put("MessageDigest.MD2", "sun.security.provider.MD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        map.put("MessageDigest.MD5", "sun.security.provider.MD5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        map.put("MessageDigest.SHA", "sun.security.provider.SHA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        map.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        map.put("Alg.Alias.MessageDigest.SHA1", "SHA");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   177
        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
   178
        map.put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   180
        map.put("MessageDigest.SHA-224", "sun.security.provider.SHA2$SHA224");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   181
        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
   182
        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
   183
                "SHA-224");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   184
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   185
        map.put("MessageDigest.SHA-256", "sun.security.provider.SHA2$SHA256");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   186
        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
   187
        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
   188
                "SHA-256");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        map.put("MessageDigest.SHA-384", "sun.security.provider.SHA5$SHA384");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   190
        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
   191
        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
   192
                "SHA-384");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        map.put("MessageDigest.SHA-512", "sun.security.provider.SHA5$SHA512");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
   194
        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
   195
        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
   196
                "SHA-512");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
         * Algorithm Parameter Generator engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        map.put("AlgorithmParameterGenerator.DSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            "sun.security.provider.DSAParameterGenerator");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
         * Algorithm Parameter engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        map.put("AlgorithmParameters.DSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            "sun.security.provider.DSAParameters");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   209
        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
   210
        map.put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        map.put("Alg.Alias.AlgorithmParameters.1.3.14.3.2.12", "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
         * Key factories
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        map.put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   217
        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
   218
        map.put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        map.put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         * Certificates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        map.put("CertificateFactory.X.509",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            "sun.security.provider.X509Factory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        map.put("Alg.Alias.CertificateFactory.X509", "X.509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
         * KeyStore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        map.put("KeyStore.JKS", "sun.security.provider.JavaKeyStore$JKS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        map.put("KeyStore.CaseExactJKS",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                        "sun.security.provider.JavaKeyStore$CaseExactJKS");
15664
e33b115f1981 8007755: Support the logical grouping of keystores
vinnie
parents: 13672
diff changeset
   234
        map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
         * Policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        map.put("Policy.JavaPolicy", "sun.security.provider.PolicySpiFile");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         * Configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        map.put("Configuration.JavaLoginConfig",
19385
a7b34a4b1fcb 8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents: 16915
diff changeset
   245
                        "sun.security.provider.ConfigFile$Spi");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         * CertPathBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        map.put("CertPathBuilder.PKIX",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            "sun.security.provider.certpath.SunCertPathBuilder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        map.put("CertPathBuilder.PKIX ValidationAlgorithm",
26967
c182469301ee 8037550: Update RFC references in javadoc to RFC 5280
juh
parents: 25859
diff changeset
   253
            "RFC5280");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         * CertPathValidator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        map.put("CertPathValidator.PKIX",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            "sun.security.provider.certpath.PKIXCertPathValidator");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        map.put("CertPathValidator.PKIX ValidationAlgorithm",
26967
c182469301ee 8037550: Update RFC references in javadoc to RFC 5280
juh
parents: 25859
diff changeset
   261
            "RFC5280");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
         * CertStores
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        map.put("CertStore.LDAP",
4039
afadb206ca44 6889552: Sun provider should not require LDAP CertStore to be present
alanb
parents: 2
diff changeset
   267
            "sun.security.provider.certpath.ldap.LDAPCertStore");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        map.put("CertStore.LDAP LDAPSchema", "RFC2587");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        map.put("CertStore.Collection",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            "sun.security.provider.certpath.CollectionCertStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        map.put("CertStore.com.sun.security.IndexedCollection",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            "sun.security.provider.certpath.IndexedCollectionCertStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         * KeySize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         */
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   277
        map.put("Signature.NONEwithDSA KeySize", "1024");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        map.put("Signature.SHA1withDSA KeySize", "1024");
13672
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   279
        map.put("Signature.SHA224withDSA KeySize", "2048");
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   280
        map.put("Signature.SHA256withDSA KeySize", "2048");
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   281
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   282
        map.put("KeyPairGenerator.DSA KeySize", "2048");
604588823b5a 7044060: Need to support NSA Suite B Cryptography algorithms
valeriep
parents: 12685
diff changeset
   283
        map.put("AlgorithmParameterGenerator.DSA KeySize", "2048");
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
         * Implementation type: software or hardware
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        map.put("Signature.SHA1withDSA ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        map.put("KeyPairGenerator.DSA ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        map.put("MessageDigest.MD5 ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        map.put("MessageDigest.SHA ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        map.put("AlgorithmParameterGenerator.DSA ImplementedIn",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        map.put("KeyFactory.DSA ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        map.put("CertificateFactory.X.509 ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        map.put("KeyStore.JKS ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        map.put("CertPathValidator.PKIX ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        map.put("CertPathBuilder.PKIX ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        map.put("CertStore.LDAP ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        map.put("CertStore.Collection ImplementedIn", "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        map.put("CertStore.com.sun.security.IndexedCollection ImplementedIn",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            "Software");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    // name of the *System* property, takes precedence over PROP_RNDSOURCE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    private final static String PROP_EGD = "java.security.egd";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    // name of the *Security* property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    private final static String PROP_RNDSOURCE = "securerandom.source";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    final static String URL_DEV_RANDOM = "file:/dev/random";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    final static String URL_DEV_URANDOM = "file:/dev/urandom";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    private static final String seedSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        seedSource = AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                new PrivilegedAction<String>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   322
            @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            public String run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                String egdSource = System.getProperty(PROP_EGD, "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                if (egdSource.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                    return egdSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                egdSource = Security.getProperty(PROP_RNDSOURCE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                if (egdSource == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                return egdSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    static String getSeedSource() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return seedSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
16915
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   341
    /*
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   342
     * 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
   343
     * 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
   344
     * URISyntaxException we make best efforts for backwards
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   345
     * compatibility. e.g. space character in deviceName string.
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   346
     *
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   347
     * Method called within PrivilegedExceptionAction block.
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   348
     *
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   349
     * Moved from SeedGenerator to avoid initialization problems with
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   350
     * signed providers.
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   351
     */
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   352
    static File getDeviceFile(URL device) throws IOException {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   353
        try {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   354
            URI deviceURI = device.toURI();
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   355
            if(deviceURI.isOpaque()) {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   356
                // File constructor does not accept opaque URI
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   357
                URI localDir = new File(
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   358
                    System.getProperty("user.dir")).toURI();
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   359
                String uriPath = localDir.toString() +
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   360
                                     deviceURI.toString().substring(5);
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   361
                return new File(URI.create(uriPath));
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   362
            } else {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   363
                return new File(deviceURI);
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   364
            }
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   365
        } catch (URISyntaxException use) {
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   366
            /*
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   367
             * Make best effort to access this File.
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   368
             * We can try using the URL path.
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   369
             */
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   370
            return new File(device.getPath());
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   371
        }
675d1569af3e 6425477: Better support for generation of high entropy random numbers
wetmore
parents: 15664
diff changeset
   372
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
}