author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 50204 | 3195a713e24d |
child 54333 | 2a29e62446bd |
child 56592 | b1902b22005e |
permissions | -rw-r--r-- |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
1 |
/** |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
30791 | 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. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import java.security.Signature; |
|
25 |
import java.security.SignedObject; |
|
26 |
import java.security.KeyPairGenerator; |
|
27 |
import java.security.KeyPair; |
|
28 |
import java.security.NoSuchProviderException; |
|
29 |
import java.security.PrivateKey; |
|
30 |
import java.security.PublicKey; |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
31 |
import java.security.spec.*; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
32 |
import java.util.*; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
33 |
import jdk.test.lib.SigTestUtil; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
34 |
import static jdk.test.lib.SigTestUtil.SignatureType; |
30791 | 35 |
|
36 |
/* |
|
37 |
* @test |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
38 |
* @bug 8050374 8181048 8146293 |
30791 | 39 |
* @summary Verify a chain of signed objects |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
40 |
* @library /test/lib |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
41 |
* @build jdk.test.lib.SigTestUtil |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
42 |
* @run main Chain |
30791 | 43 |
*/ |
44 |
public class Chain { |
|
45 |
||
46 |
static enum KeyAlg { |
|
47 |
RSA("RSA"), |
|
48 |
DSA("DSA"), |
|
49 |
EC("EC"); |
|
50 |
||
51 |
final String name; |
|
52 |
||
53 |
KeyAlg(String alg) { |
|
54 |
this.name = alg; |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
static enum Provider { |
|
59 |
Default("default"), |
|
60 |
SunRsaSign("SunRsaSign"), |
|
61 |
Sun("SUN"), |
|
62 |
SunEC("SunEC"), |
|
63 |
SunJSSE("SunJSSE"), |
|
64 |
SunMSCAPI("SunMSCAPI"); |
|
65 |
||
66 |
final String name; |
|
67 |
||
68 |
Provider(String name) { |
|
69 |
this.name = name; |
|
70 |
} |
|
71 |
} |
|
72 |
||
73 |
static enum SigAlg { |
|
74 |
MD2withRSA("MD2withRSA"), |
|
75 |
MD5withRSA("md5withRSA"), |
|
76 |
||
77 |
SHA1withDSA("SHA1withDSA"), |
|
78 |
SHA224withDSA("SHA224withDSA"), |
|
79 |
SHA256withDSA("SHA256withDSA"), |
|
80 |
||
81 |
SHA1withRSA("Sha1withrSA"), |
|
82 |
SHA224withRSA("SHA224withRSA"), |
|
83 |
SHA256withRSA("SHA256withRSA"), |
|
84 |
SHA384withRSA("SHA384withRSA"), |
|
85 |
SHA512withRSA("SHA512withRSA"), |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
86 |
SHA512_224withRSA("SHA512/224withRSA"), |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
87 |
SHA512_256withRSA("SHA512/256withRSA"), |
30791 | 88 |
|
89 |
SHA1withECDSA("SHA1withECDSA"), |
|
90 |
SHA256withECDSA("SHA256withECDSA"), |
|
91 |
SHA224withECDSA("SHA224withECDSA"), |
|
92 |
SHA384withECDSA("SHA384withECDSA"), |
|
93 |
SHA512withECDSA("SHA512withECDSA"), |
|
94 |
||
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
95 |
MD5andSHA1withRSA("MD5andSHA1withRSA"), |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
96 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
97 |
RSASSA_PSS("RSASSA-PSS"); |
30791 | 98 |
|
99 |
final String name; |
|
100 |
||
101 |
SigAlg(String name) { |
|
102 |
this.name = name; |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
static class Test { |
|
107 |
final Provider provider; |
|
108 |
final KeyAlg keyAlg; |
|
109 |
final SigAlg sigAlg; |
|
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
110 |
final int keySize; |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
111 |
final AlgorithmParameterSpec sigParams; |
30791 | 112 |
|
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
113 |
Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider) { |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
114 |
this(sigAlg, keyAlg, provider, -1, null); |
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
115 |
} |
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
116 |
|
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
117 |
Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider, int keySize) { |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
118 |
this(sigAlg, keyAlg, provider, keySize, null); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
119 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
120 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
121 |
Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider, int keySize, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
122 |
AlgorithmParameterSpec sigParams) { |
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
123 |
this.provider = provider; |
30791 | 124 |
this.keyAlg = keyAlg; |
125 |
this.sigAlg = sigAlg; |
|
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
126 |
this.keySize = keySize; |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
127 |
this.sigParams = sigParams; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
128 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
129 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
130 |
private static String formatParams(AlgorithmParameterSpec aps) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
131 |
if (aps == null) return "null"; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
132 |
if (aps instanceof PSSParameterSpec) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
133 |
PSSParameterSpec p = (PSSParameterSpec) aps; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
134 |
return String.format("PSSParameterSpec (%s, %s, %s, %s)", |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
135 |
p.getDigestAlgorithm(), formatParams(p.getMGFParameters()), |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
136 |
p.getSaltLength(), p.getTrailerField()); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
137 |
} else if (aps instanceof MGF1ParameterSpec) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
138 |
return "MGF1" + |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
139 |
((MGF1ParameterSpec)aps).getDigestAlgorithm(); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
140 |
} else { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
141 |
return aps.toString(); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
142 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
143 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
144 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
145 |
public String toString() { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
146 |
return String.format("Test: provider = %s, signature alg = %s, " |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
147 |
+ " w/ %s, key alg = %s", provider, sigAlg, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
148 |
formatParams(sigParams), keyAlg); |
30791 | 149 |
} |
150 |
} |
|
151 |
||
152 |
private static final Test[] tests = { |
|
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
153 |
new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Default, 1024), |
30791 | 154 |
new Test(SigAlg.MD2withRSA, KeyAlg.RSA, Provider.Default), |
155 |
new Test(SigAlg.MD5withRSA, KeyAlg.RSA, Provider.Default), |
|
156 |
new Test(SigAlg.SHA1withRSA, KeyAlg.RSA, Provider.Default), |
|
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
157 |
new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Sun, 1024), |
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
158 |
new Test(SigAlg.SHA224withDSA, KeyAlg.DSA, Provider.Sun, 2048), |
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
159 |
new Test(SigAlg.SHA256withDSA, KeyAlg.DSA, Provider.Sun, 2048), |
30791 | 160 |
}; |
161 |
||
162 |
private static final String str = "to-be-signed"; |
|
163 |
private static final int N = 3; |
|
164 |
||
165 |
public static void main(String argv[]) { |
|
166 |
boolean result = Arrays.stream(tests).allMatch((test) -> runTest(test)); |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
167 |
result &= runTestPSS(2048); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
168 |
if (result) { |
30791 | 169 |
System.out.println("All tests passed"); |
170 |
} else { |
|
171 |
throw new RuntimeException("Some tests failed"); |
|
172 |
} |
|
173 |
} |
|
174 |
||
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
175 |
private static boolean runTestPSS(int keysize) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
176 |
boolean result = true; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
177 |
SigAlg pss = SigAlg.RSASSA_PSS; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
178 |
Iterator<String> mdAlgs = SigTestUtil.getDigestAlgorithms |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
179 |
(SignatureType.RSASSA_PSS, keysize).iterator(); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
180 |
while (mdAlgs.hasNext()) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
181 |
result &= runTest(new Test(pss, KeyAlg.RSA, Provider.SunRsaSign, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
182 |
keysize, SigTestUtil.generateDefaultParameter |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
183 |
(SignatureType.RSASSA_PSS, mdAlgs.next()))); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
184 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
185 |
return result; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
186 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
187 |
|
30791 | 188 |
static boolean runTest(Test test) { |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
189 |
System.out.println(test); |
30791 | 190 |
try { |
191 |
// Generate all private/public key pairs |
|
192 |
PrivateKey[] privKeys = new PrivateKey[N]; |
|
193 |
PublicKey[] pubKeys = new PublicKey[N]; |
|
194 |
PublicKey[] anotherPubKeys = new PublicKey[N]; |
|
44116
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
195 |
Signature signature; |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
196 |
KeyPairGenerator kpg; |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
197 |
if (test.provider != Provider.Default) { |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
198 |
signature = Signature.getInstance(test.sigAlg.name, |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
199 |
test.provider.name); |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
200 |
kpg = KeyPairGenerator.getInstance( |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
201 |
test.keyAlg.name, test.provider.name); |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
202 |
} else { |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
203 |
signature = Signature.getInstance(test.sigAlg.name); |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
204 |
kpg = KeyPairGenerator.getInstance(test.keyAlg.name); |
fa73683c2c10
8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows
asmotrak
parents:
39502
diff
changeset
|
205 |
} |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
206 |
if (test.sigParams != null) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
207 |
signature.setParameter(test.sigParams); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
208 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47421
diff
changeset
|
209 |
|
30791 | 210 |
for (int j=0; j < N; j++) { |
47421
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
211 |
if (test.keySize != -1) { |
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
212 |
kpg.initialize(test.keySize); |
f9e03aef3a49
8181048: Refactor existing providers to refer to the same constants for default values for key length
valeriep
parents:
47216
diff
changeset
|
213 |
} |
30791 | 214 |
KeyPair kp = kpg.genKeyPair(); |
215 |
KeyPair anotherKp = kpg.genKeyPair(); |
|
216 |
privKeys[j] = kp.getPrivate(); |
|
217 |
pubKeys[j] = kp.getPublic(); |
|
218 |
anotherPubKeys[j] = anotherKp.getPublic(); |
|
219 |
||
220 |
if (Arrays.equals(pubKeys[j].getEncoded(), |
|
221 |
anotherPubKeys[j].getEncoded())) { |
|
222 |
System.out.println("Failed: it should not get " |
|
223 |
+ "the same pair of public key"); |
|
224 |
return false; |
|
225 |
} |
|
226 |
} |
|
227 |
||
228 |
// Create a chain of signed objects |
|
229 |
SignedObject[] objects = new SignedObject[N]; |
|
230 |
objects[0] = new SignedObject(str, privKeys[0], signature); |
|
231 |
for (int j = 1; j < N; j++) { |
|
232 |
objects[j] = new SignedObject(objects[j - 1], privKeys[j], |
|
233 |
signature); |
|
234 |
} |
|
235 |
||
236 |
// Verify the chain |
|
237 |
int n = objects.length - 1; |
|
238 |
SignedObject object = objects[n]; |
|
239 |
do { |
|
240 |
if (!object.verify(pubKeys[n], signature)) { |
|
241 |
System.out.println("Failed: verification failed, n = " + n); |
|
242 |
return false; |
|
243 |
} |
|
244 |
if (object.verify(anotherPubKeys[n], signature)) { |
|
245 |
System.out.println("Failed: verification should not " |
|
246 |
+ "succeed with wrong public key, n = " + n); |
|
247 |
return false; |
|
248 |
} |
|
249 |
||
250 |
object = (SignedObject) object.getObject(); |
|
251 |
n--; |
|
252 |
} while (n > 0); |
|
253 |
||
254 |
System.out.println("signed data: " + object.getObject()); |
|
255 |
if (!str.equals(object.getObject())) { |
|
256 |
System.out.println("Failed: signed data is not equal to " |
|
257 |
+ "original one"); |
|
258 |
return false; |
|
259 |
} |
|
260 |
||
261 |
System.out.println("Test passed"); |
|
262 |
return true; |
|
263 |
} catch (NoSuchProviderException nspe) { |
|
264 |
if (test.provider == Provider.SunMSCAPI |
|
265 |
&& !System.getProperty("os.name").startsWith("Windows")) { |
|
266 |
System.out.println("SunMSCAPI is available only on Windows: " |
|
267 |
+ nspe); |
|
268 |
return true; |
|
269 |
} |
|
270 |
System.out.println("Unexpected exception: " + nspe); |
|
271 |
return false; |
|
272 |
} catch (Exception e) { |
|
273 |
System.out.println("Unexpected exception: " + e); |
|
274 |
e.printStackTrace(System.out); |
|
275 |
return false; |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |