1 /* 2 * Copyright (c) 2003, 2018, 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 sun.security.rsa; 27 28 import java.util.*; 29 import java.security.Provider; 30 import static sun.security.provider.SunEntries.createAliasesWithOid; 31 32 /** 33 * Defines the entries of the SunRsaSign provider. 34 * 35 * @author Andreas Sterbenz 36 */ 37 public final class SunRsaSignEntries { 38 add(Provider p, String type, String algo, String cn, List<String> aliases, HashMap<String, String> attrs)39 private void add(Provider p, String type, String algo, String cn, 40 List<String> aliases, HashMap<String, String> attrs) { 41 services.add(new Provider.Service(p, type, algo, cn, aliases, attrs)); 42 } 43 44 // extend LinkedHashSet for consistency with SunEntries 45 // used by sun.security.provider.VerificationProvider SunRsaSignEntries(Provider p)46 public SunRsaSignEntries(Provider p) { 47 services = new LinkedHashSet<>(20, 0.9f); 48 49 // start populating content using the specified provider 50 51 // common oids 52 String rsaOid = "1.2.840.113549.1.1"; 53 List<String> rsaAliases = createAliasesWithOid(rsaOid); 54 List<String> rsapssAliases = createAliasesWithOid(rsaOid + ".10"); 55 String sha1withRSAOid2 = "1.3.14.3.2.29"; 56 57 // common attribute map 58 HashMap<String, String> attrs = new HashMap<>(3); 59 attrs.put("SupportedKeyClasses", 60 "java.security.interfaces.RSAPublicKey" + 61 "|java.security.interfaces.RSAPrivateKey"); 62 63 add(p, "KeyFactory", "RSA", 64 "sun.security.rsa.RSAKeyFactory$Legacy", 65 rsaAliases, null); 66 add(p, "KeyPairGenerator", "RSA", 67 "sun.security.rsa.RSAKeyPairGenerator$Legacy", 68 rsaAliases, null); 69 add(p, "Signature", "MD2withRSA", 70 "sun.security.rsa.RSASignature$MD2withRSA", 71 createAliasesWithOid(rsaOid + ".2"), attrs); 72 add(p, "Signature", "MD5withRSA", 73 "sun.security.rsa.RSASignature$MD5withRSA", 74 createAliasesWithOid(rsaOid + ".4"), attrs); 75 add(p, "Signature", "SHA1withRSA", 76 "sun.security.rsa.RSASignature$SHA1withRSA", 77 createAliasesWithOid(rsaOid + ".5", sha1withRSAOid2), attrs); 78 add(p, "Signature", "SHA224withRSA", 79 "sun.security.rsa.RSASignature$SHA224withRSA", 80 createAliasesWithOid(rsaOid + ".14"), attrs); 81 add(p, "Signature", "SHA256withRSA", 82 "sun.security.rsa.RSASignature$SHA256withRSA", 83 createAliasesWithOid(rsaOid + ".11"), attrs); 84 add(p, "Signature", "SHA384withRSA", 85 "sun.security.rsa.RSASignature$SHA384withRSA", 86 createAliasesWithOid(rsaOid + ".12"), attrs); 87 add(p, "Signature", "SHA512withRSA", 88 "sun.security.rsa.RSASignature$SHA512withRSA", 89 createAliasesWithOid(rsaOid + ".13"), attrs); 90 add(p, "Signature", "SHA512/224withRSA", 91 "sun.security.rsa.RSASignature$SHA512_224withRSA", 92 createAliasesWithOid(rsaOid + ".15"), attrs); 93 add(p, "Signature", "SHA512/256withRSA", 94 "sun.security.rsa.RSASignature$SHA512_256withRSA", 95 createAliasesWithOid(rsaOid + ".16"), attrs); 96 97 add(p, "KeyFactory", "RSASSA-PSS", 98 "sun.security.rsa.RSAKeyFactory$PSS", 99 rsapssAliases, null); 100 add(p, "KeyPairGenerator", "RSASSA-PSS", 101 "sun.security.rsa.RSAKeyPairGenerator$PSS", 102 rsapssAliases, null); 103 add(p, "Signature", "RSASSA-PSS", 104 "sun.security.rsa.RSAPSSSignature", 105 rsapssAliases, attrs); 106 add(p, "AlgorithmParameters", "RSASSA-PSS", 107 "sun.security.rsa.PSSParameters", 108 rsapssAliases, null); 109 } 110 iterator()111 public Iterator<Provider.Service> iterator() { 112 return services.iterator(); 113 } 114 115 private LinkedHashSet<Provider.Service> services; 116 } 117