SunJCE.java 39.1 KB
Newer Older
D
duke 已提交
1
/*
V
valeriep 已提交
2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
8
 * particular file as subject to the "Classpath" exception as provided
9
 * by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
10 11 12 13 14 15 16 17 18 19 20
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
21 22 23
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
 */

package com.sun.crypto.provider;

import java.security.AccessController;
import java.security.Provider;
import java.security.SecureRandom;


/**
 * The "SunJCE" Cryptographic Service Provider.
 *
 * @author Jan Luehe
 * @author Sharon Liu
 */

/**
 * Defines the "SunJCE" provider.
 *
 * Supported algorithms and their names:
 *
 * - RSA encryption (PKCS#1 v1.5 and raw)
 *
 * - DES
 *
 * - DES-EDE
 *
 * - AES
 *
 * - Blowfish
 *
 * - RC2
 *
 * - ARCFOUR (RC4 compatible)
 *
 * - Cipher modes ECB, CBC, CFB, OFB, PCBC, CTR, and CTS for all block ciphers
V
valeriep 已提交
60
 *   and mode GCM for AES cipher
D
duke 已提交
61 62 63 64 65 66 67 68
 *
 * - Cipher padding ISO10126Padding for non-PKCS#5 block ciphers and
 *   NoPadding and PKCS5Padding for all block ciphers
 *
 * - Password-based Encryption (PBE)
 *
 * - Diffie-Hellman Key Agreement
 *
V
valeriep 已提交
69
 * - HMAC-MD5, HMAC-SHA1, HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512
D
duke 已提交
70 71 72 73 74 75 76 77 78 79 80
 *
 */

public final class SunJCE extends Provider {

    private static final long serialVersionUID = 6812507587804302833L;

    private static final String info = "SunJCE Provider " +
    "(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, "
    + "Diffie-Hellman, HMAC)";

81 82
    private static final String OID_PKCS12_RC4_128 = "1.2.840.113549.1.12.1.1";
    private static final String OID_PKCS12_RC4_40 = "1.2.840.113549.1.12.1.2";
D
duke 已提交
83
    private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3";
84 85
    private static final String OID_PKCS12_RC2_128 = "1.2.840.113549.1.12.1.5";
    private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6";
D
duke 已提交
86 87
    private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3";
    private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12";
88
    private static final String OID_PKCS5_PBES2 = "1.2.840.113549.1.5.13";
D
duke 已提交
89 90 91 92 93
    private static final String OID_PKCS3 = "1.2.840.113549.1.3.1";

    /* Are we debugging? -- for developers */
    static final boolean debug = false;

94 95 96 97 98 99
    // lazy initialize SecureRandom to avoid potential recursion if Sun
    // provider has not been installed yet
    private static class SecureRandomHolder {
        static final SecureRandom RANDOM = new SecureRandom();
    }
    static SecureRandom getRandom() { return SecureRandomHolder.RANDOM; }
D
duke 已提交
100 101 102 103 104 105 106 107 108

    public SunJCE() {
        /* We are the "SunJCE" provider */
        super("SunJCE", 1.7d, info);

        final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" +
            "|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" +
            "|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64";
        final String BLOCK_MODES128 = BLOCK_MODES +
V
valeriep 已提交
109
            "|GCM|CFB72|CFB80|CFB88|CFB96|CFB104|CFB112|CFB120|CFB128" +
D
duke 已提交
110 111 112
            "|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128";
        final String BLOCK_PADS = "NOPADDING|PKCS5PADDING|ISO10126PADDING";

113 114
        AccessController.doPrivileged(
            new java.security.PrivilegedAction<Object>() {
D
duke 已提交
115 116
                public Object run() {

117 118 119 120 121 122 123 124 125
                    /*
                     * Cipher engines
                     */
                    put("Cipher.RSA", "com.sun.crypto.provider.RSACipher");
                    put("Cipher.RSA SupportedModes", "ECB");
                    put("Cipher.RSA SupportedPaddings",
                            "NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING"
                            + "|OAEPWITHSHA1ANDMGF1PADDING"
                            + "|OAEPWITHSHA-1ANDMGF1PADDING"
V
valeriep 已提交
126
                            + "|OAEPWITHSHA-224ANDMGF1PADDING"
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
                            + "|OAEPWITHSHA-256ANDMGF1PADDING"
                            + "|OAEPWITHSHA-384ANDMGF1PADDING"
                            + "|OAEPWITHSHA-512ANDMGF1PADDING");
                    put("Cipher.RSA SupportedKeyClasses",
                            "java.security.interfaces.RSAPublicKey" +
                            "|java.security.interfaces.RSAPrivateKey");

                    put("Cipher.DES", "com.sun.crypto.provider.DESCipher");
                    put("Cipher.DES SupportedModes", BLOCK_MODES);
                    put("Cipher.DES SupportedPaddings", BLOCK_PADS);
                    put("Cipher.DES SupportedKeyFormats", "RAW");

                    put("Cipher.DESede", "com.sun.crypto.provider.DESedeCipher");
                    put("Alg.Alias.Cipher.TripleDES", "DESede");
                    put("Cipher.DESede SupportedModes", BLOCK_MODES);
                    put("Cipher.DESede SupportedPaddings", BLOCK_PADS);
                    put("Cipher.DESede SupportedKeyFormats", "RAW");

                    put("Cipher.DESedeWrap",
                        "com.sun.crypto.provider.DESedeWrapCipher");
                    put("Cipher.DESedeWrap SupportedModes", "CBC");
                    put("Cipher.DESedeWrap SupportedPaddings", "NOPADDING");
                    put("Cipher.DESedeWrap SupportedKeyFormats", "RAW");

151 152
                    // PBES1

153 154 155 156 157 158
                    put("Cipher.PBEWithMD5AndDES",
                        "com.sun.crypto.provider.PBEWithMD5AndDESCipher");
                    put("Alg.Alias.Cipher.OID."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");
                    put("Alg.Alias.Cipher."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");
159

160 161
                    put("Cipher.PBEWithMD5AndTripleDES",
                        "com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher");
162 163 164 165 166 167 168 169 170

                    put("Cipher.PBEWithSHA1AndDESede",
                        "com.sun.crypto.provider.PKCS12PBECipherCore$" +
                        "PBEWithSHA1AndDESede");
                    put("Alg.Alias.Cipher.OID." + OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");
                    put("Alg.Alias.Cipher." + OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");

171 172 173 174 175 176 177
                    put("Cipher.PBEWithSHA1AndRC2_40",
                        "com.sun.crypto.provider.PKCS12PBECipherCore$" +
                        "PBEWithSHA1AndRC2_40");
                    put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");
                    put("Alg.Alias.Cipher." + OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");
178 179

                    put("Cipher.PBEWithSHA1AndRC2_128",
180
                        "com.sun.crypto.provider.PKCS12PBECipherCore$" +
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
                        "PBEWithSHA1AndRC2_128");
                    put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");
                    put("Alg.Alias.Cipher." + OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");

                    put("Cipher.PBEWithSHA1AndRC4_40",
                        "com.sun.crypto.provider.PKCS12PBECipherCore$" +
                        "PBEWithSHA1AndRC4_40");
                    put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");
                    put("Alg.Alias.Cipher." + OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");

                    put("Cipher.PBEWithSHA1AndRC4_128",
                        "com.sun.crypto.provider.PKCS12PBECipherCore$" +
                        "PBEWithSHA1AndRC4_128");
                    put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");
                    put("Alg.Alias.Cipher." + OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");

                    //PBES2

                    put("Cipher.PBEWithHmacSHA1AndAES_128",
                        "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_128");

                    put("Cipher.PBEWithHmacSHA224AndAES_128",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA224AndAES_128");

                    put("Cipher.PBEWithHmacSHA256AndAES_128",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA256AndAES_128");

                    put("Cipher.PBEWithHmacSHA384AndAES_128",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA384AndAES_128");

                    put("Cipher.PBEWithHmacSHA512AndAES_128",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA512AndAES_128");

                    put("Cipher.PBEWithHmacSHA1AndAES_256",
                        "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_256");

                    put("Cipher.PBEWithHmacSHA224AndAES_256",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA224AndAES_256");

                    put("Cipher.PBEWithHmacSHA256AndAES_256",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA256AndAES_256");

                    put("Cipher.PBEWithHmacSHA384AndAES_256",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA384AndAES_256");

                    put("Cipher.PBEWithHmacSHA512AndAES_256",
                        "com.sun.crypto.provider.PBES2Core$" +
                            "HmacSHA512AndAES_256");
242 243 244 245 246 247 248

                    put("Cipher.Blowfish",
                        "com.sun.crypto.provider.BlowfishCipher");
                    put("Cipher.Blowfish SupportedModes", BLOCK_MODES);
                    put("Cipher.Blowfish SupportedPaddings", BLOCK_PADS);
                    put("Cipher.Blowfish SupportedKeyFormats", "RAW");

249
                    put("Cipher.AES", "com.sun.crypto.provider.AESCipher$General");
250 251 252 253 254
                    put("Alg.Alias.Cipher.Rijndael", "AES");
                    put("Cipher.AES SupportedModes", BLOCK_MODES128);
                    put("Cipher.AES SupportedPaddings", BLOCK_PADS);
                    put("Cipher.AES SupportedKeyFormats", "RAW");

255 256 257 258 259 260 261 262 263 264 265 266
                    put("Cipher.AES_128/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
                    put("Cipher.AES_128/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
                    put("Cipher.AES_128/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
                    put("Cipher.AES_128/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
V
valeriep 已提交
267 268 269
                    put("Cipher.AES_128/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_GCM_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.6", "AES_128/GCM/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.6", "AES_128/GCM/NoPadding");
270 271 272 273 274 275 276 277 278 279 280 281 282

                    put("Cipher.AES_192/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
                    put("Cipher.AES_192/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
                    put("Cipher.AES_192/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
                    put("Cipher.AES_192/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
V
valeriep 已提交
283 284 285
                    put("Cipher.AES_192/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_GCM_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.26", "AES_192/GCM/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.26", "AES_192/GCM/NoPadding");
286 287 288 289 290 291 292 293 294 295 296 297 298

                    put("Cipher.AES_256/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
                    put("Cipher.AES_256/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
                    put("Cipher.AES_256/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
                    put("Cipher.AES_256/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
V
valeriep 已提交
299 300 301
                    put("Cipher.AES_256/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_GCM_NoPadding");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.46", "AES_256/GCM/NoPadding");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.46", "AES_256/GCM/NoPadding");
302 303

                    put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher$General");
304 305 306 307
                    put("Cipher.AESWrap SupportedModes", "ECB");
                    put("Cipher.AESWrap SupportedPaddings", "NOPADDING");
                    put("Cipher.AESWrap SupportedKeyFormats", "RAW");

308 309 310 311 312 313 314 315 316 317
                    put("Cipher.AESWrap_128", "com.sun.crypto.provider.AESWrapCipher$AES128");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.5", "AESWrap_128");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.5", "AESWrap_128");
                    put("Cipher.AESWrap_192", "com.sun.crypto.provider.AESWrapCipher$AES192");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.25", "AESWrap_192");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.25", "AESWrap_192");
                    put("Cipher.AESWrap_256", "com.sun.crypto.provider.AESWrapCipher$AES256");
                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.45", "AESWrap_256");
                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.45", "AESWrap_256");

318 319 320 321 322 323 324 325 326 327 328 329 330 331
                    put("Cipher.RC2",
                        "com.sun.crypto.provider.RC2Cipher");
                    put("Cipher.RC2 SupportedModes", BLOCK_MODES);
                    put("Cipher.RC2 SupportedPaddings", BLOCK_PADS);
                    put("Cipher.RC2 SupportedKeyFormats", "RAW");

                    put("Cipher.ARCFOUR",
                        "com.sun.crypto.provider.ARCFOURCipher");
                    put("Alg.Alias.Cipher.RC4", "ARCFOUR");
                    put("Cipher.ARCFOUR SupportedModes", "ECB");
                    put("Cipher.ARCFOUR SupportedPaddings", "NOPADDING");
                    put("Cipher.ARCFOUR SupportedKeyFormats", "RAW");

                    /*
332
                     * Key(pair) Generator engines
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
                     */
                    put("KeyGenerator.DES",
                        "com.sun.crypto.provider.DESKeyGenerator");

                    put("KeyGenerator.DESede",
                        "com.sun.crypto.provider.DESedeKeyGenerator");
                    put("Alg.Alias.KeyGenerator.TripleDES", "DESede");

                    put("KeyGenerator.Blowfish",
                        "com.sun.crypto.provider.BlowfishKeyGenerator");

                    put("KeyGenerator.AES",
                        "com.sun.crypto.provider.AESKeyGenerator");
                    put("Alg.Alias.KeyGenerator.Rijndael", "AES");

                    put("KeyGenerator.RC2",
                        "com.sun.crypto.provider.KeyGeneratorCore$" +
                        "RC2KeyGenerator");
                    put("KeyGenerator.ARCFOUR",
                        "com.sun.crypto.provider.KeyGeneratorCore$" +
                        "ARCFOURKeyGenerator");
                    put("Alg.Alias.KeyGenerator.RC4", "ARCFOUR");

                    put("KeyGenerator.HmacMD5",
                        "com.sun.crypto.provider.HmacMD5KeyGenerator");

                    put("KeyGenerator.HmacSHA1",
                        "com.sun.crypto.provider.HmacSHA1KeyGenerator");
361 362
                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.7", "HmacSHA1");
                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.7", "HmacSHA1");
363

V
valeriep 已提交
364 365 366 367 368
                    put("KeyGenerator.HmacSHA224",
                        "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.8", "HmacSHA224");
                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.8", "HmacSHA224");

369
                    put("KeyGenerator.HmacSHA256",
V
valeriep 已提交
370 371 372 373
                        "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256");
                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.9", "HmacSHA256");
                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.9", "HmacSHA256");

374
                    put("KeyGenerator.HmacSHA384",
V
valeriep 已提交
375 376 377 378
                        "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384");
                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.10", "HmacSHA384");
                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.10", "HmacSHA384");

379
                    put("KeyGenerator.HmacSHA512",
V
valeriep 已提交
380 381 382
                        "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512");
                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.11", "HmacSHA512");
                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.11", "HmacSHA512");
383 384 385 386 387 388 389 390

                    put("KeyPairGenerator.DiffieHellman",
                        "com.sun.crypto.provider.DHKeyPairGenerator");
                    put("Alg.Alias.KeyPairGenerator.DH", "DiffieHellman");
                    put("Alg.Alias.KeyPairGenerator.OID."+OID_PKCS3,
                        "DiffieHellman");
                    put("Alg.Alias.KeyPairGenerator."+OID_PKCS3,
                        "DiffieHellman");
391

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
                    /*
                     * Algorithm parameter generation engines
                     */
                    put("AlgorithmParameterGenerator.DiffieHellman",
                        "com.sun.crypto.provider.DHParameterGenerator");
                    put("Alg.Alias.AlgorithmParameterGenerator.DH",
                        "DiffieHellman");
                    put("Alg.Alias.AlgorithmParameterGenerator.OID."+OID_PKCS3,
                        "DiffieHellman");
                    put("Alg.Alias.AlgorithmParameterGenerator."+OID_PKCS3,
                        "DiffieHellman");

                    /*
                     * Key Agreement engines
                     */
                    put("KeyAgreement.DiffieHellman",
                        "com.sun.crypto.provider.DHKeyAgreement");
                    put("Alg.Alias.KeyAgreement.DH", "DiffieHellman");
                    put("Alg.Alias.KeyAgreement.OID."+OID_PKCS3, "DiffieHellman");
                    put("Alg.Alias.KeyAgreement."+OID_PKCS3, "DiffieHellman");

                    put("KeyAgreement.DiffieHellman SupportedKeyClasses",
                        "javax.crypto.interfaces.DHPublicKey" +
                        "|javax.crypto.interfaces.DHPrivateKey");

                    /*
                     * Algorithm Parameter engines
                     */
                    put("AlgorithmParameters.DiffieHellman",
                        "com.sun.crypto.provider.DHParameters");
                    put("Alg.Alias.AlgorithmParameters.DH", "DiffieHellman");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS3,
                        "DiffieHellman");
                    put("Alg.Alias.AlgorithmParameters."+OID_PKCS3,
                        "DiffieHellman");

                    put("AlgorithmParameters.DES",
                        "com.sun.crypto.provider.DESParameters");

                    put("AlgorithmParameters.DESede",
                        "com.sun.crypto.provider.DESedeParameters");
                    put("Alg.Alias.AlgorithmParameters.TripleDES", "DESede");

                    put("AlgorithmParameters.PBE",
                        "com.sun.crypto.provider.PBEParameters");

                    put("AlgorithmParameters.PBEWithMD5AndDES",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");
                    put("Alg.Alias.AlgorithmParameters."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");

                    put("AlgorithmParameters.PBEWithMD5AndTripleDES",
                        "com.sun.crypto.provider.PBEParameters");

                    put("AlgorithmParameters.PBEWithSHA1AndDESede",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");
                    put("Alg.Alias.AlgorithmParameters."+OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");

                    put("AlgorithmParameters.PBEWithSHA1AndRC2_40",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");
                    put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");

462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
                    put("AlgorithmParameters.PBEWithSHA1AndRC2_128",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");
                    put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");

                    put("AlgorithmParameters.PBEWithSHA1AndRC4_40",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");
                    put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");

                    put("AlgorithmParameters.PBEWithSHA1AndRC4_128",
                        "com.sun.crypto.provider.PBEParameters");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");
                    put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");

                    put("AlgorithmParameters.PBES2",
                        "com.sun.crypto.provider.PBES2Parameters$General");
                    put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS5_PBES2,
                        "PBES2");
                    put("Alg.Alias.AlgorithmParameters." + OID_PKCS5_PBES2,
                        "PBES2");

                    put("AlgorithmParameters.PBEWithHmacSHA1AndAES_128",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_128");

                    put("AlgorithmParameters.PBEWithHmacSHA224AndAES_128",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_128");

                    put("AlgorithmParameters.PBEWithHmacSHA256AndAES_128",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_128");

                    put("AlgorithmParameters.PBEWithHmacSHA384AndAES_128",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_128");

                    put("AlgorithmParameters.PBEWithHmacSHA512AndAES_128",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_128");

                    put("AlgorithmParameters.PBEWithHmacSHA1AndAES_256",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_256");

                    put("AlgorithmParameters.PBEWithHmacSHA224AndAES_256",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_256");

                    put("AlgorithmParameters.PBEWithHmacSHA256AndAES_256",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_256");

                    put("AlgorithmParameters.PBEWithHmacSHA384AndAES_256",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_256");

                    put("AlgorithmParameters.PBEWithHmacSHA512AndAES_256",
                        "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_256");

520 521 522 523 524 525
                    put("AlgorithmParameters.Blowfish",
                        "com.sun.crypto.provider.BlowfishParameters");

                    put("AlgorithmParameters.AES",
                        "com.sun.crypto.provider.AESParameters");
                    put("Alg.Alias.AlgorithmParameters.Rijndael", "AES");
V
valeriep 已提交
526 527
                    put("AlgorithmParameters.GCM",
                        "com.sun.crypto.provider.GCMParameters");
528

529

530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
                    put("AlgorithmParameters.RC2",
                        "com.sun.crypto.provider.RC2Parameters");

                    put("AlgorithmParameters.OAEP",
                        "com.sun.crypto.provider.OAEPParameters");

                    /*
                     * Key factories
                     */
                    put("KeyFactory.DiffieHellman",
                        "com.sun.crypto.provider.DHKeyFactory");
                    put("Alg.Alias.KeyFactory.DH", "DiffieHellman");
                    put("Alg.Alias.KeyFactory.OID."+OID_PKCS3,
                        "DiffieHellman");
                    put("Alg.Alias.KeyFactory."+OID_PKCS3, "DiffieHellman");
545

546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
                    /*
                     * Secret-key factories
                     */
                    put("SecretKeyFactory.DES",
                        "com.sun.crypto.provider.DESKeyFactory");

                    put("SecretKeyFactory.DESede",
                        "com.sun.crypto.provider.DESedeKeyFactory");
                    put("Alg.Alias.SecretKeyFactory.TripleDES", "DESede");

                    put("SecretKeyFactory.PBEWithMD5AndDES",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndDES"
                        );
                    put("Alg.Alias.SecretKeyFactory.OID."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");
                    put("Alg.Alias.SecretKeyFactory."+OID_PKCS5_MD5_DES,
                        "PBEWithMD5AndDES");

                    put("Alg.Alias.SecretKeyFactory.PBE",
                        "PBEWithMD5AndDES");

                    /*
                     * Internal in-house crypto algorithm used for
                     * the JCEKS keystore type.  Since this was developed
                     * internally, there isn't an OID corresponding to this
                     * algorithm.
                     */
                    put("SecretKeyFactory.PBEWithMD5AndTripleDES",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithMD5AndTripleDES"
                        );

                    put("SecretKeyFactory.PBEWithSHA1AndDESede",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndDESede"
                        );
                    put("Alg.Alias.SecretKeyFactory.OID."+OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_DESede,
                        "PBEWithSHA1AndDESede");

                    put("SecretKeyFactory.PBEWithSHA1AndRC2_40",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40"
                        );
                    put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40,
                        "PBEWithSHA1AndRC2_40");

594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
                    put("SecretKeyFactory.PBEWithSHA1AndRC2_128",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_128"
                        );
                    put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_128,
                        "PBEWithSHA1AndRC2_128");

                    put("SecretKeyFactory.PBEWithSHA1AndRC4_40",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_40"
                        );

                    put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_40,
                        "PBEWithSHA1AndRC4_40");

                    put("SecretKeyFactory.PBEWithSHA1AndRC4_128",
                        "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_128"
                        );

                    put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_128,
                        "PBEWithSHA1AndRC4_128");

                    put("SecretKeyFactory.PBEWithHmacSHA1AndAES_128",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA1AndAES_128");

                    put("SecretKeyFactory.PBEWithHmacSHA224AndAES_128",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA224AndAES_128");

                    put("SecretKeyFactory.PBEWithHmacSHA256AndAES_128",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA256AndAES_128");

                    put("SecretKeyFactory.PBEWithHmacSHA384AndAES_128",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA384AndAES_128");

                    put("SecretKeyFactory.PBEWithHmacSHA512AndAES_128",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA512AndAES_128");

                    put("SecretKeyFactory.PBEWithHmacSHA1AndAES_256",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA1AndAES_256");

                    put("SecretKeyFactory.PBEWithHmacSHA224AndAES_256",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA224AndAES_256");

                    put("SecretKeyFactory.PBEWithHmacSHA256AndAES_256",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA256AndAES_256");

                    put("SecretKeyFactory.PBEWithHmacSHA384AndAES_256",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA384AndAES_256");

                    put("SecretKeyFactory.PBEWithHmacSHA512AndAES_256",
                        "com.sun.crypto.provider.PBEKeyFactory$" +
                        "PBEWithHmacSHA512AndAES_256");

                    // PBKDF2

662
                    put("SecretKeyFactory.PBKDF2WithHmacSHA1",
663
                        "com.sun.crypto.provider.PBKDF2Core$HmacSHA1");
664 665 666 667 668
                    put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2,
                        "PBKDF2WithHmacSHA1");
                    put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2,
                        "PBKDF2WithHmacSHA1");

669 670 671 672 673 674 675 676 677
                    put("SecretKeyFactory.PBKDF2WithHmacSHA224",
                        "com.sun.crypto.provider.PBKDF2Core$HmacSHA224");
                    put("SecretKeyFactory.PBKDF2WithHmacSHA256",
                        "com.sun.crypto.provider.PBKDF2Core$HmacSHA256");
                    put("SecretKeyFactory.PBKDF2WithHmacSHA384",
                        "com.sun.crypto.provider.PBKDF2Core$HmacSHA384");
                    put("SecretKeyFactory.PBKDF2WithHmacSHA512",
                        "com.sun.crypto.provider.PBKDF2Core$HmacSHA512");

678 679 680 681 682
                    /*
                     * MAC
                     */
                    put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
                    put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
683 684
                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.7", "HmacSHA1");
                    put("Alg.Alias.Mac.1.2.840.113549.2.7", "HmacSHA1");
V
valeriep 已提交
685 686 687 688
                    put("Mac.HmacSHA224",
                        "com.sun.crypto.provider.HmacCore$HmacSHA224");
                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
                    put("Alg.Alias.Mac.1.2.840.113549.2.8", "HmacSHA224");
689 690
                    put("Mac.HmacSHA256",
                        "com.sun.crypto.provider.HmacCore$HmacSHA256");
V
valeriep 已提交
691 692
                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.9", "HmacSHA256");
                    put("Alg.Alias.Mac.1.2.840.113549.2.9", "HmacSHA256");
693 694
                    put("Mac.HmacSHA384",
                        "com.sun.crypto.provider.HmacCore$HmacSHA384");
V
valeriep 已提交
695 696
                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.10", "HmacSHA384");
                    put("Alg.Alias.Mac.1.2.840.113549.2.10", "HmacSHA384");
697 698
                    put("Mac.HmacSHA512",
                        "com.sun.crypto.provider.HmacCore$HmacSHA512");
V
valeriep 已提交
699 700 701
                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.11", "HmacSHA512");
                    put("Alg.Alias.Mac.1.2.840.113549.2.11", "HmacSHA512");

702 703 704
                    put("Mac.HmacPBESHA1",
                        "com.sun.crypto.provider.HmacPKCS12PBESHA1");

705 706 707 708 709 710 711 712 713 714 715 716 717
                    // PBMAC1

                    put("Mac.PBEWithHmacSHA1",
                        "com.sun.crypto.provider.PBMAC1Core$HmacSHA1");
                    put("Mac.PBEWithHmacSHA224",
                        "com.sun.crypto.provider.PBMAC1Core$HmacSHA224");
                    put("Mac.PBEWithHmacSHA256",
                        "com.sun.crypto.provider.PBMAC1Core$HmacSHA256");
                    put("Mac.PBEWithHmacSHA384",
                        "com.sun.crypto.provider.PBMAC1Core$HmacSHA384");
                    put("Mac.PBEWithHmacSHA512",
                        "com.sun.crypto.provider.PBMAC1Core$HmacSHA512");

718 719 720 721 722 723 724
                    put("Mac.SslMacMD5",
                        "com.sun.crypto.provider.SslMacCore$SslMacMD5");
                    put("Mac.SslMacSHA1",
                        "com.sun.crypto.provider.SslMacCore$SslMacSHA1");

                    put("Mac.HmacMD5 SupportedKeyFormats", "RAW");
                    put("Mac.HmacSHA1 SupportedKeyFormats", "RAW");
V
valeriep 已提交
725
                    put("Mac.HmacSHA224 SupportedKeyFormats", "RAW");
726 727 728 729
                    put("Mac.HmacSHA256 SupportedKeyFormats", "RAW");
                    put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
                    put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
                    put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW");
730 731 732 733
                    put("Mac.HmacPBESHA224 SupportedKeyFormats", "RAW");
                    put("Mac.HmacPBESHA256 SupportedKeyFormats", "RAW");
                    put("Mac.HmacPBESHA384 SupportedKeyFormats", "RAW");
                    put("Mac.HmacPBESHA512 SupportedKeyFormats", "RAW");
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
                    put("Mac.SslMacMD5 SupportedKeyFormats", "RAW");
                    put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW");

                    /*
                     * KeyStore
                     */
                    put("KeyStore.JCEKS", "com.sun.crypto.provider.JceKeyStore");

                    /*
                     * SSL/TLS mechanisms
                     *
                     * These are strictly internal implementations and may
                     * be changed at any time.  These names were chosen
                     * because PKCS11/SunPKCS11 does not yet have TLS1.2
                     * mechanisms, and it will cause calls to come here.
                     */
                    put("KeyGenerator.SunTlsPrf",
                            "com.sun.crypto.provider.TlsPrfGenerator$V10");
                    put("KeyGenerator.SunTls12Prf",
                            "com.sun.crypto.provider.TlsPrfGenerator$V12");

                    put("KeyGenerator.SunTlsMasterSecret",
                        "com.sun.crypto.provider.TlsMasterSecretGenerator");
                    put("Alg.Alias.KeyGenerator.SunTls12MasterSecret",
                        "SunTlsMasterSecret");

                    put("KeyGenerator.SunTlsKeyMaterial",
                        "com.sun.crypto.provider.TlsKeyMaterialGenerator");
                    put("Alg.Alias.KeyGenerator.SunTls12KeyMaterial",
                        "SunTlsKeyMaterial");

                    put("KeyGenerator.SunTlsRsaPremasterSecret",
                        "com.sun.crypto.provider.TlsRsaPremasterSecretGenerator");
                    put("Alg.Alias.KeyGenerator.SunTls12RsaPremasterSecret",
                        "SunTlsRsaPremasterSecret");

                    return null;
                }
            });
D
duke 已提交
773 774
    }
}