1 /* 2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.crypto.provider; 27 28 import java.security.AccessController; 29 import java.security.Provider; 30 import java.security.SecureRandom; 31 import java.security.PrivilegedAction; 32 import java.util.HashMap; 33 import java.util.List; 34 import static sun.security.util.SecurityConstants.PROVIDER_VER; 35 import static sun.security.provider.SunEntries.createAliases; 36 import static sun.security.provider.SunEntries.createAliasesWithOid; 37 38 /** 39 * The "SunJCE" Cryptographic Service Provider. 40 * 41 * @author Jan Luehe 42 * @author Sharon Liu 43 */ 44 45 /** 46 * Defines the "SunJCE" provider. 47 * 48 * Supported algorithms and their names: 49 * 50 * - RSA encryption (PKCS#1 v1.5 and raw) 51 * 52 * - DES 53 * 54 * - DES-EDE 55 * 56 * - AES 57 * 58 * - Blowfish 59 * 60 * - RC2 61 * 62 * - ARCFOUR (RC4 compatible) 63 * 64 * - ChaCha20 (Stream cipher only and in AEAD mode with Poly1305) 65 * 66 * - Cipher modes ECB, CBC, CFB, OFB, PCBC, CTR, and CTS for all block ciphers 67 * and mode GCM for AES cipher 68 * 69 * - Cipher padding ISO10126Padding for non-PKCS#5 block ciphers and 70 * NoPadding and PKCS5Padding for all block ciphers 71 * 72 * - Password-based Encryption (PBE) 73 * 74 * - Diffie-Hellman Key Agreement 75 * 76 * - HMAC-MD5, HMAC-SHA1, HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512 77 * 78 */ 79 80 public final class SunJCE extends Provider { 81 82 @java.io.Serial 83 private static final long serialVersionUID = 6812507587804302833L; 84 85 private static final String info = "SunJCE Provider " + 86 "(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, " 87 + "Diffie-Hellman, HMAC, ChaCha20)"; 88 89 /* Are we debugging? -- for developers */ 90 static final boolean debug = false; 91 92 // Instance of this provider, so we don't have to call the provider list 93 // to find ourselves or run the risk of not being in the list. 94 private static volatile SunJCE instance; 95 96 // lazy initialize SecureRandom to avoid potential recursion if Sun 97 // provider has not been installed yet 98 private static class SecureRandomHolder { 99 static final SecureRandom RANDOM = new SecureRandom(); 100 } 101 static SecureRandom getRandom() { return SecureRandomHolder.RANDOM; } 102 103 private void ps(String type, String algo, String cn, 104 List<String> aliases, HashMap<String, String> attrs) { 105 putService(new Provider.Service(this, type, algo, cn, aliases, attrs)); 106 } 107 108 public SunJCE() { 109 /* We are the "SunJCE" provider */ 110 super("SunJCE", PROVIDER_VER, info); 111 112 // if there is no security manager installed, put directly into 113 // the provider 114 if (System.getSecurityManager() == null) { 115 putEntries(); 116 } else { 117 AccessController.doPrivileged(new PrivilegedAction<Void>() { 118 @Override 119 public Void run() { 120 putEntries(); 121 return null; 122 } 123 }); 124 } 125 if (instance == null) { 126 instance = this; 127 } 128 } 129 130 void putEntries() { 131 // common aliases and oids 132 List<String> aesAliases = createAliases("Rijndael"); 133 List<String> desEdeAliases = createAliases("TripleDES"); 134 List<String> arcFourAliases = createAliases("RC4"); 135 List<String> sunTlsMSAliases = createAliases( 136 "SunTls12MasterSecret", "SunTlsExtendedMasterSecret" 137 ); 138 List<String> sunTlsKMAliases = createAliases("SunTls12KeyMaterial"); 139 List<String> sunTlsRsaPMSAliases = createAliases("SunTls12RsaPremasterSecret"); 140 141 String aes128Oid = "2.16.840.1.101.3.4.1."; 142 String aes192Oid = "2.16.840.1.101.3.4.1.2"; 143 String aes256Oid = "2.16.840.1.101.3.4.1.4"; 144 145 List<String> pkcs12RC4_128Aliases = 146 createAliasesWithOid("1.2.840.113549.1.12.1.1"); 147 148 List<String> pkcs12RC4_40Aliases = 149 createAliasesWithOid("1.2.840.113549.1.12.1.2"); 150 151 List<String> pkcs12DESedeAliases = 152 createAliasesWithOid("1.2.840.113549.1.12.1.3"); 153 154 List<String> pkcs12RC2_128Aliases = 155 createAliasesWithOid("1.2.840.113549.1.12.1.5"); 156 157 List<String> pkcs12RC2_40Aliases = 158 createAliasesWithOid("1.2.840.113549.1.12.1.6"); 159 160 List<String> pkcs5MD5_DESAliases = 161 createAliasesWithOid("1.2.840.113549.1.5.3", "PBE"); 162 163 List<String> pkcs5PBKDF2Aliases = 164 createAliasesWithOid("1.2.840.113549.1.5.12"); 165 166 List<String> pkcs5PBES2Aliases = 167 createAliasesWithOid("1.2.840.113549.1.5.13"); 168 169 List<String> diffieHellmanAliases = 170 createAliasesWithOid("1.2.840.113549.1.3.1", "DH"); 171 172 List<String> chachaPolyAliases = 173 createAliasesWithOid("1.2.840.113549.1.9.16.3.18"); 174 175 String macOidBase = "1.2.840.113549.2."; 176 List<String> macSHA1Aliases = createAliasesWithOid(macOidBase + "7"); 177 List<String> macSHA224Aliases = createAliasesWithOid(macOidBase + "8"); 178 List<String> macSHA256Aliases = createAliasesWithOid(macOidBase + "9"); 179 List<String> macSHA384Aliases = createAliasesWithOid(macOidBase + "10"); 180 List<String> macSHA512Aliases = createAliasesWithOid(macOidBase + "11"); 181 182 // reuse attribute map and reset before each reuse 183 HashMap<String, String> attrs = new HashMap<>(3); 184 attrs.put("SupportedModes", "ECB"); 185 attrs.put("SupportedPaddings", "NOPADDING|PKCS1PADDING|OAEPPADDING" 186 + "|OAEPWITHMD5ANDMGF1PADDING" 187 + "|OAEPWITHSHA1ANDMGF1PADDING" 188 + "|OAEPWITHSHA-1ANDMGF1PADDING" 189 + "|OAEPWITHSHA-224ANDMGF1PADDING" 190 + "|OAEPWITHSHA-256ANDMGF1PADDING" 191 + "|OAEPWITHSHA-384ANDMGF1PADDING" 192 + "|OAEPWITHSHA-512ANDMGF1PADDING" 193 + "|OAEPWITHSHA-512/224ANDMGF1PADDING" 194 + "|OAEPWITHSHA-512/256ANDMGF1PADDING"); 195 attrs.put("SupportedKeyClasses", 196 "java.security.interfaces.RSAPublicKey" + 197 "|java.security.interfaces.RSAPrivateKey"); 198 ps("Cipher", "RSA", 199 "com.sun.crypto.provider.RSACipher", null, attrs); 200 201 // common block cipher modes, pads 202 final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" + 203 "|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" + 204 "|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64"; 205 final String BLOCK_MODES128 = BLOCK_MODES + 206 "|GCM|CFB72|CFB80|CFB88|CFB96|CFB104|CFB112|CFB120|CFB128" + 207 "|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128"; 208 final String BLOCK_PADS = "NOPADDING|PKCS5PADDING|ISO10126PADDING"; 209 210 attrs.clear(); 211 attrs.put("SupportedModes", BLOCK_MODES); 212 attrs.put("SupportedPaddings", BLOCK_PADS); 213 attrs.put("SupportedKeyFormats", "RAW"); 214 ps("Cipher", "DES", 215 "com.sun.crypto.provider.DESCipher", null, attrs); 216 ps("Cipher", "DESede", "com.sun.crypto.provider.DESedeCipher", 217 desEdeAliases, attrs); 218 ps("Cipher", "Blowfish", 219 "com.sun.crypto.provider.BlowfishCipher", null, attrs); 220 221 ps("Cipher", "RC2", 222 "com.sun.crypto.provider.RC2Cipher", null, attrs); 223 224 attrs.clear(); 225 attrs.put("SupportedModes", BLOCK_MODES128); 226 attrs.put("SupportedPaddings", BLOCK_PADS); 227 attrs.put("SupportedKeyFormats", "RAW"); 228 ps("Cipher", "AES", "com.sun.crypto.provider.AESCipher$General", 229 aesAliases, attrs); 230 231 attrs.clear(); 232 attrs.put("SupportedKeyFormats", "RAW"); 233 ps("Cipher", "AES_128/ECB/NoPadding", 234 "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding", 235 createAliasesWithOid(aes128Oid+"1"), attrs); 236 ps("Cipher", "AES_128/CBC/NoPadding", 237 "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding", 238 createAliasesWithOid(aes128Oid+"2"), attrs); 239 ps("Cipher", "AES_128/OFB/NoPadding", 240 "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding", 241 createAliasesWithOid(aes128Oid+"3"), attrs); 242 ps("Cipher", "AES_128/CFB/NoPadding", 243 "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding", 244 createAliasesWithOid(aes128Oid+"4"), attrs); 245 ps("Cipher", "AES_128/GCM/NoPadding", 246 "com.sun.crypto.provider.AESCipher$AES128_GCM_NoPadding", 247 createAliasesWithOid(aes128Oid+"6"), attrs); 248 249 ps("Cipher", "AES_192/ECB/NoPadding", 250 "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding", 251 createAliasesWithOid(aes192Oid+"1"), attrs); 252 ps("Cipher", "AES_192/CBC/NoPadding", 253 "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding", 254 createAliasesWithOid(aes192Oid+"2"), attrs); 255 ps("Cipher", "AES_192/OFB/NoPadding", 256 "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding", 257 createAliasesWithOid(aes192Oid+"3"), attrs); 258 ps("Cipher", "AES_192/CFB/NoPadding", 259 "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding", 260 createAliasesWithOid(aes192Oid+"4"), attrs); 261 ps("Cipher", "AES_192/GCM/NoPadding", 262 "com.sun.crypto.provider.AESCipher$AES192_GCM_NoPadding", 263 createAliasesWithOid(aes192Oid+"6"), attrs); 264 265 ps("Cipher", "AES_256/ECB/NoPadding", 266 "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding", 267 createAliasesWithOid(aes256Oid+"1"), attrs); 268 ps("Cipher", "AES_256/CBC/NoPadding", 269 "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding", 270 createAliasesWithOid(aes256Oid+"2"), attrs); 271 ps("Cipher", "AES_256/OFB/NoPadding", 272 "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding", 273 createAliasesWithOid(aes256Oid+"3"), attrs); 274 ps("Cipher", "AES_256/CFB/NoPadding", 275 "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding", 276 createAliasesWithOid(aes256Oid+"4"), attrs); 277 ps("Cipher", "AES_256/GCM/NoPadding", 278 "com.sun.crypto.provider.AESCipher$AES256_GCM_NoPadding", 279 createAliasesWithOid(aes256Oid+"6"), attrs); 280 281 attrs.clear(); 282 attrs.put("SupportedModes", "CBC"); 283 attrs.put("SupportedPaddings", "NOPADDING"); 284 attrs.put("SupportedKeyFormats", "RAW"); 285 ps("Cipher", "DESedeWrap", 286 "com.sun.crypto.provider.DESedeWrapCipher", null, attrs); 287 288 attrs.clear(); 289 attrs.put("SupportedModes", "ECB"); 290 attrs.put("SupportedPaddings", "NOPADDING"); 291 attrs.put("SupportedKeyFormats", "RAW"); 292 ps("Cipher", "ARCFOUR", "com.sun.crypto.provider.ARCFOURCipher", 293 arcFourAliases, attrs); 294 ps("Cipher", "AESWrap", "com.sun.crypto.provider.AESWrapCipher$General", 295 null, attrs); 296 ps("Cipher", "AESWrap_128", 297 "com.sun.crypto.provider.AESWrapCipher$AES128", 298 createAliasesWithOid(aes128Oid+"5"), attrs); 299 ps("Cipher", "AESWrap_192", 300 "com.sun.crypto.provider.AESWrapCipher$AES192", 301 createAliasesWithOid(aes192Oid+"5"), attrs); 302 ps("Cipher", "AESWrap_256", 303 "com.sun.crypto.provider.AESWrapCipher$AES256", 304 createAliasesWithOid(aes256Oid+"5"), attrs); 305 306 attrs.clear(); 307 attrs.put("SupportedKeyFormats", "RAW"); 308 ps("Cipher", "ChaCha20", 309 "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Only", 310 null, attrs); 311 ps("Cipher", "ChaCha20-Poly1305", 312 "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Poly1305", 313 chachaPolyAliases, attrs); 314 315 // PBES1 316 ps("Cipher", "PBEWithMD5AndDES", 317 "com.sun.crypto.provider.PBEWithMD5AndDESCipher", 318 pkcs5MD5_DESAliases, null); 319 ps("Cipher", "PBEWithMD5AndTripleDES", 320 "com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher", 321 null, null); 322 ps("Cipher", "PBEWithSHA1AndDESede", 323 "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede", 324 pkcs12DESedeAliases, null); 325 ps("Cipher", "PBEWithSHA1AndRC2_40", 326 "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40", 327 pkcs12RC2_40Aliases, null); 328 ps("Cipher", "PBEWithSHA1AndRC2_128", 329 "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_128", 330 pkcs12RC2_128Aliases, null); 331 ps("Cipher", "PBEWithSHA1AndRC4_40", 332 "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC4_40", 333 pkcs12RC4_40Aliases, null); 334 335 ps("Cipher", "PBEWithSHA1AndRC4_128", 336 "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC4_128", 337 pkcs12RC4_128Aliases, null); 338 339 // PBES2 340 ps("Cipher", "PBEWithHmacSHA1AndAES_128", 341 "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_128", 342 null, null); 343 344 ps("Cipher", "PBEWithHmacSHA224AndAES_128", 345 "com.sun.crypto.provider.PBES2Core$HmacSHA224AndAES_128", 346 null, null); 347 348 ps("Cipher", "PBEWithHmacSHA256AndAES_128", 349 "com.sun.crypto.provider.PBES2Core$HmacSHA256AndAES_128", 350 null, null); 351 352 ps("Cipher", "PBEWithHmacSHA384AndAES_128", 353 "com.sun.crypto.provider.PBES2Core$HmacSHA384AndAES_128", 354 null, null); 355 356 ps("Cipher", "PBEWithHmacSHA512AndAES_128", 357 "com.sun.crypto.provider.PBES2Core$HmacSHA512AndAES_128", 358 null, null); 359 360 ps("Cipher", "PBEWithHmacSHA1AndAES_256", 361 "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_256", 362 null, null); 363 364 ps("Cipher", "PBEWithHmacSHA224AndAES_256", 365 "com.sun.crypto.provider.PBES2Core$HmacSHA224AndAES_256", 366 null, null); 367 368 ps("Cipher", "PBEWithHmacSHA256AndAES_256", 369 "com.sun.crypto.provider.PBES2Core$HmacSHA256AndAES_256", 370 null, null); 371 372 ps("Cipher", "PBEWithHmacSHA384AndAES_256", 373 "com.sun.crypto.provider.PBES2Core$HmacSHA384AndAES_256", 374 null, null); 375 376 ps("Cipher", "PBEWithHmacSHA512AndAES_256", 377 "com.sun.crypto.provider.PBES2Core$HmacSHA512AndAES_256", 378 null, null); 379 380 /* 381 * Key(pair) Generator engines 382 */ 383 ps("KeyGenerator", "DES", 384 "com.sun.crypto.provider.DESKeyGenerator", 385 null, null); 386 ps("KeyGenerator", "DESede", 387 "com.sun.crypto.provider.DESedeKeyGenerator", 388 desEdeAliases, null); 389 ps("KeyGenerator", "Blowfish", 390 "com.sun.crypto.provider.BlowfishKeyGenerator", 391 null, null); 392 ps("KeyGenerator", "AES", 393 "com.sun.crypto.provider.AESKeyGenerator", 394 aesAliases, null); 395 ps("KeyGenerator", "RC2", 396 "com.sun.crypto.provider.KeyGeneratorCore$RC2KeyGenerator", 397 null, null); 398 ps("KeyGenerator", "ARCFOUR", 399 "com.sun.crypto.provider.KeyGeneratorCore$ARCFOURKeyGenerator", 400 arcFourAliases, null); 401 ps("KeyGenerator", "ChaCha20", 402 "com.sun.crypto.provider.KeyGeneratorCore$ChaCha20KeyGenerator", 403 null, null); 404 ps("KeyGenerator", "HmacMD5", 405 "com.sun.crypto.provider.HmacMD5KeyGenerator", 406 null, null); 407 408 ps("KeyGenerator", "HmacSHA1", 409 "com.sun.crypto.provider.HmacSHA1KeyGenerator", 410 macSHA1Aliases, null); 411 ps("KeyGenerator", "HmacSHA224", 412 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224", 413 macSHA224Aliases, null); 414 ps("KeyGenerator", "HmacSHA256", 415 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256", 416 macSHA256Aliases, null); 417 ps("KeyGenerator", "HmacSHA384", 418 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384", 419 macSHA384Aliases, null); 420 ps("KeyGenerator", "HmacSHA512", 421 "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512", 422 macSHA512Aliases, null); 423 424 ps("KeyPairGenerator", "DiffieHellman", 425 "com.sun.crypto.provider.DHKeyPairGenerator", 426 diffieHellmanAliases, null); 427 428 /* 429 * Algorithm parameter generation engines 430 */ 431 ps("AlgorithmParameterGenerator", 432 "DiffieHellman", "com.sun.crypto.provider.DHParameterGenerator", 433 diffieHellmanAliases, null); 434 435 /* 436 * Key Agreement engines 437 */ 438 attrs.clear(); 439 attrs.put("SupportedKeyClasses", "javax.crypto.interfaces.DHPublicKey" + 440 "|javax.crypto.interfaces.DHPrivateKey"); 441 ps("KeyAgreement", "DiffieHellman", 442 "com.sun.crypto.provider.DHKeyAgreement", 443 diffieHellmanAliases, attrs); 444 445 /* 446 * Algorithm Parameter engines 447 */ 448 ps("AlgorithmParameters", "DiffieHellman", 449 "com.sun.crypto.provider.DHParameters", 450 diffieHellmanAliases, null); 451 452 ps("AlgorithmParameters", "DES", 453 "com.sun.crypto.provider.DESParameters", 454 null, null); 455 456 ps("AlgorithmParameters", "DESede", 457 "com.sun.crypto.provider.DESedeParameters", 458 desEdeAliases, null); 459 460 ps("AlgorithmParameters", "PBEWithMD5AndDES", 461 "com.sun.crypto.provider.PBEParameters", 462 pkcs5MD5_DESAliases, null); 463 464 ps("AlgorithmParameters", "PBEWithMD5AndTripleDES", 465 "com.sun.crypto.provider.PBEParameters", 466 null, null); 467 468 ps("AlgorithmParameters", "PBEWithSHA1AndDESede", 469 "com.sun.crypto.provider.PBEParameters", 470 pkcs12DESedeAliases, null); 471 472 ps("AlgorithmParameters", "PBEWithSHA1AndRC2_40", 473 "com.sun.crypto.provider.PBEParameters", 474 pkcs12RC2_40Aliases, null); 475 476 ps("AlgorithmParameters", "PBEWithSHA1AndRC2_128", 477 "com.sun.crypto.provider.PBEParameters", 478 pkcs12RC2_128Aliases, null); 479 480 ps("AlgorithmParameters", "PBEWithSHA1AndRC4_40", 481 "com.sun.crypto.provider.PBEParameters", 482 pkcs12RC4_40Aliases, null); 483 484 ps("AlgorithmParameters", "PBEWithSHA1AndRC4_128", 485 "com.sun.crypto.provider.PBEParameters", 486 pkcs12RC4_128Aliases, null); 487 488 ps("AlgorithmParameters", "PBES2", 489 "com.sun.crypto.provider.PBES2Parameters$General", 490 pkcs5PBES2Aliases, null); 491 492 ps("AlgorithmParameters", "PBEWithHmacSHA1AndAES_128", 493 "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_128", 494 null, null); 495 496 ps("AlgorithmParameters", "PBEWithHmacSHA224AndAES_128", 497 "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_128", 498 null, null); 499 500 ps("AlgorithmParameters", "PBEWithHmacSHA256AndAES_128", 501 "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_128", 502 null, null); 503 504 ps("AlgorithmParameters", "PBEWithHmacSHA384AndAES_128", 505 "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_128", 506 null, null); 507 508 ps("AlgorithmParameters", "PBEWithHmacSHA512AndAES_128", 509 "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_128", 510 null, null); 511 512 ps("AlgorithmParameters", "PBEWithHmacSHA1AndAES_256", 513 "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_256", 514 null, null); 515 516 ps("AlgorithmParameters", "PBEWithHmacSHA224AndAES_256", 517 "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_256", 518 null, null); 519 520 ps("AlgorithmParameters", "PBEWithHmacSHA256AndAES_256", 521 "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_256", 522 null, null); 523 524 ps("AlgorithmParameters", "PBEWithHmacSHA384AndAES_256", 525 "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_256", 526 null, null); 527 528 ps("AlgorithmParameters", "PBEWithHmacSHA512AndAES_256", 529 "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_256", 530 null, null); 531 532 ps("AlgorithmParameters", "Blowfish", 533 "com.sun.crypto.provider.BlowfishParameters", 534 null, null); 535 536 ps("AlgorithmParameters", "AES", 537 "com.sun.crypto.provider.AESParameters", 538 aesAliases, null); 539 540 ps("AlgorithmParameters", "GCM", 541 "com.sun.crypto.provider.GCMParameters", 542 null, null); 543 544 ps("AlgorithmParameters", "RC2", 545 "com.sun.crypto.provider.RC2Parameters", 546 null, null); 547 548 ps("AlgorithmParameters", "OAEP", 549 "com.sun.crypto.provider.OAEPParameters", 550 null, null); 551 552 ps("AlgorithmParameters", "ChaCha20-Poly1305", 553 "com.sun.crypto.provider.ChaCha20Poly1305Parameters", 554 chachaPolyAliases, null); 555 556 /* 557 * Key factories 558 */ 559 ps("KeyFactory", "DiffieHellman", 560 "com.sun.crypto.provider.DHKeyFactory", 561 diffieHellmanAliases, null); 562 563 /* 564 * Secret-key factories 565 */ 566 ps("SecretKeyFactory", "DES", 567 "com.sun.crypto.provider.DESKeyFactory", 568 null, null); 569 570 ps("SecretKeyFactory", "DESede", 571 "com.sun.crypto.provider.DESedeKeyFactory", 572 desEdeAliases, null); 573 574 ps("SecretKeyFactory", "PBEWithMD5AndDES", 575 "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndDES", 576 pkcs5MD5_DESAliases, null); 577 578 /* 579 * Internal in-house crypto algorithm used for 580 * the JCEKS keystore type. Since this was developed 581 * internally, there isn't an OID corresponding to this 582 * algorithm. 583 */ 584 ps("SecretKeyFactory", "PBEWithMD5AndTripleDES", 585 "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndTripleDES", 586 null, null); 587 588 ps("SecretKeyFactory", "PBEWithSHA1AndDESede", 589 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndDESede", 590 pkcs12DESedeAliases, null); 591 592 ps("SecretKeyFactory", "PBEWithSHA1AndRC2_40", 593 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40", 594 pkcs12RC2_40Aliases, null); 595 596 ps("SecretKeyFactory", "PBEWithSHA1AndRC2_128", 597 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_128", 598 pkcs12RC2_128Aliases, null); 599 600 ps("SecretKeyFactory", "PBEWithSHA1AndRC4_40", 601 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_40", 602 pkcs12RC4_40Aliases,null); 603 604 ps("SecretKeyFactory", "PBEWithSHA1AndRC4_128", 605 "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_128", 606 pkcs12RC4_128Aliases, null); 607 608 ps("SecretKeyFactory", "PBEWithHmacSHA1AndAES_128", 609 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA1AndAES_128", 610 null, null); 611 612 ps("SecretKeyFactory", "PBEWithHmacSHA224AndAES_128", 613 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA224AndAES_128", 614 null, null); 615 616 ps("SecretKeyFactory", "PBEWithHmacSHA256AndAES_128", 617 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA256AndAES_128", 618 null, null); 619 620 ps("SecretKeyFactory", "PBEWithHmacSHA384AndAES_128", 621 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA384AndAES_128", 622 null, null); 623 624 ps("SecretKeyFactory", "PBEWithHmacSHA512AndAES_128", 625 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA512AndAES_128", 626 null, null); 627 628 ps("SecretKeyFactory", "PBEWithHmacSHA1AndAES_256", 629 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA1AndAES_256", 630 null, null); 631 632 ps("SecretKeyFactory", "PBEWithHmacSHA224AndAES_256", 633 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA224AndAES_256", 634 null, null); 635 636 ps("SecretKeyFactory", "PBEWithHmacSHA256AndAES_256", 637 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA256AndAES_256", 638 null, null); 639 640 ps("SecretKeyFactory", "PBEWithHmacSHA384AndAES_256", 641 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA384AndAES_256", 642 null, null); 643 644 ps("SecretKeyFactory", "PBEWithHmacSHA512AndAES_256", 645 "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA512AndAES_256", 646 null, null); 647 648 // PBKDF2 649 ps("SecretKeyFactory", "PBKDF2WithHmacSHA1", 650 "com.sun.crypto.provider.PBKDF2Core$HmacSHA1", 651 pkcs5PBKDF2Aliases, null); 652 ps("SecretKeyFactory", "PBKDF2WithHmacSHA224", 653 "com.sun.crypto.provider.PBKDF2Core$HmacSHA224", 654 null, null); 655 ps("SecretKeyFactory", "PBKDF2WithHmacSHA256", 656 "com.sun.crypto.provider.PBKDF2Core$HmacSHA256", 657 null, null); 658 ps("SecretKeyFactory", "PBKDF2WithHmacSHA384", 659 "com.sun.crypto.provider.PBKDF2Core$HmacSHA384", 660 null, null); 661 ps("SecretKeyFactory", "PBKDF2WithHmacSHA512", 662 "com.sun.crypto.provider.PBKDF2Core$HmacSHA512", 663 null, null); 664 665 /* 666 * MAC 667 */ 668 attrs.clear(); 669 attrs.put("SupportedKeyFormats", "RAW"); 670 ps("Mac", "HmacMD5", "com.sun.crypto.provider.HmacMD5", null, attrs); 671 ps("Mac", "HmacSHA1", "com.sun.crypto.provider.HmacSHA1", 672 macSHA1Aliases, attrs); 673 ps("Mac", "HmacSHA224", "com.sun.crypto.provider.HmacCore$HmacSHA224", 674 macSHA224Aliases, attrs); 675 ps("Mac", "HmacSHA256", "com.sun.crypto.provider.HmacCore$HmacSHA256", 676 macSHA256Aliases, attrs); 677 ps("Mac", "HmacSHA384", "com.sun.crypto.provider.HmacCore$HmacSHA384", 678 macSHA384Aliases, attrs); 679 ps("Mac", "HmacSHA512", "com.sun.crypto.provider.HmacCore$HmacSHA512", 680 macSHA512Aliases, attrs); 681 // TODO: aliases with OIDs 682 ps("Mac", "HmacSHA512/224", 683 "com.sun.crypto.provider.HmacCore$HmacSHA512_224", 684 null, attrs); 685 ps("Mac", "HmacSHA512/256", 686 "com.sun.crypto.provider.HmacCore$HmacSHA512_256", 687 null, attrs); 688 ps("Mac", "HmacPBESHA1", 689 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA1", 690 null, attrs); 691 ps("Mac", "HmacPBESHA224", 692 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA224", 693 null, attrs); 694 ps("Mac", "HmacPBESHA256", 695 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA256", 696 null, attrs); 697 ps("Mac", "HmacPBESHA384", 698 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA384", 699 null, attrs); 700 ps("Mac", "HmacPBESHA512", 701 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512", 702 null, attrs); 703 ps("Mac", "HmacPBESHA512/224", 704 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512_224", 705 null, attrs); 706 ps("Mac", "HmacPBESHA512/256", 707 "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512_256", 708 null, attrs); 709 710 711 // PBMAC1 712 ps("Mac", "PBEWithHmacSHA1", 713 "com.sun.crypto.provider.PBMAC1Core$HmacSHA1", null, attrs); 714 ps("Mac", "PBEWithHmacSHA224", 715 "com.sun.crypto.provider.PBMAC1Core$HmacSHA224", null, attrs); 716 ps("Mac", "PBEWithHmacSHA256", 717 "com.sun.crypto.provider.PBMAC1Core$HmacSHA256", null, attrs); 718 ps("Mac", "PBEWithHmacSHA384", 719 "com.sun.crypto.provider.PBMAC1Core$HmacSHA384", null, attrs); 720 ps("Mac", "PBEWithHmacSHA512", 721 "com.sun.crypto.provider.PBMAC1Core$HmacSHA512", null, attrs); 722 ps("Mac", "SslMacMD5", 723 "com.sun.crypto.provider.SslMacCore$SslMacMD5", null, attrs); 724 ps("Mac", "SslMacSHA1", 725 "com.sun.crypto.provider.SslMacCore$SslMacSHA1", null, attrs); 726 727 /* 728 * KeyStore 729 */ 730 ps("KeyStore", "JCEKS", 731 "com.sun.crypto.provider.JceKeyStore", 732 null, null); 733 734 /* 735 * SSL/TLS mechanisms 736 * 737 * These are strictly internal implementations and may 738 * be changed at any time. These names were chosen 739 * because PKCS11/SunPKCS11 does not yet have TLS1.2 740 * mechanisms, and it will cause calls to come here. 741 */ 742 ps("KeyGenerator", "SunTlsPrf", 743 "com.sun.crypto.provider.TlsPrfGenerator$V10", 744 null, null); 745 ps("KeyGenerator", "SunTls12Prf", 746 "com.sun.crypto.provider.TlsPrfGenerator$V12", 747 null, null); 748 749 ps("KeyGenerator", "SunTlsMasterSecret", 750 "com.sun.crypto.provider.TlsMasterSecretGenerator", 751 createAliases("SunTls12MasterSecret", 752 "SunTlsExtendedMasterSecret"), null); 753 754 ps("KeyGenerator", "SunTlsKeyMaterial", 755 "com.sun.crypto.provider.TlsKeyMaterialGenerator", 756 createAliases("SunTls12KeyMaterial"), null); 757 758 ps("KeyGenerator", "SunTlsRsaPremasterSecret", 759 "com.sun.crypto.provider.TlsRsaPremasterSecretGenerator", 760 createAliases("SunTls12RsaPremasterSecret"), null); 761 } 762 763 // Return the instance of this class or create one if needed. 764 static SunJCE getInstance() { 765 if (instance == null) { 766 return new SunJCE(); 767 } 768 return instance; 769 } 770 }