author | valeriep |
Thu, 13 Dec 2018 01:15:21 +0000 | |
changeset 52995 | 9af672cab7cb |
parent 50204 | 3195a713e24d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.rsa; |
|
27 |
||
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
28 |
import java.util.*; |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
29 |
import java.security.Provider; |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
30 |
import static sun.security.provider.SunEntries.createAliasesWithOid; |
2 | 31 |
|
32 |
/** |
|
33 |
* Defines the entries of the SunRsaSign provider. |
|
34 |
* |
|
35 |
* @author Andreas Sterbenz |
|
36 |
*/ |
|
37 |
public final class SunRsaSignEntries { |
|
38 |
||
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
39 |
private void add(Provider p, String type, String algo, String cn, |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
40 |
List<String> aliases, HashMap<String, String> attrs) { |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
41 |
services.add(new Provider.Service(p, type, algo, cn, aliases, attrs)); |
2 | 42 |
} |
43 |
||
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
44 |
// extend LinkedHashSet for consistency with SunEntries |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
45 |
// used by sun.security.provider.VerificationProvider |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
46 |
public SunRsaSignEntries(Provider p) { |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
47 |
services = new LinkedHashSet<>(20, 0.9f); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
48 |
|
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
49 |
// start populating content using the specified provider |
2 | 50 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
51 |
// common oids |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
52 |
String rsaOid = "1.2.840.113549.1.1"; |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
53 |
List<String> rsaAliases = createAliasesWithOid(rsaOid); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
54 |
List<String> rsapssAliases = createAliasesWithOid(rsaOid + ".10"); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
55 |
String sha1withRSAOid2 = "1.3.14.3.2.29"; |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
56 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
57 |
// common attribute map |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
58 |
HashMap<String, String> attrs = new HashMap<>(3); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
59 |
attrs.put("SupportedKeyClasses", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
60 |
"java.security.interfaces.RSAPublicKey" + |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
61 |
"|java.security.interfaces.RSAPrivateKey"); |
2 | 62 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
63 |
add(p, "KeyFactory", "RSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
64 |
"sun.security.rsa.RSAKeyFactory$Legacy", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
65 |
rsaAliases, null); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
66 |
add(p, "KeyPairGenerator", "RSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
67 |
"sun.security.rsa.RSAKeyPairGenerator$Legacy", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
68 |
rsaAliases, null); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
69 |
add(p, "Signature", "MD2withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
70 |
"sun.security.rsa.RSASignature$MD2withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
71 |
createAliasesWithOid(rsaOid + ".2"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
72 |
add(p, "Signature", "MD5withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
73 |
"sun.security.rsa.RSASignature$MD5withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
74 |
createAliasesWithOid(rsaOid + ".4"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
75 |
add(p, "Signature", "SHA1withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
76 |
"sun.security.rsa.RSASignature$SHA1withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
77 |
createAliasesWithOid(rsaOid + ".5", sha1withRSAOid2), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
78 |
add(p, "Signature", "SHA224withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
79 |
"sun.security.rsa.RSASignature$SHA224withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
80 |
createAliasesWithOid(rsaOid + ".14"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
81 |
add(p, "Signature", "SHA256withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
82 |
"sun.security.rsa.RSASignature$SHA256withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
83 |
createAliasesWithOid(rsaOid + ".11"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
84 |
add(p, "Signature", "SHA384withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
85 |
"sun.security.rsa.RSASignature$SHA384withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
86 |
createAliasesWithOid(rsaOid + ".12"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
87 |
add(p, "Signature", "SHA512withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
88 |
"sun.security.rsa.RSASignature$SHA512withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
89 |
createAliasesWithOid(rsaOid + ".13"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
90 |
add(p, "Signature", "SHA512/224withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
91 |
"sun.security.rsa.RSASignature$SHA512_224withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
92 |
createAliasesWithOid(rsaOid + ".15"), attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
93 |
add(p, "Signature", "SHA512/256withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
94 |
"sun.security.rsa.RSASignature$SHA512_256withRSA", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
95 |
createAliasesWithOid(rsaOid + ".16"), attrs); |
2 | 96 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
97 |
add(p, "KeyFactory", "RSASSA-PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
98 |
"sun.security.rsa.RSAKeyFactory$PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
99 |
rsapssAliases, null); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
100 |
add(p, "KeyPairGenerator", "RSASSA-PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
101 |
"sun.security.rsa.RSAKeyPairGenerator$PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
102 |
rsapssAliases, null); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
103 |
add(p, "Signature", "RSASSA-PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
104 |
"sun.security.rsa.RSAPSSSignature", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
105 |
rsapssAliases, attrs); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
106 |
add(p, "AlgorithmParameters", "RSASSA-PSS", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
107 |
"sun.security.rsa.PSSParameters", |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
108 |
rsapssAliases, null); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
109 |
} |
2 | 110 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
111 |
public Iterator<Provider.Service> iterator() { |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
112 |
return services.iterator(); |
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
113 |
} |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
114 |
|
52995
9af672cab7cb
7092821: java.security.Provider.getService() is synchronized and became scalability bottleneck
valeriep
parents:
50204
diff
changeset
|
115 |
private LinkedHashSet<Provider.Service> services; |
2 | 116 |
} |