src/java.base/share/classes/sun/security/rsa/SunRsaSignEntries.java
changeset 52995 9af672cab7cb
parent 50204 3195a713e24d
equal deleted inserted replaced
52994:d590cf6b4fac 52995:9af672cab7cb
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package sun.security.rsa;
    26 package sun.security.rsa;
    27 
    27 
    28 import java.util.Map;
    28 import java.util.*;
       
    29 import java.security.Provider;
       
    30 import static sun.security.provider.SunEntries.createAliasesWithOid;
    29 
    31 
    30 /**
    32 /**
    31  * Defines the entries of the SunRsaSign provider.
    33  * Defines the entries of the SunRsaSign provider.
    32  *
    34  *
    33  * @author  Andreas Sterbenz
    35  * @author  Andreas Sterbenz
    34  */
    36  */
    35 public final class SunRsaSignEntries {
    37 public final class SunRsaSignEntries {
    36 
    38 
    37     private SunRsaSignEntries() {
    39     private void add(Provider p, String type, String algo, String cn,
    38         // empty
    40              List<String> aliases, HashMap<String, String> attrs) {
       
    41          services.add(new Provider.Service(p, type, algo, cn, aliases, attrs));
    39     }
    42     }
    40 
    43 
    41     public static void putEntries(Map<Object, Object> map) {
    44     // extend LinkedHashSet for consistency with SunEntries
       
    45     // used by sun.security.provider.VerificationProvider
       
    46     public SunRsaSignEntries(Provider p) {
       
    47         services = new LinkedHashSet<>(20, 0.9f);
    42 
    48 
    43         // main algorithms
    49         // start populating content using the specified provider
    44         map.put("KeyFactory.RSA",
       
    45                 "sun.security.rsa.RSAKeyFactory$Legacy");
       
    46         map.put("KeyPairGenerator.RSA",
       
    47                 "sun.security.rsa.RSAKeyPairGenerator$Legacy");
       
    48         map.put("Signature.MD2withRSA",
       
    49                 "sun.security.rsa.RSASignature$MD2withRSA");
       
    50         map.put("Signature.MD5withRSA",
       
    51                 "sun.security.rsa.RSASignature$MD5withRSA");
       
    52         map.put("Signature.SHA1withRSA",
       
    53                 "sun.security.rsa.RSASignature$SHA1withRSA");
       
    54         map.put("Signature.SHA224withRSA",
       
    55                 "sun.security.rsa.RSASignature$SHA224withRSA");
       
    56         map.put("Signature.SHA256withRSA",
       
    57                 "sun.security.rsa.RSASignature$SHA256withRSA");
       
    58         map.put("Signature.SHA384withRSA",
       
    59                 "sun.security.rsa.RSASignature$SHA384withRSA");
       
    60         map.put("Signature.SHA512withRSA",
       
    61                 "sun.security.rsa.RSASignature$SHA512withRSA");
       
    62         map.put("Signature.SHA512/224withRSA",
       
    63                 "sun.security.rsa.RSASignature$SHA512_224withRSA");
       
    64         map.put("Signature.SHA512/256withRSA",
       
    65                 "sun.security.rsa.RSASignature$SHA512_256withRSA");
       
    66 
    50 
    67         map.put("KeyFactory.RSASSA-PSS",
    51         // common oids
    68                 "sun.security.rsa.RSAKeyFactory$PSS");
    52         String rsaOid = "1.2.840.113549.1.1";
    69         map.put("KeyPairGenerator.RSASSA-PSS",
    53         List<String> rsaAliases = createAliasesWithOid(rsaOid);
    70                 "sun.security.rsa.RSAKeyPairGenerator$PSS");
    54         List<String> rsapssAliases = createAliasesWithOid(rsaOid + ".10");
    71         map.put("Signature.RSASSA-PSS",
    55         String sha1withRSAOid2 = "1.3.14.3.2.29";
    72                 "sun.security.rsa.RSAPSSSignature");
       
    73         map.put("AlgorithmParameters.RSASSA-PSS",
       
    74                 "sun.security.rsa.PSSParameters");
       
    75 
    56 
    76         // attributes for supported key classes
    57         // common attribute map
    77         String rsaKeyClasses = "java.security.interfaces.RSAPublicKey" +
    58         HashMap<String, String> attrs = new HashMap<>(3);
    78                 "|java.security.interfaces.RSAPrivateKey";
    59         attrs.put("SupportedKeyClasses",
    79         map.put("Signature.MD2withRSA SupportedKeyClasses", rsaKeyClasses);
    60                 "java.security.interfaces.RSAPublicKey" +
    80         map.put("Signature.MD5withRSA SupportedKeyClasses", rsaKeyClasses);
    61                 "|java.security.interfaces.RSAPrivateKey");
    81         map.put("Signature.SHA1withRSA SupportedKeyClasses", rsaKeyClasses);
       
    82         map.put("Signature.SHA224withRSA SupportedKeyClasses", rsaKeyClasses);
       
    83         map.put("Signature.SHA256withRSA SupportedKeyClasses", rsaKeyClasses);
       
    84         map.put("Signature.SHA384withRSA SupportedKeyClasses", rsaKeyClasses);
       
    85         map.put("Signature.SHA512withRSA SupportedKeyClasses", rsaKeyClasses);
       
    86         map.put("Signature.SHA512/224withRSA SupportedKeyClasses", rsaKeyClasses);
       
    87         map.put("Signature.SHA512/256withRSA SupportedKeyClasses", rsaKeyClasses);
       
    88         map.put("Signature.RSASSA-PSS SupportedKeyClasses", rsaKeyClasses);
       
    89 
    62 
    90         // aliases
    63         add(p, "KeyFactory", "RSA",
    91         map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1",     "RSA");
    64                 "sun.security.rsa.RSAKeyFactory$Legacy",
    92         map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1", "RSA");
    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);
    93 
    96 
    94         map.put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1",     "RSA");
    97         add(p, "KeyFactory", "RSASSA-PSS",
    95         map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1", "RSA");
    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     }
    96 
   110 
    97         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.2",     "MD2withRSA");
   111     public Iterator<Provider.Service> iterator() {
    98         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.2", "MD2withRSA");
   112         return services.iterator();
       
   113     }
    99 
   114 
   100         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.4",     "MD5withRSA");
   115     private LinkedHashSet<Provider.Service> services;
   101         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.4", "MD5withRSA");
       
   102 
       
   103         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.5",     "SHA1withRSA");
       
   104         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5", "SHA1withRSA");
       
   105         map.put("Alg.Alias.Signature.1.3.14.3.2.29",            "SHA1withRSA");
       
   106 
       
   107         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.14",     "SHA224withRSA");
       
   108         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.14", "SHA224withRSA");
       
   109 
       
   110         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11",     "SHA256withRSA");
       
   111         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
       
   112 
       
   113         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12",     "SHA384withRSA");
       
   114         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA");
       
   115 
       
   116         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13",     "SHA512withRSA");
       
   117         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA");
       
   118         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.15",     "SHA512/224withRSA");
       
   119         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.15", "SHA512/224withRSA");
       
   120         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.16",     "SHA512/256withRSA");
       
   121         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.16", "SHA512/256withRSA");
       
   122 
       
   123         map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.10",     "RSASSA-PSS");
       
   124         map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
       
   125 
       
   126         map.put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.10",     "RSASSA-PSS");
       
   127         map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
       
   128 
       
   129         map.put("Alg.Alias.Signature.1.2.840.113549.1.1.10",     "RSASSA-PSS");
       
   130         map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
       
   131 
       
   132         map.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.1.10",     "RSASSA-PSS");
       
   133         map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
       
   134     }
       
   135 }
   116 }