1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
53 *
54 * - DES-EDE
55 *
56 * - AES
57 *
58 * - Blowfish
59 *
60 * - RC2
61 *
62 * - ARCFOUR (RC4 compatible)
63 *
64 * - Cipher modes ECB, CBC, CFB, OFB, PCBC, CTR, and CTS for all block ciphers
65 *
66 * - Cipher padding ISO10126Padding for non-PKCS#5 block ciphers and
67 * NoPadding and PKCS5Padding for all block ciphers
68 *
69 * - Password-based Encryption (PBE)
70 *
71 * - Diffie-Hellman Key Agreement
72 *
73 * - HMAC-MD5, HMAC-SHA1, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512
74 *
75 */
76
77 public final class SunJCE extends Provider {
78
79 private static final long serialVersionUID = 6812507587804302833L;
80
81 private static final String info = "SunJCE Provider " +
82 "(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, "
83 + "Diffie-Hellman, HMAC)";
84
85 private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6";
86 private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3";
87 private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3";
88 private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12";
89 private static final String OID_PKCS3 = "1.2.840.113549.1.3.1";
90
91 /* Are we debugging? -- for developers */
92 static final boolean debug = false;
93
100 final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" +
101 "|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" +
102 "|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64";
103 final String BLOCK_MODES128 = BLOCK_MODES +
104 "|CFB72|CFB80|CFB88|CFB96|CFB104|CFB112|CFB120|CFB128" +
105 "|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128";
106 final String BLOCK_PADS = "NOPADDING|PKCS5PADDING|ISO10126PADDING";
107
108 AccessController.doPrivileged(new java.security.PrivilegedAction() {
109 public Object run() {
110
111 /*
112 * Cipher engines
113 */
114 put("Cipher.RSA", "com.sun.crypto.provider.RSACipher");
115 put("Cipher.RSA SupportedModes", "ECB");
116 put("Cipher.RSA SupportedPaddings",
117 "NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING"
118 + "|OAEPWITHSHA1ANDMGF1PADDING"
119 + "|OAEPWITHSHA-1ANDMGF1PADDING"
120 + "|OAEPWITHSHA-256ANDMGF1PADDING"
121 + "|OAEPWITHSHA-384ANDMGF1PADDING"
122 + "|OAEPWITHSHA-512ANDMGF1PADDING");
123 put("Cipher.RSA SupportedKeyClasses",
124 "java.security.interfaces.RSAPublicKey" +
125 "|java.security.interfaces.RSAPrivateKey");
126
127 put("Cipher.DES", "com.sun.crypto.provider.DESCipher");
128 put("Cipher.DES SupportedModes", BLOCK_MODES);
129 put("Cipher.DES SupportedPaddings", BLOCK_PADS);
130 put("Cipher.DES SupportedKeyFormats", "RAW");
131
132 put("Cipher.DESede", "com.sun.crypto.provider.DESedeCipher");
133 put("Alg.Alias.Cipher.TripleDES", "DESede");
134 put("Cipher.DESede SupportedModes", BLOCK_MODES);
135 put("Cipher.DESede SupportedPaddings", BLOCK_PADS);
136 put("Cipher.DESede SupportedKeyFormats", "RAW");
137
138 put("Cipher.DESedeWrap",
139 "com.sun.crypto.provider.DESedeWrapCipher");
208 "com.sun.crypto.provider.BlowfishKeyGenerator");
209
210 put("KeyGenerator.AES",
211 "com.sun.crypto.provider.AESKeyGenerator");
212 put("Alg.Alias.KeyGenerator.Rijndael", "AES");
213
214 put("KeyGenerator.RC2",
215 "com.sun.crypto.provider.KeyGeneratorCore$" +
216 "RC2KeyGenerator");
217 put("KeyGenerator.ARCFOUR",
218 "com.sun.crypto.provider.KeyGeneratorCore$" +
219 "ARCFOURKeyGenerator");
220 put("Alg.Alias.KeyGenerator.RC4", "ARCFOUR");
221
222 put("KeyGenerator.HmacMD5",
223 "com.sun.crypto.provider.HmacMD5KeyGenerator");
224
225 put("KeyGenerator.HmacSHA1",
226 "com.sun.crypto.provider.HmacSHA1KeyGenerator");
227
228 put("KeyGenerator.HmacSHA256",
229 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA256KG");
230 put("KeyGenerator.HmacSHA384",
231 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA384KG");
232 put("KeyGenerator.HmacSHA512",
233 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA512KG");
234
235 put("KeyPairGenerator.DiffieHellman",
236 "com.sun.crypto.provider.DHKeyPairGenerator");
237 put("Alg.Alias.KeyPairGenerator.DH", "DiffieHellman");
238 put("Alg.Alias.KeyPairGenerator.OID."+OID_PKCS3,
239 "DiffieHellman");
240 put("Alg.Alias.KeyPairGenerator."+OID_PKCS3,
241 "DiffieHellman");
242 /*
243 * Algorithm parameter generation engines
244 */
245 put("AlgorithmParameterGenerator.DiffieHellman",
246 "com.sun.crypto.provider.DHParameterGenerator");
247 put("Alg.Alias.AlgorithmParameterGenerator.DH",
248 "DiffieHellman");
249 put("Alg.Alias.AlgorithmParameterGenerator.OID."+OID_PKCS3,
250 "DiffieHellman");
251 put("Alg.Alias.AlgorithmParameterGenerator."+OID_PKCS3,
252 "DiffieHellman");
253
376 put("SecretKeyFactory.PBEWithSHA1AndRC2_40",
377 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40"
378 );
379 put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_40,
380 "PBEWithSHA1AndRC2_40");
381 put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40,
382 "PBEWithSHA1AndRC2_40");
383
384 put("SecretKeyFactory.PBKDF2WithHmacSHA1",
385 "com.sun.crypto.provider.PBKDF2HmacSHA1Factory");
386 put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2,
387 "PBKDF2WithHmacSHA1");
388 put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2,
389 "PBKDF2WithHmacSHA1");
390
391 /*
392 * MAC
393 */
394 put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
395 put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
396 put("Mac.HmacSHA256",
397 "com.sun.crypto.provider.HmacCore$HmacSHA256");
398 put("Mac.HmacSHA384",
399 "com.sun.crypto.provider.HmacCore$HmacSHA384");
400 put("Mac.HmacSHA512",
401 "com.sun.crypto.provider.HmacCore$HmacSHA512");
402 put("Mac.HmacPBESHA1",
403 "com.sun.crypto.provider.HmacPKCS12PBESHA1");
404
405 put("Mac.SslMacMD5",
406 "com.sun.crypto.provider.SslMacCore$SslMacMD5");
407 put("Mac.SslMacSHA1",
408 "com.sun.crypto.provider.SslMacCore$SslMacSHA1");
409
410 put("Mac.HmacMD5 SupportedKeyFormats", "RAW");
411 put("Mac.HmacSHA1 SupportedKeyFormats", "RAW");
412 put("Mac.HmacSHA256 SupportedKeyFormats", "RAW");
413 put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
414 put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
415 put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW");
416 put("Mac.SslMacMD5 SupportedKeyFormats", "RAW");
417 put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW");
418
419 /*
420 * KeyStore
421 */
422 put("KeyStore.JCEKS", "com.sun.crypto.provider.JceKeyStore");
423
424 /*
425 * SSL/TLS mechanisms
426 *
427 * These are strictly internal implementations and may
428 * be changed at any time. These names were chosen
429 * because PKCS11/SunPKCS11 does not yet have TLS1.2
430 * mechanisms, and it will cause calls to come here.
431 */
|
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
53 *
54 * - DES-EDE
55 *
56 * - AES
57 *
58 * - Blowfish
59 *
60 * - RC2
61 *
62 * - ARCFOUR (RC4 compatible)
63 *
64 * - Cipher modes ECB, CBC, CFB, OFB, PCBC, CTR, and CTS for all block ciphers
65 *
66 * - Cipher padding ISO10126Padding for non-PKCS#5 block ciphers and
67 * NoPadding and PKCS5Padding for all block ciphers
68 *
69 * - Password-based Encryption (PBE)
70 *
71 * - Diffie-Hellman Key Agreement
72 *
73 * - HMAC-MD5, HMAC-SHA1, HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512
74 *
75 */
76
77 public final class SunJCE extends Provider {
78
79 private static final long serialVersionUID = 6812507587804302833L;
80
81 private static final String info = "SunJCE Provider " +
82 "(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, "
83 + "Diffie-Hellman, HMAC)";
84
85 private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6";
86 private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3";
87 private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3";
88 private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12";
89 private static final String OID_PKCS3 = "1.2.840.113549.1.3.1";
90
91 /* Are we debugging? -- for developers */
92 static final boolean debug = false;
93
100 final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" +
101 "|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" +
102 "|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64";
103 final String BLOCK_MODES128 = BLOCK_MODES +
104 "|CFB72|CFB80|CFB88|CFB96|CFB104|CFB112|CFB120|CFB128" +
105 "|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128";
106 final String BLOCK_PADS = "NOPADDING|PKCS5PADDING|ISO10126PADDING";
107
108 AccessController.doPrivileged(new java.security.PrivilegedAction() {
109 public Object run() {
110
111 /*
112 * Cipher engines
113 */
114 put("Cipher.RSA", "com.sun.crypto.provider.RSACipher");
115 put("Cipher.RSA SupportedModes", "ECB");
116 put("Cipher.RSA SupportedPaddings",
117 "NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING"
118 + "|OAEPWITHSHA1ANDMGF1PADDING"
119 + "|OAEPWITHSHA-1ANDMGF1PADDING"
120 + "|OAEPWITHSHA-224ANDMGF1PADDING"
121 + "|OAEPWITHSHA-256ANDMGF1PADDING"
122 + "|OAEPWITHSHA-384ANDMGF1PADDING"
123 + "|OAEPWITHSHA-512ANDMGF1PADDING");
124 put("Cipher.RSA SupportedKeyClasses",
125 "java.security.interfaces.RSAPublicKey" +
126 "|java.security.interfaces.RSAPrivateKey");
127
128 put("Cipher.DES", "com.sun.crypto.provider.DESCipher");
129 put("Cipher.DES SupportedModes", BLOCK_MODES);
130 put("Cipher.DES SupportedPaddings", BLOCK_PADS);
131 put("Cipher.DES SupportedKeyFormats", "RAW");
132
133 put("Cipher.DESede", "com.sun.crypto.provider.DESedeCipher");
134 put("Alg.Alias.Cipher.TripleDES", "DESede");
135 put("Cipher.DESede SupportedModes", BLOCK_MODES);
136 put("Cipher.DESede SupportedPaddings", BLOCK_PADS);
137 put("Cipher.DESede SupportedKeyFormats", "RAW");
138
139 put("Cipher.DESedeWrap",
140 "com.sun.crypto.provider.DESedeWrapCipher");
209 "com.sun.crypto.provider.BlowfishKeyGenerator");
210
211 put("KeyGenerator.AES",
212 "com.sun.crypto.provider.AESKeyGenerator");
213 put("Alg.Alias.KeyGenerator.Rijndael", "AES");
214
215 put("KeyGenerator.RC2",
216 "com.sun.crypto.provider.KeyGeneratorCore$" +
217 "RC2KeyGenerator");
218 put("KeyGenerator.ARCFOUR",
219 "com.sun.crypto.provider.KeyGeneratorCore$" +
220 "ARCFOURKeyGenerator");
221 put("Alg.Alias.KeyGenerator.RC4", "ARCFOUR");
222
223 put("KeyGenerator.HmacMD5",
224 "com.sun.crypto.provider.HmacMD5KeyGenerator");
225
226 put("KeyGenerator.HmacSHA1",
227 "com.sun.crypto.provider.HmacSHA1KeyGenerator");
228
229 put("KeyGenerator.HmacSHA224",
230 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
231 put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.8", "HmacSHA224");
232 put("Alg.Alias.KeyGenerator.1.2.840.113549.2.8", "HmacSHA224");
233
234 put("KeyGenerator.HmacSHA256",
235 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256");
236 put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.9", "HmacSHA256");
237 put("Alg.Alias.KeyGenerator.1.2.840.113549.2.9", "HmacSHA256");
238
239 put("KeyGenerator.HmacSHA384",
240 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384");
241 put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.10", "HmacSHA384");
242 put("Alg.Alias.KeyGenerator.1.2.840.113549.2.10", "HmacSHA384");
243
244 put("KeyGenerator.HmacSHA512",
245 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512");
246 put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.11", "HmacSHA512");
247 put("Alg.Alias.KeyGenerator.1.2.840.113549.2.11", "HmacSHA512");
248
249 put("KeyPairGenerator.DiffieHellman",
250 "com.sun.crypto.provider.DHKeyPairGenerator");
251 put("Alg.Alias.KeyPairGenerator.DH", "DiffieHellman");
252 put("Alg.Alias.KeyPairGenerator.OID."+OID_PKCS3,
253 "DiffieHellman");
254 put("Alg.Alias.KeyPairGenerator."+OID_PKCS3,
255 "DiffieHellman");
256 /*
257 * Algorithm parameter generation engines
258 */
259 put("AlgorithmParameterGenerator.DiffieHellman",
260 "com.sun.crypto.provider.DHParameterGenerator");
261 put("Alg.Alias.AlgorithmParameterGenerator.DH",
262 "DiffieHellman");
263 put("Alg.Alias.AlgorithmParameterGenerator.OID."+OID_PKCS3,
264 "DiffieHellman");
265 put("Alg.Alias.AlgorithmParameterGenerator."+OID_PKCS3,
266 "DiffieHellman");
267
390 put("SecretKeyFactory.PBEWithSHA1AndRC2_40",
391 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40"
392 );
393 put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_40,
394 "PBEWithSHA1AndRC2_40");
395 put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40,
396 "PBEWithSHA1AndRC2_40");
397
398 put("SecretKeyFactory.PBKDF2WithHmacSHA1",
399 "com.sun.crypto.provider.PBKDF2HmacSHA1Factory");
400 put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2,
401 "PBKDF2WithHmacSHA1");
402 put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2,
403 "PBKDF2WithHmacSHA1");
404
405 /*
406 * MAC
407 */
408 put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
409 put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
410 put("Mac.HmacSHA224",
411 "com.sun.crypto.provider.HmacCore$HmacSHA224");
412 put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
413 put("Alg.Alias.Mac.1.2.840.113549.2.8", "HmacSHA224");
414 put("Mac.HmacSHA256",
415 "com.sun.crypto.provider.HmacCore$HmacSHA256");
416 put("Alg.Alias.Mac.OID.1.2.840.113549.2.9", "HmacSHA256");
417 put("Alg.Alias.Mac.1.2.840.113549.2.9", "HmacSHA256");
418 put("Mac.HmacSHA384",
419 "com.sun.crypto.provider.HmacCore$HmacSHA384");
420 put("Alg.Alias.Mac.OID.1.2.840.113549.2.10", "HmacSHA384");
421 put("Alg.Alias.Mac.1.2.840.113549.2.10", "HmacSHA384");
422 put("Mac.HmacSHA512",
423 "com.sun.crypto.provider.HmacCore$HmacSHA512");
424 put("Alg.Alias.Mac.OID.1.2.840.113549.2.11", "HmacSHA512");
425 put("Alg.Alias.Mac.1.2.840.113549.2.11", "HmacSHA512");
426
427 put("Mac.HmacPBESHA1",
428 "com.sun.crypto.provider.HmacPKCS12PBESHA1");
429
430 put("Mac.SslMacMD5",
431 "com.sun.crypto.provider.SslMacCore$SslMacMD5");
432 put("Mac.SslMacSHA1",
433 "com.sun.crypto.provider.SslMacCore$SslMacSHA1");
434
435 put("Mac.HmacMD5 SupportedKeyFormats", "RAW");
436 put("Mac.HmacSHA1 SupportedKeyFormats", "RAW");
437 put("Mac.HmacSHA224 SupportedKeyFormats", "RAW");
438 put("Mac.HmacSHA256 SupportedKeyFormats", "RAW");
439 put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
440 put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
441 put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW");
442 put("Mac.SslMacMD5 SupportedKeyFormats", "RAW");
443 put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW");
444
445 /*
446 * KeyStore
447 */
448 put("KeyStore.JCEKS", "com.sun.crypto.provider.JceKeyStore");
449
450 /*
451 * SSL/TLS mechanisms
452 *
453 * These are strictly internal implementations and may
454 * be changed at any time. These names were chosen
455 * because PKCS11/SunPKCS11 does not yet have TLS1.2
456 * mechanisms, and it will cause calls to come here.
457 */
|