1 /* 2 * Copyright (c) 2003, 2020, 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.util.SecurityProviderConstants.getAliases; 31 32 /** 33 * Defines the entries of the SunRsaSign provider. 34 * 35 * @author Andreas Sterbenz 36 */ 37 public final class SunRsaSignEntries { 38 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, 42 aliases, attrs)); 43 } 44 45 private void addA(Provider p, String type, String algo, String cn, 46 HashMap<String, String> attrs) { 47 services.add(new Provider.Service(p, type, algo, cn, 48 getAliases(algo), attrs)); 49 } 50 51 // extend LinkedHashSet for consistency with SunEntries 52 // used by sun.security.provider.VerificationProvider 53 public SunRsaSignEntries(Provider p) { 54 services = new LinkedHashSet<>(20, 0.9f); 55 56 // start populating content using the specified provider 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 getAliases("PKCS1"), null); 66 add(p, "KeyPairGenerator", "RSA", 67 "sun.security.rsa.RSAKeyPairGenerator$Legacy", 68 getAliases("PKCS1"), null); 69 addA(p, "Signature", "MD2withRSA", 70 "sun.security.rsa.RSASignature$MD2withRSA", attrs); 71 addA(p, "Signature", "MD5withRSA", 72 "sun.security.rsa.RSASignature$MD5withRSA", attrs); 73 addA(p, "Signature", "SHA1withRSA", 74 "sun.security.rsa.RSASignature$SHA1withRSA", attrs); 75 addA(p, "Signature", "SHA224withRSA", 76 "sun.security.rsa.RSASignature$SHA224withRSA", attrs); 77 addA(p, "Signature", "SHA256withRSA", 78 "sun.security.rsa.RSASignature$SHA256withRSA", attrs); 79 addA(p, "Signature", "SHA384withRSA", 80 "sun.security.rsa.RSASignature$SHA384withRSA", attrs); 81 addA(p, "Signature", "SHA512withRSA", 82 "sun.security.rsa.RSASignature$SHA512withRSA", attrs); 83 addA(p, "Signature", "SHA512/224withRSA", 84 "sun.security.rsa.RSASignature$SHA512_224withRSA", attrs); 85 addA(p, "Signature", "SHA512/256withRSA", 86 "sun.security.rsa.RSASignature$SHA512_256withRSA", attrs); 87 88 addA(p, "KeyFactory", "RSASSA-PSS", 89 "sun.security.rsa.RSAKeyFactory$PSS", attrs); 90 addA(p, "KeyPairGenerator", "RSASSA-PSS", 91 "sun.security.rsa.RSAKeyPairGenerator$PSS", attrs); 92 addA(p, "Signature", "RSASSA-PSS", 93 "sun.security.rsa.RSAPSSSignature", attrs); 94 addA(p, "AlgorithmParameters", "RSASSA-PSS", 95 "sun.security.rsa.PSSParameters", attrs); 96 } 97 98 public Iterator<Provider.Service> iterator() { 99 return services.iterator(); 100 } 101 102 private LinkedHashSet<Provider.Service> services; 103 }