author | kvn |
Thu, 16 Apr 2015 14:01:18 -0700 | |
changeset 30083 | 385348cd698e |
parent 25859 | 3317bb8137f4 |
child 31270 | e6470b24700d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22121
b1aa108cccb5
8030823: Security Providers need to have their version numbers updated for JDK9
ascarpino
parents:
20485
diff
changeset
|
2 |
* Copyright (c) 2005, 2014, 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.mscapi; |
|
27 |
||
28 |
import java.security.AccessController; |
|
29 |
import java.security.PrivilegedAction; |
|
30 |
import java.security.Provider; |
|
31 |
import java.util.HashMap; |
|
32 |
import java.util.Map; |
|
33 |
||
34 |
/** |
|
35 |
* A Cryptographic Service Provider for the Microsoft Crypto API. |
|
36 |
* |
|
37 |
* @since 1.6 |
|
38 |
*/ |
|
39 |
||
40 |
public final class SunMSCAPI extends Provider { |
|
41 |
||
42 |
private static final long serialVersionUID = 8622598936488630849L; //TODO |
|
43 |
||
44 |
private static final String INFO = "Sun's Microsoft Crypto API provider"; |
|
45 |
||
46 |
static { |
|
51 | 47 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
48 |
public Void run() { |
|
2 | 49 |
System.loadLibrary("sunmscapi"); |
50 |
return null; |
|
51 |
} |
|
52 |
}); |
|
53 |
} |
|
54 |
||
55 |
public SunMSCAPI() { |
|
22121
b1aa108cccb5
8030823: Security Providers need to have their version numbers updated for JDK9
ascarpino
parents:
20485
diff
changeset
|
56 |
super("SunMSCAPI", 1.9d, INFO); |
2 | 57 |
|
58 |
// if there is no security manager installed, put directly into |
|
59 |
// the provider. Otherwise, create a temporary map and use a |
|
60 |
// doPrivileged() call at the end to transfer the contents |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9533
diff
changeset
|
61 |
final Map<Object, Object> map = |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9533
diff
changeset
|
62 |
(System.getSecurityManager() == null) |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9533
diff
changeset
|
63 |
? this : new HashMap<Object, Object>(); |
2 | 64 |
|
65 |
/* |
|
66 |
* Secure random |
|
67 |
*/ |
|
68 |
map.put("SecureRandom.Windows-PRNG", "sun.security.mscapi.PRNG"); |
|
69 |
||
70 |
/* |
|
71 |
* Key store |
|
72 |
*/ |
|
73 |
map.put("KeyStore.Windows-MY", "sun.security.mscapi.KeyStore$MY"); |
|
74 |
map.put("KeyStore.Windows-ROOT", "sun.security.mscapi.KeyStore$ROOT"); |
|
75 |
||
76 |
/* |
|
77 |
* Signature engines |
|
78 |
*/ |
|
9533
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
79 |
// NONEwithRSA must be supplied with a pre-computed message digest. |
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
80 |
// Only the following digest algorithms are supported: MD5, SHA-1, |
12700
9c9ad46c7c40
7169496: Problem with the SHA-224 support for SunMSCAPI provider
valeriep
parents:
12685
diff
changeset
|
81 |
// SHA-256, SHA-384, SHA-512 and a special-purpose digest |
12685 | 82 |
// algorithm which is a concatenation of SHA-1 and MD5 digests. |
9533
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
83 |
map.put("Signature.NONEwithRSA", |
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
84 |
"sun.security.mscapi.RSASignature$Raw"); |
2 | 85 |
map.put("Signature.SHA1withRSA", |
86 |
"sun.security.mscapi.RSASignature$SHA1"); |
|
9524 | 87 |
map.put("Signature.SHA256withRSA", |
88 |
"sun.security.mscapi.RSASignature$SHA256"); |
|
12685 | 89 |
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA"); |
90 |
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA"); |
|
9524 | 91 |
map.put("Signature.SHA384withRSA", |
92 |
"sun.security.mscapi.RSASignature$SHA384"); |
|
12685 | 93 |
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384withRSA"); |
94 |
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA"); |
|
95 |
||
9524 | 96 |
map.put("Signature.SHA512withRSA", |
97 |
"sun.security.mscapi.RSASignature$SHA512"); |
|
12685 | 98 |
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA"); |
99 |
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA"); |
|
100 |
||
2 | 101 |
map.put("Signature.MD5withRSA", |
102 |
"sun.security.mscapi.RSASignature$MD5"); |
|
103 |
map.put("Signature.MD2withRSA", |
|
104 |
"sun.security.mscapi.RSASignature$MD2"); |
|
105 |
||
106 |
// supported key classes |
|
9533
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
107 |
map.put("Signature.NONEwithRSA SupportedKeyClasses", |
13cc5e8eb9f1
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
9524
diff
changeset
|
108 |
"sun.security.mscapi.Key"); |
2 | 109 |
map.put("Signature.SHA1withRSA SupportedKeyClasses", |
110 |
"sun.security.mscapi.Key"); |
|
9524 | 111 |
map.put("Signature.SHA256withRSA SupportedKeyClasses", |
112 |
"sun.security.mscapi.Key"); |
|
113 |
map.put("Signature.SHA384withRSA SupportedKeyClasses", |
|
114 |
"sun.security.mscapi.Key"); |
|
115 |
map.put("Signature.SHA512withRSA SupportedKeyClasses", |
|
116 |
"sun.security.mscapi.Key"); |
|
2 | 117 |
map.put("Signature.MD5withRSA SupportedKeyClasses", |
118 |
"sun.security.mscapi.Key"); |
|
119 |
map.put("Signature.MD2withRSA SupportedKeyClasses", |
|
120 |
"sun.security.mscapi.Key"); |
|
121 |
||
122 |
/* |
|
123 |
* Key Pair Generator engines |
|
124 |
*/ |
|
125 |
map.put("KeyPairGenerator.RSA", |
|
126 |
"sun.security.mscapi.RSAKeyPairGenerator"); |
|
127 |
map.put("KeyPairGenerator.RSA KeySize", "1024"); |
|
128 |
||
129 |
/* |
|
130 |
* Cipher engines |
|
131 |
*/ |
|
132 |
map.put("Cipher.RSA", "sun.security.mscapi.RSACipher"); |
|
133 |
map.put("Cipher.RSA/ECB/PKCS1Padding", |
|
134 |
"sun.security.mscapi.RSACipher"); |
|
135 |
map.put("Cipher.RSA SupportedModes", "ECB"); |
|
136 |
map.put("Cipher.RSA SupportedPaddings", "PKCS1PADDING"); |
|
137 |
map.put("Cipher.RSA SupportedKeyClasses", "sun.security.mscapi.Key"); |
|
138 |
||
139 |
if (map != this) { |
|
23582
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
140 |
final Provider provider = this; |
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
141 |
PrivilegedAction<Void> putAllAction = () -> { |
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
142 |
provider.putAll(map); |
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
143 |
return null; |
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
144 |
}; |
d5fa3327ab3a
8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents:
22121
diff
changeset
|
145 |
AccessController.doPrivileged(putAllAction); |
2 | 146 |
} |
147 |
} |
|
148 |
} |