• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 /*
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.android.org.conscrypt.java.security;
19 
20 import static org.junit.Assert.assertArrayEquals;
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
26 
27 import com.android.org.conscrypt.Conscrypt;
28 import com.android.org.conscrypt.TestUtils;
29 import com.android.org.conscrypt.testing.BrokenProvider;
30 import com.android.org.conscrypt.testing.OpaqueProvider;
31 import java.math.BigInteger;
32 import java.nio.ByteBuffer;
33 import java.nio.charset.Charset;
34 import java.security.AlgorithmParameters;
35 import java.security.InvalidKeyException;
36 import java.security.KeyFactory;
37 import java.security.KeyPair;
38 import java.security.KeyPairGenerator;
39 import java.security.MessageDigest;
40 import java.security.PrivateKey;
41 import java.security.Provider;
42 import java.security.ProviderException;
43 import java.security.PublicKey;
44 import java.security.Security;
45 import java.security.Signature;
46 import java.security.SignatureException;
47 import java.security.spec.AlgorithmParameterSpec;
48 import java.security.spec.DSAPrivateKeySpec;
49 import java.security.spec.DSAPublicKeySpec;
50 import java.security.spec.ECFieldFp;
51 import java.security.spec.ECParameterSpec;
52 import java.security.spec.ECPoint;
53 import java.security.spec.ECPublicKeySpec;
54 import java.security.spec.EllipticCurve;
55 import java.security.spec.InvalidKeySpecException;
56 import java.security.spec.InvalidParameterSpecException;
57 import java.security.spec.MGF1ParameterSpec;
58 import java.security.spec.PSSParameterSpec;
59 import java.security.spec.RSAPrivateCrtKeySpec;
60 import java.security.spec.RSAPrivateKeySpec;
61 import java.security.spec.RSAPublicKeySpec;
62 import java.security.spec.X509EncodedKeySpec;
63 import java.util.ArrayList;
64 import java.util.Arrays;
65 import java.util.HashMap;
66 import java.util.List;
67 import java.util.Locale;
68 import java.util.Map;
69 import java.util.concurrent.Callable;
70 import java.util.concurrent.CountDownLatch;
71 import java.util.concurrent.ExecutionException;
72 import java.util.concurrent.ExecutorService;
73 import java.util.concurrent.Executors;
74 import java.util.concurrent.Future;
75 import java.util.concurrent.TimeUnit;
76 import libcore.junit.util.EnableDeprecatedBouncyCastleAlgorithmsRule;
77 import org.junit.ClassRule;
78 import org.junit.Test;
79 import org.junit.rules.TestRule;
80 import org.junit.runner.RunWith;
81 import org.junit.runners.JUnit4;
82 import tests.util.ServiceTester;
83 
84 /**
85  * @hide This class is not part of the Android public SDK API
86  */
87 @RunWith(JUnit4.class)
88 public class SignatureTest {
89 
90     // BEGIN Android-Added: Allow access to deprecated BC algorithms.
91     // Allow access to deprecated BC algorithms in this test, so we can ensure they
92     // continue to work
93     @ClassRule
94     public static TestRule enableDeprecatedBCAlgorithmsRule =
95             EnableDeprecatedBouncyCastleAlgorithmsRule.getInstance();
96     // END Android-Added: Allow access to deprecated BC algorithms.
97 
98     // 20 bytes for DSA
99     private final byte[] EMPTY_DATA = new byte[20];
100 
101     @Test
test_getInstance()102     public void test_getInstance() throws Exception {
103         ServiceTester
104                 .test("Signature")
105                 // Do not test AndroidKeyStore's Signature. It needs an AndroidKeyStore-specific
106                 // key. It's OKish not to test AndroidKeyStore's Signature here because it's tested
107                 // by cts/tests/test/keystore.
108                 .skipProvider("AndroidKeyStore")
109                 .skipProvider("AndroidKeyStoreBCWorkaround")
110                 // The SunMSCAPI is very strange, including only supporting its own keys,
111                 // so don't test it.
112                 .skipProvider("SunMSCAPI")
113                 // SunPKCS11-NSS has a problem where failed verifications can leave the
114                 // operation open, which results in future init() calls to throw an exception.
115                 // This appears to be a problem in the underlying library (see
116                 // https://bugs.openjdk.java.net/browse/JDK-8044554), but skip verifying it all
117                 // the same.
118                 .skipProvider("SunPKCS11-NSS")
119                 // We don't have code to generate key pairs for these yet.
120                 .skipAlgorithm("Ed448")
121                 .skipAlgorithm("Ed25519")
122                 .skipAlgorithm("EdDSA")
123                 .run(new ServiceTester.Test() {
124                     @Override
125                     public void test(Provider provider, String algorithm) throws Exception {
126                         KeyPair kp = keyPair(algorithm);
127                         // Signature.getInstance(String)
128                         Signature sig1 = Signature.getInstance(algorithm);
129                         assertEquals(algorithm, sig1.getAlgorithm());
130                         test_Signature(sig1, kp);
131 
132                         // Signature.getInstance(String, Provider)
133                         Signature sig2 = Signature.getInstance(algorithm, provider);
134                         assertEquals(algorithm, sig2.getAlgorithm());
135                         assertEquals(provider, sig2.getProvider());
136                         test_Signature(sig2, kp);
137 
138                         // Signature.getInstance(String, String)
139                         Signature sig3 = Signature.getInstance(algorithm, provider.getName());
140                         assertEquals(algorithm, sig3.getAlgorithm());
141                         assertEquals(provider, sig3.getProvider());
142                         test_Signature(sig3, kp);
143                     }
144                 });
145     }
146 
147     private final Map<String, KeyPair> keypairAlgorithmToInstance
148             = new HashMap<String, KeyPair>();
149 
keyPair(String sigAlgorithm)150     private KeyPair keyPair(String sigAlgorithm) throws Exception {
151         String sigAlgorithmUpperCase = sigAlgorithm.toUpperCase(Locale.US);
152         if (sigAlgorithmUpperCase.endsWith("ENCRYPTION")) {
153             sigAlgorithm = sigAlgorithm.substring(0, sigAlgorithm.length()-"ENCRYPTION".length());
154             sigAlgorithmUpperCase = sigAlgorithm.toUpperCase(Locale.US);
155         }
156 
157         String kpAlgorithm;
158         // note ECDSA must be before DSA
159         if (sigAlgorithmUpperCase.endsWith("ECDSA")
160             || sigAlgorithmUpperCase.endsWith("ECDSAINP1363FORMAT")) {
161             kpAlgorithm = "EC";
162         } else if (sigAlgorithmUpperCase.endsWith("DSA")
163                 || sigAlgorithmUpperCase.endsWith("DSAINP1363FORMAT")) {
164             kpAlgorithm = "DSA";
165         } else if (sigAlgorithmUpperCase.endsWith("RSA")
166                 || sigAlgorithmUpperCase.endsWith("RSA/PSS")
167                 || sigAlgorithmUpperCase.endsWith("RSASSA-PSS")) {
168             kpAlgorithm = "RSA";
169         } else {
170             throw new Exception("Unknown KeyPair algorithm for Signature algorithm "
171                                 + sigAlgorithm);
172         }
173 
174         KeyPair kp = keypairAlgorithmToInstance.get(kpAlgorithm);
175         if (kp == null) {
176             KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpAlgorithm);
177             if (kpAlgorithm.equals("DSA")) {
178                 kpg.initialize(1024);
179             }
180             kp = kpg.generateKeyPair();
181             keypairAlgorithmToInstance.put(kpAlgorithm, kp);
182         }
183         return kp;
184     }
185 
getAlgParamSpec(String algorithm)186     private AlgorithmParameterSpec getAlgParamSpec(String algorithm) {
187         if (algorithm.equalsIgnoreCase("RSASSA-PSS")) {
188             return PSSParameterSpec.DEFAULT;
189         }
190         return null;
191     }
192 
test_Signature(Signature sig, KeyPair keyPair)193     private void test_Signature(Signature sig, KeyPair keyPair) throws Exception {
194         AlgorithmParameterSpec params = getAlgParamSpec(sig.getAlgorithm());
195         sig.initSign(keyPair.getPrivate());
196         if (params != null) {
197             sig.setParameter(params);
198         }
199         sig.update(EMPTY_DATA);
200         byte[] signature = sig.sign();
201         assertNotNull(sig.getAlgorithm(), signature);
202         assertTrue(sig.getAlgorithm(), signature.length > 0);
203 
204         sig.initVerify(keyPair.getPublic());
205         if (params != null) {
206             sig.setParameter(params);
207         }
208         sig.update(EMPTY_DATA);
209         assertTrue(sig.getAlgorithm(), sig.verify(signature));
210 
211         // After verify, should be reusable as if we are after initVerify
212         sig.update(EMPTY_DATA);
213         assertTrue(sig.getAlgorithm(), sig.verify(signature));
214 
215         /*
216          * The RI appears to clear out the input data in RawDSA while calling
217          * verify a second time.
218          */
219         if (StandardNames.IS_RI && (
220                 "NONEwithDSA".equalsIgnoreCase(sig.getAlgorithm())
221                 || "NONEwithDSAinP1363Format".equalsIgnoreCase(sig.getAlgorithm())
222                 || "RawDSA".equalsIgnoreCase(sig.getAlgorithm()))) {
223             try {
224                 sig.verify(signature);
225                 fail("Expected RI to have a NONEwithDSA bug");
226             } catch (SignatureException bug) {
227             }
228         } else if (StandardNames.IS_RI
229                 && "NONEwithECDSA".equalsIgnoreCase(sig.getAlgorithm())
230                 && "SunPKCS11-NSS".equalsIgnoreCase(sig.getProvider().getName())) {
231             // This provider doesn't work properly
232             try {
233                 sig.verify(signature);
234                 fail("Expected RI to have a NONEwithECDSA bug");
235             } catch (ProviderException bug) {
236             }
237         } else {
238             // Calling Signature.verify a second time should not throw
239             // http://code.google.com/p/android/issues/detail?id=34933
240             sig.verify(signature);
241         }
242 
243         if (Conscrypt.isConscrypt(sig.getProvider())) {
244             testSignature_MultipleThreads_Misuse(sig, keyPair.getPrivate());
245         }
246     }
247 
248     private static final byte[] PK_BYTES = TestUtils.decodeHex(
249             "30819f300d06092a864886f70d010101050003818d0030818902818100cd769d178f61475fce3001"
250             + "2604218320c77a427121d3b41dd76756c8fc0c428cd15cb754adc85466f47547b1c85623d9c17fc6"
251             + "4f202fca21099caf99460c824ad657caa8c2db34996838d32623c4f23c8b6a4e6698603901262619"
252             + "4840e0896b1a6ec4f6652484aad04569bb6a885b822a10d700224359c632dc7324520cbb3d020301"
253             + "0001");
254     private static final byte[] CONTENT = TestUtils.decodeHex(
255             "f2fa9d73656e00fa01edc12e73656e2e7670632e6432004867268c46dd95030b93ce7260423e5c00"
256             + "fabd4d656d6265727300fa018dc12e73656e2e7670632e643100d7c258dc00fabd44657669636573"
257             + "00faa54b65797300fa02b5c12e4d2e4b009471968cc68835f8a68dde10f53d19693d480de767e5fb"
258             + "976f3562324006372300fabdfd04e1f51ef3aa00fa8d00000001a203e202859471968cc68835f8a6"
259             + "8dde10f53d19693d480de767e5fb976f356232400637230002bab504e1f51ef5810002c29d28463f"
260             + "0003da8d000001e201eaf2fa9d73656e00fa01edc12e73656e2e7670632e6432004867268c46dd95"
261             + "030b93ce7260423e5c00fabd4d656d6265727300fa018dc12e73656e2e7670632e643100d7c258dc"
262             + "00fabd4465766963657300faa54b65797300fa02b5c12e4d2e4b009471968cc68835f8a68dde10f5"
263             + "3d19693d480de767e5fb976f3562324006372300fabdfd04e1f51ef3aa000003e202859471968cc6"
264             + "8835f8a68dde10f53d19693d480de767e5fb976f3562324006372300000000019a0a9530819f300d"
265             + "06092a864886f70d010101050003818d0030818902818100cd769d178f61475fce30012604218320"
266             + "c77a427121d3b41dd76756c8fc0c428cd15cb754adc85466f47547b1c85623d9c17fc64f202fca21"
267             + "099caf99460c824ad657caa8c2db34996838d32623c4f23c8b6a4e66986039012626194840e0896b"
268             + "1a6ec4f6652484aad04569bb6a885b822a10d700224359c632dc7324520cbb3d020301000100");
269     private static final byte[] SIGNATURE = TestUtils.decodeHex(
270             "b4016456148cd2e9f580470aad63d19c1fee52b38c9dcb5b4d61a7ca369a7277497775d106d86394"
271             + "a69229184333b5a3e6261d5bcebdb02530ca9909f4d790199eae7c140f7db39dee2232191bdf0bfb"
272             + "34fdadc44326b9b3f3fa828652bab07f0362ac141c8c3784ebdec44e0b156a5e7bccdc81a56fe954"
273             + "56ac8c0e4ae12d97");
274 
275 
276     /**
277      * This should actually fail because the ASN.1 encoding is incorrect. It is
278      * missing the NULL in the AlgorithmIdentifier field.
279      * <p>
280      * http://code.google.com/p/android/issues/detail?id=18566 <br/>
281      * http://b/5038554
282      */
283     @Test
test18566_AlgorithmOid_MissingNull_Failure()284     public void test18566_AlgorithmOid_MissingNull_Failure() throws Exception {
285         X509EncodedKeySpec keySpec = new X509EncodedKeySpec(PK_BYTES);
286         KeyFactory keyFactory = KeyFactory.getInstance("RSA");
287         PublicKey pk = keyFactory.generatePublic(keySpec);
288 
289         Signature sig = Signature.getInstance("SHA256withRSA");
290         sig.initVerify(pk);
291         sig.update(CONTENT);
292         assertFalse(sig.verify(SIGNATURE));
293     }
294 
295     /*
296      * Test vectors generated with this private key:
297      *
298      * -----BEGIN RSA PRIVATE KEY-----
299      * MIIEpAIBAAKCAQEA4Ec+irjyKE/rnnQv+XSPoRjtmGM8kvUq63ouvg075gMpvnZq
300      * 0Q62pRXQ0s/ZvqeTDwwwZTeJn3lYzT6FsB+IGFJNMSWEqUslHjYltUFB7b/uGYgI
301      * 4buX/Hy0m56qr2jpyY19DtxTu8D6ADQ1bWMF+7zDxwAUBThqu8hzyw8+90JfPTPf
302      * ezFa4DbSoLZq/UdQOxab8247UWJRW3Ff2oPeryxYrrmr+zCXw8yd2dvl7ylsF2E5
303      * Ao6KZx5jBW1F9AGI0sQTNJCEXeUsJTTpxrJHjAe9rpKII7YtBmx3cPn2Pz26JH9T
304      * CER0e+eqqF2FO4vSRKzsPePImrRkU6tNJMOsaQIDAQABAoIBADd4R3al8XaY9ayW
305      * DfuDobZ1ZOZIvQWXz4q4CHGG8macJ6nsvdSA8Bl6gNBzCebGqW+SUzHlf4tKxvTU
306      * XtpFojJpwJ/EKMB6Tm7fc4oV3sl/q9Lyu0ehTyDqcvz+TDbgGtp3vRN82NTaELsW
307      * LpSkZilx8XX5hfoYjwVsuX7igW9Dq503R2Ekhs2owWGWwwgYqZXshdOEZ3kSZ7O/
308      * IfJzcQppJYYldoQcW2cSwS1L0govMpmtt8E12l6VFavadufK8qO+gFUdBzt4vxFi
309      * xIrSt/R0OgI47k0lL31efmUzzK5kzLOTYAdaL9HgNOw65c6cQIzL8OJeQRQCFoez
310      * 3UdUroECgYEA9UGIS8Nzeyki1BGe9F4t7izUy7dfRVBaFXqlAJ+Zxzot8HJKxGAk
311      * MGMy6omBd2NFRl3G3x4KbxQK/ztzluaomUrF2qloc0cv43dJ0U6z4HXmKdvrNYMz
312      * im82SdCiZUp6Qv2atr+krE1IHTkLsimwZL3DEcwb4bYxidp8QM3s8rECgYEA6hp0
313      * LduIHO23KIyH442GjdekCdFaQ/RF1Td6C1cx3b/KLa8oqOE81cCvzsM0fXSjniNa
314      * PNljPydN4rlPkt9DgzkR2enxz1jyfeLgj/RZZMcg0+whOdx8r8kSlTzeyy81Wi4s
315      * NaUPrXVMs7IxZkJLo7bjESoriYw4xcFe2yOGkzkCgYBRgo8exv2ZYCmQG68dfjN7
316      * pfCvJ+mE6tiVrOYr199O5FoiQInyzBUa880XP84EdLywTzhqLNzA4ANrokGfVFeS
317      * YtRxAL6TGYSj76Bb7PFBV03AebOpXEqD5sQ/MhTW3zLVEt4ZgIXlMeYWuD/X3Z0f
318      * TiYHwzM9B8VdEH0dOJNYcQKBgQDbT7UPUN6O21P/NMgJMYigUShn2izKBIl3WeWH
319      * wkQBDa+GZNWegIPRbBZHiTAfZ6nweAYNg0oq29NnV1toqKhCwrAqibPzH8zsiiL+
320      * OVeVxcbHQitOXXSh6ajzDndZufwtY5wfFWc+hOk6XvFQb0MVODw41Fy9GxQEj0ch
321      * 3IIyYQKBgQDYEUWTr0FfthLb8ZI3ENVNB0hiBadqO0MZSWjA3/HxHvD2GkozfV/T
322      * dBu8lkDkR7i2tsR8OsEgQ1fTsMVbqShr2nP2KSlvX6kUbYl2NX08dR51FIaWpAt0
323      * aFyCzjCQLWOdck/yTV4ulAfuNO3tLjtN9lqpvP623yjQe6aQPxZXaA==
324      * -----END RSA PRIVATE KEY-----
325      *
326      */
327 
328     private static final BigInteger RSA_2048_modulus = new BigInteger(new byte[] {
329         (byte) 0x00, (byte) 0xe0, (byte) 0x47, (byte) 0x3e, (byte) 0x8a, (byte) 0xb8, (byte) 0xf2, (byte) 0x28,
330         (byte) 0x4f, (byte) 0xeb, (byte) 0x9e, (byte) 0x74, (byte) 0x2f, (byte) 0xf9, (byte) 0x74, (byte) 0x8f,
331         (byte) 0xa1, (byte) 0x18, (byte) 0xed, (byte) 0x98, (byte) 0x63, (byte) 0x3c, (byte) 0x92, (byte) 0xf5,
332         (byte) 0x2a, (byte) 0xeb, (byte) 0x7a, (byte) 0x2e, (byte) 0xbe, (byte) 0x0d, (byte) 0x3b, (byte) 0xe6,
333         (byte) 0x03, (byte) 0x29, (byte) 0xbe, (byte) 0x76, (byte) 0x6a, (byte) 0xd1, (byte) 0x0e, (byte) 0xb6,
334         (byte) 0xa5, (byte) 0x15, (byte) 0xd0, (byte) 0xd2, (byte) 0xcf, (byte) 0xd9, (byte) 0xbe, (byte) 0xa7,
335         (byte) 0x93, (byte) 0x0f, (byte) 0x0c, (byte) 0x30, (byte) 0x65, (byte) 0x37, (byte) 0x89, (byte) 0x9f,
336         (byte) 0x79, (byte) 0x58, (byte) 0xcd, (byte) 0x3e, (byte) 0x85, (byte) 0xb0, (byte) 0x1f, (byte) 0x88,
337         (byte) 0x18, (byte) 0x52, (byte) 0x4d, (byte) 0x31, (byte) 0x25, (byte) 0x84, (byte) 0xa9, (byte) 0x4b,
338         (byte) 0x25, (byte) 0x1e, (byte) 0x36, (byte) 0x25, (byte) 0xb5, (byte) 0x41, (byte) 0x41, (byte) 0xed,
339         (byte) 0xbf, (byte) 0xee, (byte) 0x19, (byte) 0x88, (byte) 0x08, (byte) 0xe1, (byte) 0xbb, (byte) 0x97,
340         (byte) 0xfc, (byte) 0x7c, (byte) 0xb4, (byte) 0x9b, (byte) 0x9e, (byte) 0xaa, (byte) 0xaf, (byte) 0x68,
341         (byte) 0xe9, (byte) 0xc9, (byte) 0x8d, (byte) 0x7d, (byte) 0x0e, (byte) 0xdc, (byte) 0x53, (byte) 0xbb,
342         (byte) 0xc0, (byte) 0xfa, (byte) 0x00, (byte) 0x34, (byte) 0x35, (byte) 0x6d, (byte) 0x63, (byte) 0x05,
343         (byte) 0xfb, (byte) 0xbc, (byte) 0xc3, (byte) 0xc7, (byte) 0x00, (byte) 0x14, (byte) 0x05, (byte) 0x38,
344         (byte) 0x6a, (byte) 0xbb, (byte) 0xc8, (byte) 0x73, (byte) 0xcb, (byte) 0x0f, (byte) 0x3e, (byte) 0xf7,
345         (byte) 0x42, (byte) 0x5f, (byte) 0x3d, (byte) 0x33, (byte) 0xdf, (byte) 0x7b, (byte) 0x31, (byte) 0x5a,
346         (byte) 0xe0, (byte) 0x36, (byte) 0xd2, (byte) 0xa0, (byte) 0xb6, (byte) 0x6a, (byte) 0xfd, (byte) 0x47,
347         (byte) 0x50, (byte) 0x3b, (byte) 0x16, (byte) 0x9b, (byte) 0xf3, (byte) 0x6e, (byte) 0x3b, (byte) 0x51,
348         (byte) 0x62, (byte) 0x51, (byte) 0x5b, (byte) 0x71, (byte) 0x5f, (byte) 0xda, (byte) 0x83, (byte) 0xde,
349         (byte) 0xaf, (byte) 0x2c, (byte) 0x58, (byte) 0xae, (byte) 0xb9, (byte) 0xab, (byte) 0xfb, (byte) 0x30,
350         (byte) 0x97, (byte) 0xc3, (byte) 0xcc, (byte) 0x9d, (byte) 0xd9, (byte) 0xdb, (byte) 0xe5, (byte) 0xef,
351         (byte) 0x29, (byte) 0x6c, (byte) 0x17, (byte) 0x61, (byte) 0x39, (byte) 0x02, (byte) 0x8e, (byte) 0x8a,
352         (byte) 0x67, (byte) 0x1e, (byte) 0x63, (byte) 0x05, (byte) 0x6d, (byte) 0x45, (byte) 0xf4, (byte) 0x01,
353         (byte) 0x88, (byte) 0xd2, (byte) 0xc4, (byte) 0x13, (byte) 0x34, (byte) 0x90, (byte) 0x84, (byte) 0x5d,
354         (byte) 0xe5, (byte) 0x2c, (byte) 0x25, (byte) 0x34, (byte) 0xe9, (byte) 0xc6, (byte) 0xb2, (byte) 0x47,
355         (byte) 0x8c, (byte) 0x07, (byte) 0xbd, (byte) 0xae, (byte) 0x92, (byte) 0x88, (byte) 0x23, (byte) 0xb6,
356         (byte) 0x2d, (byte) 0x06, (byte) 0x6c, (byte) 0x77, (byte) 0x70, (byte) 0xf9, (byte) 0xf6, (byte) 0x3f,
357         (byte) 0x3d, (byte) 0xba, (byte) 0x24, (byte) 0x7f, (byte) 0x53, (byte) 0x08, (byte) 0x44, (byte) 0x74,
358         (byte) 0x7b, (byte) 0xe7, (byte) 0xaa, (byte) 0xa8, (byte) 0x5d, (byte) 0x85, (byte) 0x3b, (byte) 0x8b,
359         (byte) 0xd2, (byte) 0x44, (byte) 0xac, (byte) 0xec, (byte) 0x3d, (byte) 0xe3, (byte) 0xc8, (byte) 0x9a,
360         (byte) 0xb4, (byte) 0x64, (byte) 0x53, (byte) 0xab, (byte) 0x4d, (byte) 0x24, (byte) 0xc3, (byte) 0xac,
361         (byte) 0x69,
362     });
363 
364     private static final BigInteger RSA_2048_privateExponent = new BigInteger(new byte[] {
365         (byte) 0x37, (byte) 0x78, (byte) 0x47, (byte) 0x76, (byte) 0xa5, (byte) 0xf1, (byte) 0x76, (byte) 0x98,
366         (byte) 0xf5, (byte) 0xac, (byte) 0x96, (byte) 0x0d, (byte) 0xfb, (byte) 0x83, (byte) 0xa1, (byte) 0xb6,
367         (byte) 0x75, (byte) 0x64, (byte) 0xe6, (byte) 0x48, (byte) 0xbd, (byte) 0x05, (byte) 0x97, (byte) 0xcf,
368         (byte) 0x8a, (byte) 0xb8, (byte) 0x08, (byte) 0x71, (byte) 0x86, (byte) 0xf2, (byte) 0x66, (byte) 0x9c,
369         (byte) 0x27, (byte) 0xa9, (byte) 0xec, (byte) 0xbd, (byte) 0xd4, (byte) 0x80, (byte) 0xf0, (byte) 0x19,
370         (byte) 0x7a, (byte) 0x80, (byte) 0xd0, (byte) 0x73, (byte) 0x09, (byte) 0xe6, (byte) 0xc6, (byte) 0xa9,
371         (byte) 0x6f, (byte) 0x92, (byte) 0x53, (byte) 0x31, (byte) 0xe5, (byte) 0x7f, (byte) 0x8b, (byte) 0x4a,
372         (byte) 0xc6, (byte) 0xf4, (byte) 0xd4, (byte) 0x5e, (byte) 0xda, (byte) 0x45, (byte) 0xa2, (byte) 0x32,
373         (byte) 0x69, (byte) 0xc0, (byte) 0x9f, (byte) 0xc4, (byte) 0x28, (byte) 0xc0, (byte) 0x7a, (byte) 0x4e,
374         (byte) 0x6e, (byte) 0xdf, (byte) 0x73, (byte) 0x8a, (byte) 0x15, (byte) 0xde, (byte) 0xc9, (byte) 0x7f,
375         (byte) 0xab, (byte) 0xd2, (byte) 0xf2, (byte) 0xbb, (byte) 0x47, (byte) 0xa1, (byte) 0x4f, (byte) 0x20,
376         (byte) 0xea, (byte) 0x72, (byte) 0xfc, (byte) 0xfe, (byte) 0x4c, (byte) 0x36, (byte) 0xe0, (byte) 0x1a,
377         (byte) 0xda, (byte) 0x77, (byte) 0xbd, (byte) 0x13, (byte) 0x7c, (byte) 0xd8, (byte) 0xd4, (byte) 0xda,
378         (byte) 0x10, (byte) 0xbb, (byte) 0x16, (byte) 0x2e, (byte) 0x94, (byte) 0xa4, (byte) 0x66, (byte) 0x29,
379         (byte) 0x71, (byte) 0xf1, (byte) 0x75, (byte) 0xf9, (byte) 0x85, (byte) 0xfa, (byte) 0x18, (byte) 0x8f,
380         (byte) 0x05, (byte) 0x6c, (byte) 0xb9, (byte) 0x7e, (byte) 0xe2, (byte) 0x81, (byte) 0x6f, (byte) 0x43,
381         (byte) 0xab, (byte) 0x9d, (byte) 0x37, (byte) 0x47, (byte) 0x61, (byte) 0x24, (byte) 0x86, (byte) 0xcd,
382         (byte) 0xa8, (byte) 0xc1, (byte) 0x61, (byte) 0x96, (byte) 0xc3, (byte) 0x08, (byte) 0x18, (byte) 0xa9,
383         (byte) 0x95, (byte) 0xec, (byte) 0x85, (byte) 0xd3, (byte) 0x84, (byte) 0x67, (byte) 0x79, (byte) 0x12,
384         (byte) 0x67, (byte) 0xb3, (byte) 0xbf, (byte) 0x21, (byte) 0xf2, (byte) 0x73, (byte) 0x71, (byte) 0x0a,
385         (byte) 0x69, (byte) 0x25, (byte) 0x86, (byte) 0x25, (byte) 0x76, (byte) 0x84, (byte) 0x1c, (byte) 0x5b,
386         (byte) 0x67, (byte) 0x12, (byte) 0xc1, (byte) 0x2d, (byte) 0x4b, (byte) 0xd2, (byte) 0x0a, (byte) 0x2f,
387         (byte) 0x32, (byte) 0x99, (byte) 0xad, (byte) 0xb7, (byte) 0xc1, (byte) 0x35, (byte) 0xda, (byte) 0x5e,
388         (byte) 0x95, (byte) 0x15, (byte) 0xab, (byte) 0xda, (byte) 0x76, (byte) 0xe7, (byte) 0xca, (byte) 0xf2,
389         (byte) 0xa3, (byte) 0xbe, (byte) 0x80, (byte) 0x55, (byte) 0x1d, (byte) 0x07, (byte) 0x3b, (byte) 0x78,
390         (byte) 0xbf, (byte) 0x11, (byte) 0x62, (byte) 0xc4, (byte) 0x8a, (byte) 0xd2, (byte) 0xb7, (byte) 0xf4,
391         (byte) 0x74, (byte) 0x3a, (byte) 0x02, (byte) 0x38, (byte) 0xee, (byte) 0x4d, (byte) 0x25, (byte) 0x2f,
392         (byte) 0x7d, (byte) 0x5e, (byte) 0x7e, (byte) 0x65, (byte) 0x33, (byte) 0xcc, (byte) 0xae, (byte) 0x64,
393         (byte) 0xcc, (byte) 0xb3, (byte) 0x93, (byte) 0x60, (byte) 0x07, (byte) 0x5a, (byte) 0x2f, (byte) 0xd1,
394         (byte) 0xe0, (byte) 0x34, (byte) 0xec, (byte) 0x3a, (byte) 0xe5, (byte) 0xce, (byte) 0x9c, (byte) 0x40,
395         (byte) 0x8c, (byte) 0xcb, (byte) 0xf0, (byte) 0xe2, (byte) 0x5e, (byte) 0x41, (byte) 0x14, (byte) 0x02,
396         (byte) 0x16, (byte) 0x87, (byte) 0xb3, (byte) 0xdd, (byte) 0x47, (byte) 0x54, (byte) 0xae, (byte) 0x81,
397     });
398 
399     private static final BigInteger RSA_2048_publicExponent = new BigInteger(new byte[] {
400         (byte) 0x01, (byte) 0x00, (byte) 0x01,
401     });
402 
403     private static final BigInteger RSA_2048_primeP = new BigInteger(new byte[] {
404         (byte) 0x00, (byte) 0xf5, (byte) 0x41, (byte) 0x88, (byte) 0x4b, (byte) 0xc3, (byte) 0x73, (byte) 0x7b,
405         (byte) 0x29, (byte) 0x22, (byte) 0xd4, (byte) 0x11, (byte) 0x9e, (byte) 0xf4, (byte) 0x5e, (byte) 0x2d,
406         (byte) 0xee, (byte) 0x2c, (byte) 0xd4, (byte) 0xcb, (byte) 0xb7, (byte) 0x5f, (byte) 0x45, (byte) 0x50,
407         (byte) 0x5a, (byte) 0x15, (byte) 0x7a, (byte) 0xa5, (byte) 0x00, (byte) 0x9f, (byte) 0x99, (byte) 0xc7,
408         (byte) 0x3a, (byte) 0x2d, (byte) 0xf0, (byte) 0x72, (byte) 0x4a, (byte) 0xc4, (byte) 0x60, (byte) 0x24,
409         (byte) 0x30, (byte) 0x63, (byte) 0x32, (byte) 0xea, (byte) 0x89, (byte) 0x81, (byte) 0x77, (byte) 0x63,
410         (byte) 0x45, (byte) 0x46, (byte) 0x5d, (byte) 0xc6, (byte) 0xdf, (byte) 0x1e, (byte) 0x0a, (byte) 0x6f,
411         (byte) 0x14, (byte) 0x0a, (byte) 0xff, (byte) 0x3b, (byte) 0x73, (byte) 0x96, (byte) 0xe6, (byte) 0xa8,
412         (byte) 0x99, (byte) 0x4a, (byte) 0xc5, (byte) 0xda, (byte) 0xa9, (byte) 0x68, (byte) 0x73, (byte) 0x47,
413         (byte) 0x2f, (byte) 0xe3, (byte) 0x77, (byte) 0x49, (byte) 0xd1, (byte) 0x4e, (byte) 0xb3, (byte) 0xe0,
414         (byte) 0x75, (byte) 0xe6, (byte) 0x29, (byte) 0xdb, (byte) 0xeb, (byte) 0x35, (byte) 0x83, (byte) 0x33,
415         (byte) 0x8a, (byte) 0x6f, (byte) 0x36, (byte) 0x49, (byte) 0xd0, (byte) 0xa2, (byte) 0x65, (byte) 0x4a,
416         (byte) 0x7a, (byte) 0x42, (byte) 0xfd, (byte) 0x9a, (byte) 0xb6, (byte) 0xbf, (byte) 0xa4, (byte) 0xac,
417         (byte) 0x4d, (byte) 0x48, (byte) 0x1d, (byte) 0x39, (byte) 0x0b, (byte) 0xb2, (byte) 0x29, (byte) 0xb0,
418         (byte) 0x64, (byte) 0xbd, (byte) 0xc3, (byte) 0x11, (byte) 0xcc, (byte) 0x1b, (byte) 0xe1, (byte) 0xb6,
419         (byte) 0x31, (byte) 0x89, (byte) 0xda, (byte) 0x7c, (byte) 0x40, (byte) 0xcd, (byte) 0xec, (byte) 0xf2,
420         (byte) 0xb1,
421     });
422 
423     private static final BigInteger RSA_2048_primeQ = new BigInteger(new byte[] {
424         (byte) 0x00, (byte) 0xea, (byte) 0x1a, (byte) 0x74, (byte) 0x2d, (byte) 0xdb, (byte) 0x88, (byte) 0x1c,
425         (byte) 0xed, (byte) 0xb7, (byte) 0x28, (byte) 0x8c, (byte) 0x87, (byte) 0xe3, (byte) 0x8d, (byte) 0x86,
426         (byte) 0x8d, (byte) 0xd7, (byte) 0xa4, (byte) 0x09, (byte) 0xd1, (byte) 0x5a, (byte) 0x43, (byte) 0xf4,
427         (byte) 0x45, (byte) 0xd5, (byte) 0x37, (byte) 0x7a, (byte) 0x0b, (byte) 0x57, (byte) 0x31, (byte) 0xdd,
428         (byte) 0xbf, (byte) 0xca, (byte) 0x2d, (byte) 0xaf, (byte) 0x28, (byte) 0xa8, (byte) 0xe1, (byte) 0x3c,
429         (byte) 0xd5, (byte) 0xc0, (byte) 0xaf, (byte) 0xce, (byte) 0xc3, (byte) 0x34, (byte) 0x7d, (byte) 0x74,
430         (byte) 0xa3, (byte) 0x9e, (byte) 0x23, (byte) 0x5a, (byte) 0x3c, (byte) 0xd9, (byte) 0x63, (byte) 0x3f,
431         (byte) 0x27, (byte) 0x4d, (byte) 0xe2, (byte) 0xb9, (byte) 0x4f, (byte) 0x92, (byte) 0xdf, (byte) 0x43,
432         (byte) 0x83, (byte) 0x39, (byte) 0x11, (byte) 0xd9, (byte) 0xe9, (byte) 0xf1, (byte) 0xcf, (byte) 0x58,
433         (byte) 0xf2, (byte) 0x7d, (byte) 0xe2, (byte) 0xe0, (byte) 0x8f, (byte) 0xf4, (byte) 0x59, (byte) 0x64,
434         (byte) 0xc7, (byte) 0x20, (byte) 0xd3, (byte) 0xec, (byte) 0x21, (byte) 0x39, (byte) 0xdc, (byte) 0x7c,
435         (byte) 0xaf, (byte) 0xc9, (byte) 0x12, (byte) 0x95, (byte) 0x3c, (byte) 0xde, (byte) 0xcb, (byte) 0x2f,
436         (byte) 0x35, (byte) 0x5a, (byte) 0x2e, (byte) 0x2c, (byte) 0x35, (byte) 0xa5, (byte) 0x0f, (byte) 0xad,
437         (byte) 0x75, (byte) 0x4c, (byte) 0xb3, (byte) 0xb2, (byte) 0x31, (byte) 0x66, (byte) 0x42, (byte) 0x4b,
438         (byte) 0xa3, (byte) 0xb6, (byte) 0xe3, (byte) 0x11, (byte) 0x2a, (byte) 0x2b, (byte) 0x89, (byte) 0x8c,
439         (byte) 0x38, (byte) 0xc5, (byte) 0xc1, (byte) 0x5e, (byte) 0xdb, (byte) 0x23, (byte) 0x86, (byte) 0x93,
440         (byte) 0x39,
441     });
442 
443     /* Test data is: "Android.\n" */
444     private static final byte[] Vector1Data = new byte[] {
445         (byte) 0x41, (byte) 0x6e, (byte) 0x64, (byte) 0x72, (byte) 0x6f, (byte) 0x69, (byte) 0x64, (byte) 0x2e,
446         (byte) 0x0a,
447     };
448 
449     private static final byte[] SHA1withRSA_Vector1Signature = {
450         (byte) 0x6d, (byte) 0x5b, (byte) 0xff, (byte) 0x68, (byte) 0xda, (byte) 0x18, (byte) 0x98, (byte) 0x72,
451         (byte) 0x5c, (byte) 0x1f, (byte) 0x46, (byte) 0x51, (byte) 0x77, (byte) 0x15, (byte) 0x11, (byte) 0xcb,
452         (byte) 0xe0, (byte) 0xb9, (byte) 0x3b, (byte) 0x7d, (byte) 0xf5, (byte) 0x96, (byte) 0x98, (byte) 0x24,
453         (byte) 0x85, (byte) 0x9d, (byte) 0x3e, (byte) 0xed, (byte) 0x9b, (byte) 0xb2, (byte) 0x8a, (byte) 0x91,
454         (byte) 0xfb, (byte) 0xf6, (byte) 0x85, (byte) 0x64, (byte) 0x74, (byte) 0x18, (byte) 0xb5, (byte) 0x1c,
455         (byte) 0xb3, (byte) 0x8d, (byte) 0x99, (byte) 0x0d, (byte) 0xdf, (byte) 0xaa, (byte) 0xa6, (byte) 0xa1,
456         (byte) 0xc3, (byte) 0xb6, (byte) 0x25, (byte) 0xb3, (byte) 0x06, (byte) 0xe0, (byte) 0xef, (byte) 0x28,
457         (byte) 0xb0, (byte) 0x4d, (byte) 0x50, (byte) 0xc7, (byte) 0x75, (byte) 0x39, (byte) 0xb9, (byte) 0x2c,
458         (byte) 0x47, (byte) 0xb5, (byte) 0xe2, (byte) 0x96, (byte) 0xf8, (byte) 0xf6, (byte) 0xcb, (byte) 0xa0,
459         (byte) 0x58, (byte) 0xc9, (byte) 0x3e, (byte) 0xd5, (byte) 0xfc, (byte) 0x26, (byte) 0xd9, (byte) 0x55,
460         (byte) 0x73, (byte) 0x39, (byte) 0x75, (byte) 0xb3, (byte) 0xb0, (byte) 0x0a, (byte) 0x5f, (byte) 0x5e,
461         (byte) 0x3b, (byte) 0x4a, (byte) 0x2e, (byte) 0xb1, (byte) 0x0e, (byte) 0x7d, (byte) 0xe5, (byte) 0xcc,
462         (byte) 0x04, (byte) 0x2c, (byte) 0xd1, (byte) 0x0a, (byte) 0x32, (byte) 0xaa, (byte) 0xd9, (byte) 0x8d,
463         (byte) 0x1f, (byte) 0xcb, (byte) 0xe3, (byte) 0x7f, (byte) 0x63, (byte) 0x12, (byte) 0xb1, (byte) 0x98,
464         (byte) 0x46, (byte) 0x46, (byte) 0x07, (byte) 0xd9, (byte) 0x49, (byte) 0xd2, (byte) 0xbf, (byte) 0xb5,
465         (byte) 0xbc, (byte) 0xbb, (byte) 0xfd, (byte) 0x1c, (byte) 0xd7, (byte) 0x11, (byte) 0x94, (byte) 0xaa,
466         (byte) 0x5f, (byte) 0x7b, (byte) 0xb2, (byte) 0x0c, (byte) 0x5d, (byte) 0x94, (byte) 0x53, (byte) 0x5e,
467         (byte) 0x81, (byte) 0x5c, (byte) 0xbb, (byte) 0x1d, (byte) 0x4f, (byte) 0x30, (byte) 0xcd, (byte) 0xf8,
468         (byte) 0xd7, (byte) 0xa5, (byte) 0xfa, (byte) 0x5e, (byte) 0xe0, (byte) 0x19, (byte) 0x3f, (byte) 0xa4,
469         (byte) 0xaa, (byte) 0x56, (byte) 0x4e, (byte) 0xec, (byte) 0xeb, (byte) 0xee, (byte) 0xa2, (byte) 0x6c,
470         (byte) 0xc9, (byte) 0x4f, (byte) 0xc2, (byte) 0xcc, (byte) 0x2a, (byte) 0xbc, (byte) 0x5b, (byte) 0x09,
471         (byte) 0x10, (byte) 0x73, (byte) 0x61, (byte) 0x0c, (byte) 0x04, (byte) 0xb6, (byte) 0xb7, (byte) 0x2c,
472         (byte) 0x37, (byte) 0xd2, (byte) 0xca, (byte) 0x2d, (byte) 0x54, (byte) 0xf2, (byte) 0xf7, (byte) 0x77,
473         (byte) 0xe1, (byte) 0xba, (byte) 0x9f, (byte) 0x29, (byte) 0x07, (byte) 0xa2, (byte) 0x74, (byte) 0xc6,
474         (byte) 0xe9, (byte) 0x1e, (byte) 0xde, (byte) 0xd7, (byte) 0x9c, (byte) 0x4b, (byte) 0xb7, (byte) 0x66,
475         (byte) 0x52, (byte) 0xe8, (byte) 0xac, (byte) 0xf6, (byte) 0x76, (byte) 0xab, (byte) 0x16, (byte) 0x82,
476         (byte) 0x96, (byte) 0x87, (byte) 0x40, (byte) 0x0f, (byte) 0xad, (byte) 0x2d, (byte) 0x46, (byte) 0xa6,
477         (byte) 0x28, (byte) 0x04, (byte) 0x13, (byte) 0xc2, (byte) 0xce, (byte) 0x50, (byte) 0x56, (byte) 0x6d,
478         (byte) 0xbe, (byte) 0x0c, (byte) 0x91, (byte) 0xd0, (byte) 0x8e, (byte) 0x80, (byte) 0x9e, (byte) 0x91,
479         (byte) 0x8f, (byte) 0x62, (byte) 0xb3, (byte) 0x57, (byte) 0xd6, (byte) 0xae, (byte) 0x53, (byte) 0x91,
480         (byte) 0x83, (byte) 0xe9, (byte) 0x38, (byte) 0x77, (byte) 0x8f, (byte) 0x20, (byte) 0xdd, (byte) 0x13,
481         (byte) 0x7d, (byte) 0x15, (byte) 0x44, (byte) 0x7e, (byte) 0xb5, (byte) 0x00, (byte) 0xd6, (byte) 0x45,
482     };
483 
484     private static final byte[] Vector2Data = new byte[] {
485         (byte) 0x54, (byte) 0x68, (byte) 0x69, (byte) 0x73, (byte) 0x20, (byte) 0x69, (byte) 0x73, (byte) 0x20,
486         (byte) 0x61, (byte) 0x20, (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e, (byte) 0x65, (byte) 0x64,
487         (byte) 0x20, (byte) 0x6d, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x61, (byte) 0x67, (byte) 0x65,
488         (byte) 0x20, (byte) 0x66, (byte) 0x72, (byte) 0x6f, (byte) 0x6d, (byte) 0x20, (byte) 0x4b, (byte) 0x65,
489         (byte) 0x6e, (byte) 0x6e, (byte) 0x79, (byte) 0x20, (byte) 0x52, (byte) 0x6f, (byte) 0x6f, (byte) 0x74,
490         (byte) 0x2e, (byte) 0x0a,
491     };
492 
493     private static final byte[] SHA1withRSA_Vector2Signature = new byte[] {
494         (byte) 0x2e, (byte) 0xa6, (byte) 0x33, (byte) 0xd1, (byte) 0x9d, (byte) 0xfc, (byte) 0x4e, (byte) 0x27,
495         (byte) 0xb3, (byte) 0xa8, (byte) 0x9a, (byte) 0xf2, (byte) 0x48, (byte) 0x62, (byte) 0x15, (byte) 0xa2,
496         (byte) 0xce, (byte) 0x5f, (byte) 0x2b, (byte) 0x0e, (byte) 0xc5, (byte) 0x26, (byte) 0xba, (byte) 0xd9,
497         (byte) 0x0f, (byte) 0x60, (byte) 0xeb, (byte) 0xf0, (byte) 0xd5, (byte) 0x5c, (byte) 0x6b, (byte) 0x23,
498         (byte) 0x11, (byte) 0x95, (byte) 0xa4, (byte) 0xbd, (byte) 0x11, (byte) 0x68, (byte) 0xe7, (byte) 0x3a,
499         (byte) 0x37, (byte) 0x3d, (byte) 0x79, (byte) 0xb8, (byte) 0x4f, (byte) 0xe9, (byte) 0xa1, (byte) 0x88,
500         (byte) 0xfb, (byte) 0xa9, (byte) 0x8b, (byte) 0x34, (byte) 0xa1, (byte) 0xe0, (byte) 0xca, (byte) 0x11,
501         (byte) 0xdd, (byte) 0xd0, (byte) 0x83, (byte) 0x7f, (byte) 0xc1, (byte) 0x0b, (byte) 0x16, (byte) 0x61,
502         (byte) 0xac, (byte) 0x09, (byte) 0xa2, (byte) 0xdd, (byte) 0x40, (byte) 0x5b, (byte) 0x8c, (byte) 0x7a,
503         (byte) 0xb2, (byte) 0xb4, (byte) 0x02, (byte) 0x7c, (byte) 0xd4, (byte) 0x9a, (byte) 0xe6, (byte) 0xa5,
504         (byte) 0x1a, (byte) 0x27, (byte) 0x77, (byte) 0x70, (byte) 0xe3, (byte) 0xe3, (byte) 0x71, (byte) 0xc7,
505         (byte) 0x59, (byte) 0xc7, (byte) 0x9f, (byte) 0xb8, (byte) 0xef, (byte) 0xe7, (byte) 0x15, (byte) 0x02,
506         (byte) 0x0d, (byte) 0x70, (byte) 0xdc, (byte) 0x2c, (byte) 0xe9, (byte) 0xf7, (byte) 0x63, (byte) 0x2a,
507         (byte) 0xb5, (byte) 0xee, (byte) 0x9f, (byte) 0x29, (byte) 0x56, (byte) 0x86, (byte) 0x99, (byte) 0xb3,
508         (byte) 0x0f, (byte) 0xe5, (byte) 0x1f, (byte) 0x76, (byte) 0x22, (byte) 0x3b, (byte) 0x7f, (byte) 0xa9,
509         (byte) 0x9e, (byte) 0xd4, (byte) 0xc4, (byte) 0x83, (byte) 0x5d, (byte) 0x57, (byte) 0xcc, (byte) 0x37,
510         (byte) 0xcb, (byte) 0x9a, (byte) 0x9e, (byte) 0x73, (byte) 0x44, (byte) 0x93, (byte) 0xb4, (byte) 0xf1,
511         (byte) 0x6b, (byte) 0x98, (byte) 0xa0, (byte) 0x57, (byte) 0xbb, (byte) 0x5e, (byte) 0x8f, (byte) 0x89,
512         (byte) 0x5b, (byte) 0x97, (byte) 0x26, (byte) 0xe4, (byte) 0xd0, (byte) 0x51, (byte) 0x0a, (byte) 0x5a,
513         (byte) 0xb7, (byte) 0x12, (byte) 0x1a, (byte) 0x6d, (byte) 0xb0, (byte) 0x79, (byte) 0x30, (byte) 0x51,
514         (byte) 0x83, (byte) 0x2e, (byte) 0xe2, (byte) 0x7a, (byte) 0x67, (byte) 0x66, (byte) 0xd3, (byte) 0x95,
515         (byte) 0xca, (byte) 0xfc, (byte) 0xcb, (byte) 0x92, (byte) 0x79, (byte) 0x32, (byte) 0x26, (byte) 0x86,
516         (byte) 0xe1, (byte) 0x0d, (byte) 0xd8, (byte) 0x19, (byte) 0xfa, (byte) 0x65, (byte) 0x37, (byte) 0xc9,
517         (byte) 0x4c, (byte) 0x2a, (byte) 0xe1, (byte) 0x42, (byte) 0xc7, (byte) 0xd4, (byte) 0xb7, (byte) 0xeb,
518         (byte) 0x1f, (byte) 0xc3, (byte) 0x53, (byte) 0x64, (byte) 0x6f, (byte) 0x2b, (byte) 0x78, (byte) 0x18,
519         (byte) 0x03, (byte) 0xda, (byte) 0x8d, (byte) 0x62, (byte) 0x24, (byte) 0x70, (byte) 0xab, (byte) 0xe6,
520         (byte) 0x16, (byte) 0x13, (byte) 0x24, (byte) 0x6b, (byte) 0x5f, (byte) 0xd3, (byte) 0xec, (byte) 0xc1,
521         (byte) 0x58, (byte) 0x64, (byte) 0xbd, (byte) 0x30, (byte) 0x98, (byte) 0x5e, (byte) 0x33, (byte) 0xce,
522         (byte) 0x87, (byte) 0x64, (byte) 0x14, (byte) 0x07, (byte) 0x85, (byte) 0x43, (byte) 0x3e, (byte) 0x9f,
523         (byte) 0x27, (byte) 0x9f, (byte) 0x63, (byte) 0x66, (byte) 0x9d, (byte) 0x26, (byte) 0x19, (byte) 0xc0,
524         (byte) 0x02, (byte) 0x08, (byte) 0x15, (byte) 0xcb, (byte) 0xb4, (byte) 0xaa, (byte) 0x4a, (byte) 0xc8,
525         (byte) 0xc0, (byte) 0x09, (byte) 0x15, (byte) 0x7d, (byte) 0x8a, (byte) 0x21, (byte) 0xbc, (byte) 0xa3,
526     };
527 
528     /*
529      * echo 'Android.' | openssl dgst -sha224 -binary -sign privkey.pem  | recode ../x1 | sed 's/0x/(byte) 0x/g'
530      */
531     private static final byte[] SHA224withRSA_Vector2Signature = new byte[] {
532         (byte) 0xBD, (byte) 0x3F, (byte) 0xD4, (byte) 0x20, (byte) 0x5B, (byte) 0xC0, (byte) 0x89, (byte) 0x4F,
533         (byte) 0x99, (byte) 0x6C, (byte) 0xF4, (byte) 0xA4, (byte) 0x70, (byte) 0xE3, (byte) 0x5B, (byte) 0x33,
534         (byte) 0xB3, (byte) 0xCA, (byte) 0xFE, (byte) 0x1F, (byte) 0xB9, (byte) 0x3A, (byte) 0xD6, (byte) 0x9B,
535         (byte) 0x1E, (byte) 0xDA, (byte) 0x65, (byte) 0x06, (byte) 0xBD, (byte) 0xC3, (byte) 0x2B, (byte) 0xF8,
536         (byte) 0x0E, (byte) 0xA0, (byte) 0xB5, (byte) 0x33, (byte) 0x7F, (byte) 0x15, (byte) 0xDC, (byte) 0xBB,
537         (byte) 0xDC, (byte) 0x98, (byte) 0x96, (byte) 0xF5, (byte) 0xF8, (byte) 0xE5, (byte) 0x55, (byte) 0x7D,
538         (byte) 0x48, (byte) 0x51, (byte) 0xC5, (byte) 0xAE, (byte) 0x12, (byte) 0xA2, (byte) 0x61, (byte) 0xC7,
539         (byte) 0xA2, (byte) 0x00, (byte) 0x0F, (byte) 0x35, (byte) 0x54, (byte) 0x3C, (byte) 0x7E, (byte) 0x97,
540         (byte) 0x19, (byte) 0x2D, (byte) 0x8F, (byte) 0xFD, (byte) 0x51, (byte) 0x04, (byte) 0x72, (byte) 0x23,
541         (byte) 0x65, (byte) 0x16, (byte) 0x41, (byte) 0x12, (byte) 0x46, (byte) 0xD6, (byte) 0x20, (byte) 0xB6,
542         (byte) 0x4E, (byte) 0xD6, (byte) 0xE8, (byte) 0x60, (byte) 0x91, (byte) 0x05, (byte) 0xCA, (byte) 0x57,
543         (byte) 0x6F, (byte) 0x53, (byte) 0xA4, (byte) 0x05, (byte) 0x2A, (byte) 0x37, (byte) 0xDD, (byte) 0x2E,
544         (byte) 0xA4, (byte) 0xC7, (byte) 0xBF, (byte) 0x9E, (byte) 0xF6, (byte) 0xD5, (byte) 0xD4, (byte) 0x34,
545         (byte) 0xB8, (byte) 0xB3, (byte) 0x8B, (byte) 0x66, (byte) 0x2C, (byte) 0xB6, (byte) 0x5F, (byte) 0xA4,
546         (byte) 0xB7, (byte) 0x77, (byte) 0xF8, (byte) 0x9A, (byte) 0x9C, (byte) 0x44, (byte) 0x9F, (byte) 0xF0,
547         (byte) 0xCA, (byte) 0x53, (byte) 0x56, (byte) 0x2F, (byte) 0x99, (byte) 0x2E, (byte) 0x4B, (byte) 0xA2,
548         (byte) 0x26, (byte) 0x50, (byte) 0x30, (byte) 0x97, (byte) 0x2B, (byte) 0x4B, (byte) 0x0C, (byte) 0x3E,
549         (byte) 0x28, (byte) 0x0B, (byte) 0x88, (byte) 0x87, (byte) 0x9E, (byte) 0xCE, (byte) 0xCB, (byte) 0x57,
550         (byte) 0x72, (byte) 0x6B, (byte) 0xF6, (byte) 0xD6, (byte) 0xAA, (byte) 0x4D, (byte) 0x5F, (byte) 0x19,
551         (byte) 0x7A, (byte) 0xAD, (byte) 0x44, (byte) 0x09, (byte) 0x33, (byte) 0x62, (byte) 0xC8, (byte) 0x56,
552         (byte) 0x82, (byte) 0x84, (byte) 0xBF, (byte) 0x52, (byte) 0xC6, (byte) 0xA2, (byte) 0x2B, (byte) 0xE3,
553         (byte) 0xC2, (byte) 0x7F, (byte) 0xE3, (byte) 0x06, (byte) 0xC3, (byte) 0x30, (byte) 0xB8, (byte) 0xD4,
554         (byte) 0x01, (byte) 0xE6, (byte) 0x3D, (byte) 0xDB, (byte) 0xCA, (byte) 0xE4, (byte) 0xFB, (byte) 0xA8,
555         (byte) 0x7B, (byte) 0x2D, (byte) 0x8F, (byte) 0x39, (byte) 0x7A, (byte) 0x63, (byte) 0x9F, (byte) 0x02,
556         (byte) 0xE8, (byte) 0x91, (byte) 0xD1, (byte) 0xEE, (byte) 0x60, (byte) 0xEE, (byte) 0xCA, (byte) 0xF2,
557         (byte) 0x33, (byte) 0x7D, (byte) 0xF2, (byte) 0x41, (byte) 0x52, (byte) 0x0B, (byte) 0x9B, (byte) 0x1B,
558         (byte) 0x2D, (byte) 0x89, (byte) 0x38, (byte) 0xEC, (byte) 0x24, (byte) 0x60, (byte) 0x40, (byte) 0x40,
559         (byte) 0x6F, (byte) 0xB6, (byte) 0x6F, (byte) 0x86, (byte) 0xB5, (byte) 0x0A, (byte) 0x3D, (byte) 0x98,
560         (byte) 0x77, (byte) 0x3F, (byte) 0x59, (byte) 0x41, (byte) 0x3E, (byte) 0x4D, (byte) 0xE4, (byte) 0x4E,
561         (byte) 0x91, (byte) 0xCD, (byte) 0x8E, (byte) 0x33, (byte) 0x60, (byte) 0x16, (byte) 0x8D, (byte) 0xAB,
562         (byte) 0x04, (byte) 0x14, (byte) 0xE8, (byte) 0x76, (byte) 0xF1, (byte) 0x06, (byte) 0xCD, (byte) 0x4A,
563         (byte) 0x88, (byte) 0xC7, (byte) 0x69, (byte) 0x6B, (byte) 0xC6, (byte) 0xDA, (byte) 0x9E, (byte) 0x09
564     };
565 
566     private static final byte[] SHA256withRSA_Vector2Signature = new byte[] {
567         (byte) 0x18, (byte) 0x6e, (byte) 0x31, (byte) 0x1f, (byte) 0x1d, (byte) 0x44, (byte) 0x09, (byte) 0x3e,
568         (byte) 0xa0, (byte) 0xc4, (byte) 0x3d, (byte) 0xb4, (byte) 0x1b, (byte) 0xf2, (byte) 0xd8, (byte) 0xa4,
569         (byte) 0x59, (byte) 0xab, (byte) 0xb5, (byte) 0x37, (byte) 0x28, (byte) 0xb8, (byte) 0x94, (byte) 0x6b,
570         (byte) 0x6f, (byte) 0x13, (byte) 0x54, (byte) 0xff, (byte) 0xac, (byte) 0x15, (byte) 0x84, (byte) 0xd0,
571         (byte) 0xc9, (byte) 0x15, (byte) 0x5b, (byte) 0x69, (byte) 0x05, (byte) 0xf1, (byte) 0x44, (byte) 0xfd,
572         (byte) 0xde, (byte) 0xe8, (byte) 0xb4, (byte) 0x12, (byte) 0x59, (byte) 0x9e, (byte) 0x4c, (byte) 0x0b,
573         (byte) 0xd5, (byte) 0x49, (byte) 0x33, (byte) 0x28, (byte) 0xe0, (byte) 0xcb, (byte) 0x87, (byte) 0x85,
574         (byte) 0xd8, (byte) 0x18, (byte) 0x6f, (byte) 0xfe, (byte) 0xa2, (byte) 0x23, (byte) 0x82, (byte) 0xf0,
575         (byte) 0xe5, (byte) 0x39, (byte) 0x1b, (byte) 0x8c, (byte) 0x93, (byte) 0x11, (byte) 0x49, (byte) 0x72,
576         (byte) 0x2a, (byte) 0x5b, (byte) 0x25, (byte) 0xff, (byte) 0x4e, (byte) 0x88, (byte) 0x70, (byte) 0x9d,
577         (byte) 0x9d, (byte) 0xff, (byte) 0xe2, (byte) 0xc0, (byte) 0x7e, (byte) 0xc8, (byte) 0x03, (byte) 0x40,
578         (byte) 0xbe, (byte) 0x44, (byte) 0x09, (byte) 0xeb, (byte) 0x9e, (byte) 0x8e, (byte) 0x88, (byte) 0xe4,
579         (byte) 0x98, (byte) 0x82, (byte) 0x06, (byte) 0xa4, (byte) 0x9d, (byte) 0x63, (byte) 0x88, (byte) 0x65,
580         (byte) 0xa3, (byte) 0x8e, (byte) 0x0d, (byte) 0x22, (byte) 0xf3, (byte) 0x33, (byte) 0xf2, (byte) 0x40,
581         (byte) 0xe8, (byte) 0x91, (byte) 0x67, (byte) 0x72, (byte) 0x29, (byte) 0x1c, (byte) 0x08, (byte) 0xff,
582         (byte) 0x54, (byte) 0xa0, (byte) 0xcc, (byte) 0xad, (byte) 0x84, (byte) 0x88, (byte) 0x4b, (byte) 0x3b,
583         (byte) 0xef, (byte) 0xf9, (byte) 0x5e, (byte) 0xb3, (byte) 0x41, (byte) 0x6a, (byte) 0xbd, (byte) 0x94,
584         (byte) 0x16, (byte) 0x7d, (byte) 0x9d, (byte) 0x53, (byte) 0x77, (byte) 0xf1, (byte) 0x6a, (byte) 0x95,
585         (byte) 0x57, (byte) 0xad, (byte) 0x65, (byte) 0x9d, (byte) 0x75, (byte) 0x95, (byte) 0xf6, (byte) 0x6a,
586         (byte) 0xd2, (byte) 0x88, (byte) 0xea, (byte) 0x5b, (byte) 0xa2, (byte) 0x94, (byte) 0x8f, (byte) 0x5e,
587         (byte) 0x84, (byte) 0x18, (byte) 0x19, (byte) 0x46, (byte) 0x83, (byte) 0x0b, (byte) 0x6d, (byte) 0x5b,
588         (byte) 0xb9, (byte) 0xdb, (byte) 0xa4, (byte) 0xe5, (byte) 0x17, (byte) 0x02, (byte) 0x9e, (byte) 0x11,
589         (byte) 0xed, (byte) 0xd9, (byte) 0x7b, (byte) 0x83, (byte) 0x87, (byte) 0x89, (byte) 0xf3, (byte) 0xe4,
590         (byte) 0xbf, (byte) 0x0e, (byte) 0xe8, (byte) 0xdc, (byte) 0x55, (byte) 0x9c, (byte) 0xf7, (byte) 0xc9,
591         (byte) 0xc3, (byte) 0xe2, (byte) 0x2c, (byte) 0xf7, (byte) 0x8c, (byte) 0xaa, (byte) 0x17, (byte) 0x1f,
592         (byte) 0xd1, (byte) 0xc7, (byte) 0x74, (byte) 0xc7, (byte) 0x8e, (byte) 0x1c, (byte) 0x5b, (byte) 0xd2,
593         (byte) 0x31, (byte) 0x74, (byte) 0x43, (byte) 0x9a, (byte) 0x52, (byte) 0xbf, (byte) 0x89, (byte) 0xc5,
594         (byte) 0xb4, (byte) 0x80, (byte) 0x6a, (byte) 0x9e, (byte) 0x05, (byte) 0xdb, (byte) 0xbb, (byte) 0x07,
595         (byte) 0x8c, (byte) 0x08, (byte) 0x61, (byte) 0xba, (byte) 0xa4, (byte) 0xbc, (byte) 0x80, (byte) 0x3a,
596         (byte) 0xdd, (byte) 0x3b, (byte) 0x1a, (byte) 0x8c, (byte) 0x21, (byte) 0xd8, (byte) 0xa3, (byte) 0xc0,
597         (byte) 0xc7, (byte) 0xd1, (byte) 0x08, (byte) 0xe1, (byte) 0x34, (byte) 0x99, (byte) 0xc0, (byte) 0xcf,
598         (byte) 0x80, (byte) 0xff, (byte) 0xfa, (byte) 0x07, (byte) 0xef, (byte) 0x5c, (byte) 0x45, (byte) 0xe5,
599     };
600 
601     private static final byte[] SHA384withRSA_Vector2Signature = new byte[] {
602         (byte) 0xaf, (byte) 0xf7, (byte) 0x7a, (byte) 0xc2, (byte) 0xbb, (byte) 0xb8, (byte) 0xbd, (byte) 0xe3,
603         (byte) 0x42, (byte) 0xaa, (byte) 0x16, (byte) 0x8a, (byte) 0x52, (byte) 0x6c, (byte) 0x99, (byte) 0x66,
604         (byte) 0x08, (byte) 0xbe, (byte) 0x15, (byte) 0xd9, (byte) 0x7c, (byte) 0x60, (byte) 0x2c, (byte) 0xac,
605         (byte) 0x4d, (byte) 0x4c, (byte) 0xf4, (byte) 0xdf, (byte) 0xbc, (byte) 0x16, (byte) 0x58, (byte) 0x0a,
606         (byte) 0x4e, (byte) 0xde, (byte) 0x8d, (byte) 0xb3, (byte) 0xbd, (byte) 0x03, (byte) 0x4e, (byte) 0x23,
607         (byte) 0x40, (byte) 0xa5, (byte) 0x80, (byte) 0xae, (byte) 0x83, (byte) 0xb4, (byte) 0x0f, (byte) 0x99,
608         (byte) 0x44, (byte) 0xc3, (byte) 0x5e, (byte) 0xdb, (byte) 0x59, (byte) 0x1d, (byte) 0xea, (byte) 0x7b,
609         (byte) 0x4d, (byte) 0xf3, (byte) 0xd2, (byte) 0xad, (byte) 0xbd, (byte) 0x21, (byte) 0x9f, (byte) 0x8e,
610         (byte) 0x87, (byte) 0x8f, (byte) 0x12, (byte) 0x13, (byte) 0x33, (byte) 0xf1, (byte) 0xc0, (byte) 0x9d,
611         (byte) 0xe7, (byte) 0xec, (byte) 0x6e, (byte) 0xad, (byte) 0xea, (byte) 0x5d, (byte) 0x69, (byte) 0xbb,
612         (byte) 0xab, (byte) 0x5b, (byte) 0xd8, (byte) 0x55, (byte) 0x56, (byte) 0xc8, (byte) 0xda, (byte) 0x81,
613         (byte) 0x41, (byte) 0xfb, (byte) 0xd3, (byte) 0x11, (byte) 0x6c, (byte) 0x97, (byte) 0xa7, (byte) 0xc3,
614         (byte) 0xf1, (byte) 0x31, (byte) 0xbf, (byte) 0xbe, (byte) 0x3f, (byte) 0xdb, (byte) 0x35, (byte) 0x85,
615         (byte) 0xb7, (byte) 0xb0, (byte) 0x75, (byte) 0x7f, (byte) 0xaf, (byte) 0xfb, (byte) 0x65, (byte) 0x61,
616         (byte) 0xc7, (byte) 0x0e, (byte) 0x63, (byte) 0xb5, (byte) 0x7d, (byte) 0x95, (byte) 0xe9, (byte) 0x16,
617         (byte) 0x9d, (byte) 0x6a, (byte) 0x00, (byte) 0x9f, (byte) 0x5e, (byte) 0xcd, (byte) 0xff, (byte) 0xa6,
618         (byte) 0xbc, (byte) 0x71, (byte) 0xf2, (byte) 0x2c, (byte) 0xd3, (byte) 0x68, (byte) 0xb9, (byte) 0x3f,
619         (byte) 0xaa, (byte) 0x06, (byte) 0xf1, (byte) 0x9c, (byte) 0x7e, (byte) 0xca, (byte) 0x4a, (byte) 0xfe,
620         (byte) 0xb1, (byte) 0x73, (byte) 0x19, (byte) 0x80, (byte) 0x05, (byte) 0xa6, (byte) 0x85, (byte) 0x14,
621         (byte) 0xda, (byte) 0x7a, (byte) 0x16, (byte) 0x7a, (byte) 0xc2, (byte) 0x46, (byte) 0x57, (byte) 0xa7,
622         (byte) 0xc0, (byte) 0xbf, (byte) 0xcd, (byte) 0xdc, (byte) 0x2f, (byte) 0x64, (byte) 0xf6, (byte) 0x6d,
623         (byte) 0xdc, (byte) 0xcb, (byte) 0x5a, (byte) 0x29, (byte) 0x95, (byte) 0x1c, (byte) 0xfe, (byte) 0xf2,
624         (byte) 0xda, (byte) 0x7e, (byte) 0xcb, (byte) 0x26, (byte) 0x12, (byte) 0xc6, (byte) 0xb0, (byte) 0xba,
625         (byte) 0x84, (byte) 0x9b, (byte) 0x4f, (byte) 0xba, (byte) 0x1b, (byte) 0x78, (byte) 0x25, (byte) 0xb8,
626         (byte) 0x8f, (byte) 0x2e, (byte) 0x51, (byte) 0x5f, (byte) 0x9e, (byte) 0xfc, (byte) 0x40, (byte) 0xbc,
627         (byte) 0x85, (byte) 0xcd, (byte) 0x86, (byte) 0x7f, (byte) 0x88, (byte) 0xc5, (byte) 0xaa, (byte) 0x2b,
628         (byte) 0x78, (byte) 0xb1, (byte) 0x9c, (byte) 0x51, (byte) 0x9a, (byte) 0xe1, (byte) 0xe1, (byte) 0xc0,
629         (byte) 0x40, (byte) 0x47, (byte) 0xcb, (byte) 0xa4, (byte) 0xb7, (byte) 0x6c, (byte) 0x31, (byte) 0xf2,
630         (byte) 0xc8, (byte) 0x9a, (byte) 0xad, (byte) 0x0b, (byte) 0xd3, (byte) 0xf6, (byte) 0x85, (byte) 0x9a,
631         (byte) 0x8f, (byte) 0x4f, (byte) 0xc9, (byte) 0xd8, (byte) 0x33, (byte) 0x7c, (byte) 0x45, (byte) 0x30,
632         (byte) 0xea, (byte) 0x17, (byte) 0xd3, (byte) 0xe3, (byte) 0x90, (byte) 0x2c, (byte) 0xda, (byte) 0xde,
633         (byte) 0x41, (byte) 0x17, (byte) 0x3f, (byte) 0x08, (byte) 0xb9, (byte) 0x34, (byte) 0xc0, (byte) 0xd1,
634     };
635 
636     private static final byte[] SHA512withRSA_Vector2Signature = new byte[] {
637         (byte) 0x19, (byte) 0xe2, (byte) 0xe5, (byte) 0xf3, (byte) 0x18, (byte) 0x83, (byte) 0xec, (byte) 0xf0,
638         (byte) 0xab, (byte) 0x50, (byte) 0x05, (byte) 0x4b, (byte) 0x5f, (byte) 0x22, (byte) 0xfc, (byte) 0x82,
639         (byte) 0x6d, (byte) 0xca, (byte) 0xe7, (byte) 0xbe, (byte) 0x23, (byte) 0x94, (byte) 0xfa, (byte) 0xf9,
640         (byte) 0xa4, (byte) 0x8a, (byte) 0x95, (byte) 0x4d, (byte) 0x14, (byte) 0x08, (byte) 0x8b, (byte) 0x5e,
641         (byte) 0x03, (byte) 0x1b, (byte) 0x74, (byte) 0xde, (byte) 0xc1, (byte) 0x45, (byte) 0x9c, (byte) 0xce,
642         (byte) 0x1d, (byte) 0xac, (byte) 0xab, (byte) 0xd3, (byte) 0xa8, (byte) 0xc3, (byte) 0xca, (byte) 0x67,
643         (byte) 0x80, (byte) 0xf6, (byte) 0x03, (byte) 0x46, (byte) 0x65, (byte) 0x77, (byte) 0x59, (byte) 0xbb,
644         (byte) 0xb8, (byte) 0x83, (byte) 0xee, (byte) 0xc2, (byte) 0x3e, (byte) 0x78, (byte) 0xdd, (byte) 0x89,
645         (byte) 0xcd, (byte) 0x9b, (byte) 0x78, (byte) 0x35, (byte) 0xa9, (byte) 0x09, (byte) 0xc8, (byte) 0x77,
646         (byte) 0xdd, (byte) 0xd3, (byte) 0xa0, (byte) 0x64, (byte) 0xb0, (byte) 0x74, (byte) 0x48, (byte) 0x51,
647         (byte) 0x4f, (byte) 0xa0, (byte) 0xae, (byte) 0x33, (byte) 0xb3, (byte) 0x28, (byte) 0xb0, (byte) 0xa8,
648         (byte) 0x78, (byte) 0x8f, (byte) 0xa2, (byte) 0x32, (byte) 0xa6, (byte) 0x0a, (byte) 0xaa, (byte) 0x09,
649         (byte) 0xb5, (byte) 0x8d, (byte) 0x4c, (byte) 0x44, (byte) 0x46, (byte) 0xb4, (byte) 0xd2, (byte) 0x06,
650         (byte) 0x6b, (byte) 0x8c, (byte) 0x51, (byte) 0x6e, (byte) 0x9c, (byte) 0xfa, (byte) 0x1f, (byte) 0x94,
651         (byte) 0x3e, (byte) 0x19, (byte) 0x9c, (byte) 0x63, (byte) 0xfe, (byte) 0xa9, (byte) 0x9a, (byte) 0xe3,
652         (byte) 0x6c, (byte) 0x82, (byte) 0x64, (byte) 0x5f, (byte) 0xca, (byte) 0xc2, (byte) 0x8d, (byte) 0x66,
653         (byte) 0xbe, (byte) 0x12, (byte) 0x6e, (byte) 0xb6, (byte) 0x35, (byte) 0x6d, (byte) 0xaa, (byte) 0xed,
654         (byte) 0x4b, (byte) 0x50, (byte) 0x08, (byte) 0x1c, (byte) 0xbf, (byte) 0x07, (byte) 0x70, (byte) 0x78,
655         (byte) 0xc0, (byte) 0xbb, (byte) 0xc5, (byte) 0x8d, (byte) 0x6c, (byte) 0x8d, (byte) 0x35, (byte) 0xff,
656         (byte) 0x04, (byte) 0x81, (byte) 0xd8, (byte) 0xf4, (byte) 0xd2, (byte) 0x4a, (byte) 0xc3, (byte) 0x05,
657         (byte) 0x23, (byte) 0xcb, (byte) 0xeb, (byte) 0x20, (byte) 0xb1, (byte) 0xd4, (byte) 0x2d, (byte) 0xd8,
658         (byte) 0x7a, (byte) 0xd4, (byte) 0x7e, (byte) 0xf6, (byte) 0xa9, (byte) 0xe8, (byte) 0x72, (byte) 0x69,
659         (byte) 0xfe, (byte) 0xab, (byte) 0x54, (byte) 0x4d, (byte) 0xd1, (byte) 0xf4, (byte) 0x6b, (byte) 0x83,
660         (byte) 0x31, (byte) 0x17, (byte) 0xed, (byte) 0x26, (byte) 0xe9, (byte) 0xd2, (byte) 0x5b, (byte) 0xad,
661         (byte) 0x42, (byte) 0x42, (byte) 0xa5, (byte) 0x8f, (byte) 0x98, (byte) 0x7c, (byte) 0x1b, (byte) 0x5c,
662         (byte) 0x8e, (byte) 0x88, (byte) 0x56, (byte) 0x20, (byte) 0x8e, (byte) 0x48, (byte) 0xf9, (byte) 0x4d,
663         (byte) 0x82, (byte) 0x91, (byte) 0xcb, (byte) 0xc8, (byte) 0x1c, (byte) 0x7c, (byte) 0xa5, (byte) 0x69,
664         (byte) 0x1b, (byte) 0x40, (byte) 0xc2, (byte) 0x4c, (byte) 0x25, (byte) 0x16, (byte) 0x4f, (byte) 0xfa,
665         (byte) 0x09, (byte) 0xeb, (byte) 0xf5, (byte) 0x6c, (byte) 0x55, (byte) 0x3c, (byte) 0x6e, (byte) 0xf7,
666         (byte) 0xc0, (byte) 0xc1, (byte) 0x34, (byte) 0xd1, (byte) 0x53, (byte) 0xa3, (byte) 0x69, (byte) 0x64,
667         (byte) 0xee, (byte) 0xf4, (byte) 0xf9, (byte) 0xc7, (byte) 0x96, (byte) 0x60, (byte) 0x84, (byte) 0x87,
668         (byte) 0xb4, (byte) 0xc7, (byte) 0x3c, (byte) 0x26, (byte) 0xa7, (byte) 0x3a, (byte) 0xbf, (byte) 0x95,
669     };
670 
671     private static final byte[] MD5withRSA_Vector2Signature = new byte[] {
672         (byte) 0x04, (byte) 0x17, (byte) 0x83, (byte) 0x10, (byte) 0xe2, (byte) 0x6e, (byte) 0xdf, (byte) 0xa9,
673         (byte) 0xae, (byte) 0xd2, (byte) 0xdc, (byte) 0x5f, (byte) 0x70, (byte) 0x1d, (byte) 0xaf, (byte) 0x54,
674         (byte) 0xc0, (byte) 0x5f, (byte) 0x0b, (byte) 0x2c, (byte) 0xe6, (byte) 0xd0, (byte) 0x00, (byte) 0x18,
675         (byte) 0x4c, (byte) 0xf6, (byte) 0x8f, (byte) 0x18, (byte) 0x10, (byte) 0x74, (byte) 0x90, (byte) 0x99,
676         (byte) 0xa9, (byte) 0x90, (byte) 0x3c, (byte) 0x5a, (byte) 0x38, (byte) 0xd3, (byte) 0x3d, (byte) 0x48,
677         (byte) 0xcf, (byte) 0x31, (byte) 0xaf, (byte) 0x12, (byte) 0x98, (byte) 0xfb, (byte) 0x66, (byte) 0xe8,
678         (byte) 0x58, (byte) 0xec, (byte) 0xca, (byte) 0xe1, (byte) 0x42, (byte) 0xf9, (byte) 0x84, (byte) 0x17,
679         (byte) 0x6f, (byte) 0x4c, (byte) 0x3e, (byte) 0xc4, (byte) 0x40, (byte) 0xc6, (byte) 0x70, (byte) 0xb0,
680         (byte) 0x38, (byte) 0xf3, (byte) 0x47, (byte) 0xeb, (byte) 0x6f, (byte) 0xcb, (byte) 0xea, (byte) 0x21,
681         (byte) 0x41, (byte) 0xf3, (byte) 0xa0, (byte) 0x3e, (byte) 0x42, (byte) 0xad, (byte) 0xa5, (byte) 0xad,
682         (byte) 0x5d, (byte) 0x2c, (byte) 0x1a, (byte) 0x8e, (byte) 0x3e, (byte) 0xb3, (byte) 0xa5, (byte) 0x78,
683         (byte) 0x3d, (byte) 0x56, (byte) 0x09, (byte) 0x93, (byte) 0xc9, (byte) 0x93, (byte) 0xd3, (byte) 0xd2,
684         (byte) 0x9a, (byte) 0xc5, (byte) 0xa5, (byte) 0x2e, (byte) 0xb2, (byte) 0xd8, (byte) 0x37, (byte) 0xc7,
685         (byte) 0x13, (byte) 0x1a, (byte) 0x0b, (byte) 0xda, (byte) 0x50, (byte) 0x28, (byte) 0x6d, (byte) 0x47,
686         (byte) 0x65, (byte) 0x52, (byte) 0xcd, (byte) 0xe7, (byte) 0xec, (byte) 0x57, (byte) 0x00, (byte) 0x41,
687         (byte) 0x34, (byte) 0x28, (byte) 0xb9, (byte) 0x8b, (byte) 0x03, (byte) 0x41, (byte) 0xb6, (byte) 0xd5,
688         (byte) 0xa8, (byte) 0xef, (byte) 0xd3, (byte) 0xdd, (byte) 0x80, (byte) 0xd5, (byte) 0x69, (byte) 0xe4,
689         (byte) 0xf0, (byte) 0x4d, (byte) 0xa4, (byte) 0x7d, (byte) 0x60, (byte) 0x2f, (byte) 0xef, (byte) 0x79,
690         (byte) 0x07, (byte) 0x75, (byte) 0xeb, (byte) 0xf7, (byte) 0x4b, (byte) 0x43, (byte) 0x41, (byte) 0xdb,
691         (byte) 0x33, (byte) 0xad, (byte) 0x9c, (byte) 0x7b, (byte) 0x78, (byte) 0x83, (byte) 0x34, (byte) 0x77,
692         (byte) 0xe4, (byte) 0x80, (byte) 0xbe, (byte) 0xe6, (byte) 0x6f, (byte) 0xdd, (byte) 0xac, (byte) 0xa5,
693         (byte) 0x37, (byte) 0xcf, (byte) 0xb5, (byte) 0x44, (byte) 0x11, (byte) 0x77, (byte) 0x96, (byte) 0x45,
694         (byte) 0xf9, (byte) 0xae, (byte) 0x48, (byte) 0xa6, (byte) 0xbe, (byte) 0x30, (byte) 0x32, (byte) 0xeb,
695         (byte) 0x43, (byte) 0x6f, (byte) 0x66, (byte) 0x39, (byte) 0x57, (byte) 0xf8, (byte) 0xe6, (byte) 0x60,
696         (byte) 0x31, (byte) 0xd0, (byte) 0xfc, (byte) 0xcf, (byte) 0x9f, (byte) 0xe5, (byte) 0x3d, (byte) 0xcf,
697         (byte) 0xbd, (byte) 0x7b, (byte) 0x13, (byte) 0x20, (byte) 0xce, (byte) 0x11, (byte) 0xfd, (byte) 0xe5,
698         (byte) 0xff, (byte) 0x90, (byte) 0x85, (byte) 0xdf, (byte) 0xca, (byte) 0x3d, (byte) 0xd9, (byte) 0x44,
699         (byte) 0x16, (byte) 0xc2, (byte) 0x32, (byte) 0x28, (byte) 0xc7, (byte) 0x01, (byte) 0x6d, (byte) 0xea,
700         (byte) 0xcb, (byte) 0x0d, (byte) 0x85, (byte) 0x08, (byte) 0x6f, (byte) 0xcb, (byte) 0x41, (byte) 0x6a,
701         (byte) 0x3c, (byte) 0x0f, (byte) 0x3d, (byte) 0x38, (byte) 0xb5, (byte) 0x61, (byte) 0xc5, (byte) 0x64,
702         (byte) 0x64, (byte) 0x81, (byte) 0x4c, (byte) 0xcd, (byte) 0xd1, (byte) 0x6a, (byte) 0x87, (byte) 0x28,
703         (byte) 0x02, (byte) 0xaf, (byte) 0x8f, (byte) 0x59, (byte) 0xe5, (byte) 0x67, (byte) 0x25, (byte) 0x00,
704     };
705 
706     /*
707      * openssl rsautl -raw -sign -inkey rsa.key | recode ../x1 | sed 's/0x/(byte) 0x/g'
708      */
709     private static final byte[] NONEwithRSA_Vector1Signature = new byte[] {
710         (byte) 0x35, (byte) 0x43, (byte) 0x38, (byte) 0x44, (byte) 0xAD, (byte) 0x3F,
711         (byte) 0x97, (byte) 0x02, (byte) 0xFB, (byte) 0x59, (byte) 0x1F, (byte) 0x4A,
712         (byte) 0x2B, (byte) 0xB9, (byte) 0x06, (byte) 0xEC, (byte) 0x66, (byte) 0xE6,
713         (byte) 0xD2, (byte) 0xC5, (byte) 0x8B, (byte) 0x7B, (byte) 0xE3, (byte) 0x18,
714         (byte) 0xBF, (byte) 0x07, (byte) 0xD6, (byte) 0x01, (byte) 0xF9, (byte) 0xD9,
715         (byte) 0x89, (byte) 0xC4, (byte) 0xDB, (byte) 0x00, (byte) 0x68, (byte) 0xFF,
716         (byte) 0x9B, (byte) 0x43, (byte) 0x90, (byte) 0xF2, (byte) 0xDB, (byte) 0x83,
717         (byte) 0xF4, (byte) 0x7E, (byte) 0xC6, (byte) 0x81, (byte) 0x01, (byte) 0x3A,
718         (byte) 0x0B, (byte) 0xE5, (byte) 0xED, (byte) 0x08, (byte) 0x73, (byte) 0x3E,
719         (byte) 0xE1, (byte) 0x3F, (byte) 0xDF, (byte) 0x1F, (byte) 0x07, (byte) 0x6D,
720         (byte) 0x22, (byte) 0x8D, (byte) 0xCC, (byte) 0x4E, (byte) 0xE3, (byte) 0x9A,
721         (byte) 0xBC, (byte) 0xCC, (byte) 0x8F, (byte) 0x9E, (byte) 0x9B, (byte) 0x02,
722         (byte) 0x48, (byte) 0x00, (byte) 0xAC, (byte) 0x9F, (byte) 0xA4, (byte) 0x8F,
723         (byte) 0x87, (byte) 0xA1, (byte) 0xA8, (byte) 0xE6, (byte) 0x9D, (byte) 0xCD,
724         (byte) 0x8B, (byte) 0x05, (byte) 0xE9, (byte) 0xD2, (byte) 0x05, (byte) 0x8D,
725         (byte) 0xC9, (byte) 0x95, (byte) 0x16, (byte) 0xD0, (byte) 0xCD, (byte) 0x43,
726         (byte) 0x25, (byte) 0x8A, (byte) 0x11, (byte) 0x46, (byte) 0xD7, (byte) 0x74,
727         (byte) 0x4C, (byte) 0xCF, (byte) 0x58, (byte) 0xF9, (byte) 0xA1, (byte) 0x30,
728         (byte) 0x84, (byte) 0x52, (byte) 0xC9, (byte) 0x01, (byte) 0x5F, (byte) 0x24,
729         (byte) 0x4C, (byte) 0xB1, (byte) 0x9F, (byte) 0x7D, (byte) 0x12, (byte) 0x38,
730         (byte) 0x27, (byte) 0x0F, (byte) 0x5E, (byte) 0xFF, (byte) 0xE0, (byte) 0x55,
731         (byte) 0x8B, (byte) 0xA3, (byte) 0xAD, (byte) 0x60, (byte) 0x35, (byte) 0x83,
732         (byte) 0x58, (byte) 0xAF, (byte) 0x99, (byte) 0xDE, (byte) 0x3F, (byte) 0x5D,
733         (byte) 0x80, (byte) 0x80, (byte) 0xFF, (byte) 0x9B, (byte) 0xDE, (byte) 0x5C,
734         (byte) 0xAB, (byte) 0x97, (byte) 0x43, (byte) 0x64, (byte) 0xD9, (byte) 0x9F,
735         (byte) 0xFB, (byte) 0x67, (byte) 0x65, (byte) 0xA5, (byte) 0x99, (byte) 0xE7,
736         (byte) 0xE6, (byte) 0xEB, (byte) 0x05, (byte) 0x95, (byte) 0xFC, (byte) 0x46,
737         (byte) 0x28, (byte) 0x4B, (byte) 0xD8, (byte) 0x8C, (byte) 0xF5, (byte) 0x0A,
738         (byte) 0xEB, (byte) 0x1F, (byte) 0x30, (byte) 0xEA, (byte) 0xE7, (byte) 0x67,
739         (byte) 0x11, (byte) 0x25, (byte) 0xF0, (byte) 0x44, (byte) 0x75, (byte) 0x74,
740         (byte) 0x94, (byte) 0x06, (byte) 0x78, (byte) 0xD0, (byte) 0x21, (byte) 0xF4,
741         (byte) 0x3F, (byte) 0xC8, (byte) 0xC4, (byte) 0x4A, (byte) 0x57, (byte) 0xBE,
742         (byte) 0x02, (byte) 0x3C, (byte) 0x93, (byte) 0xF6, (byte) 0x95, (byte) 0xFB,
743         (byte) 0xD1, (byte) 0x77, (byte) 0x8B, (byte) 0x43, (byte) 0xF0, (byte) 0xB9,
744         (byte) 0x7D, (byte) 0xE0, (byte) 0x32, (byte) 0xE1, (byte) 0x72, (byte) 0xB5,
745         (byte) 0x62, (byte) 0x3F, (byte) 0x86, (byte) 0xC3, (byte) 0xD4, (byte) 0x5F,
746         (byte) 0x5E, (byte) 0x54, (byte) 0x1B, (byte) 0x5B, (byte) 0xE6, (byte) 0x74,
747         (byte) 0xA1, (byte) 0x0B, (byte) 0xE5, (byte) 0x18, (byte) 0xD2, (byte) 0x4F,
748         (byte) 0x93, (byte) 0xF3, (byte) 0x09, (byte) 0x58, (byte) 0xCE, (byte) 0xF0,
749         (byte) 0xA3, (byte) 0x61, (byte) 0xE4, (byte) 0x6E, (byte) 0x46, (byte) 0x45,
750         (byte) 0x89, (byte) 0x50, (byte) 0xBD, (byte) 0x03, (byte) 0x3F, (byte) 0x38,
751         (byte) 0xDA, (byte) 0x5D, (byte) 0xD0, (byte) 0x1B, (byte) 0x1F, (byte) 0xB1,
752         (byte) 0xEE, (byte) 0x89, (byte) 0x59, (byte) 0xC5,
753     };
754 
755     /*
756      * echo "This is a signed message from Kenny Root." | openssl sha1 -binary -out digest.bin \
757      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
758      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha1 -pkeyopt rsa_pss_saltlen:20 \
759      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
760      */
761     private static final byte[] SHA1withRSAPSS_Vector2Signature = new byte[] {
762         (byte) 0x66, (byte) 0xE3, (byte) 0xA5, (byte) 0x20, (byte) 0xE9, (byte) 0x5D,
763         (byte) 0xDF, (byte) 0x99, (byte) 0xA6, (byte) 0x04, (byte) 0x77, (byte) 0xF8,
764         (byte) 0x39, (byte) 0x78, (byte) 0x74, (byte) 0xF5, (byte) 0xC2, (byte) 0x4E,
765         (byte) 0x9E, (byte) 0xEB, (byte) 0x24, (byte) 0xDE, (byte) 0xB4, (byte) 0x36,
766         (byte) 0x69, (byte) 0x1F, (byte) 0xAC, (byte) 0x01, (byte) 0xFF, (byte) 0x5A,
767         (byte) 0xE3, (byte) 0x89, (byte) 0x8A, (byte) 0xE9, (byte) 0x92, (byte) 0x32,
768         (byte) 0xA7, (byte) 0xA4, (byte) 0xC0, (byte) 0x25, (byte) 0x00, (byte) 0x14,
769         (byte) 0xFF, (byte) 0x38, (byte) 0x19, (byte) 0x37, (byte) 0x84, (byte) 0x1A,
770         (byte) 0x3D, (byte) 0xCA, (byte) 0xEE, (byte) 0xF3, (byte) 0xC6, (byte) 0x91,
771         (byte) 0xED, (byte) 0x02, (byte) 0xE6, (byte) 0x1D, (byte) 0x73, (byte) 0xDA,
772         (byte) 0xD4, (byte) 0x55, (byte) 0x93, (byte) 0x54, (byte) 0x9A, (byte) 0xE6,
773         (byte) 0x2E, (byte) 0x7D, (byte) 0x5C, (byte) 0x41, (byte) 0xAF, (byte) 0xED,
774         (byte) 0xAD, (byte) 0x8E, (byte) 0x7F, (byte) 0x47, (byte) 0x3B, (byte) 0x23,
775         (byte) 0xC3, (byte) 0xB8, (byte) 0xBB, (byte) 0xCD, (byte) 0x87, (byte) 0xC4,
776         (byte) 0xA3, (byte) 0x32, (byte) 0x16, (byte) 0x57, (byte) 0xCC, (byte) 0xB8,
777         (byte) 0xB6, (byte) 0x96, (byte) 0x84, (byte) 0x1A, (byte) 0xBC, (byte) 0xF8,
778         (byte) 0x09, (byte) 0x53, (byte) 0xB0, (byte) 0x9D, (byte) 0xE1, (byte) 0x6F,
779         (byte) 0xB2, (byte) 0xEB, (byte) 0x83, (byte) 0xDC, (byte) 0x61, (byte) 0x31,
780         (byte) 0xD7, (byte) 0x02, (byte) 0xB4, (byte) 0xD1, (byte) 0xBA, (byte) 0xBD,
781         (byte) 0xF0, (byte) 0x78, (byte) 0xC6, (byte) 0xBE, (byte) 0x1F, (byte) 0xB0,
782         (byte) 0xE1, (byte) 0xCA, (byte) 0x32, (byte) 0x57, (byte) 0x9F, (byte) 0x8C,
783         (byte) 0xD3, (byte) 0xBB, (byte) 0x04, (byte) 0x1B, (byte) 0x30, (byte) 0x74,
784         (byte) 0x5D, (byte) 0xEA, (byte) 0xD3, (byte) 0x6B, (byte) 0x74, (byte) 0x31,
785         (byte) 0x6F, (byte) 0x33, (byte) 0x5A, (byte) 0x70, (byte) 0x96, (byte) 0x8B,
786         (byte) 0xCB, (byte) 0x22, (byte) 0xF3, (byte) 0xAA, (byte) 0x74, (byte) 0x82,
787         (byte) 0xB2, (byte) 0x82, (byte) 0x71, (byte) 0x4D, (byte) 0x42, (byte) 0x13,
788         (byte) 0x3F, (byte) 0xEA, (byte) 0xE3, (byte) 0x39, (byte) 0xC5, (byte) 0x03,
789         (byte) 0x27, (byte) 0xFF, (byte) 0x78, (byte) 0xB2, (byte) 0xA6, (byte) 0x71,
790         (byte) 0x07, (byte) 0x1C, (byte) 0xB3, (byte) 0x97, (byte) 0xFB, (byte) 0xE8,
791         (byte) 0x85, (byte) 0x6D, (byte) 0x14, (byte) 0xDF, (byte) 0xF9, (byte) 0x7D,
792         (byte) 0x0D, (byte) 0x0C, (byte) 0x9F, (byte) 0xC3, (byte) 0xE2, (byte) 0xDB,
793         (byte) 0xE0, (byte) 0xA5, (byte) 0x05, (byte) 0xBC, (byte) 0x47, (byte) 0x36,
794         (byte) 0xEB, (byte) 0x1E, (byte) 0xBA, (byte) 0x60, (byte) 0x12, (byte) 0x19,
795         (byte) 0xA5, (byte) 0x7E, (byte) 0x55, (byte) 0x0C, (byte) 0x9B, (byte) 0xD4,
796         (byte) 0x9A, (byte) 0xE9, (byte) 0x72, (byte) 0x5C, (byte) 0x5B, (byte) 0xF4,
797         (byte) 0xAA, (byte) 0x4A, (byte) 0x12, (byte) 0x8B, (byte) 0xC2, (byte) 0x8E,
798         (byte) 0xC2, (byte) 0x9A, (byte) 0x3E, (byte) 0x0C, (byte) 0x40, (byte) 0xA4,
799         (byte) 0x0A, (byte) 0xFF, (byte) 0xF8, (byte) 0xC1, (byte) 0x85, (byte) 0x59,
800         (byte) 0xDA, (byte) 0xC6, (byte) 0x8C, (byte) 0x83, (byte) 0x2A, (byte) 0x68,
801         (byte) 0x84, (byte) 0x53, (byte) 0x17, (byte) 0x28, (byte) 0x78, (byte) 0x3F,
802         (byte) 0x5A, (byte) 0xA4, (byte) 0x04, (byte) 0xE6, (byte) 0x23, (byte) 0x8D,
803         (byte) 0x2A, (byte) 0x71, (byte) 0xC1, (byte) 0xBC, (byte) 0x1C, (byte) 0xFD,
804         (byte) 0x75, (byte) 0x16, (byte) 0x6E, (byte) 0x85,
805     };
806     private static final PSSParameterSpec SHA1withRSAPSS_Vector2Signature_ParameterSpec =
807             new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
808 
809     /*
810      * echo "This is a signed message from Kenny Root." | openssl sha1 -binary -out digest.bin \
811      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
812      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha1 -pkeyopt rsa_pss_saltlen:0 \
813      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
814      */
815     private static final byte[] SHA1withRSAPSS_NoSalt_Vector2Signature = new byte[] {
816         (byte) 0x31, (byte) 0x61, (byte) 0xA5, (byte) 0x47, (byte) 0x28, (byte) 0x44,
817         (byte) 0x48, (byte) 0x5A, (byte) 0xDA, (byte) 0x78, (byte) 0xA7, (byte) 0x85,
818         (byte) 0xE9, (byte) 0x64, (byte) 0x69, (byte) 0xCF, (byte) 0x14, (byte) 0x07,
819         (byte) 0x3F, (byte) 0xA8, (byte) 0xDB, (byte) 0xFC, (byte) 0xB7, (byte) 0x89,
820         (byte) 0x87, (byte) 0x74, (byte) 0xB9, (byte) 0x81, (byte) 0x37, (byte) 0x62,
821         (byte) 0xD1, (byte) 0x07, (byte) 0x0F, (byte) 0x3D, (byte) 0xDF, (byte) 0xA8,
822         (byte) 0x84, (byte) 0x38, (byte) 0x31, (byte) 0xEB, (byte) 0x17, (byte) 0x3F,
823         (byte) 0xE0, (byte) 0x28, (byte) 0x75, (byte) 0x1F, (byte) 0xE9, (byte) 0x4D,
824         (byte) 0xD3, (byte) 0x62, (byte) 0xFA, (byte) 0xCF, (byte) 0xCC, (byte) 0x2E,
825         (byte) 0xC7, (byte) 0x81, (byte) 0xE1, (byte) 0xEA, (byte) 0xEC, (byte) 0x78,
826         (byte) 0xFE, (byte) 0x19, (byte) 0x59, (byte) 0x54, (byte) 0x1D, (byte) 0x27,
827         (byte) 0xED, (byte) 0x0C, (byte) 0x54, (byte) 0xDF, (byte) 0xE3, (byte) 0x44,
828         (byte) 0x31, (byte) 0x21, (byte) 0x31, (byte) 0xA7, (byte) 0x23, (byte) 0xC4,
829         (byte) 0xE2, (byte) 0x69, (byte) 0x8A, (byte) 0xB3, (byte) 0x1A, (byte) 0x72,
830         (byte) 0x4F, (byte) 0x4E, (byte) 0x82, (byte) 0x86, (byte) 0x2D, (byte) 0x2B,
831         (byte) 0x85, (byte) 0xFE, (byte) 0x4A, (byte) 0x28, (byte) 0x90, (byte) 0xF7,
832         (byte) 0xDF, (byte) 0xD6, (byte) 0xB1, (byte) 0x3E, (byte) 0xC6, (byte) 0xFB,
833         (byte) 0x76, (byte) 0x7B, (byte) 0x3D, (byte) 0x12, (byte) 0x81, (byte) 0x6E,
834         (byte) 0xFD, (byte) 0x00, (byte) 0x7D, (byte) 0xD0, (byte) 0xDC, (byte) 0x25,
835         (byte) 0xD0, (byte) 0x86, (byte) 0x6C, (byte) 0xE8, (byte) 0x0F, (byte) 0x09,
836         (byte) 0x82, (byte) 0x74, (byte) 0x89, (byte) 0x79, (byte) 0x69, (byte) 0x73,
837         (byte) 0x37, (byte) 0x64, (byte) 0xEE, (byte) 0x53, (byte) 0x57, (byte) 0x20,
838         (byte) 0xFA, (byte) 0x0B, (byte) 0x4A, (byte) 0x5A, (byte) 0x4D, (byte) 0x33,
839         (byte) 0xAC, (byte) 0x8B, (byte) 0x04, (byte) 0xA5, (byte) 0x4A, (byte) 0x1A,
840         (byte) 0x9B, (byte) 0x66, (byte) 0xAA, (byte) 0x0B, (byte) 0x3D, (byte) 0x15,
841         (byte) 0xD9, (byte) 0x3E, (byte) 0x2F, (byte) 0xD2, (byte) 0xA1, (byte) 0x28,
842         (byte) 0x13, (byte) 0x59, (byte) 0x98, (byte) 0xC3, (byte) 0x45, (byte) 0x7C,
843         (byte) 0xEE, (byte) 0x60, (byte) 0xD0, (byte) 0xBD, (byte) 0x42, (byte) 0x16,
844         (byte) 0x84, (byte) 0x19, (byte) 0xF6, (byte) 0xD9, (byte) 0xF7, (byte) 0x7D,
845         (byte) 0x77, (byte) 0xAD, (byte) 0x60, (byte) 0xE2, (byte) 0xE3, (byte) 0x22,
846         (byte) 0xB9, (byte) 0xFA, (byte) 0xD5, (byte) 0xFA, (byte) 0x6E, (byte) 0x1F,
847         (byte) 0x69, (byte) 0x3F, (byte) 0xB1, (byte) 0xA7, (byte) 0x1A, (byte) 0x22,
848         (byte) 0xF7, (byte) 0x31, (byte) 0x97, (byte) 0x68, (byte) 0x62, (byte) 0x0F,
849         (byte) 0x39, (byte) 0xB0, (byte) 0xE7, (byte) 0x63, (byte) 0xAE, (byte) 0x65,
850         (byte) 0x69, (byte) 0xD0, (byte) 0xD3, (byte) 0x56, (byte) 0xC9, (byte) 0xA6,
851         (byte) 0xA4, (byte) 0xA5, (byte) 0xA4, (byte) 0x61, (byte) 0xA9, (byte) 0xC4,
852         (byte) 0x45, (byte) 0xCD, (byte) 0x49, (byte) 0x76, (byte) 0xC8, (byte) 0x53,
853         (byte) 0x46, (byte) 0xD0, (byte) 0x63, (byte) 0x35, (byte) 0x89, (byte) 0x04,
854         (byte) 0x22, (byte) 0xD7, (byte) 0xB6, (byte) 0x63, (byte) 0xAF, (byte) 0xC2,
855         (byte) 0x97, (byte) 0x10, (byte) 0xDF, (byte) 0xDE, (byte) 0xE6, (byte) 0x39,
856         (byte) 0x25, (byte) 0x2F, (byte) 0xEA, (byte) 0xD8, (byte) 0x56, (byte) 0x5A,
857         (byte) 0xC1, (byte) 0xB8, (byte) 0xCA, (byte) 0xC1, (byte) 0x8A, (byte) 0xB8,
858         (byte) 0x87, (byte) 0x2F, (byte) 0xCD, (byte) 0x21,
859     };
860     private static final PSSParameterSpec SHA1withRSAPSS_NoSalt_Vector2Signature_ParameterSpec =
861             new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 0, 1);
862 
863     /*
864      * echo "This is a signed message from Kenny Root." | openssl sha1 -binary -out digest.bin \
865      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
866      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha1 -pkeyopt rsa_pss_saltlen:234 \
867      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
868      */
869     private static final byte[] SHA1withRSAPSS_MaxSalt_Vector2Signature = new byte[] {
870         (byte) 0x49, (byte) 0xDB, (byte) 0xAD, (byte) 0x48, (byte) 0x7C, (byte) 0x06,
871         (byte) 0x03, (byte) 0x7C, (byte) 0x58, (byte) 0xE1, (byte) 0x38, (byte) 0x20,
872         (byte) 0x46, (byte) 0x28, (byte) 0x60, (byte) 0x64, (byte) 0x94, (byte) 0x51,
873         (byte) 0xA3, (byte) 0xD1, (byte) 0xC9, (byte) 0x52, (byte) 0xC6, (byte) 0x2A,
874         (byte) 0xB3, (byte) 0xCC, (byte) 0xD6, (byte) 0x19, (byte) 0x50, (byte) 0x99,
875         (byte) 0x60, (byte) 0x58, (byte) 0xA2, (byte) 0x86, (byte) 0xA8, (byte) 0x74,
876         (byte) 0x50, (byte) 0x8C, (byte) 0x0E, (byte) 0x32, (byte) 0x58, (byte) 0x56,
877         (byte) 0x6D, (byte) 0x30, (byte) 0x38, (byte) 0xFB, (byte) 0x26, (byte) 0xC3,
878         (byte) 0xFD, (byte) 0x8E, (byte) 0x36, (byte) 0x73, (byte) 0x82, (byte) 0x9A,
879         (byte) 0xB4, (byte) 0xE5, (byte) 0x22, (byte) 0x96, (byte) 0x55, (byte) 0x3C,
880         (byte) 0x18, (byte) 0xD7, (byte) 0x46, (byte) 0xF1, (byte) 0x7C, (byte) 0xE6,
881         (byte) 0x8E, (byte) 0x0A, (byte) 0x18, (byte) 0xA7, (byte) 0x29, (byte) 0x96,
882         (byte) 0x8D, (byte) 0xFC, (byte) 0x0E, (byte) 0xBE, (byte) 0x91, (byte) 0xA0,
883         (byte) 0xF8, (byte) 0xE2, (byte) 0x70, (byte) 0x5A, (byte) 0xE3, (byte) 0x76,
884         (byte) 0xAC, (byte) 0x18, (byte) 0x10, (byte) 0xB4, (byte) 0xB1, (byte) 0xFF,
885         (byte) 0x58, (byte) 0xBC, (byte) 0x10, (byte) 0xF5, (byte) 0x88, (byte) 0x2F,
886         (byte) 0x0B, (byte) 0x10, (byte) 0x9D, (byte) 0x52, (byte) 0x2D, (byte) 0x42,
887         (byte) 0xDB, (byte) 0xFD, (byte) 0xA7, (byte) 0x23, (byte) 0x3C, (byte) 0x4B,
888         (byte) 0xB3, (byte) 0xD2, (byte) 0x96, (byte) 0x1B, (byte) 0xCE, (byte) 0xB3,
889         (byte) 0xA3, (byte) 0xC3, (byte) 0x42, (byte) 0xA4, (byte) 0x0E, (byte) 0x35,
890         (byte) 0x5C, (byte) 0xC2, (byte) 0x32, (byte) 0xC7, (byte) 0x8C, (byte) 0xFC,
891         (byte) 0x7F, (byte) 0xE0, (byte) 0xF7, (byte) 0x1D, (byte) 0x38, (byte) 0x21,
892         (byte) 0x3C, (byte) 0xDF, (byte) 0x82, (byte) 0x1A, (byte) 0xBD, (byte) 0x83,
893         (byte) 0xE9, (byte) 0x56, (byte) 0xF0, (byte) 0xF1, (byte) 0x54, (byte) 0x76,
894         (byte) 0xE3, (byte) 0xCE, (byte) 0x86, (byte) 0x69, (byte) 0xC2, (byte) 0x61,
895         (byte) 0x6D, (byte) 0x8E, (byte) 0xF5, (byte) 0xA3, (byte) 0x61, (byte) 0xCA,
896         (byte) 0x16, (byte) 0xCB, (byte) 0x7A, (byte) 0xF5, (byte) 0xBF, (byte) 0x36,
897         (byte) 0xCB, (byte) 0x7D, (byte) 0xB1, (byte) 0xE9, (byte) 0x70, (byte) 0x41,
898         (byte) 0xCF, (byte) 0x89, (byte) 0x51, (byte) 0x13, (byte) 0xCC, (byte) 0x95,
899         (byte) 0x50, (byte) 0xC8, (byte) 0xB6, (byte) 0x30, (byte) 0x35, (byte) 0xE3,
900         (byte) 0x13, (byte) 0x08, (byte) 0xF6, (byte) 0xBE, (byte) 0x20, (byte) 0xF1,
901         (byte) 0x48, (byte) 0x4D, (byte) 0x46, (byte) 0x95, (byte) 0xFE, (byte) 0x9E,
902         (byte) 0xD2, (byte) 0xD5, (byte) 0x29, (byte) 0x81, (byte) 0x2E, (byte) 0x0F,
903         (byte) 0x6F, (byte) 0xA7, (byte) 0x02, (byte) 0x15, (byte) 0xCA, (byte) 0x75,
904         (byte) 0x77, (byte) 0x29, (byte) 0x7C, (byte) 0x3A, (byte) 0xE3, (byte) 0x2B,
905         (byte) 0xD7, (byte) 0x3D, (byte) 0x5C, (byte) 0x94, (byte) 0x3B, (byte) 0x2A,
906         (byte) 0x91, (byte) 0xDB, (byte) 0xFA, (byte) 0x69, (byte) 0x47, (byte) 0x1C,
907         (byte) 0x2C, (byte) 0x46, (byte) 0x49, (byte) 0xE6, (byte) 0x37, (byte) 0x5D,
908         (byte) 0x78, (byte) 0x71, (byte) 0x76, (byte) 0xC1, (byte) 0xB6, (byte) 0x2E,
909         (byte) 0x4E, (byte) 0x3C, (byte) 0x83, (byte) 0x6F, (byte) 0x82, (byte) 0xC3,
910         (byte) 0xD8, (byte) 0x50, (byte) 0xD7, (byte) 0x1B, (byte) 0xAF, (byte) 0xF9,
911         (byte) 0xE3, (byte) 0xF1, (byte) 0x47, (byte) 0xC8, (byte) 0x12, (byte) 0x86,
912         (byte) 0x82, (byte) 0x9D, (byte) 0x3F, (byte) 0xCE,
913     };
914     private static final PSSParameterSpec SHA1withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec =
915             new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 234, 1);
916 
917     /*
918      * echo "This is a signed message from Kenny Root." | openssl sha224 -binary -out digest.bin \
919      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
920      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha224 -pkeyopt rsa_pss_saltlen:28 \
921      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
922      */
923     private static final byte[] SHA224withRSAPSS_Vector2Signature = new byte[] {
924         (byte) 0x86, (byte) 0x41, (byte) 0xCC, (byte) 0x4B, (byte) 0x82, (byte) 0x74,
925         (byte) 0x04, (byte) 0x43, (byte) 0x8C, (byte) 0xAB, (byte) 0xF6, (byte) 0x3B,
926         (byte) 0xFB, (byte) 0x94, (byte) 0xBC, (byte) 0x4C, (byte) 0x0A, (byte) 0xFE,
927         (byte) 0x0F, (byte) 0x4F, (byte) 0x0F, (byte) 0x9F, (byte) 0x84, (byte) 0x35,
928         (byte) 0x57, (byte) 0x8B, (byte) 0x8D, (byte) 0xC3, (byte) 0x58, (byte) 0xA6,
929         (byte) 0x70, (byte) 0xAC, (byte) 0x40, (byte) 0x6D, (byte) 0xBC, (byte) 0xC1,
930         (byte) 0x6A, (byte) 0xFA, (byte) 0x31, (byte) 0x3B, (byte) 0x7A, (byte) 0x23,
931         (byte) 0xCA, (byte) 0x1F, (byte) 0xCD, (byte) 0xA7, (byte) 0xE3, (byte) 0xD6,
932         (byte) 0x7C, (byte) 0x2C, (byte) 0xF3, (byte) 0x6F, (byte) 0xF5, (byte) 0x82,
933         (byte) 0x9E, (byte) 0x18, (byte) 0x70, (byte) 0x90, (byte) 0xE6, (byte) 0xA3,
934         (byte) 0x44, (byte) 0x61, (byte) 0xB6, (byte) 0x46, (byte) 0x9B, (byte) 0x0D,
935         (byte) 0xE5, (byte) 0x3C, (byte) 0xAE, (byte) 0x22, (byte) 0xF4, (byte) 0x87,
936         (byte) 0xB7, (byte) 0x03, (byte) 0xD8, (byte) 0x42, (byte) 0x33, (byte) 0x4E,
937         (byte) 0xCC, (byte) 0x7A, (byte) 0xDF, (byte) 0xD7, (byte) 0x57, (byte) 0xEB,
938         (byte) 0x51, (byte) 0x6C, (byte) 0xB1, (byte) 0x99, (byte) 0x4D, (byte) 0x94,
939         (byte) 0x82, (byte) 0xA7, (byte) 0x69, (byte) 0x85, (byte) 0x8D, (byte) 0x82,
940         (byte) 0x18, (byte) 0xE4, (byte) 0x53, (byte) 0xF5, (byte) 0x9F, (byte) 0x82,
941         (byte) 0x1C, (byte) 0xE1, (byte) 0x25, (byte) 0x1C, (byte) 0x8E, (byte) 0xE7,
942         (byte) 0xC1, (byte) 0xEC, (byte) 0xBE, (byte) 0x3F, (byte) 0xC3, (byte) 0xED,
943         (byte) 0x41, (byte) 0x89, (byte) 0x94, (byte) 0x13, (byte) 0x11, (byte) 0x75,
944         (byte) 0x3F, (byte) 0x38, (byte) 0x52, (byte) 0x58, (byte) 0xAB, (byte) 0x88,
945         (byte) 0x01, (byte) 0x30, (byte) 0xB4, (byte) 0xCD, (byte) 0x45, (byte) 0x3E,
946         (byte) 0x1A, (byte) 0x5F, (byte) 0x36, (byte) 0xF8, (byte) 0x51, (byte) 0x90,
947         (byte) 0x6E, (byte) 0x6F, (byte) 0x31, (byte) 0x9D, (byte) 0x40, (byte) 0x90,
948         (byte) 0x1A, (byte) 0xA8, (byte) 0x10, (byte) 0xEF, (byte) 0x9D, (byte) 0xF8,
949         (byte) 0xB0, (byte) 0x03, (byte) 0x01, (byte) 0xFB, (byte) 0xD8, (byte) 0x3D,
950         (byte) 0x83, (byte) 0x79, (byte) 0x01, (byte) 0xA7, (byte) 0x82, (byte) 0xC2,
951         (byte) 0x46, (byte) 0x35, (byte) 0x68, (byte) 0xD2, (byte) 0x08, (byte) 0x81,
952         (byte) 0x31, (byte) 0x14, (byte) 0xE8, (byte) 0x13, (byte) 0x8C, (byte) 0xD4,
953         (byte) 0xC4, (byte) 0xCB, (byte) 0xB9, (byte) 0x85, (byte) 0x25, (byte) 0x93,
954         (byte) 0x40, (byte) 0x88, (byte) 0x34, (byte) 0x11, (byte) 0xDA, (byte) 0xFF,
955         (byte) 0xEF, (byte) 0x4D, (byte) 0xDC, (byte) 0x31, (byte) 0x74, (byte) 0x7B,
956         (byte) 0x5E, (byte) 0xA7, (byte) 0x51, (byte) 0x15, (byte) 0x13, (byte) 0xB1,
957         (byte) 0x9E, (byte) 0x06, (byte) 0x51, (byte) 0xBA, (byte) 0x11, (byte) 0xDA,
958         (byte) 0x64, (byte) 0x1B, (byte) 0x78, (byte) 0x76, (byte) 0x57, (byte) 0x96,
959         (byte) 0xF3, (byte) 0x1B, (byte) 0x86, (byte) 0xB2, (byte) 0xF3, (byte) 0x66,
960         (byte) 0x64, (byte) 0x2B, (byte) 0x04, (byte) 0x81, (byte) 0x8C, (byte) 0xDC,
961         (byte) 0xE0, (byte) 0xEA, (byte) 0x66, (byte) 0x62, (byte) 0x44, (byte) 0x31,
962         (byte) 0xA2, (byte) 0x19, (byte) 0xF1, (byte) 0x77, (byte) 0x67, (byte) 0x58,
963         (byte) 0x18, (byte) 0x5B, (byte) 0xCB, (byte) 0xBA, (byte) 0x28, (byte) 0x91,
964         (byte) 0x47, (byte) 0x5B, (byte) 0x4F, (byte) 0x17, (byte) 0x23, (byte) 0x2A,
965         (byte) 0xE4, (byte) 0xB0, (byte) 0xAE, (byte) 0x82, (byte) 0x4E, (byte) 0xCA,
966         (byte) 0xA6, (byte) 0x12, (byte) 0xCA, (byte) 0x70,
967     };
968     private static final PSSParameterSpec SHA224withRSAPSS_Vector2Signature_ParameterSpec =
969             new PSSParameterSpec("SHA-224", "MGF1", new MGF1ParameterSpec("SHA-224"), 28, 1);
970 
971     /*
972      * echo "This is a signed message from Kenny Root." | openssl sha224 -binary -out digest.bin \
973      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
974      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha224 -pkeyopt rsa_pss_saltlen:0 \
975      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
976      */
977     private static final byte[] SHA224withRSAPSS_NoSalt_Vector2Signature = new byte[] {
978         (byte) 0xD8, (byte) 0x38, (byte) 0x48, (byte) 0xCD, (byte) 0xA4, (byte) 0x09,
979         (byte) 0x36, (byte) 0x35, (byte) 0x47, (byte) 0x55, (byte) 0xDB, (byte) 0x6C,
980         (byte) 0x2D, (byte) 0x83, (byte) 0x17, (byte) 0x10, (byte) 0x3E, (byte) 0xCE,
981         (byte) 0x95, (byte) 0x02, (byte) 0x58, (byte) 0xCE, (byte) 0xA8, (byte) 0x02,
982         (byte) 0x44, (byte) 0xB7, (byte) 0xE4, (byte) 0x32, (byte) 0x3D, (byte) 0x50,
983         (byte) 0xE1, (byte) 0x8C, (byte) 0xF3, (byte) 0x24, (byte) 0x6F, (byte) 0xA4,
984         (byte) 0x2D, (byte) 0xD7, (byte) 0xFB, (byte) 0x70, (byte) 0x97, (byte) 0xBE,
985         (byte) 0xED, (byte) 0x27, (byte) 0x2D, (byte) 0x22, (byte) 0xDC, (byte) 0x62,
986         (byte) 0x97, (byte) 0x66, (byte) 0x39, (byte) 0xE0, (byte) 0x36, (byte) 0x5F,
987         (byte) 0x07, (byte) 0x78, (byte) 0xAF, (byte) 0x5E, (byte) 0xDC, (byte) 0xFD,
988         (byte) 0x21, (byte) 0xA8, (byte) 0xD5, (byte) 0xA7, (byte) 0xD1, (byte) 0xBA,
989         (byte) 0x1C, (byte) 0xDA, (byte) 0xCA, (byte) 0x80, (byte) 0x72, (byte) 0x8A,
990         (byte) 0xDD, (byte) 0x5C, (byte) 0x16, (byte) 0x6A, (byte) 0x47, (byte) 0xFC,
991         (byte) 0x11, (byte) 0x42, (byte) 0x7E, (byte) 0x4E, (byte) 0x3F, (byte) 0x49,
992         (byte) 0xCF, (byte) 0x2F, (byte) 0x54, (byte) 0xD7, (byte) 0x13, (byte) 0x76,
993         (byte) 0x5D, (byte) 0xE9, (byte) 0x2A, (byte) 0x29, (byte) 0xCC, (byte) 0x73,
994         (byte) 0xDB, (byte) 0xE5, (byte) 0xDE, (byte) 0x48, (byte) 0xA2, (byte) 0xE9,
995         (byte) 0xD1, (byte) 0xD0, (byte) 0x35, (byte) 0xFE, (byte) 0xA1, (byte) 0x1C,
996         (byte) 0x13, (byte) 0x04, (byte) 0x75, (byte) 0x77, (byte) 0xF4, (byte) 0x55,
997         (byte) 0x03, (byte) 0xC4, (byte) 0x6D, (byte) 0xAC, (byte) 0x25, (byte) 0x1D,
998         (byte) 0x57, (byte) 0xFF, (byte) 0x0D, (byte) 0xE0, (byte) 0x91, (byte) 0xEA,
999         (byte) 0xF6, (byte) 0x1F, (byte) 0x3F, (byte) 0x69, (byte) 0xD6, (byte) 0x00,
1000         (byte) 0xBD, (byte) 0x89, (byte) 0xEA, (byte) 0xD3, (byte) 0x31, (byte) 0x80,
1001         (byte) 0x5E, (byte) 0x04, (byte) 0x4C, (byte) 0x59, (byte) 0xDE, (byte) 0xD0,
1002         (byte) 0x62, (byte) 0x93, (byte) 0x3B, (byte) 0xC9, (byte) 0x9F, (byte) 0xE7,
1003         (byte) 0x69, (byte) 0xC0, (byte) 0xB8, (byte) 0xED, (byte) 0xBF, (byte) 0x0D,
1004         (byte) 0x60, (byte) 0x28, (byte) 0x55, (byte) 0x20, (byte) 0x0C, (byte) 0x9F,
1005         (byte) 0xA2, (byte) 0x42, (byte) 0x34, (byte) 0x95, (byte) 0xAE, (byte) 0xF8,
1006         (byte) 0x67, (byte) 0x7C, (byte) 0xF1, (byte) 0xA0, (byte) 0xC0, (byte) 0x74,
1007         (byte) 0xF2, (byte) 0xDF, (byte) 0x75, (byte) 0x5B, (byte) 0x6E, (byte) 0x2F,
1008         (byte) 0xFB, (byte) 0x1F, (byte) 0xDD, (byte) 0xC3, (byte) 0xD3, (byte) 0x90,
1009         (byte) 0x0A, (byte) 0x33, (byte) 0xF6, (byte) 0x03, (byte) 0x16, (byte) 0xC4,
1010         (byte) 0xF8, (byte) 0xED, (byte) 0xB7, (byte) 0x45, (byte) 0x39, (byte) 0x5D,
1011         (byte) 0x7C, (byte) 0xF8, (byte) 0x82, (byte) 0xCE, (byte) 0x7D, (byte) 0xFB,
1012         (byte) 0x02, (byte) 0x2D, (byte) 0xE0, (byte) 0x96, (byte) 0x35, (byte) 0x60,
1013         (byte) 0x5D, (byte) 0xBC, (byte) 0x35, (byte) 0x80, (byte) 0x4C, (byte) 0x39,
1014         (byte) 0x7C, (byte) 0xE7, (byte) 0xD4, (byte) 0xB4, (byte) 0x19, (byte) 0xD1,
1015         (byte) 0xE5, (byte) 0x8E, (byte) 0x6D, (byte) 0x25, (byte) 0x0C, (byte) 0xB9,
1016         (byte) 0x0C, (byte) 0x8D, (byte) 0x45, (byte) 0xE4, (byte) 0x67, (byte) 0x73,
1017         (byte) 0xCF, (byte) 0x87, (byte) 0x7C, (byte) 0x78, (byte) 0xAA, (byte) 0xB9,
1018         (byte) 0x42, (byte) 0xAE, (byte) 0x7F, (byte) 0xB8, (byte) 0xEC, (byte) 0x4F,
1019         (byte) 0xD2, (byte) 0x85, (byte) 0x01, (byte) 0x80, (byte) 0x00, (byte) 0xBD,
1020         (byte) 0xF5, (byte) 0xEA, (byte) 0x44, (byte) 0x6D,
1021     };
1022     private static final PSSParameterSpec SHA224withRSAPSS_NoSalt_Vector2Signature_ParameterSpec =
1023             new PSSParameterSpec("SHA-224", "MGF1", new MGF1ParameterSpec("SHA-224"), 0, 1);
1024 
1025     /*
1026      * echo "This is a signed message from Kenny Root." | openssl sha224 -binary -out digest.bin \
1027      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1028      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha224 -pkeyopt rsa_pss_saltlen:226 \
1029      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1030      */
1031     private static final byte[] SHA224withRSAPSS_MaxSalt_Vector2Signature = new byte[] {
1032         (byte) 0x2C, (byte) 0x19, (byte) 0x5E, (byte) 0x63, (byte) 0xC5, (byte) 0x32,
1033         (byte) 0xC3, (byte) 0xC7, (byte) 0x52, (byte) 0xE9, (byte) 0x69, (byte) 0x4C,
1034         (byte) 0x04, (byte) 0xE5, (byte) 0x4A, (byte) 0xF2, (byte) 0x72, (byte) 0x78,
1035         (byte) 0xBF, (byte) 0xC5, (byte) 0x8D, (byte) 0x5A, (byte) 0x71, (byte) 0xEF,
1036         (byte) 0xA9, (byte) 0x58, (byte) 0x77, (byte) 0x94, (byte) 0x49, (byte) 0x71,
1037         (byte) 0xBF, (byte) 0x45, (byte) 0x3E, (byte) 0xA4, (byte) 0x2E, (byte) 0x33,
1038         (byte) 0x9B, (byte) 0x4E, (byte) 0xA4, (byte) 0x95, (byte) 0x07, (byte) 0x9C,
1039         (byte) 0xAA, (byte) 0xC4, (byte) 0xA8, (byte) 0x60, (byte) 0xBC, (byte) 0xCD,
1040         (byte) 0xC3, (byte) 0x45, (byte) 0xE6, (byte) 0xBC, (byte) 0xAD, (byte) 0xB6,
1041         (byte) 0xF3, (byte) 0x0E, (byte) 0xF6, (byte) 0xD5, (byte) 0xCF, (byte) 0x33,
1042         (byte) 0xA3, (byte) 0x82, (byte) 0x62, (byte) 0x52, (byte) 0x95, (byte) 0xA8,
1043         (byte) 0x0E, (byte) 0xD4, (byte) 0xAC, (byte) 0x1F, (byte) 0x9A, (byte) 0xDC,
1044         (byte) 0x00, (byte) 0xD6, (byte) 0x78, (byte) 0xEA, (byte) 0x53, (byte) 0x00,
1045         (byte) 0x19, (byte) 0xE3, (byte) 0x81, (byte) 0x7C, (byte) 0x7A, (byte) 0x8E,
1046         (byte) 0x30, (byte) 0x57, (byte) 0xB7, (byte) 0x81, (byte) 0xD7, (byte) 0x4D,
1047         (byte) 0x1D, (byte) 0xCB, (byte) 0x99, (byte) 0x8D, (byte) 0xE4, (byte) 0xFA,
1048         (byte) 0x6E, (byte) 0x4E, (byte) 0xA6, (byte) 0xDA, (byte) 0x13, (byte) 0x92,
1049         (byte) 0x31, (byte) 0x7C, (byte) 0x2B, (byte) 0x3A, (byte) 0xA0, (byte) 0xF1,
1050         (byte) 0x03, (byte) 0x83, (byte) 0x12, (byte) 0xD1, (byte) 0x23, (byte) 0xED,
1051         (byte) 0xC4, (byte) 0x01, (byte) 0x57, (byte) 0x63, (byte) 0xAF, (byte) 0x40,
1052         (byte) 0x15, (byte) 0xEC, (byte) 0xB8, (byte) 0x5A, (byte) 0xCE, (byte) 0x3D,
1053         (byte) 0x3E, (byte) 0xCD, (byte) 0xD8, (byte) 0xF3, (byte) 0x76, (byte) 0xCA,
1054         (byte) 0x23, (byte) 0x20, (byte) 0x68, (byte) 0x17, (byte) 0x5B, (byte) 0x7F,
1055         (byte) 0xBC, (byte) 0x22, (byte) 0x67, (byte) 0x2A, (byte) 0x91, (byte) 0x05,
1056         (byte) 0xB3, (byte) 0x85, (byte) 0x60, (byte) 0xD8, (byte) 0x76, (byte) 0xD5,
1057         (byte) 0x2B, (byte) 0x9C, (byte) 0x80, (byte) 0xB6, (byte) 0xEA, (byte) 0x1E,
1058         (byte) 0x05, (byte) 0xC7, (byte) 0x95, (byte) 0x2C, (byte) 0x4F, (byte) 0x14,
1059         (byte) 0x5F, (byte) 0xEE, (byte) 0x08, (byte) 0x32, (byte) 0xF7, (byte) 0x12,
1060         (byte) 0x2B, (byte) 0xCD, (byte) 0xF3, (byte) 0x83, (byte) 0x7C, (byte) 0xCE,
1061         (byte) 0x04, (byte) 0x8A, (byte) 0x36, (byte) 0x3D, (byte) 0xB2, (byte) 0x97,
1062         (byte) 0x15, (byte) 0xDB, (byte) 0xD6, (byte) 0xFA, (byte) 0x53, (byte) 0x29,
1063         (byte) 0xD1, (byte) 0x43, (byte) 0x55, (byte) 0xDD, (byte) 0xAE, (byte) 0xA7,
1064         (byte) 0xB4, (byte) 0x2C, (byte) 0xD9, (byte) 0xA7, (byte) 0x74, (byte) 0xA8,
1065         (byte) 0x08, (byte) 0xD6, (byte) 0xC2, (byte) 0x05, (byte) 0xBF, (byte) 0x67,
1066         (byte) 0x3B, (byte) 0xBA, (byte) 0x8D, (byte) 0x99, (byte) 0xC1, (byte) 0x14,
1067         (byte) 0x1A, (byte) 0x32, (byte) 0xCA, (byte) 0xD5, (byte) 0xCC, (byte) 0xF9,
1068         (byte) 0x64, (byte) 0x07, (byte) 0x5B, (byte) 0xB8, (byte) 0xA9, (byte) 0x69,
1069         (byte) 0xED, (byte) 0x01, (byte) 0xCD, (byte) 0xD2, (byte) 0x88, (byte) 0x67,
1070         (byte) 0xFF, (byte) 0x92, (byte) 0xA3, (byte) 0xC6, (byte) 0x97, (byte) 0x97,
1071         (byte) 0xA1, (byte) 0xC5, (byte) 0x15, (byte) 0xC8, (byte) 0xB6, (byte) 0xFE,
1072         (byte) 0x4A, (byte) 0x07, (byte) 0x2E, (byte) 0x46, (byte) 0x3F, (byte) 0x27,
1073         (byte) 0xB8, (byte) 0xEE, (byte) 0x69, (byte) 0xCB, (byte) 0xDC, (byte) 0x30,
1074         (byte) 0x19, (byte) 0x77, (byte) 0xC5, (byte) 0xEF,
1075     };
1076     private static final PSSParameterSpec SHA224withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec =
1077             new PSSParameterSpec("SHA-224", "MGF1", new MGF1ParameterSpec("SHA-224"), 226, 1);
1078 
1079     /*
1080      * echo "This is a signed message from Kenny Root." | openssl sha256 -binary -out digest.bin \
1081      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1082      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha256 -pkeyopt rsa_pss_saltlen:32 \
1083      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1084      */
1085     private static final byte[] SHA256withRSAPSS_Vector2Signature = new byte[] {
1086         (byte) 0x94, (byte) 0x33, (byte) 0xCB, (byte) 0x9E, (byte) 0x2C, (byte) 0x17,
1087         (byte) 0x46, (byte) 0xB3, (byte) 0x8F, (byte) 0xB7, (byte) 0x93, (byte) 0x98,
1088         (byte) 0xA3, (byte) 0x45, (byte) 0xEA, (byte) 0xD4, (byte) 0x51, (byte) 0x60,
1089         (byte) 0x3E, (byte) 0x00, (byte) 0xA3, (byte) 0x93, (byte) 0x05, (byte) 0x0F,
1090         (byte) 0xCB, (byte) 0x6E, (byte) 0xFF, (byte) 0xA5, (byte) 0x97, (byte) 0x18,
1091         (byte) 0xF6, (byte) 0xED, (byte) 0x6B, (byte) 0x6C, (byte) 0xAD, (byte) 0x9C,
1092         (byte) 0x73, (byte) 0x63, (byte) 0x9C, (byte) 0x5B, (byte) 0xA5, (byte) 0xA1,
1093         (byte) 0x42, (byte) 0xA3, (byte) 0x0E, (byte) 0x32, (byte) 0xF5, (byte) 0xF0,
1094         (byte) 0x55, (byte) 0xEE, (byte) 0x58, (byte) 0xC1, (byte) 0xBD, (byte) 0x99,
1095         (byte) 0x0A, (byte) 0x2B, (byte) 0xFD, (byte) 0xBD, (byte) 0x1E, (byte) 0x23,
1096         (byte) 0xEF, (byte) 0x99, (byte) 0x7D, (byte) 0xC1, (byte) 0xE2, (byte) 0xD5,
1097         (byte) 0x71, (byte) 0x6C, (byte) 0x96, (byte) 0x70, (byte) 0xC3, (byte) 0x75,
1098         (byte) 0x48, (byte) 0x83, (byte) 0x85, (byte) 0x5E, (byte) 0xC6, (byte) 0x3A,
1099         (byte) 0xFF, (byte) 0xE5, (byte) 0xF1, (byte) 0x6B, (byte) 0x85, (byte) 0x7B,
1100         (byte) 0x61, (byte) 0xA6, (byte) 0xB1, (byte) 0xCF, (byte) 0x60, (byte) 0x09,
1101         (byte) 0x32, (byte) 0xAF, (byte) 0xEF, (byte) 0x95, (byte) 0xA4, (byte) 0x1B,
1102         (byte) 0xD6, (byte) 0xFA, (byte) 0xD0, (byte) 0xD7, (byte) 0x17, (byte) 0xCA,
1103         (byte) 0xB0, (byte) 0x19, (byte) 0x21, (byte) 0x7F, (byte) 0x5E, (byte) 0x9B,
1104         (byte) 0xBB, (byte) 0xB8, (byte) 0xE0, (byte) 0xB1, (byte) 0x95, (byte) 0xB3,
1105         (byte) 0xDA, (byte) 0x0B, (byte) 0xB8, (byte) 0xFA, (byte) 0x15, (byte) 0x75,
1106         (byte) 0x73, (byte) 0x88, (byte) 0xC8, (byte) 0x45, (byte) 0x33, (byte) 0xD1,
1107         (byte) 0x5C, (byte) 0xB7, (byte) 0xFB, (byte) 0x38, (byte) 0x05, (byte) 0xA0,
1108         (byte) 0x85, (byte) 0x99, (byte) 0x2C, (byte) 0xB1, (byte) 0xC2, (byte) 0xFE,
1109         (byte) 0xAC, (byte) 0x5D, (byte) 0x2C, (byte) 0x1B, (byte) 0xD3, (byte) 0x42,
1110         (byte) 0x81, (byte) 0xC8, (byte) 0x1C, (byte) 0xB7, (byte) 0x53, (byte) 0x7E,
1111         (byte) 0xC5, (byte) 0x9F, (byte) 0x84, (byte) 0x97, (byte) 0x6F, (byte) 0x00,
1112         (byte) 0xC3, (byte) 0x5E, (byte) 0x8B, (byte) 0x67, (byte) 0x3D, (byte) 0x9A,
1113         (byte) 0xD0, (byte) 0xE2, (byte) 0x9B, (byte) 0x2D, (byte) 0xC6, (byte) 0xD8,
1114         (byte) 0xEF, (byte) 0x19, (byte) 0x14, (byte) 0x49, (byte) 0x88, (byte) 0x52,
1115         (byte) 0xF7, (byte) 0x93, (byte) 0xEB, (byte) 0xDB, (byte) 0xB6, (byte) 0x55,
1116         (byte) 0x05, (byte) 0xB6, (byte) 0xE7, (byte) 0x70, (byte) 0xE4, (byte) 0x5A,
1117         (byte) 0x9E, (byte) 0x80, (byte) 0x78, (byte) 0x48, (byte) 0xA8, (byte) 0xE5,
1118         (byte) 0x59, (byte) 0x8D, (byte) 0x1C, (byte) 0x5D, (byte) 0x95, (byte) 0x38,
1119         (byte) 0x25, (byte) 0xFC, (byte) 0x38, (byte) 0xC3, (byte) 0xFF, (byte) 0xE2,
1120         (byte) 0x6F, (byte) 0xE4, (byte) 0xFC, (byte) 0x64, (byte) 0x8B, (byte) 0xCA,
1121         (byte) 0x91, (byte) 0x5F, (byte) 0x0B, (byte) 0x4E, (byte) 0x9A, (byte) 0xB5,
1122         (byte) 0x22, (byte) 0x5D, (byte) 0xC5, (byte) 0x5A, (byte) 0x77, (byte) 0xED,
1123         (byte) 0x23, (byte) 0xE0, (byte) 0x13, (byte) 0x8F, (byte) 0xAC, (byte) 0x13,
1124         (byte) 0xE5, (byte) 0x81, (byte) 0xEE, (byte) 0xD1, (byte) 0xAD, (byte) 0x8A,
1125         (byte) 0x0F, (byte) 0x2B, (byte) 0x4C, (byte) 0xB2, (byte) 0x13, (byte) 0x54,
1126         (byte) 0x44, (byte) 0x8E, (byte) 0x53, (byte) 0xE2, (byte) 0x33, (byte) 0x14,
1127         (byte) 0x7F, (byte) 0x9B, (byte) 0xA9, (byte) 0xD3, (byte) 0xBB, (byte) 0xFC,
1128         (byte) 0xAC, (byte) 0xC9, (byte) 0x31, (byte) 0xB6,
1129     };
1130     private static final PSSParameterSpec SHA256withRSAPSS_Vector2Signature_ParameterSpec =
1131             new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1);
1132 
1133     /*
1134      * echo "This is a signed message from Kenny Root." | openssl sha256 -binary -out digest.bin \
1135      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1136      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha256 -pkeyopt rsa_pss_saltlen:0 \
1137      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1138      */
1139     private static final byte[] SHA256withRSAPSS_NoSalt_Vector2Signature = new byte[] {
1140         (byte) 0x4C, (byte) 0xB7, (byte) 0x33, (byte) 0x78, (byte) 0x0A, (byte) 0xA7,
1141         (byte) 0xEB, (byte) 0x35, (byte) 0x5E, (byte) 0x99, (byte) 0x8F, (byte) 0xE9,
1142         (byte) 0x2A, (byte) 0x3D, (byte) 0x8C, (byte) 0x9B, (byte) 0x19, (byte) 0xC7,
1143         (byte) 0xC8, (byte) 0xB8, (byte) 0x10, (byte) 0xC5, (byte) 0x6D, (byte) 0xA4,
1144         (byte) 0x44, (byte) 0x3E, (byte) 0xAB, (byte) 0x90, (byte) 0x82, (byte) 0x70,
1145         (byte) 0xFA, (byte) 0x7B, (byte) 0xE6, (byte) 0x06, (byte) 0x36, (byte) 0x06,
1146         (byte) 0x93, (byte) 0x54, (byte) 0x50, (byte) 0xCD, (byte) 0x5F, (byte) 0xAA,
1147         (byte) 0x01, (byte) 0x42, (byte) 0xAD, (byte) 0xB9, (byte) 0x02, (byte) 0x6E,
1148         (byte) 0xAE, (byte) 0x60, (byte) 0x00, (byte) 0x60, (byte) 0x55, (byte) 0x1B,
1149         (byte) 0xBB, (byte) 0x9E, (byte) 0x03, (byte) 0xB7, (byte) 0x86, (byte) 0x3D,
1150         (byte) 0xCC, (byte) 0xFA, (byte) 0x6E, (byte) 0x20, (byte) 0x07, (byte) 0x61,
1151         (byte) 0x8F, (byte) 0x53, (byte) 0xC6, (byte) 0x2B, (byte) 0xEF, (byte) 0x8F,
1152         (byte) 0x0F, (byte) 0x8B, (byte) 0x80, (byte) 0x22, (byte) 0xDC, (byte) 0x9E,
1153         (byte) 0x20, (byte) 0x4A, (byte) 0x57, (byte) 0xA1, (byte) 0x15, (byte) 0xE0,
1154         (byte) 0x01, (byte) 0x95, (byte) 0xDB, (byte) 0x46, (byte) 0x85, (byte) 0x6D,
1155         (byte) 0x27, (byte) 0x9F, (byte) 0x44, (byte) 0x3B, (byte) 0xB1, (byte) 0x35,
1156         (byte) 0x04, (byte) 0x9D, (byte) 0xF8, (byte) 0xC6, (byte) 0xD7, (byte) 0xD7,
1157         (byte) 0xEF, (byte) 0x9A, (byte) 0x53, (byte) 0x5A, (byte) 0x73, (byte) 0xB3,
1158         (byte) 0xD0, (byte) 0x32, (byte) 0x39, (byte) 0xE1, (byte) 0x28, (byte) 0x3A,
1159         (byte) 0x9D, (byte) 0x69, (byte) 0x4E, (byte) 0x57, (byte) 0xC1, (byte) 0xDF,
1160         (byte) 0xFE, (byte) 0x5F, (byte) 0xA8, (byte) 0xFF, (byte) 0xE8, (byte) 0x75,
1161         (byte) 0x85, (byte) 0x33, (byte) 0x90, (byte) 0x83, (byte) 0x3D, (byte) 0x8F,
1162         (byte) 0x15, (byte) 0x47, (byte) 0x16, (byte) 0xF2, (byte) 0x32, (byte) 0xF9,
1163         (byte) 0x46, (byte) 0x96, (byte) 0xCC, (byte) 0x2E, (byte) 0x8F, (byte) 0x27,
1164         (byte) 0x3F, (byte) 0xCF, (byte) 0x91, (byte) 0xA6, (byte) 0x9E, (byte) 0xBF,
1165         (byte) 0x42, (byte) 0x2F, (byte) 0xD6, (byte) 0x52, (byte) 0xD7, (byte) 0x3B,
1166         (byte) 0xCD, (byte) 0xFE, (byte) 0x0B, (byte) 0x4A, (byte) 0x3B, (byte) 0x19,
1167         (byte) 0x57, (byte) 0x47, (byte) 0x65, (byte) 0x33, (byte) 0xD9, (byte) 0xF7,
1168         (byte) 0xE4, (byte) 0xC3, (byte) 0x05, (byte) 0x49, (byte) 0x3C, (byte) 0xC0,
1169         (byte) 0xDF, (byte) 0xC1, (byte) 0x54, (byte) 0x18, (byte) 0x8D, (byte) 0xDA,
1170         (byte) 0xE4, (byte) 0x59, (byte) 0xE9, (byte) 0x3B, (byte) 0xD6, (byte) 0x89,
1171         (byte) 0x07, (byte) 0x99, (byte) 0xB0, (byte) 0xF4, (byte) 0x09, (byte) 0x0A,
1172         (byte) 0x2C, (byte) 0xBA, (byte) 0x0B, (byte) 0xE4, (byte) 0x79, (byte) 0xB1,
1173         (byte) 0xDB, (byte) 0xAD, (byte) 0xAB, (byte) 0x5D, (byte) 0xA2, (byte) 0x1E,
1174         (byte) 0x76, (byte) 0x7F, (byte) 0x74, (byte) 0x62, (byte) 0x49, (byte) 0x07,
1175         (byte) 0x7A, (byte) 0x5B, (byte) 0xD7, (byte) 0x0F, (byte) 0xA4, (byte) 0x2C,
1176         (byte) 0x36, (byte) 0x13, (byte) 0x42, (byte) 0xBA, (byte) 0xCF, (byte) 0x0A,
1177         (byte) 0xFC, (byte) 0xC3, (byte) 0x31, (byte) 0x5E, (byte) 0x06, (byte) 0x84,
1178         (byte) 0x8A, (byte) 0x8A, (byte) 0x84, (byte) 0x0D, (byte) 0x48, (byte) 0xBD,
1179         (byte) 0x67, (byte) 0xCF, (byte) 0x04, (byte) 0xB4, (byte) 0xFB, (byte) 0xBB,
1180         (byte) 0x04, (byte) 0x91, (byte) 0xB1, (byte) 0x0A, (byte) 0xA4, (byte) 0x70,
1181         (byte) 0x58, (byte) 0x1A, (byte) 0x9B, (byte) 0x02, (byte) 0x86, (byte) 0xBD,
1182         (byte) 0xAE, (byte) 0x77, (byte) 0x97, (byte) 0x1C,
1183     };
1184     private static final PSSParameterSpec SHA256withRSAPSS_NoSalt_Vector2Signature_ParameterSpec =
1185             new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 0, 1);
1186 
1187     /*
1188      * echo "This is a signed message from Kenny Root." | openssl sha256 -binary -out digest.bin \
1189      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1190      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha256 -pkeyopt rsa_pss_saltlen:222 \
1191      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1192      */
1193     private static final byte[] SHA256withRSAPSS_MaxSalt_Vector2Signature = new byte[] {
1194         (byte) 0x3B, (byte) 0x43, (byte) 0xA8, (byte) 0xB5, (byte) 0x34, (byte) 0xD8,
1195         (byte) 0xF9, (byte) 0xAD, (byte) 0xDD, (byte) 0x1F, (byte) 0x7A, (byte) 0x73,
1196         (byte) 0xBF, (byte) 0xFA, (byte) 0xED, (byte) 0x10, (byte) 0xF3, (byte) 0x16,
1197         (byte) 0xCC, (byte) 0xE5, (byte) 0x09, (byte) 0x0F, (byte) 0x68, (byte) 0x02,
1198         (byte) 0xE7, (byte) 0x55, (byte) 0x0D, (byte) 0xCF, (byte) 0x1B, (byte) 0x83,
1199         (byte) 0xCD, (byte) 0xA2, (byte) 0xD6, (byte) 0x02, (byte) 0xDD, (byte) 0x72,
1200         (byte) 0xA6, (byte) 0x5F, (byte) 0x05, (byte) 0x8A, (byte) 0x1E, (byte) 0xA1,
1201         (byte) 0x4F, (byte) 0x92, (byte) 0xD9, (byte) 0x09, (byte) 0x19, (byte) 0x6E,
1202         (byte) 0x80, (byte) 0xA0, (byte) 0x47, (byte) 0x98, (byte) 0x5C, (byte) 0xF7,
1203         (byte) 0x34, (byte) 0x52, (byte) 0x7D, (byte) 0x85, (byte) 0xCF, (byte) 0x9F,
1204         (byte) 0xEB, (byte) 0xAF, (byte) 0xB4, (byte) 0x53, (byte) 0xF0, (byte) 0x5D,
1205         (byte) 0x28, (byte) 0x87, (byte) 0xAC, (byte) 0xA7, (byte) 0xB4, (byte) 0xCF,
1206         (byte) 0xDD, (byte) 0x8B, (byte) 0xA4, (byte) 0xC9, (byte) 0xCA, (byte) 0xAA,
1207         (byte) 0xF4, (byte) 0xA8, (byte) 0x25, (byte) 0x26, (byte) 0x34, (byte) 0x11,
1208         (byte) 0x14, (byte) 0x24, (byte) 0x1C, (byte) 0x1C, (byte) 0x50, (byte) 0xC8,
1209         (byte) 0xFF, (byte) 0x7E, (byte) 0xFF, (byte) 0x6F, (byte) 0x4F, (byte) 0x14,
1210         (byte) 0xB3, (byte) 0x57, (byte) 0x48, (byte) 0x0A, (byte) 0x5A, (byte) 0x95,
1211         (byte) 0x5D, (byte) 0xEB, (byte) 0x71, (byte) 0x4E, (byte) 0x86, (byte) 0xFC,
1212         (byte) 0x38, (byte) 0x1B, (byte) 0x93, (byte) 0x45, (byte) 0x09, (byte) 0x15,
1213         (byte) 0xD3, (byte) 0x06, (byte) 0x6B, (byte) 0x9D, (byte) 0x05, (byte) 0x5C,
1214         (byte) 0x4A, (byte) 0xB3, (byte) 0x93, (byte) 0xD1, (byte) 0x01, (byte) 0x54,
1215         (byte) 0xCC, (byte) 0xED, (byte) 0xBF, (byte) 0x0E, (byte) 0x7E, (byte) 0x33,
1216         (byte) 0x32, (byte) 0xA6, (byte) 0xA5, (byte) 0xF7, (byte) 0x3D, (byte) 0x2E,
1217         (byte) 0xCB, (byte) 0x76, (byte) 0xA7, (byte) 0x22, (byte) 0x64, (byte) 0xB8,
1218         (byte) 0x19, (byte) 0x53, (byte) 0xFE, (byte) 0x8C, (byte) 0xC8, (byte) 0x1E,
1219         (byte) 0x6C, (byte) 0xEE, (byte) 0x08, (byte) 0x07, (byte) 0x7E, (byte) 0x93,
1220         (byte) 0x43, (byte) 0x1B, (byte) 0xCF, (byte) 0x37, (byte) 0xE4, (byte) 0xAB,
1221         (byte) 0xE7, (byte) 0xD7, (byte) 0x83, (byte) 0x8E, (byte) 0x19, (byte) 0xAE,
1222         (byte) 0x05, (byte) 0x51, (byte) 0x91, (byte) 0x10, (byte) 0x7B, (byte) 0x70,
1223         (byte) 0xFC, (byte) 0x73, (byte) 0x12, (byte) 0x96, (byte) 0xFA, (byte) 0xD0,
1224         (byte) 0xCA, (byte) 0xA3, (byte) 0x59, (byte) 0xA7, (byte) 0xDD, (byte) 0xC3,
1225         (byte) 0x1D, (byte) 0x9C, (byte) 0x7B, (byte) 0x50, (byte) 0xBB, (byte) 0x57,
1226         (byte) 0xB8, (byte) 0x86, (byte) 0xF2, (byte) 0xCA, (byte) 0xC4, (byte) 0x86,
1227         (byte) 0x7A, (byte) 0x96, (byte) 0x90, (byte) 0x02, (byte) 0xDF, (byte) 0xA0,
1228         (byte) 0x88, (byte) 0x0E, (byte) 0x89, (byte) 0x45, (byte) 0x27, (byte) 0x52,
1229         (byte) 0xDA, (byte) 0x86, (byte) 0x42, (byte) 0x4B, (byte) 0x90, (byte) 0xC3,
1230         (byte) 0xC1, (byte) 0x41, (byte) 0x60, (byte) 0x5C, (byte) 0x29, (byte) 0x15,
1231         (byte) 0xE5, (byte) 0x5C, (byte) 0x43, (byte) 0x9B, (byte) 0x40, (byte) 0xE5,
1232         (byte) 0x04, (byte) 0x1B, (byte) 0x4A, (byte) 0x93, (byte) 0xDD, (byte) 0x55,
1233         (byte) 0xC4, (byte) 0xFC, (byte) 0xFE, (byte) 0x0C, (byte) 0x65, (byte) 0x96,
1234         (byte) 0x98, (byte) 0xDE, (byte) 0xC5, (byte) 0x05, (byte) 0xC5, (byte) 0x3E,
1235         (byte) 0xB0, (byte) 0x25, (byte) 0x4E, (byte) 0x65, (byte) 0x24, (byte) 0x8D,
1236         (byte) 0x4E, (byte) 0x9D, (byte) 0x94, (byte) 0x01,
1237     };
1238     private static final PSSParameterSpec SHA256withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec =
1239             new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 222, 1);
1240 
1241     /*
1242      * echo "This is a signed message from Kenny Root." | openssl sha384 -binary -out digest.bin \
1243      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1244      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha384 -pkeyopt rsa_pss_saltlen:48 \
1245      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1246      */
1247     private static final byte[] SHA384withRSAPSS_Vector2Signature = new byte[] {
1248         (byte) 0x20, (byte) 0xCB, (byte) 0x97, (byte) 0x9C, (byte) 0x2E, (byte) 0x51,
1249         (byte) 0x59, (byte) 0x56, (byte) 0x9F, (byte) 0x04, (byte) 0x47, (byte) 0x7C,
1250         (byte) 0x5C, (byte) 0x57, (byte) 0x59, (byte) 0xBC, (byte) 0x43, (byte) 0xD9,
1251         (byte) 0x4B, (byte) 0xEC, (byte) 0xAC, (byte) 0xB9, (byte) 0x88, (byte) 0xA2,
1252         (byte) 0x30, (byte) 0x8B, (byte) 0xEE, (byte) 0x2F, (byte) 0xC1, (byte) 0x73,
1253         (byte) 0xF1, (byte) 0x13, (byte) 0xB2, (byte) 0x5E, (byte) 0x1A, (byte) 0xC8,
1254         (byte) 0xD2, (byte) 0xAA, (byte) 0x27, (byte) 0x16, (byte) 0xA1, (byte) 0x14,
1255         (byte) 0xAB, (byte) 0x45, (byte) 0x8A, (byte) 0x7E, (byte) 0x22, (byte) 0x22,
1256         (byte) 0x2A, (byte) 0x2E, (byte) 0xDA, (byte) 0x6A, (byte) 0x7E, (byte) 0x3F,
1257         (byte) 0x66, (byte) 0x99, (byte) 0x55, (byte) 0xAF, (byte) 0x2B, (byte) 0x94,
1258         (byte) 0xD8, (byte) 0x6B, (byte) 0xC2, (byte) 0x60, (byte) 0xB5, (byte) 0x55,
1259         (byte) 0xA9, (byte) 0x26, (byte) 0x29, (byte) 0xFC, (byte) 0x17, (byte) 0x56,
1260         (byte) 0x05, (byte) 0xB7, (byte) 0x48, (byte) 0x2F, (byte) 0xAB, (byte) 0x68,
1261         (byte) 0xCF, (byte) 0x37, (byte) 0x62, (byte) 0x79, (byte) 0x4F, (byte) 0x32,
1262         (byte) 0x04, (byte) 0xF6, (byte) 0xEA, (byte) 0xBE, (byte) 0x79, (byte) 0x84,
1263         (byte) 0x73, (byte) 0xEE, (byte) 0x1C, (byte) 0xEE, (byte) 0x9F, (byte) 0x72,
1264         (byte) 0x7A, (byte) 0xC6, (byte) 0x64, (byte) 0xB4, (byte) 0x4F, (byte) 0xDE,
1265         (byte) 0x0B, (byte) 0x38, (byte) 0x47, (byte) 0x62, (byte) 0xA9, (byte) 0xFD,
1266         (byte) 0x1B, (byte) 0x75, (byte) 0xEC, (byte) 0xFE, (byte) 0x2D, (byte) 0x04,
1267         (byte) 0x2D, (byte) 0x0A, (byte) 0xCE, (byte) 0x13, (byte) 0xFA, (byte) 0xDA,
1268         (byte) 0x3F, (byte) 0x4C, (byte) 0x11, (byte) 0xEA, (byte) 0x02, (byte) 0x00,
1269         (byte) 0x0A, (byte) 0x93, (byte) 0x12, (byte) 0xDC, (byte) 0x60, (byte) 0xE7,
1270         (byte) 0x52, (byte) 0x90, (byte) 0x8A, (byte) 0xA3, (byte) 0xAE, (byte) 0xC5,
1271         (byte) 0x9A, (byte) 0xD7, (byte) 0xD5, (byte) 0x0D, (byte) 0xBC, (byte) 0x7A,
1272         (byte) 0xDB, (byte) 0xF4, (byte) 0x10, (byte) 0xE0, (byte) 0xDB, (byte) 0xC0,
1273         (byte) 0x97, (byte) 0xF1, (byte) 0x84, (byte) 0xCF, (byte) 0x66, (byte) 0xB2,
1274         (byte) 0x04, (byte) 0x58, (byte) 0x81, (byte) 0xB5, (byte) 0x9B, (byte) 0x4A,
1275         (byte) 0xF9, (byte) 0xD7, (byte) 0xCA, (byte) 0x51, (byte) 0x09, (byte) 0x67,
1276         (byte) 0x48, (byte) 0x7B, (byte) 0xE5, (byte) 0xE9, (byte) 0x07, (byte) 0x4E,
1277         (byte) 0x6A, (byte) 0xC1, (byte) 0xA6, (byte) 0x68, (byte) 0x90, (byte) 0x17,
1278         (byte) 0xAB, (byte) 0x0E, (byte) 0xFB, (byte) 0x3E, (byte) 0x39, (byte) 0x74,
1279         (byte) 0x85, (byte) 0x04, (byte) 0x42, (byte) 0x0A, (byte) 0x9E, (byte) 0x02,
1280         (byte) 0xA9, (byte) 0x50, (byte) 0xFF, (byte) 0x23, (byte) 0x2D, (byte) 0x30,
1281         (byte) 0xDD, (byte) 0x17, (byte) 0xC0, (byte) 0x82, (byte) 0xF7, (byte) 0xBB,
1282         (byte) 0x3B, (byte) 0x03, (byte) 0xBD, (byte) 0xB1, (byte) 0x96, (byte) 0xCD,
1283         (byte) 0x71, (byte) 0x3F, (byte) 0x67, (byte) 0x59, (byte) 0x5E, (byte) 0x45,
1284         (byte) 0xE0, (byte) 0x1C, (byte) 0x80, (byte) 0x52, (byte) 0xD7, (byte) 0xF0,
1285         (byte) 0xC1, (byte) 0xE6, (byte) 0xCF, (byte) 0x59, (byte) 0x13, (byte) 0x25,
1286         (byte) 0x6F, (byte) 0x9F, (byte) 0xBB, (byte) 0xB9, (byte) 0x7F, (byte) 0x7E,
1287         (byte) 0x7D, (byte) 0x93, (byte) 0xD9, (byte) 0x3F, (byte) 0x95, (byte) 0xB7,
1288         (byte) 0x9A, (byte) 0xDB, (byte) 0xE2, (byte) 0x2C, (byte) 0x53, (byte) 0x83,
1289         (byte) 0x9A, (byte) 0x06, (byte) 0x6D, (byte) 0x22, (byte) 0x81, (byte) 0xB5,
1290         (byte) 0x63, (byte) 0xAE, (byte) 0x4A, (byte) 0xEE,
1291     };
1292     private static final PSSParameterSpec SHA384withRSAPSS_Vector2Signature_ParameterSpec =
1293             new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384, 48, 1);
1294 
1295     /*
1296      * echo "This is a signed message from Kenny Root." | openssl sha384 -binary -out digest.bin \
1297      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1298      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha384 -pkeyopt rsa_pss_saltlen:0 \
1299      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1300      */
1301     private static final byte[] SHA384withRSAPSS_NoSalt_Vector2Signature = new byte[] {
1302         (byte) 0x41, (byte) 0x0C, (byte) 0x3A, (byte) 0xEC, (byte) 0xF6, (byte) 0xD9,
1303         (byte) 0x8F, (byte) 0xA3, (byte) 0x61, (byte) 0xBB, (byte) 0x03, (byte) 0xED,
1304         (byte) 0xD9, (byte) 0x69, (byte) 0x7D, (byte) 0xE1, (byte) 0xE1, (byte) 0x4E,
1305         (byte) 0x5E, (byte) 0x71, (byte) 0x4E, (byte) 0x88, (byte) 0x9C, (byte) 0x79,
1306         (byte) 0xD3, (byte) 0x71, (byte) 0x28, (byte) 0x07, (byte) 0x28, (byte) 0x19,
1307         (byte) 0x96, (byte) 0x55, (byte) 0x30, (byte) 0x81, (byte) 0x29, (byte) 0x5C,
1308         (byte) 0x4A, (byte) 0x18, (byte) 0x69, (byte) 0x36, (byte) 0x74, (byte) 0xAC,
1309         (byte) 0x99, (byte) 0xB1, (byte) 0xBC, (byte) 0xA0, (byte) 0xFC, (byte) 0x17,
1310         (byte) 0xA4, (byte) 0xD1, (byte) 0xAE, (byte) 0x84, (byte) 0xA6, (byte) 0x09,
1311         (byte) 0x6B, (byte) 0xB3, (byte) 0x02, (byte) 0xB2, (byte) 0x81, (byte) 0x04,
1312         (byte) 0x59, (byte) 0x8C, (byte) 0xCF, (byte) 0xAD, (byte) 0xFB, (byte) 0x76,
1313         (byte) 0x6F, (byte) 0xE2, (byte) 0x5E, (byte) 0x09, (byte) 0xE5, (byte) 0xBC,
1314         (byte) 0x54, (byte) 0xBD, (byte) 0x08, (byte) 0xA8, (byte) 0x18, (byte) 0x60,
1315         (byte) 0xAF, (byte) 0x09, (byte) 0x67, (byte) 0x15, (byte) 0x03, (byte) 0xA8,
1316         (byte) 0x8B, (byte) 0x3F, (byte) 0x31, (byte) 0xB7, (byte) 0x76, (byte) 0xFD,
1317         (byte) 0xF6, (byte) 0x82, (byte) 0xC7, (byte) 0x89, (byte) 0xC2, (byte) 0x47,
1318         (byte) 0x80, (byte) 0x06, (byte) 0x4F, (byte) 0x8C, (byte) 0x9C, (byte) 0xD7,
1319         (byte) 0x4F, (byte) 0x63, (byte) 0x1E, (byte) 0xF0, (byte) 0x34, (byte) 0xD7,
1320         (byte) 0x91, (byte) 0xD2, (byte) 0x96, (byte) 0x62, (byte) 0xFD, (byte) 0x68,
1321         (byte) 0xE3, (byte) 0xE0, (byte) 0xFB, (byte) 0x7D, (byte) 0x0A, (byte) 0xD7,
1322         (byte) 0x52, (byte) 0xFE, (byte) 0xD1, (byte) 0x95, (byte) 0x9E, (byte) 0xD2,
1323         (byte) 0x84, (byte) 0xBE, (byte) 0x3D, (byte) 0x1F, (byte) 0x8C, (byte) 0xC4,
1324         (byte) 0xD6, (byte) 0xE3, (byte) 0xCF, (byte) 0xE8, (byte) 0xB3, (byte) 0x82,
1325         (byte) 0x2E, (byte) 0xFA, (byte) 0x39, (byte) 0xA3, (byte) 0x20, (byte) 0x3C,
1326         (byte) 0xBE, (byte) 0x6A, (byte) 0xFA, (byte) 0x04, (byte) 0xD2, (byte) 0x74,
1327         (byte) 0x41, (byte) 0xDC, (byte) 0xE8, (byte) 0x0E, (byte) 0xE7, (byte) 0xF2,
1328         (byte) 0x36, (byte) 0xD4, (byte) 0x2E, (byte) 0x6A, (byte) 0xCF, (byte) 0xDF,
1329         (byte) 0x8B, (byte) 0x4B, (byte) 0x77, (byte) 0xE8, (byte) 0x0A, (byte) 0x64,
1330         (byte) 0x86, (byte) 0x2C, (byte) 0xCA, (byte) 0x92, (byte) 0x01, (byte) 0xB2,
1331         (byte) 0x8A, (byte) 0xB8, (byte) 0xB2, (byte) 0x6C, (byte) 0x0B, (byte) 0x18,
1332         (byte) 0x90, (byte) 0x31, (byte) 0x93, (byte) 0x29, (byte) 0xBA, (byte) 0xB1,
1333         (byte) 0x88, (byte) 0x94, (byte) 0x44, (byte) 0x0B, (byte) 0x38, (byte) 0x64,
1334         (byte) 0xC1, (byte) 0xDE, (byte) 0x0B, (byte) 0xD8, (byte) 0xE4, (byte) 0xBA,
1335         (byte) 0x0A, (byte) 0x41, (byte) 0x24, (byte) 0x35, (byte) 0xAA, (byte) 0xE3,
1336         (byte) 0x59, (byte) 0x8E, (byte) 0x57, (byte) 0x51, (byte) 0x43, (byte) 0xE1,
1337         (byte) 0x9C, (byte) 0xF6, (byte) 0xF8, (byte) 0x16, (byte) 0x68, (byte) 0x83,
1338         (byte) 0x08, (byte) 0x8C, (byte) 0x2D, (byte) 0x40, (byte) 0xD2, (byte) 0xEF,
1339         (byte) 0xD6, (byte) 0xAE, (byte) 0x98, (byte) 0x77, (byte) 0xE8, (byte) 0xF2,
1340         (byte) 0xC7, (byte) 0x19, (byte) 0x61, (byte) 0xD6, (byte) 0x43, (byte) 0xCD,
1341         (byte) 0x76, (byte) 0x2E, (byte) 0x7A, (byte) 0xCB, (byte) 0x1A, (byte) 0x5D,
1342         (byte) 0x73, (byte) 0x45, (byte) 0xF2, (byte) 0x7C, (byte) 0xD0, (byte) 0x88,
1343         (byte) 0x83, (byte) 0x51, (byte) 0xF3, (byte) 0x19, (byte) 0x0F, (byte) 0xD5,
1344         (byte) 0x40, (byte) 0x3F, (byte) 0xD9, (byte) 0xBF,
1345     };
1346     private static final PSSParameterSpec SHA384withRSAPSS_NoSalt_Vector2Signature_ParameterSpec =
1347             new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384, 0, 1);
1348 
1349     /*
1350      * echo "This is a signed message from Kenny Root." | openssl sha384 -binary -out digest.bin \
1351      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1352      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha384 -pkeyopt rsa_pss_saltlen:206 \
1353      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1354      */
1355     private static final byte[] SHA384withRSAPSS_MaxSalt_Vector2Signature = new byte[] {
1356         (byte) 0xDE, (byte) 0xF7, (byte) 0xC3, (byte) 0x21, (byte) 0x79, (byte) 0x0F,
1357         (byte) 0x55, (byte) 0xD1, (byte) 0x56, (byte) 0x9A, (byte) 0xB0, (byte) 0x08,
1358         (byte) 0xA1, (byte) 0x27, (byte) 0xC9, (byte) 0x5E, (byte) 0x64, (byte) 0xF4,
1359         (byte) 0xC7, (byte) 0x83, (byte) 0x94, (byte) 0xCA, (byte) 0xBD, (byte) 0x50,
1360         (byte) 0xD6, (byte) 0xC5, (byte) 0x56, (byte) 0x94, (byte) 0xBD, (byte) 0x0B,
1361         (byte) 0x55, (byte) 0xE6, (byte) 0x04, (byte) 0xAD, (byte) 0xAF, (byte) 0xAF,
1362         (byte) 0x4F, (byte) 0x2D, (byte) 0x91, (byte) 0x7F, (byte) 0xF1, (byte) 0x60,
1363         (byte) 0x0C, (byte) 0xEE, (byte) 0xE8, (byte) 0x44, (byte) 0xFC, (byte) 0x69,
1364         (byte) 0x80, (byte) 0x43, (byte) 0xBC, (byte) 0xAB, (byte) 0x83, (byte) 0x35,
1365         (byte) 0xB0, (byte) 0xC6, (byte) 0xCB, (byte) 0xE6, (byte) 0x92, (byte) 0x29,
1366         (byte) 0x09, (byte) 0xCF, (byte) 0xDB, (byte) 0xAD, (byte) 0x16, (byte) 0x93,
1367         (byte) 0xC7, (byte) 0xBE, (byte) 0x81, (byte) 0x68, (byte) 0x0F, (byte) 0x7B,
1368         (byte) 0xC1, (byte) 0xC2, (byte) 0x8C, (byte) 0xBA, (byte) 0x59, (byte) 0x80,
1369         (byte) 0xAE, (byte) 0xFB, (byte) 0x60, (byte) 0x22, (byte) 0x28, (byte) 0x36,
1370         (byte) 0xBE, (byte) 0x37, (byte) 0x72, (byte) 0x86, (byte) 0x02, (byte) 0x4B,
1371         (byte) 0xF9, (byte) 0x14, (byte) 0x5A, (byte) 0x6B, (byte) 0x32, (byte) 0x44,
1372         (byte) 0x72, (byte) 0x33, (byte) 0x2E, (byte) 0x7F, (byte) 0xA1, (byte) 0xFD,
1373         (byte) 0x07, (byte) 0xF2, (byte) 0xD9, (byte) 0x9D, (byte) 0x03, (byte) 0x77,
1374         (byte) 0x17, (byte) 0xFB, (byte) 0x0E, (byte) 0xFF, (byte) 0xF7, (byte) 0x37,
1375         (byte) 0x68, (byte) 0xF6, (byte) 0x8F, (byte) 0x9B, (byte) 0x2C, (byte) 0xEB,
1376         (byte) 0xAF, (byte) 0x6C, (byte) 0x50, (byte) 0x9F, (byte) 0x34, (byte) 0xB2,
1377         (byte) 0x52, (byte) 0x3B, (byte) 0x94, (byte) 0x6F, (byte) 0x60, (byte) 0x16,
1378         (byte) 0x52, (byte) 0x0A, (byte) 0xBF, (byte) 0x95, (byte) 0x41, (byte) 0x44,
1379         (byte) 0x83, (byte) 0x91, (byte) 0x85, (byte) 0xA1, (byte) 0xF7, (byte) 0xF9,
1380         (byte) 0x17, (byte) 0x4A, (byte) 0xF7, (byte) 0xF1, (byte) 0xE8, (byte) 0x9C,
1381         (byte) 0x75, (byte) 0x86, (byte) 0x12, (byte) 0x44, (byte) 0x19, (byte) 0x5C,
1382         (byte) 0x65, (byte) 0x31, (byte) 0x89, (byte) 0x2A, (byte) 0xFC, (byte) 0xBE,
1383         (byte) 0xE8, (byte) 0xEC, (byte) 0xC9, (byte) 0xD7, (byte) 0x41, (byte) 0xDA,
1384         (byte) 0xD9, (byte) 0xC9, (byte) 0x8B, (byte) 0x90, (byte) 0x60, (byte) 0xCC,
1385         (byte) 0xB2, (byte) 0x7A, (byte) 0xBA, (byte) 0xA0, (byte) 0xEE, (byte) 0xBE,
1386         (byte) 0x9C, (byte) 0xE7, (byte) 0xF2, (byte) 0x27, (byte) 0x92, (byte) 0x9C,
1387         (byte) 0x3C, (byte) 0x0F, (byte) 0x5C, (byte) 0xEE, (byte) 0x38, (byte) 0x48,
1388         (byte) 0xCF, (byte) 0xFF, (byte) 0x33, (byte) 0x35, (byte) 0x80, (byte) 0x99,
1389         (byte) 0x5D, (byte) 0xA7, (byte) 0x5A, (byte) 0x7A, (byte) 0xEA, (byte) 0x96,
1390         (byte) 0x74, (byte) 0x28, (byte) 0x36, (byte) 0x7B, (byte) 0xE1, (byte) 0x33,
1391         (byte) 0x7C, (byte) 0x78, (byte) 0xEC, (byte) 0x05, (byte) 0x72, (byte) 0x0E,
1392         (byte) 0x5D, (byte) 0x16, (byte) 0x5C, (byte) 0x77, (byte) 0x58, (byte) 0xA7,
1393         (byte) 0x31, (byte) 0x3F, (byte) 0xBA, (byte) 0x91, (byte) 0xA7, (byte) 0x16,
1394         (byte) 0xFC, (byte) 0x31, (byte) 0xCA, (byte) 0x30, (byte) 0xE0, (byte) 0xF4,
1395         (byte) 0x5D, (byte) 0x07, (byte) 0x4A, (byte) 0x9C, (byte) 0x1D, (byte) 0x2B,
1396         (byte) 0x4E, (byte) 0xB8, (byte) 0x7C, (byte) 0x67, (byte) 0xCB, (byte) 0x34,
1397         (byte) 0x69, (byte) 0x85, (byte) 0x4E, (byte) 0x99, (byte) 0x41, (byte) 0x8A,
1398         (byte) 0x35, (byte) 0x85, (byte) 0xF2, (byte) 0x1A,
1399     };
1400     private static final PSSParameterSpec SHA384withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec =
1401             new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384, 206, 1);
1402 
1403     /*
1404      * echo "This is a signed message from Kenny Root." | openssl sha512 -binary -out digest.bin \
1405      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1406      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha512 -pkeyopt rsa_pss_saltlen:64 \
1407      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1408      */
1409     private static final byte[] SHA512withRSAPSS_Vector2Signature = new byte[] {
1410         (byte) 0x9F, (byte) 0xED, (byte) 0xF8, (byte) 0xEE, (byte) 0x30, (byte) 0x5F,
1411         (byte) 0x30, (byte) 0x63, (byte) 0x1D, (byte) 0x86, (byte) 0xD3, (byte) 0xAD,
1412         (byte) 0x1D, (byte) 0xD8, (byte) 0xD2, (byte) 0x67, (byte) 0xE2, (byte) 0x43,
1413         (byte) 0x64, (byte) 0x71, (byte) 0x98, (byte) 0x82, (byte) 0x00, (byte) 0x84,
1414         (byte) 0x2C, (byte) 0x88, (byte) 0x1A, (byte) 0x28, (byte) 0xCD, (byte) 0xA2,
1415         (byte) 0x34, (byte) 0x17, (byte) 0x0F, (byte) 0x34, (byte) 0x8A, (byte) 0x10,
1416         (byte) 0x79, (byte) 0x6C, (byte) 0xCB, (byte) 0xDA, (byte) 0x2F, (byte) 0xDF,
1417         (byte) 0x4D, (byte) 0x98, (byte) 0x01, (byte) 0xE8, (byte) 0xB3, (byte) 0xF5,
1418         (byte) 0xCD, (byte) 0x60, (byte) 0xEA, (byte) 0xDE, (byte) 0xA5, (byte) 0x0C,
1419         (byte) 0x09, (byte) 0xA1, (byte) 0x4A, (byte) 0xC4, (byte) 0x6B, (byte) 0x09,
1420         (byte) 0xB3, (byte) 0x37, (byte) 0x1F, (byte) 0x8A, (byte) 0x64, (byte) 0x81,
1421         (byte) 0x2E, (byte) 0x22, (byte) 0x75, (byte) 0x24, (byte) 0x3B, (byte) 0xC0,
1422         (byte) 0x0E, (byte) 0x1F, (byte) 0x37, (byte) 0xC9, (byte) 0x1E, (byte) 0x6F,
1423         (byte) 0xAF, (byte) 0x3E, (byte) 0x9B, (byte) 0x3F, (byte) 0xA3, (byte) 0xC3,
1424         (byte) 0x0B, (byte) 0xB9, (byte) 0x83, (byte) 0x60, (byte) 0x02, (byte) 0xC6,
1425         (byte) 0x29, (byte) 0x83, (byte) 0x09, (byte) 0x16, (byte) 0xD9, (byte) 0x3D,
1426         (byte) 0x84, (byte) 0x02, (byte) 0x81, (byte) 0x20, (byte) 0xE9, (byte) 0x01,
1427         (byte) 0x5B, (byte) 0x85, (byte) 0xC8, (byte) 0x81, (byte) 0x25, (byte) 0x6B,
1428         (byte) 0xCB, (byte) 0x78, (byte) 0x48, (byte) 0x65, (byte) 0x3A, (byte) 0xD6,
1429         (byte) 0x95, (byte) 0x9B, (byte) 0x62, (byte) 0x2D, (byte) 0x84, (byte) 0x54,
1430         (byte) 0x12, (byte) 0x94, (byte) 0xB7, (byte) 0xF0, (byte) 0x1C, (byte) 0xB6,
1431         (byte) 0x59, (byte) 0xCD, (byte) 0xC3, (byte) 0x86, (byte) 0xE6, (byte) 0x63,
1432         (byte) 0xD7, (byte) 0x99, (byte) 0x9A, (byte) 0xC4, (byte) 0xBF, (byte) 0x8E,
1433         (byte) 0xDD, (byte) 0x46, (byte) 0x10, (byte) 0xBE, (byte) 0xAB, (byte) 0x78,
1434         (byte) 0xC6, (byte) 0x30, (byte) 0x47, (byte) 0x23, (byte) 0xB6, (byte) 0x2C,
1435         (byte) 0x02, (byte) 0x5E, (byte) 0x1F, (byte) 0x07, (byte) 0x96, (byte) 0x54,
1436         (byte) 0xEE, (byte) 0x28, (byte) 0xC7, (byte) 0xEC, (byte) 0x57, (byte) 0xDB,
1437         (byte) 0x9E, (byte) 0xEF, (byte) 0xE4, (byte) 0x11, (byte) 0xF8, (byte) 0x04,
1438         (byte) 0xA9, (byte) 0x26, (byte) 0xC2, (byte) 0x61, (byte) 0xF1, (byte) 0x84,
1439         (byte) 0xEB, (byte) 0x94, (byte) 0xBD, (byte) 0x48, (byte) 0xCA, (byte) 0xD1,
1440         (byte) 0x84, (byte) 0xCE, (byte) 0x82, (byte) 0x2E, (byte) 0xF6, (byte) 0x4E,
1441         (byte) 0x17, (byte) 0x6F, (byte) 0x78, (byte) 0xB9, (byte) 0x0B, (byte) 0xA9,
1442         (byte) 0x7D, (byte) 0xBC, (byte) 0xE5, (byte) 0xF8, (byte) 0x7D, (byte) 0xA8,
1443         (byte) 0x76, (byte) 0x7A, (byte) 0x8B, (byte) 0xB5, (byte) 0x05, (byte) 0x42,
1444         (byte) 0x37, (byte) 0xDA, (byte) 0x15, (byte) 0xE2, (byte) 0xC4, (byte) 0x70,
1445         (byte) 0x6E, (byte) 0x95, (byte) 0x60, (byte) 0x47, (byte) 0xF9, (byte) 0x0F,
1446         (byte) 0xF4, (byte) 0xA2, (byte) 0x73, (byte) 0xF1, (byte) 0x73, (byte) 0xBD,
1447         (byte) 0x0B, (byte) 0x9B, (byte) 0x44, (byte) 0xB6, (byte) 0xA9, (byte) 0xAF,
1448         (byte) 0x50, (byte) 0x2D, (byte) 0x5C, (byte) 0xA3, (byte) 0x72, (byte) 0x6F,
1449         (byte) 0x85, (byte) 0xE8, (byte) 0x0C, (byte) 0xF9, (byte) 0xE1, (byte) 0xE8,
1450         (byte) 0xF7, (byte) 0xC0, (byte) 0x85, (byte) 0x14, (byte) 0x53, (byte) 0x95,
1451         (byte) 0xF9, (byte) 0x9E, (byte) 0x65, (byte) 0x05, (byte) 0xF0, (byte) 0x22,
1452         (byte) 0x7F, (byte) 0x4F, (byte) 0x40, (byte) 0x45,
1453     };
1454     private static final PSSParameterSpec SHA512withRSAPSS_Vector2Signature_ParameterSpec =
1455             new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 64, 1);
1456 
1457     /*
1458      * echo "This is a signed message from Kenny Root." | openssl sha512 -binary -out digest.bin \
1459      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1460      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha512 -pkeyopt rsa_pss_saltlen:64 \
1461      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1462      */
1463     private static final byte[] SHA512withRSAPSS_NoSalt_Vector2Signature = new byte[] {
1464         (byte) 0x49, (byte) 0xA3, (byte) 0xBC, (byte) 0x2E, (byte) 0x67, (byte) 0x96,
1465         (byte) 0xA5, (byte) 0x3E, (byte) 0x39, (byte) 0x46, (byte) 0xD6, (byte) 0xA1,
1466         (byte) 0xA0, (byte) 0x4F, (byte) 0x3A, (byte) 0x03, (byte) 0x8F, (byte) 0x62,
1467         (byte) 0xF2, (byte) 0xD8, (byte) 0x90, (byte) 0xAD, (byte) 0xE2, (byte) 0x3B,
1468         (byte) 0x4F, (byte) 0x98, (byte) 0x88, (byte) 0x51, (byte) 0x41, (byte) 0x09,
1469         (byte) 0x23, (byte) 0xEB, (byte) 0xF4, (byte) 0x5D, (byte) 0x6A, (byte) 0x22,
1470         (byte) 0x12, (byte) 0x12, (byte) 0xDC, (byte) 0x27, (byte) 0xE9, (byte) 0xF7,
1471         (byte) 0x64, (byte) 0xA3, (byte) 0xDE, (byte) 0x3A, (byte) 0xB0, (byte) 0xD6,
1472         (byte) 0xF2, (byte) 0xC6, (byte) 0xBC, (byte) 0x0B, (byte) 0xA2, (byte) 0xA1,
1473         (byte) 0xAA, (byte) 0xB0, (byte) 0x51, (byte) 0xDA, (byte) 0x4F, (byte) 0x28,
1474         (byte) 0xA8, (byte) 0xEB, (byte) 0x34, (byte) 0x60, (byte) 0x37, (byte) 0xF7,
1475         (byte) 0x50, (byte) 0x7D, (byte) 0xB8, (byte) 0xE7, (byte) 0x24, (byte) 0x8E,
1476         (byte) 0xAC, (byte) 0x03, (byte) 0x31, (byte) 0xB8, (byte) 0xE0, (byte) 0xDB,
1477         (byte) 0x97, (byte) 0xE9, (byte) 0x1B, (byte) 0x7E, (byte) 0x27, (byte) 0x99,
1478         (byte) 0x93, (byte) 0x4D, (byte) 0x46, (byte) 0xB3, (byte) 0xFE, (byte) 0xD6,
1479         (byte) 0x23, (byte) 0xB3, (byte) 0xAB, (byte) 0x3E, (byte) 0x33, (byte) 0xA1,
1480         (byte) 0x10, (byte) 0x4E, (byte) 0x34, (byte) 0x27, (byte) 0x58, (byte) 0x25,
1481         (byte) 0xB7, (byte) 0xBA, (byte) 0xEE, (byte) 0xBE, (byte) 0xE0, (byte) 0x6E,
1482         (byte) 0x54, (byte) 0xF7, (byte) 0x73, (byte) 0x7B, (byte) 0x5A, (byte) 0x9C,
1483         (byte) 0x74, (byte) 0xEA, (byte) 0xC7, (byte) 0x7E, (byte) 0xC6, (byte) 0xF7,
1484         (byte) 0xD5, (byte) 0x32, (byte) 0x0E, (byte) 0x28, (byte) 0x99, (byte) 0xD8,
1485         (byte) 0xEF, (byte) 0x97, (byte) 0x62, (byte) 0x8A, (byte) 0xE3, (byte) 0x16,
1486         (byte) 0xAD, (byte) 0xE2, (byte) 0xF4, (byte) 0x11, (byte) 0x91, (byte) 0x17,
1487         (byte) 0xF3, (byte) 0x32, (byte) 0x90, (byte) 0xCB, (byte) 0x3C, (byte) 0x89,
1488         (byte) 0xF4, (byte) 0x20, (byte) 0xF1, (byte) 0x2D, (byte) 0x74, (byte) 0x22,
1489         (byte) 0x50, (byte) 0x64, (byte) 0xC2, (byte) 0xF4, (byte) 0xC4, (byte) 0x0D,
1490         (byte) 0x18, (byte) 0x6A, (byte) 0x02, (byte) 0x52, (byte) 0x14, (byte) 0x85,
1491         (byte) 0x67, (byte) 0xA4, (byte) 0x08, (byte) 0xE5, (byte) 0xBF, (byte) 0x65,
1492         (byte) 0x15, (byte) 0xB3, (byte) 0x5A, (byte) 0x88, (byte) 0xEB, (byte) 0xD4,
1493         (byte) 0x75, (byte) 0xF9, (byte) 0x52, (byte) 0x73, (byte) 0xA0, (byte) 0x5E,
1494         (byte) 0xBA, (byte) 0x37, (byte) 0x6A, (byte) 0x61, (byte) 0x2B, (byte) 0x16,
1495         (byte) 0x8A, (byte) 0xA8, (byte) 0x00, (byte) 0xBB, (byte) 0x4D, (byte) 0xFA,
1496         (byte) 0x04, (byte) 0xB8, (byte) 0xAB, (byte) 0x4D, (byte) 0xA4, (byte) 0xFC,
1497         (byte) 0x9D, (byte) 0xCF, (byte) 0x63, (byte) 0x83, (byte) 0x34, (byte) 0xAE,
1498         (byte) 0xAE, (byte) 0xA6, (byte) 0x77, (byte) 0x73, (byte) 0xA2, (byte) 0xB5,
1499         (byte) 0x77, (byte) 0xAC, (byte) 0x00, (byte) 0x03, (byte) 0x06, (byte) 0xD4,
1500         (byte) 0xDF, (byte) 0x81, (byte) 0x61, (byte) 0xCE, (byte) 0x8E, (byte) 0xC1,
1501         (byte) 0xD5, (byte) 0x99, (byte) 0xD5, (byte) 0x2F, (byte) 0xE8, (byte) 0x27,
1502         (byte) 0xFA, (byte) 0x84, (byte) 0x7E, (byte) 0x57, (byte) 0xF1, (byte) 0xC9,
1503         (byte) 0xEB, (byte) 0x4F, (byte) 0xF9, (byte) 0x92, (byte) 0xC6, (byte) 0xD0,
1504         (byte) 0x25, (byte) 0x8A, (byte) 0x16, (byte) 0xD0, (byte) 0xEC, (byte) 0xE5,
1505         (byte) 0x33, (byte) 0xA6, (byte) 0xF9, (byte) 0xD5, (byte) 0x0C, (byte) 0x7B,
1506         (byte) 0xEC, (byte) 0xC6, (byte) 0x58, (byte) 0x45,
1507     };
1508     private static final PSSParameterSpec SHA512withRSAPSS_NoSalt_Vector2Signature_ParameterSpec =
1509             new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 0, 1);
1510 
1511     /*
1512      * echo "This is a signed message from Kenny Root." | openssl sha512 -binary -out digest.bin \
1513      *     && openssl pkeyutl -sign -in digest.bin -inkey privkey.pem \
1514      *         -pkeyopt rsa_padding_mode:pss -pkeyopt digest:sha512 -pkeyopt rsa_pss_saltlen:190 \
1515      *     | recode ../x1 | sed 's/0x/(byte) 0x/g'
1516      */
1517     private static final byte[] SHA512withRSAPSS_MaxSalt_Vector2Signature = new byte[] {
1518         (byte) 0x90, (byte) 0x92, (byte) 0x45, (byte) 0xA1, (byte) 0x1E, (byte) 0x0F,
1519         (byte) 0x5F, (byte) 0xF6, (byte) 0x8F, (byte) 0xA0, (byte) 0xBE, (byte) 0x34,
1520         (byte) 0x29, (byte) 0x62, (byte) 0xBE, (byte) 0x41, (byte) 0x80, (byte) 0xF0,
1521         (byte) 0xB8, (byte) 0x9F, (byte) 0x29, (byte) 0x63, (byte) 0x89, (byte) 0x26,
1522         (byte) 0xC2, (byte) 0x22, (byte) 0x1F, (byte) 0x60, (byte) 0xB6, (byte) 0xFC,
1523         (byte) 0x5A, (byte) 0x3E, (byte) 0x99, (byte) 0xB8, (byte) 0xC6, (byte) 0x3B,
1524         (byte) 0x67, (byte) 0x33, (byte) 0x97, (byte) 0x19, (byte) 0xC6, (byte) 0xFF,
1525         (byte) 0x0C, (byte) 0xA9, (byte) 0x04, (byte) 0x5A, (byte) 0xF0, (byte) 0x02,
1526         (byte) 0x9A, (byte) 0x19, (byte) 0x0F, (byte) 0xEA, (byte) 0x77, (byte) 0x0D,
1527         (byte) 0x56, (byte) 0x38, (byte) 0x0A, (byte) 0xED, (byte) 0x4E, (byte) 0xB7,
1528         (byte) 0x57, (byte) 0xBD, (byte) 0xC9, (byte) 0xA3, (byte) 0xE8, (byte) 0xC0,
1529         (byte) 0x7D, (byte) 0xF6, (byte) 0xA3, (byte) 0x4B, (byte) 0x61, (byte) 0x45,
1530         (byte) 0x06, (byte) 0x5E, (byte) 0x56, (byte) 0xF5, (byte) 0xEF, (byte) 0x76,
1531         (byte) 0x6B, (byte) 0xB7, (byte) 0xD4, (byte) 0xBB, (byte) 0xA4, (byte) 0x3C,
1532         (byte) 0x52, (byte) 0xF8, (byte) 0x06, (byte) 0x67, (byte) 0xF7, (byte) 0xC3,
1533         (byte) 0x8C, (byte) 0x5E, (byte) 0xDF, (byte) 0xFE, (byte) 0x30, (byte) 0x2E,
1534         (byte) 0xF8, (byte) 0x59, (byte) 0x3C, (byte) 0x3B, (byte) 0xEA, (byte) 0xA0,
1535         (byte) 0x5D, (byte) 0x8F, (byte) 0x18, (byte) 0x73, (byte) 0x1A, (byte) 0x2D,
1536         (byte) 0xB1, (byte) 0x55, (byte) 0x07, (byte) 0xC8, (byte) 0x33, (byte) 0xED,
1537         (byte) 0x8A, (byte) 0x5E, (byte) 0xC3, (byte) 0xAE, (byte) 0x51, (byte) 0x31,
1538         (byte) 0xC4, (byte) 0xFA, (byte) 0xE8, (byte) 0xE9, (byte) 0xBE, (byte) 0x2E,
1539         (byte) 0x28, (byte) 0xAA, (byte) 0xED, (byte) 0xA8, (byte) 0x4B, (byte) 0xA3,
1540         (byte) 0x13, (byte) 0xB9, (byte) 0x82, (byte) 0x57, (byte) 0xD1, (byte) 0x72,
1541         (byte) 0x0D, (byte) 0xA7, (byte) 0xF8, (byte) 0x67, (byte) 0xB8, (byte) 0x55,
1542         (byte) 0xF3, (byte) 0x06, (byte) 0xAE, (byte) 0xA7, (byte) 0x69, (byte) 0x66,
1543         (byte) 0x0B, (byte) 0x80, (byte) 0x56, (byte) 0x65, (byte) 0xC7, (byte) 0xE9,
1544         (byte) 0x60, (byte) 0xDC, (byte) 0x2D, (byte) 0x4B, (byte) 0x26, (byte) 0xA9,
1545         (byte) 0xED, (byte) 0x54, (byte) 0x79, (byte) 0x9E, (byte) 0x55, (byte) 0x1D,
1546         (byte) 0xEE, (byte) 0x78, (byte) 0x49, (byte) 0xA1, (byte) 0x1F, (byte) 0x9B,
1547         (byte) 0x37, (byte) 0xC0, (byte) 0xBA, (byte) 0xE6, (byte) 0x4B, (byte) 0x3B,
1548         (byte) 0xAF, (byte) 0x12, (byte) 0x99, (byte) 0x32, (byte) 0x14, (byte) 0x8C,
1549         (byte) 0x4D, (byte) 0xEB, (byte) 0x08, (byte) 0xA4, (byte) 0xE3, (byte) 0xC6,
1550         (byte) 0x37, (byte) 0x8B, (byte) 0x6E, (byte) 0x7C, (byte) 0xEC, (byte) 0xA3,
1551         (byte) 0x78, (byte) 0xED, (byte) 0x4E, (byte) 0x36, (byte) 0xBC, (byte) 0xA2,
1552         (byte) 0x7D, (byte) 0x11, (byte) 0x0E, (byte) 0xD0, (byte) 0x53, (byte) 0x14,
1553         (byte) 0x93, (byte) 0x16, (byte) 0x54, (byte) 0x45, (byte) 0x79, (byte) 0x7A,
1554         (byte) 0x1A, (byte) 0xA1, (byte) 0xEC, (byte) 0xF3, (byte) 0x12, (byte) 0x3F,
1555         (byte) 0xFE, (byte) 0x68, (byte) 0xFF, (byte) 0x5A, (byte) 0x3F, (byte) 0xE7,
1556         (byte) 0x13, (byte) 0x37, (byte) 0xEB, (byte) 0x60, (byte) 0x0A, (byte) 0x8E,
1557         (byte) 0x4F, (byte) 0x54, (byte) 0x46, (byte) 0x19, (byte) 0x82, (byte) 0xBF,
1558         (byte) 0xB7, (byte) 0xD2, (byte) 0x19, (byte) 0x71, (byte) 0x78, (byte) 0x38,
1559         (byte) 0x4C, (byte) 0xE3, (byte) 0xC4, (byte) 0xEA, (byte) 0x8F, (byte) 0x9B,
1560         (byte) 0xE5, (byte) 0xBA, (byte) 0x06, (byte) 0xFC,
1561     };
1562     private static final PSSParameterSpec SHA512withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec =
1563             new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 190, 1);
1564 
1565     @Test
testGetCommonInstances_Success()1566     public void testGetCommonInstances_Success() throws Exception {
1567         assertNotNull(Signature.getInstance("SHA1withRSA"));
1568         assertNotNull(Signature.getInstance("SHA256withRSA"));
1569         assertNotNull(Signature.getInstance("SHA384withRSA"));
1570         assertNotNull(Signature.getInstance("SHA512withRSA"));
1571         assertNotNull(Signature.getInstance("NONEwithRSA"));
1572         assertNotNull(Signature.getInstance("MD5withRSA"));
1573         assertNotNull(Signature.getInstance("SHA1withDSA"));
1574     }
1575 
verify(Signature sig, PublicKey key, byte[] data, byte[] signature)1576     private void verify(Signature sig, PublicKey key, byte[] data, byte[] signature)
1577             throws Exception {
1578         sig.initVerify(key);
1579         sig.update(data);
1580 
1581         assertTrue("Signature must match expected signature",
1582                 sig.verify(signature));
1583 
1584         ByteBuffer heap = ByteBuffer.wrap(data);
1585         sig.initVerify(key);
1586         sig.update(heap);
1587 
1588         assertTrue("Signature must match expected signature",
1589                 sig.verify(signature));
1590 
1591         ByteBuffer direct = ByteBuffer.allocateDirect(data.length);
1592         direct.put(data);
1593         direct.flip();
1594         sig.initVerify(key);
1595         sig.update(direct);
1596 
1597         assertTrue("Signature must match expected signature",
1598                 sig.verify(signature));
1599     }
1600 
1601     @Test
testVerify_SHA1withRSA_Key_Success()1602     public void testVerify_SHA1withRSA_Key_Success() throws Exception {
1603         KeyFactory kf = KeyFactory.getInstance("RSA");
1604         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1605         PublicKey pubKey = kf.generatePublic(keySpec);
1606 
1607         Signature sig = Signature.getInstance("SHA1withRSA");
1608         verify(sig, pubKey, Vector1Data, SHA1withRSA_Vector1Signature);
1609     }
1610 
1611     @Test
testVerify_SHA256withRSA_Key_Success()1612     public void testVerify_SHA256withRSA_Key_Success() throws Exception {
1613         KeyFactory kf = KeyFactory.getInstance("RSA");
1614         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1615         PublicKey pubKey = kf.generatePublic(keySpec);
1616 
1617         Signature sig = Signature.getInstance("SHA256withRSA");
1618         verify(sig, pubKey, Vector2Data, SHA256withRSA_Vector2Signature);
1619     }
1620 
1621     @Test
testVerify_SHA384withRSA_Key_Success()1622     public void testVerify_SHA384withRSA_Key_Success() throws Exception {
1623         KeyFactory kf = KeyFactory.getInstance("RSA");
1624         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1625         PublicKey pubKey = kf.generatePublic(keySpec);
1626 
1627         Signature sig = Signature.getInstance("SHA384withRSA");
1628         verify(sig, pubKey, Vector2Data, SHA384withRSA_Vector2Signature);
1629     }
1630 
1631     @Test
testVerify_SHA512withRSA_Key_Success()1632     public void testVerify_SHA512withRSA_Key_Success() throws Exception {
1633         KeyFactory kf = KeyFactory.getInstance("RSA");
1634         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1635         PublicKey pubKey = kf.generatePublic(keySpec);
1636 
1637         Signature sig = Signature.getInstance("SHA512withRSA");
1638         verify(sig, pubKey, Vector2Data, SHA512withRSA_Vector2Signature);
1639     }
1640 
1641     @Test
testVerify_MD5withRSA_Key_Success()1642     public void testVerify_MD5withRSA_Key_Success() throws Exception {
1643         KeyFactory kf = KeyFactory.getInstance("RSA");
1644         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1645         PublicKey pubKey = kf.generatePublic(keySpec);
1646 
1647         Signature sig = Signature.getInstance("MD5withRSA");
1648         verify(sig, pubKey, Vector2Data, MD5withRSA_Vector2Signature);
1649     }
1650 
1651     @Test
testVerify_SHA1withRSAPSS_Key_Success()1652     public void testVerify_SHA1withRSAPSS_Key_Success() throws Exception {
1653         KeyFactory kf = KeyFactory.getInstance("RSA");
1654         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1655         PublicKey pubKey = kf.generatePublic(keySpec);
1656 
1657         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
1658         sig.initVerify(pubKey);
1659         assertPSSAlgorithmParametersEquals(
1660                 SHA1withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
1661         sig.update(Vector2Data);
1662 
1663         assertTrue("Signature must verify",
1664                 sig.verify(SHA1withRSAPSS_Vector2Signature));
1665     }
1666 
1667     @Test
testVerify_SHA1withRSAPSS_NoSalt_Key_Success()1668     public void testVerify_SHA1withRSAPSS_NoSalt_Key_Success() throws Exception {
1669         KeyFactory kf = KeyFactory.getInstance("RSA");
1670         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1671         PublicKey pubKey = kf.generatePublic(keySpec);
1672 
1673         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
1674         sig.initVerify(pubKey);
1675         sig.setParameter(SHA1withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
1676         sig.update(Vector2Data);
1677 
1678         assertTrue("Signature must verify",
1679                 sig.verify(SHA1withRSAPSS_NoSalt_Vector2Signature));
1680     }
1681 
1682     @Test
testVerify_SHA1withRSAPSS_MaxSalt_Key_Success()1683     public void testVerify_SHA1withRSAPSS_MaxSalt_Key_Success() throws Exception {
1684         KeyFactory kf = KeyFactory.getInstance("RSA");
1685         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1686         PublicKey pubKey = kf.generatePublic(keySpec);
1687 
1688         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
1689         sig.initVerify(pubKey);
1690         sig.setParameter(SHA1withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
1691         sig.update(Vector2Data);
1692 
1693         assertTrue("Signature must verify",
1694                 sig.verify(SHA1withRSAPSS_MaxSalt_Vector2Signature));
1695     }
1696 
1697     @Test
testVerify_SHA224withRSAPSS_Key_Success()1698     public void testVerify_SHA224withRSAPSS_Key_Success() throws Exception {
1699         KeyFactory kf = KeyFactory.getInstance("RSA");
1700         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1701         PublicKey pubKey = kf.generatePublic(keySpec);
1702 
1703         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
1704         sig.initVerify(pubKey);
1705         assertPSSAlgorithmParametersEquals(
1706                 SHA224withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
1707         sig.update(Vector2Data);
1708 
1709         assertTrue("Signature must verify",
1710                 sig.verify(SHA224withRSAPSS_Vector2Signature));
1711     }
1712 
1713     @Test
testVerify_SHA224withRSAPSS_NoSalt_Key_Success()1714     public void testVerify_SHA224withRSAPSS_NoSalt_Key_Success() throws Exception {
1715         KeyFactory kf = KeyFactory.getInstance("RSA");
1716         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1717         PublicKey pubKey = kf.generatePublic(keySpec);
1718 
1719         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
1720         sig.initVerify(pubKey);
1721         sig.setParameter(SHA224withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
1722         sig.update(Vector2Data);
1723 
1724         assertTrue("Signature must verify",
1725                 sig.verify(SHA224withRSAPSS_NoSalt_Vector2Signature));
1726     }
1727 
1728     @Test
testVerify_SHA224withRSAPSS_MaxSalt_Key_Success()1729     public void testVerify_SHA224withRSAPSS_MaxSalt_Key_Success() throws Exception {
1730         KeyFactory kf = KeyFactory.getInstance("RSA");
1731         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1732         PublicKey pubKey = kf.generatePublic(keySpec);
1733 
1734         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
1735         sig.initVerify(pubKey);
1736         sig.setParameter(SHA224withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
1737         sig.update(Vector2Data);
1738 
1739         assertTrue("Signature must verify",
1740                 sig.verify(SHA224withRSAPSS_MaxSalt_Vector2Signature));
1741     }
1742 
1743     @Test
testVerify_SHA256withRSAPSS_Key_Success()1744     public void testVerify_SHA256withRSAPSS_Key_Success() throws Exception {
1745         KeyFactory kf = KeyFactory.getInstance("RSA");
1746         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1747         PublicKey pubKey = kf.generatePublic(keySpec);
1748 
1749         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
1750         sig.initVerify(pubKey);
1751         assertPSSAlgorithmParametersEquals(
1752                 SHA256withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
1753         sig.update(Vector2Data);
1754 
1755         assertTrue("Signature must verify",
1756                 sig.verify(SHA256withRSAPSS_Vector2Signature));
1757     }
1758 
1759     @Test
testVerify_SHA256withRSAPSS_NoSalt_Key_Success()1760     public void testVerify_SHA256withRSAPSS_NoSalt_Key_Success() throws Exception {
1761         KeyFactory kf = KeyFactory.getInstance("RSA");
1762         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1763         PublicKey pubKey = kf.generatePublic(keySpec);
1764 
1765         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
1766         sig.initVerify(pubKey);
1767         sig.setParameter(SHA256withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
1768         sig.update(Vector2Data);
1769 
1770         assertTrue("Signature must verify",
1771                 sig.verify(SHA256withRSAPSS_NoSalt_Vector2Signature));
1772     }
1773 
1774     @Test
testVerify_SHA256withRSAPSS_MaxSalt_Key_Success()1775     public void testVerify_SHA256withRSAPSS_MaxSalt_Key_Success() throws Exception {
1776         KeyFactory kf = KeyFactory.getInstance("RSA");
1777         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1778         PublicKey pubKey = kf.generatePublic(keySpec);
1779 
1780         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
1781         sig.initVerify(pubKey);
1782         sig.setParameter(SHA256withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
1783         sig.update(Vector2Data);
1784 
1785         assertTrue("Signature must verify",
1786                 sig.verify(SHA256withRSAPSS_MaxSalt_Vector2Signature));
1787     }
1788 
1789     @Test
testVerify_SHA384withRSAPSS_Key_Success()1790     public void testVerify_SHA384withRSAPSS_Key_Success() throws Exception {
1791         KeyFactory kf = KeyFactory.getInstance("RSA");
1792         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1793         PublicKey pubKey = kf.generatePublic(keySpec);
1794 
1795         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
1796         sig.initVerify(pubKey);
1797         assertPSSAlgorithmParametersEquals(
1798                 SHA384withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
1799         sig.update(Vector2Data);
1800 
1801         assertTrue("Signature must verify",
1802                 sig.verify(SHA384withRSAPSS_Vector2Signature));
1803     }
1804 
1805     @Test
testVerify_SHA384withRSAPSS_NoSalt_Key_Success()1806     public void testVerify_SHA384withRSAPSS_NoSalt_Key_Success() throws Exception {
1807         KeyFactory kf = KeyFactory.getInstance("RSA");
1808         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1809         PublicKey pubKey = kf.generatePublic(keySpec);
1810 
1811         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
1812         sig.initVerify(pubKey);
1813         sig.setParameter(SHA384withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
1814         sig.update(Vector2Data);
1815 
1816         assertTrue("Signature must verify",
1817                 sig.verify(SHA384withRSAPSS_NoSalt_Vector2Signature));
1818     }
1819 
1820     @Test
testVerify_SHA384withRSAPSS_MaxSalt_Key_Success()1821     public void testVerify_SHA384withRSAPSS_MaxSalt_Key_Success() throws Exception {
1822         KeyFactory kf = KeyFactory.getInstance("RSA");
1823         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1824         PublicKey pubKey = kf.generatePublic(keySpec);
1825 
1826         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
1827         sig.initVerify(pubKey);
1828         sig.setParameter(SHA384withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
1829         sig.update(Vector2Data);
1830 
1831         assertTrue("Signature must verify",
1832                 sig.verify(SHA384withRSAPSS_MaxSalt_Vector2Signature));
1833     }
1834 
1835     @Test
testVerify_SHA512withRSAPSS_Key_Success()1836     public void testVerify_SHA512withRSAPSS_Key_Success() throws Exception {
1837         KeyFactory kf = KeyFactory.getInstance("RSA");
1838         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1839         PublicKey pubKey = kf.generatePublic(keySpec);
1840 
1841         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
1842         sig.initVerify(pubKey);
1843         assertPSSAlgorithmParametersEquals(
1844                 SHA512withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
1845         sig.update(Vector2Data);
1846 
1847         assertTrue("Signature must verify",
1848                 sig.verify(SHA512withRSAPSS_Vector2Signature));
1849     }
1850 
1851     @Test
testVerify_SHA512withRSAPSS_NoSalt_Key_Success()1852     public void testVerify_SHA512withRSAPSS_NoSalt_Key_Success() throws Exception {
1853         KeyFactory kf = KeyFactory.getInstance("RSA");
1854         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1855         PublicKey pubKey = kf.generatePublic(keySpec);
1856 
1857         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
1858         sig.initVerify(pubKey);
1859         sig.setParameter(SHA512withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
1860         sig.update(Vector2Data);
1861 
1862         assertTrue("Signature must verify",
1863                 sig.verify(SHA512withRSAPSS_NoSalt_Vector2Signature));
1864     }
1865 
1866     @Test
testVerify_SHA512withRSAPSS_MaxSalt_Key_Success()1867     public void testVerify_SHA512withRSAPSS_MaxSalt_Key_Success() throws Exception {
1868         KeyFactory kf = KeyFactory.getInstance("RSA");
1869         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1870         PublicKey pubKey = kf.generatePublic(keySpec);
1871 
1872         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
1873         sig.initVerify(pubKey);
1874         sig.setParameter(SHA512withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
1875         sig.update(Vector2Data);
1876 
1877         assertTrue("Signature must verify",
1878                 sig.verify(SHA512withRSAPSS_MaxSalt_Vector2Signature));
1879     }
1880 
1881     @Test
testVerify_SHA1withRSA_Key_InitSignThenInitVerify_Success()1882     public void testVerify_SHA1withRSA_Key_InitSignThenInitVerify_Success() throws Exception {
1883         KeyFactory kf = KeyFactory.getInstance("RSA");
1884         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
1885                 RSA_2048_publicExponent);
1886         PublicKey pubKey = kf.generatePublic(pubKeySpec);
1887 
1888         RSAPrivateKeySpec privKeySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
1889                 RSA_2048_privateExponent);
1890         PrivateKey privKey = kf.generatePrivate(privKeySpec);
1891 
1892         Signature sig = Signature.getInstance("SHA1withRSA");
1893 
1894         // Start a signing operation
1895         sig.initSign(privKey);
1896         sig.update(Vector2Data);
1897 
1898         // Switch to verify
1899         sig.initVerify(pubKey);
1900         sig.update(Vector1Data);
1901 
1902         assertTrue("Signature must match expected signature",
1903                 sig.verify(SHA1withRSA_Vector1Signature));
1904     }
1905 
1906     @Test
testVerify_SHA1withRSA_Key_TwoMessages_Success()1907     public void testVerify_SHA1withRSA_Key_TwoMessages_Success() throws Exception {
1908         KeyFactory kf = KeyFactory.getInstance("RSA");
1909         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1910         PublicKey pubKey = kf.generatePublic(keySpec);
1911 
1912         Signature sig = Signature.getInstance("SHA1withRSA");
1913         sig.initVerify(pubKey);
1914 
1915         sig.update(Vector1Data);
1916         assertTrue("First signature must match expected signature",
1917                 sig.verify(SHA1withRSA_Vector1Signature));
1918 
1919         sig.update(Vector2Data);
1920         assertTrue("Second signature must match expected signature",
1921                 sig.verify(SHA1withRSA_Vector2Signature));
1922     }
1923 
1924     @Test
testVerify_SHA1withRSA_Key_WrongExpectedSignature_Failure()1925     public void testVerify_SHA1withRSA_Key_WrongExpectedSignature_Failure() throws Exception {
1926         KeyFactory kf = KeyFactory.getInstance("RSA");
1927         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
1928         PublicKey pubKey = kf.generatePublic(keySpec);
1929 
1930         Signature sig = Signature.getInstance("SHA1withRSA");
1931         sig.initVerify(pubKey);
1932         sig.update(Vector1Data);
1933 
1934         assertFalse("Signature should fail to verify", sig.verify(SHA1withRSA_Vector2Signature));
1935     }
1936 
1937     @Test
testSign_SHA1withRSA_CrtKeyWithPublicExponent_Success()1938     public void testSign_SHA1withRSA_CrtKeyWithPublicExponent_Success() throws Exception {
1939         KeyFactory kf = KeyFactory.getInstance("RSA");
1940         RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(RSA_2048_modulus,
1941                 RSA_2048_publicExponent, RSA_2048_privateExponent, null, null, null, null, null);
1942 
1943         // The RI fails on this key which is totally unreasonable.
1944         final PrivateKey privKey;
1945         try {
1946             privKey = kf.generatePrivate(keySpec);
1947         } catch (NullPointerException e) {
1948             if (StandardNames.IS_RI) {
1949                 return;
1950             } else {
1951                 fail("Private key should be created");
1952                 return;
1953             }
1954         }
1955 
1956         Signature sig = Signature.getInstance("SHA1withRSA");
1957         sig.initSign(privKey);
1958         sig.update(Vector1Data);
1959 
1960         byte[] signature = sig.sign();
1961         assertNotNull("Signature must not be null", signature);
1962         assertTrue("Signature should match expected",
1963                 Arrays.equals(signature, SHA1withRSA_Vector1Signature));
1964 
1965         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
1966                 RSA_2048_publicExponent);
1967         PublicKey pubKey = kf.generatePublic(pubKeySpec);
1968         sig.initVerify(pubKey);
1969         sig.update(Vector1Data);
1970         assertTrue("Signature must verify correctly", sig.verify(signature));
1971     }
1972 
1973     @Test
testSign_SHA1withRSA_CrtKey_NoPrivateExponent_Failure()1974     public void testSign_SHA1withRSA_CrtKey_NoPrivateExponent_Failure() throws Exception {
1975         KeyFactory kf = KeyFactory.getInstance("RSA");
1976         RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(RSA_2048_modulus,
1977                 RSA_2048_publicExponent, null, RSA_2048_primeP, RSA_2048_primeQ, null, null, null);
1978 
1979         // Failing on this key early is okay.
1980         final PrivateKey privKey;
1981         try {
1982             privKey = kf.generatePrivate(keySpec);
1983         } catch (NullPointerException e) {
1984             return;
1985         } catch (InvalidKeySpecException e) {
1986             return;
1987         }
1988 
1989         Signature sig = Signature.getInstance("SHA1withRSA");
1990 
1991         try {
1992             sig.initSign(privKey);
1993             fail("Should throw error when private exponent is not available");
1994         } catch (InvalidKeyException expected) {
1995         }
1996     }
1997 
1998     @Test
testSign_SHA1withRSA_CrtKey_NoModulus_Failure()1999     public void testSign_SHA1withRSA_CrtKey_NoModulus_Failure() throws Exception {
2000         KeyFactory kf = KeyFactory.getInstance("RSA");
2001         RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(null, RSA_2048_publicExponent,
2002                 RSA_2048_privateExponent, RSA_2048_primeP, RSA_2048_primeQ, null, null, null);
2003 
2004         // Failing on this key early is okay.
2005         final PrivateKey privKey;
2006         try {
2007             privKey = kf.generatePrivate(keySpec);
2008         } catch (NullPointerException e) {
2009             return;
2010         } catch (InvalidKeySpecException e) {
2011             return;
2012         }
2013 
2014         Signature sig = Signature.getInstance("SHA1withRSA");
2015 
2016         try {
2017             sig.initSign(privKey);
2018             fail("Should throw error when modulus is not available");
2019         } catch (InvalidKeyException expected) {
2020         }
2021     }
2022 
2023     @Test
testSign_SHA1withRSA_Key_EmptyKey_Failure()2024     public void testSign_SHA1withRSA_Key_EmptyKey_Failure() throws Exception {
2025         KeyFactory kf = KeyFactory.getInstance("RSA");
2026         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(null, null);
2027 
2028         // Failing on this key early is okay.
2029         final PrivateKey privKey;
2030         try {
2031             privKey = kf.generatePrivate(keySpec);
2032         } catch (NullPointerException e) {
2033             return;
2034         } catch (InvalidKeySpecException e) {
2035             return;
2036         }
2037 
2038         Signature sig = Signature.getInstance("SHA1withRSA");
2039 
2040         try {
2041             sig.initSign(privKey);
2042             fail("Should throw error when key is empty");
2043         } catch (InvalidKeyException expected) {
2044         }
2045     }
2046 
sign(Signature sig, PrivateKey privKey, PublicKey pubKey, byte[] data, byte[] signature)2047     private void sign(Signature sig, PrivateKey privKey, PublicKey pubKey, byte[] data,
2048             byte[] signature) throws Exception {
2049         sig.initSign(privKey);
2050         sig.update(data);
2051 
2052         byte[] generatedSignature = sig.sign();
2053         assertNotNull("Signature must not be null", generatedSignature);
2054         assertArrayEquals("Signature should match expected", signature, generatedSignature);
2055 
2056         sig.initVerify(pubKey);
2057         sig.update(data);
2058         assertTrue("Signature must verify correctly", sig.verify(generatedSignature));
2059 
2060         ByteBuffer heap = ByteBuffer.wrap(data);
2061         sig.initSign(privKey);
2062         sig.update(heap);
2063 
2064         generatedSignature = sig.sign();
2065         assertNotNull("Signature must not be null", generatedSignature);
2066         assertArrayEquals("Signature should match expected", signature, generatedSignature);
2067 
2068         heap.rewind();
2069         sig.initVerify(pubKey);
2070         sig.update(heap);
2071         assertTrue("Signature must verify correctly", sig.verify(generatedSignature));
2072 
2073         ByteBuffer direct = ByteBuffer.allocateDirect(data.length);
2074         direct.put(data);
2075         direct.flip();
2076         sig.initSign(privKey);
2077         sig.update(direct);
2078 
2079         generatedSignature = sig.sign();
2080         assertNotNull("Signature must not be null", generatedSignature);
2081         assertArrayEquals("Signature should match expected", signature, generatedSignature);
2082 
2083         direct.rewind();
2084         sig.initVerify(pubKey);
2085         sig.update(direct);
2086         assertTrue("Signature must verify correctly", sig.verify(generatedSignature));
2087 
2088     }
2089 
2090     @Test
testSign_SHA1withRSA_Key_Success()2091     public void testSign_SHA1withRSA_Key_Success() throws Exception {
2092         KeyFactory kf = KeyFactory.getInstance("RSA");
2093         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2094                 RSA_2048_privateExponent);
2095         PrivateKey privKey = kf.generatePrivate(keySpec);
2096         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2097                 RSA_2048_publicExponent);
2098         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2099 
2100         Signature sig = Signature.getInstance("SHA1withRSA");
2101         sign(sig, privKey, pubKey, Vector1Data, SHA1withRSA_Vector1Signature);
2102     }
2103 
2104     @Test
testSign_SHA224withRSA_Key_Success()2105     public void testSign_SHA224withRSA_Key_Success() throws Exception {
2106         KeyFactory kf = KeyFactory.getInstance("RSA");
2107         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2108                 RSA_2048_privateExponent);
2109         PrivateKey privKey = kf.generatePrivate(keySpec);
2110         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2111                 RSA_2048_publicExponent);
2112         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2113 
2114         Signature sig = Signature.getInstance("SHA224withRSA");
2115         sign(sig, privKey, pubKey, Vector2Data, SHA224withRSA_Vector2Signature);
2116     }
2117 
2118     @Test
testSign_SHA256withRSA_Key_Success()2119     public void testSign_SHA256withRSA_Key_Success() throws Exception {
2120         KeyFactory kf = KeyFactory.getInstance("RSA");
2121         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2122                 RSA_2048_privateExponent);
2123         PrivateKey privKey = kf.generatePrivate(keySpec);
2124         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2125                 RSA_2048_publicExponent);
2126         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2127 
2128         Signature sig = Signature.getInstance("SHA256withRSA");
2129         sign(sig, privKey, pubKey, Vector2Data, SHA256withRSA_Vector2Signature);
2130     }
2131 
2132     @Test
testSign_SHA384withRSA_Key_Success()2133     public void testSign_SHA384withRSA_Key_Success() throws Exception {
2134         KeyFactory kf = KeyFactory.getInstance("RSA");
2135         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2136                 RSA_2048_privateExponent);
2137         PrivateKey privKey = kf.generatePrivate(keySpec);
2138         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2139                 RSA_2048_publicExponent);
2140         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2141 
2142         Signature sig = Signature.getInstance("SHA384withRSA");
2143         sign(sig, privKey, pubKey, Vector2Data, SHA384withRSA_Vector2Signature);
2144     }
2145 
2146     @Test
testSign_SHA512withRSA_Key_Success()2147     public void testSign_SHA512withRSA_Key_Success() throws Exception {
2148         KeyFactory kf = KeyFactory.getInstance("RSA");
2149         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2150                 RSA_2048_privateExponent);
2151         PrivateKey privKey = kf.generatePrivate(keySpec);
2152         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2153                 RSA_2048_publicExponent);
2154         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2155 
2156         Signature sig = Signature.getInstance("SHA512withRSA");
2157         sign(sig, privKey, pubKey, Vector2Data, SHA512withRSA_Vector2Signature);
2158     }
2159 
2160     @Test
testSign_MD5withRSA_Key_Success()2161     public void testSign_MD5withRSA_Key_Success() throws Exception {
2162         KeyFactory kf = KeyFactory.getInstance("RSA");
2163         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2164                 RSA_2048_privateExponent);
2165         PrivateKey privKey = kf.generatePrivate(keySpec);
2166         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2167                 RSA_2048_publicExponent);
2168         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2169 
2170         Signature sig = Signature.getInstance("MD5withRSA");
2171         sign(sig, privKey, pubKey, Vector2Data, MD5withRSA_Vector2Signature);
2172     }
2173 
2174     @Test
testSign_SHA1withRSAPSS_Key_Success()2175     public void testSign_SHA1withRSAPSS_Key_Success() throws Exception {
2176         KeyFactory kf = KeyFactory.getInstance("RSA");
2177         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2178                 RSA_2048_privateExponent);
2179         PrivateKey privKey = kf.generatePrivate(keySpec);
2180 
2181         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
2182         sig.initSign(privKey);
2183         sig.update(Vector2Data);
2184 
2185         byte[] signature = sig.sign();
2186         assertNotNull("Signature must not be null", signature);
2187         assertPSSAlgorithmParametersEquals(
2188                 SHA1withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
2189 
2190         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2191                 RSA_2048_publicExponent);
2192         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2193         sig.initVerify(pubKey);
2194         sig.update(Vector2Data);
2195         assertTrue("Signature must verify correctly", sig.verify(signature));
2196     }
2197 
2198     @Test
testSign_SHA1withRSAPSS_NoSalt_Key_Success()2199     public void testSign_SHA1withRSAPSS_NoSalt_Key_Success() throws Exception {
2200         KeyFactory kf = KeyFactory.getInstance("RSA");
2201         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2202                 RSA_2048_privateExponent);
2203         PrivateKey privKey = kf.generatePrivate(keySpec);
2204 
2205         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
2206         sig.initSign(privKey);
2207         sig.setParameter(SHA1withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2208         sig.update(Vector2Data);
2209 
2210         byte[] signature = sig.sign();
2211         assertNotNull("Signature must not be null", signature);
2212         assertPSSAlgorithmParametersEquals(
2213                 SHA1withRSAPSS_NoSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2214         assertTrue("Signature should match expected",
2215                 Arrays.equals(signature, SHA1withRSAPSS_NoSalt_Vector2Signature));
2216 
2217         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2218                 RSA_2048_publicExponent);
2219         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2220         sig.initVerify(pubKey);
2221         sig.setParameter(SHA1withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2222         sig.update(Vector2Data);
2223         assertTrue("Signature must verify correctly", sig.verify(signature));
2224     }
2225 
2226     @Test
testSign_SHA1withRSAPSS_MaxSalt_Key_Success()2227     public void testSign_SHA1withRSAPSS_MaxSalt_Key_Success() throws Exception {
2228         KeyFactory kf = KeyFactory.getInstance("RSA");
2229         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2230                 RSA_2048_privateExponent);
2231         PrivateKey privKey = kf.generatePrivate(keySpec);
2232 
2233         Signature sig = Signature.getInstance("SHA1withRSA/PSS");
2234         sig.initSign(privKey);
2235         sig.setParameter(SHA1withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2236         sig.update(Vector2Data);
2237 
2238         byte[] signature = sig.sign();
2239         assertNotNull("Signature must not be null", signature);
2240         assertPSSAlgorithmParametersEquals(
2241                 SHA1withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2242 
2243         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2244                 RSA_2048_publicExponent);
2245         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2246         sig = Signature.getInstance("SHA1withRSA/PSS");
2247         sig.initVerify(pubKey);
2248         sig.setParameter(SHA1withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2249         sig.update(Vector2Data);
2250         assertTrue("Signature must verify correctly", sig.verify(signature));
2251     }
2252 
2253     @Test
testSign_SHA224withRSAPSS_Key_Success()2254     public void testSign_SHA224withRSAPSS_Key_Success() throws Exception {
2255         KeyFactory kf = KeyFactory.getInstance("RSA");
2256         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2257                 RSA_2048_privateExponent);
2258         PrivateKey privKey = kf.generatePrivate(keySpec);
2259 
2260         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
2261         sig.initSign(privKey);
2262         sig.update(Vector2Data);
2263 
2264         byte[] signature = sig.sign();
2265         assertNotNull("Signature must not be null", signature);
2266         assertPSSAlgorithmParametersEquals(
2267                 SHA224withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
2268 
2269         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2270                 RSA_2048_publicExponent);
2271         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2272         sig.initVerify(pubKey);
2273         sig.update(Vector2Data);
2274         assertTrue("Signature must verify correctly", sig.verify(signature));
2275     }
2276 
2277     @Test
testSign_SHA224withRSAPSS_NoSalt_Key_Success()2278     public void testSign_SHA224withRSAPSS_NoSalt_Key_Success() throws Exception {
2279         KeyFactory kf = KeyFactory.getInstance("RSA");
2280         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2281                 RSA_2048_privateExponent);
2282         PrivateKey privKey = kf.generatePrivate(keySpec);
2283 
2284         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
2285         sig.initSign(privKey);
2286         sig.setParameter(SHA224withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2287         sig.update(Vector2Data);
2288 
2289         byte[] signature = sig.sign();
2290         assertNotNull("Signature must not be null", signature);
2291         assertPSSAlgorithmParametersEquals(
2292                 SHA224withRSAPSS_NoSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2293         assertTrue("Signature should match expected",
2294                 Arrays.equals(signature, SHA224withRSAPSS_NoSalt_Vector2Signature));
2295 
2296         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2297                 RSA_2048_publicExponent);
2298         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2299         sig.initVerify(pubKey);
2300         sig.setParameter(SHA224withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2301         sig.update(Vector2Data);
2302         assertTrue("Signature must verify correctly", sig.verify(signature));
2303     }
2304 
2305     @Test
testSign_SHA224withRSAPSS_MaxSalt_Key_Success()2306     public void testSign_SHA224withRSAPSS_MaxSalt_Key_Success() throws Exception {
2307         KeyFactory kf = KeyFactory.getInstance("RSA");
2308         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2309                 RSA_2048_privateExponent);
2310         PrivateKey privKey = kf.generatePrivate(keySpec);
2311 
2312         Signature sig = Signature.getInstance("SHA224withRSA/PSS");
2313         sig.initSign(privKey);
2314         sig.setParameter(SHA224withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2315         sig.update(Vector2Data);
2316 
2317         byte[] signature = sig.sign();
2318         assertNotNull("Signature must not be null", signature);
2319         assertPSSAlgorithmParametersEquals(
2320                 SHA224withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2321 
2322         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2323                 RSA_2048_publicExponent);
2324         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2325         sig = Signature.getInstance("SHA224withRSA/PSS");
2326         sig.initVerify(pubKey);
2327         sig.setParameter(SHA224withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2328         sig.update(Vector2Data);
2329         assertTrue("Signature must verify correctly", sig.verify(signature));
2330     }
2331 
2332     @Test
testSign_SHA256withRSAPSS_Key_Success()2333     public void testSign_SHA256withRSAPSS_Key_Success() throws Exception {
2334         KeyFactory kf = KeyFactory.getInstance("RSA");
2335         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2336                 RSA_2048_privateExponent);
2337         PrivateKey privKey = kf.generatePrivate(keySpec);
2338 
2339         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
2340         sig.initSign(privKey);
2341         sig.update(Vector2Data);
2342 
2343         byte[] signature = sig.sign();
2344         assertNotNull("Signature must not be null", signature);
2345         assertPSSAlgorithmParametersEquals(
2346                 SHA256withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
2347 
2348         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2349                 RSA_2048_publicExponent);
2350         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2351         sig.initVerify(pubKey);
2352         sig.update(Vector2Data);
2353         assertTrue("Signature must verify correctly", sig.verify(signature));
2354     }
2355 
2356     @Test
testSign_SHA256withRSAPSS_NoSalt_Key_Success()2357     public void testSign_SHA256withRSAPSS_NoSalt_Key_Success() throws Exception {
2358         KeyFactory kf = KeyFactory.getInstance("RSA");
2359         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2360                 RSA_2048_privateExponent);
2361         PrivateKey privKey = kf.generatePrivate(keySpec);
2362 
2363         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
2364         sig.initSign(privKey);
2365         sig.setParameter(SHA256withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2366         sig.update(Vector2Data);
2367 
2368         byte[] signature = sig.sign();
2369         assertNotNull("Signature must not be null", signature);
2370         assertPSSAlgorithmParametersEquals(
2371                 SHA256withRSAPSS_NoSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2372         assertTrue("Signature should match expected",
2373                 Arrays.equals(signature, SHA256withRSAPSS_NoSalt_Vector2Signature));
2374 
2375         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2376                 RSA_2048_publicExponent);
2377         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2378         sig.initVerify(pubKey);
2379         sig.setParameter(SHA256withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2380         sig.update(Vector2Data);
2381         assertTrue("Signature must verify correctly", sig.verify(signature));
2382     }
2383 
2384     @Test
testSign_SHA256withRSAPSS_MaxSalt_Key_Success()2385     public void testSign_SHA256withRSAPSS_MaxSalt_Key_Success() throws Exception {
2386         KeyFactory kf = KeyFactory.getInstance("RSA");
2387         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2388                 RSA_2048_privateExponent);
2389         PrivateKey privKey = kf.generatePrivate(keySpec);
2390 
2391         Signature sig = Signature.getInstance("SHA256withRSA/PSS");
2392         sig.initSign(privKey);
2393         sig.setParameter(SHA256withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2394         sig.update(Vector2Data);
2395 
2396         byte[] signature = sig.sign();
2397         assertNotNull("Signature must not be null", signature);
2398         assertPSSAlgorithmParametersEquals(
2399                 SHA256withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2400 
2401         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2402                 RSA_2048_publicExponent);
2403         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2404         sig = Signature.getInstance("SHA256withRSA/PSS");
2405         sig.initVerify(pubKey);
2406         sig.setParameter(SHA256withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2407         sig.update(Vector2Data);
2408         assertTrue("Signature must verify correctly", sig.verify(signature));
2409     }
2410 
2411     @Test
testSign_SHA384withRSAPSS_Key_Success()2412     public void testSign_SHA384withRSAPSS_Key_Success() throws Exception {
2413         KeyFactory kf = KeyFactory.getInstance("RSA");
2414         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2415                 RSA_2048_privateExponent);
2416         PrivateKey privKey = kf.generatePrivate(keySpec);
2417 
2418         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
2419         sig.initSign(privKey);
2420         sig.update(Vector2Data);
2421 
2422         byte[] signature = sig.sign();
2423         assertNotNull("Signature must not be null", signature);
2424         assertPSSAlgorithmParametersEquals(
2425                 SHA384withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
2426 
2427         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2428                 RSA_2048_publicExponent);
2429         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2430         sig.initVerify(pubKey);
2431         sig.update(Vector2Data);
2432         assertTrue("Signature must verify correctly", sig.verify(signature));
2433     }
2434 
2435     @Test
testSign_SHA384withRSAPSS_NoSalt_Key_Success()2436     public void testSign_SHA384withRSAPSS_NoSalt_Key_Success() throws Exception {
2437         KeyFactory kf = KeyFactory.getInstance("RSA");
2438         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2439                 RSA_2048_privateExponent);
2440         PrivateKey privKey = kf.generatePrivate(keySpec);
2441 
2442         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
2443         sig.initSign(privKey);
2444         sig.setParameter(SHA384withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2445         sig.update(Vector2Data);
2446 
2447         byte[] signature = sig.sign();
2448         assertNotNull("Signature must not be null", signature);
2449         assertPSSAlgorithmParametersEquals(
2450                 SHA384withRSAPSS_NoSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2451         assertTrue("Signature should match expected",
2452                 Arrays.equals(signature, SHA384withRSAPSS_NoSalt_Vector2Signature));
2453 
2454         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2455                 RSA_2048_publicExponent);
2456         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2457         sig.initVerify(pubKey);
2458         sig.setParameter(SHA384withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2459         sig.update(Vector2Data);
2460         assertTrue("Signature must verify correctly", sig.verify(signature));
2461     }
2462 
2463     @Test
testSign_SHA384withRSAPSS_MaxSalt_Key_Success()2464     public void testSign_SHA384withRSAPSS_MaxSalt_Key_Success() throws Exception {
2465         KeyFactory kf = KeyFactory.getInstance("RSA");
2466         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2467                 RSA_2048_privateExponent);
2468         PrivateKey privKey = kf.generatePrivate(keySpec);
2469 
2470         Signature sig = Signature.getInstance("SHA384withRSA/PSS");
2471         sig.initSign(privKey);
2472         sig.setParameter(SHA384withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2473         sig.update(Vector2Data);
2474 
2475         byte[] signature = sig.sign();
2476         assertNotNull("Signature must not be null", signature);
2477         assertPSSAlgorithmParametersEquals(
2478                 SHA384withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2479 
2480         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2481                 RSA_2048_publicExponent);
2482         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2483         sig = Signature.getInstance("SHA384withRSA/PSS");
2484         sig.initVerify(pubKey);
2485         sig.setParameter(SHA384withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2486         sig.update(Vector2Data);
2487         assertTrue("Signature must verify correctly", sig.verify(signature));
2488     }
2489 
2490     @Test
testSign_SHA512withRSAPSS_Key_Success()2491     public void testSign_SHA512withRSAPSS_Key_Success() throws Exception {
2492         KeyFactory kf = KeyFactory.getInstance("RSA");
2493         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2494                 RSA_2048_privateExponent);
2495         PrivateKey privKey = kf.generatePrivate(keySpec);
2496 
2497         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
2498         sig.initSign(privKey);
2499         sig.update(Vector2Data);
2500 
2501         byte[] signature = sig.sign();
2502         assertNotNull("Signature must not be null", signature);
2503         assertPSSAlgorithmParametersEquals(
2504                 SHA512withRSAPSS_Vector2Signature_ParameterSpec, sig.getParameters());
2505 
2506         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2507                 RSA_2048_publicExponent);
2508         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2509         sig.initVerify(pubKey);
2510         sig.update(Vector2Data);
2511         assertTrue("Signature must verify correctly", sig.verify(signature));
2512     }
2513 
2514     @Test
testSign_SHA512withRSAPSS_NoSalt_Key_Success()2515     public void testSign_SHA512withRSAPSS_NoSalt_Key_Success() throws Exception {
2516         KeyFactory kf = KeyFactory.getInstance("RSA");
2517         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2518                 RSA_2048_privateExponent);
2519         PrivateKey privKey = kf.generatePrivate(keySpec);
2520 
2521         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
2522         sig.initSign(privKey);
2523         sig.setParameter(SHA512withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2524         sig.update(Vector2Data);
2525 
2526         byte[] signature = sig.sign();
2527         assertNotNull("Signature must not be null", signature);
2528         assertPSSAlgorithmParametersEquals(
2529                 SHA512withRSAPSS_NoSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2530         assertTrue("Signature should match expected",
2531                 Arrays.equals(signature, SHA512withRSAPSS_NoSalt_Vector2Signature));
2532 
2533         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2534                 RSA_2048_publicExponent);
2535         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2536         sig.initVerify(pubKey);
2537         sig.setParameter(SHA512withRSAPSS_NoSalt_Vector2Signature_ParameterSpec);
2538         sig.update(Vector2Data);
2539         assertTrue("Signature must verify correctly", sig.verify(signature));
2540     }
2541 
2542     @Test
testSign_SHA512withRSAPSS_MaxSalt_Key_Success()2543     public void testSign_SHA512withRSAPSS_MaxSalt_Key_Success() throws Exception {
2544         KeyFactory kf = KeyFactory.getInstance("RSA");
2545         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2546                 RSA_2048_privateExponent);
2547         PrivateKey privKey = kf.generatePrivate(keySpec);
2548 
2549         Signature sig = Signature.getInstance("SHA512withRSA/PSS");
2550         sig.initSign(privKey);
2551         sig.setParameter(SHA512withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2552         sig.update(Vector2Data);
2553 
2554         byte[] signature = sig.sign();
2555         assertNotNull("Signature must not be null", signature);
2556         assertPSSAlgorithmParametersEquals(
2557                 SHA512withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec, sig.getParameters());
2558 
2559         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2560                 RSA_2048_publicExponent);
2561         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2562         sig = Signature.getInstance("SHA512withRSA/PSS");
2563         sig.initVerify(pubKey);
2564         sig.setParameter(SHA512withRSAPSS_MaxSalt_Vector2Signature_ParameterSpec);
2565         sig.update(Vector2Data);
2566         assertTrue("Signature must verify correctly", sig.verify(signature));
2567     }
2568 
2569     @Test
testSign_NONEwithRSA_Key_Success()2570     public void testSign_NONEwithRSA_Key_Success() throws Exception {
2571         KeyFactory kf = KeyFactory.getInstance("RSA");
2572         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2573                 RSA_2048_privateExponent);
2574         PrivateKey privKey = kf.generatePrivate(keySpec);
2575 
2576         Signature sig = Signature.getInstance("NONEwithRSA");
2577         sig.initSign(privKey);
2578         sig.update(Vector1Data);
2579 
2580         byte[] signature = sig.sign();
2581         assertNotNull("Signature must not be null", signature);
2582         assertTrue("Signature should match expected",
2583                 Arrays.equals(signature, NONEwithRSA_Vector1Signature));
2584 
2585         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2586                 RSA_2048_publicExponent);
2587         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2588         sig.initVerify(pubKey);
2589         sig.update(Vector1Data);
2590         assertTrue("Signature must verify correctly", sig.verify(signature));
2591     }
2592 
2593     @Test
testVerify_NONEwithRSA_Key_WrongSignature_Failure()2594     public void testVerify_NONEwithRSA_Key_WrongSignature_Failure() throws Exception {
2595         KeyFactory kf = KeyFactory.getInstance("RSA");
2596 
2597         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2598                 RSA_2048_publicExponent);
2599         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2600 
2601         Signature sig = Signature.getInstance("NONEwithRSA");
2602         sig.initVerify(pubKey);
2603         sig.update(Vector1Data);
2604         assertFalse("Invalid signature must not verify",
2605                 sig.verify("Invalid".getBytes("UTF-8")));
2606     }
2607 
2608     @Test
testSign_NONEwithRSA_Key_DataTooLarge_Failure()2609     public void testSign_NONEwithRSA_Key_DataTooLarge_Failure() throws Exception {
2610         KeyFactory kf = KeyFactory.getInstance("RSA");
2611         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2612                 RSA_2048_privateExponent);
2613         PrivateKey privKey = kf.generatePrivate(keySpec);
2614 
2615         Signature sig = Signature.getInstance("NONEwithRSA");
2616         sig.initSign(privKey);
2617 
2618         final int oneTooBig = RSA_2048_modulus.bitLength() - 10;
2619         for (int i = 0; i < oneTooBig; i++) {
2620             sig.update((byte) i);
2621         }
2622 
2623         try {
2624             sig.sign();
2625             fail("Should throw exception when data is too large");
2626         } catch (SignatureException expected) {
2627         }
2628     }
2629 
2630     @Test
testSign_NONEwithRSA_Key_DataTooLarge_SingleByte_Failure()2631     public void testSign_NONEwithRSA_Key_DataTooLarge_SingleByte_Failure() throws Exception {
2632         KeyFactory kf = KeyFactory.getInstance("RSA");
2633         RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(RSA_2048_modulus,
2634                 RSA_2048_privateExponent);
2635         PrivateKey privKey = kf.generatePrivate(keySpec);
2636 
2637         Signature sig = Signature.getInstance("NONEwithRSA");
2638         sig.initSign(privKey);
2639 
2640         // This should make it two bytes too big.
2641         final int oneTooBig = RSA_2048_modulus.bitLength() - 10;
2642         for (int i = 0; i < oneTooBig; i++) {
2643             sig.update((byte) i);
2644         }
2645 
2646         try {
2647             sig.sign();
2648             fail("Should throw exception when data is too large");
2649         } catch (SignatureException expected) {
2650         }
2651     }
2652 
2653     @Test
testVerify_NONEwithRSA_Key_DataTooLarge_Failure()2654     public void testVerify_NONEwithRSA_Key_DataTooLarge_Failure() throws Exception {
2655         KeyFactory kf = KeyFactory.getInstance("RSA");
2656 
2657         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2658                 RSA_2048_publicExponent);
2659         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2660 
2661         Signature sig = Signature.getInstance("NONEwithRSA");
2662         sig.initVerify(pubKey);
2663 
2664         // This should make it one bytes too big.
2665         final int oneTooBig = RSA_2048_modulus.bitLength() + 1;
2666         final byte[] vector = new byte[oneTooBig];
2667         for (int i = 0; i < oneTooBig; i++) {
2668             vector[i] = Vector1Data[i % Vector1Data.length];
2669         }
2670         sig.update(vector);
2671 
2672         assertFalse("Should not verify when signature is too large",
2673                 sig.verify(NONEwithRSA_Vector1Signature));
2674     }
2675 
2676     @Test
testVerify_NONEwithRSA_Key_DataTooLarge_SingleByte_Failure()2677     public void testVerify_NONEwithRSA_Key_DataTooLarge_SingleByte_Failure() throws Exception {
2678         KeyFactory kf = KeyFactory.getInstance("RSA");
2679 
2680         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2681                 RSA_2048_publicExponent);
2682         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2683 
2684         Signature sig = Signature.getInstance("NONEwithRSA");
2685         sig.initVerify(pubKey);
2686 
2687         // This should make it twice as big as it should be.
2688         final int tooBig = RSA_2048_modulus.bitLength() * 2;
2689         for (int i = 0; i < tooBig; i++) {
2690             sig.update(Vector1Data[i % Vector1Data.length]);
2691         }
2692 
2693         assertFalse("Should not verify when signature is too large",
2694                 sig.verify(NONEwithRSA_Vector1Signature));
2695     }
2696 
2697     @Test
testVerify_NONEwithRSA_Key_SignatureTooSmall_Failure()2698     public void testVerify_NONEwithRSA_Key_SignatureTooSmall_Failure() throws Exception {
2699         KeyFactory kf = KeyFactory.getInstance("RSA");
2700 
2701         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2702                 RSA_2048_publicExponent);
2703         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2704 
2705         Signature sig = Signature.getInstance("NONEwithRSA");
2706         sig.initVerify(pubKey);
2707         sig.update(Vector1Data);
2708 
2709         assertFalse("Invalid signature should not verify",
2710                 sig.verify("Invalid sig".getBytes("UTF-8")));
2711     }
2712 
2713     @Test
testVerify_NONEwithRSA_Key_SignatureTooLarge_Failure()2714     public void testVerify_NONEwithRSA_Key_SignatureTooLarge_Failure() throws Exception {
2715         KeyFactory kf = KeyFactory.getInstance("RSA");
2716 
2717         RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus,
2718                 RSA_2048_publicExponent);
2719         PublicKey pubKey = kf.generatePublic(pubKeySpec);
2720 
2721         Signature sig = Signature.getInstance("NONEwithRSA");
2722         sig.initVerify(pubKey);
2723         sig.update(Vector1Data);
2724 
2725         byte[] invalidSignature = new byte[NONEwithRSA_Vector1Signature.length * 2];
2726         System.arraycopy(NONEwithRSA_Vector1Signature, 0, invalidSignature, 0,
2727                 NONEwithRSA_Vector1Signature.length);
2728         System.arraycopy(NONEwithRSA_Vector1Signature, 0, invalidSignature,
2729                 NONEwithRSA_Vector1Signature.length, NONEwithRSA_Vector1Signature.length);
2730 
2731         try {
2732             sig.verify(invalidSignature);
2733             fail("Should throw exception when signature is too large");
2734         } catch (SignatureException expected) {
2735         }
2736     }
2737 
2738     @Test
testSign_NONEwithECDSA_Key_Success()2739     public void testSign_NONEwithECDSA_Key_Success() throws Exception {
2740         KeyPair keys = keyPair("NONEwithECDSA");
2741         Signature sig = Signature.getInstance("NONEwithECDSA");
2742 
2743         sig.initSign(keys.getPrivate());
2744         sig.update(Vector1Data);
2745         byte[] signature = sig.sign();
2746         assertNotNull("Signature must not be null", signature);
2747         assertTrue("Signature must not be empty", signature.length > 0);
2748 
2749         sig.initVerify(keys.getPublic());
2750         sig.update(Vector1Data);
2751         assertTrue("Signature must verify correctly", sig.verify(signature));
2752     }
2753 
2754     @Test
testVerify_NONEwithECDSA_Key_Success()2755     public void testVerify_NONEwithECDSA_Key_Success() throws Exception {
2756         PublicKey pub = getNamedCurveEcPublicKey();
2757         MessageDigest sha1 = MessageDigest.getInstance("SHA1");
2758         Signature sig = Signature.getInstance("NONEwithECDSA");
2759 
2760         // NAMED_CURVE_SIGNATURE was signed using SHA1withECDSA, so NONEwithECDSA should
2761         // verify the digest
2762         sig.initVerify(pub);
2763         sig.update(sha1.digest(NAMED_CURVE_VECTOR));
2764         assertTrue(sig.verify(NAMED_CURVE_SIGNATURE));
2765     }
2766 
2767     @Test
testVerify_NONEwithECDSA_Key_WrongData_Failure()2768     public void testVerify_NONEwithECDSA_Key_WrongData_Failure() throws Exception {
2769         PublicKey pub = getNamedCurveEcPublicKey();
2770         Signature sig = Signature.getInstance("NONEwithECDSA");
2771 
2772         sig.initVerify(pub);
2773         sig.update(NAMED_CURVE_VECTOR);
2774         assertFalse(sig.verify(NAMED_CURVE_SIGNATURE));
2775     }
2776 
2777     // Suppress ErrorProne's warning about the try block that doesn't call fail() but
2778     // expects an exception, it's intentional
2779     @SuppressWarnings("MissingFail")
2780     @Test
testVerify_NONEwithECDSA_Key_SingleByte_Failure()2781     public void testVerify_NONEwithECDSA_Key_SingleByte_Failure() throws Exception {
2782         PublicKey pub = getNamedCurveEcPublicKey();
2783         MessageDigest sha1 = MessageDigest.getInstance("SHA1");
2784         Signature sig = Signature.getInstance("NONEwithECDSA");
2785 
2786         byte[] corrupted = new byte[NAMED_CURVE_SIGNATURE.length];
2787         corrupted[0] = (byte) (corrupted[0] ^ 1);
2788 
2789         sig.initVerify(pub);
2790         sig.update(sha1.digest(NAMED_CURVE_VECTOR));
2791         try {
2792             assertFalse(sig.verify(corrupted));
2793         } catch (SignatureException expected) {
2794             // It's valid to either return false or throw an exception, accept either
2795         }
2796     }
2797 
2798     // Tests that an opaque key will be accepted by the ECDSA signature and will delegate to a
2799     // functioning alternative provider
2800     @Test
test_NONEwithECDSA_OpaqueKey()2801     public void test_NONEwithECDSA_OpaqueKey() throws Exception {
2802         KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
2803         keyGen.initialize(256);
2804         KeyPair kp = keyGen.generateKeyPair();
2805 
2806         // Insert this at #2 so that Conscrypt is still the first provider and CryptoUpcalls
2807         // has to drop to manual provider selection rather than relying on Signature's internals
2808         Security.insertProviderAt(new OpaqueProvider(), 2);
2809         try {
2810             Signature sig = Signature.getInstance(
2811                 "NONEwithECDSA", TestUtils.getConscryptProvider());
2812             sig.initSign(OpaqueProvider.wrapKeyMarked(kp.getPrivate()));
2813             sig.update(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
2814             byte[] data = sig.sign();
2815 
2816             sig.initVerify(kp.getPublic());
2817             sig.update(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
2818             assertTrue(sig.verify(data));
2819         } finally {
2820             Security.removeProvider(OpaqueProvider.NAME);
2821         }
2822     }
2823 
2824     // Tests that an opaque key will be accepted by the ECDSA signature and that a broken
2825     // alternative provider that throws UnsupportedOperationException will be skipped and
2826     // a functioning provider that follows will work.
2827     @Test
test_NONEwithECDSA_OpaqueKey_BrokenProvider()2828     public void test_NONEwithECDSA_OpaqueKey_BrokenProvider() throws Exception {
2829         KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
2830         keyGen.initialize(256);
2831         KeyPair kp = keyGen.generateKeyPair();
2832 
2833         // Insert these at #2 so that Conscrypt is still the first provider and CryptoUpcalls
2834         // has to drop to manual provider selection rather than relying on Signature's internals
2835         Security.insertProviderAt(new OpaqueProvider(), 2);
2836         Security.insertProviderAt(new BrokenProvider(), 2);
2837         try {
2838             Signature sig = Signature.getInstance(
2839                 "NONEwithECDSA", TestUtils.getConscryptProvider());
2840             sig.initSign(OpaqueProvider.wrapKeyMarked(kp.getPrivate()));
2841             sig.update(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
2842             byte[] data = sig.sign();
2843 
2844             sig.initVerify(kp.getPublic());
2845             sig.update(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
2846             assertTrue(sig.verify(data));
2847         } finally {
2848             Security.removeProvider(OpaqueProvider.NAME);
2849             Security.removeProvider(BrokenProvider.NAME);
2850         }
2851     }
2852 
2853     /*
2854      * These tests were generated with this DSA private key:
2855      *
2856      * -----BEGIN DSA PRIVATE KEY-----
2857      * MIIBugIBAAKBgQCeYcKJ73epThNnZB8JAf4kE1Pgt5CoTnb+iYJ/esU8TgwgVTCV
2858      * QoXhQH0njwcN6NyZ77MHlDTWfP+cvmnT60Q3UO9J+OJb2NEQhJfq46UcwE5pynA9
2859      * eLkW5f5hXYpasyxhtgE70AF8Mo3h82kOi1jGzwCU+EkqS+raAP9L0L5AIwIVAL/u
2860      * qg8SNFBy+GAT2PFBARClL1dfAoGAd9R6EsyBfn7rOvvmhm1aEB2tqU+5A10hGuQw
2861      * lXWOzV7RvQpF7uf3a2UCYNAurz28B90rjjPAk4DZK6dxV3a8jrng1/QjjUEal08s
2862      * G9VLZuj60lANF6s0MT2kiNiOqKduFwO3D2h8ZHuSuGPkmmcYgSfUCxNI031O9qiP
2863      * VhctCFECgYAz7i1DhjRGUkCdYQd5tVaI42lhXOV71MTYPbuFOIxTL/hny7Z0PZWR
2864      * A1blmYE6vrArDEhzpmRvDJZSIMzMfJjUIGu1KO73zpo9siK0xY0/sw5r3QC9txP2
2865      * 2Mv3BUIl5TLrs9outQJ0VMwldY2fElgCLWcSVkH44qZwWir1cq+cIwIUEGPDardb
2866      * pNvWlWgTDD6a6ZTby+M=
2867      * -----END DSA PRIVATE KEY-----
2868      *
2869      */
2870 
2871     private static final BigInteger DSA_priv = new BigInteger(new byte[] {
2872         (byte) 0x10, (byte) 0x63, (byte) 0xc3, (byte) 0x6a, (byte) 0xb7, (byte) 0x5b, (byte) 0xa4, (byte) 0xdb,
2873         (byte) 0xd6, (byte) 0x95, (byte) 0x68, (byte) 0x13, (byte) 0x0c, (byte) 0x3e, (byte) 0x9a, (byte) 0xe9,
2874         (byte) 0x94, (byte) 0xdb, (byte) 0xcb, (byte) 0xe3,
2875     });
2876 
2877     private static final BigInteger DSA_pub = new BigInteger(new byte[] {
2878         (byte) 0x33, (byte) 0xee, (byte) 0x2d, (byte) 0x43, (byte) 0x86, (byte) 0x34, (byte) 0x46, (byte) 0x52,
2879         (byte) 0x40, (byte) 0x9d, (byte) 0x61, (byte) 0x07, (byte) 0x79, (byte) 0xb5, (byte) 0x56, (byte) 0x88,
2880         (byte) 0xe3, (byte) 0x69, (byte) 0x61, (byte) 0x5c, (byte) 0xe5, (byte) 0x7b, (byte) 0xd4, (byte) 0xc4,
2881         (byte) 0xd8, (byte) 0x3d, (byte) 0xbb, (byte) 0x85, (byte) 0x38, (byte) 0x8c, (byte) 0x53, (byte) 0x2f,
2882         (byte) 0xf8, (byte) 0x67, (byte) 0xcb, (byte) 0xb6, (byte) 0x74, (byte) 0x3d, (byte) 0x95, (byte) 0x91,
2883         (byte) 0x03, (byte) 0x56, (byte) 0xe5, (byte) 0x99, (byte) 0x81, (byte) 0x3a, (byte) 0xbe, (byte) 0xb0,
2884         (byte) 0x2b, (byte) 0x0c, (byte) 0x48, (byte) 0x73, (byte) 0xa6, (byte) 0x64, (byte) 0x6f, (byte) 0x0c,
2885         (byte) 0x96, (byte) 0x52, (byte) 0x20, (byte) 0xcc, (byte) 0xcc, (byte) 0x7c, (byte) 0x98, (byte) 0xd4,
2886         (byte) 0x20, (byte) 0x6b, (byte) 0xb5, (byte) 0x28, (byte) 0xee, (byte) 0xf7, (byte) 0xce, (byte) 0x9a,
2887         (byte) 0x3d, (byte) 0xb2, (byte) 0x22, (byte) 0xb4, (byte) 0xc5, (byte) 0x8d, (byte) 0x3f, (byte) 0xb3,
2888         (byte) 0x0e, (byte) 0x6b, (byte) 0xdd, (byte) 0x00, (byte) 0xbd, (byte) 0xb7, (byte) 0x13, (byte) 0xf6,
2889         (byte) 0xd8, (byte) 0xcb, (byte) 0xf7, (byte) 0x05, (byte) 0x42, (byte) 0x25, (byte) 0xe5, (byte) 0x32,
2890         (byte) 0xeb, (byte) 0xb3, (byte) 0xda, (byte) 0x2e, (byte) 0xb5, (byte) 0x02, (byte) 0x74, (byte) 0x54,
2891         (byte) 0xcc, (byte) 0x25, (byte) 0x75, (byte) 0x8d, (byte) 0x9f, (byte) 0x12, (byte) 0x58, (byte) 0x02,
2892         (byte) 0x2d, (byte) 0x67, (byte) 0x12, (byte) 0x56, (byte) 0x41, (byte) 0xf8, (byte) 0xe2, (byte) 0xa6,
2893         (byte) 0x70, (byte) 0x5a, (byte) 0x2a, (byte) 0xf5, (byte) 0x72, (byte) 0xaf, (byte) 0x9c, (byte) 0x23,
2894     });
2895 
2896     private static final BigInteger DSA_P = new BigInteger(new byte[] {
2897         (byte) 0x00, (byte) 0x9e, (byte) 0x61, (byte) 0xc2, (byte) 0x89, (byte) 0xef, (byte) 0x77, (byte) 0xa9,
2898         (byte) 0x4e, (byte) 0x13, (byte) 0x67, (byte) 0x64, (byte) 0x1f, (byte) 0x09, (byte) 0x01, (byte) 0xfe,
2899         (byte) 0x24, (byte) 0x13, (byte) 0x53, (byte) 0xe0, (byte) 0xb7, (byte) 0x90, (byte) 0xa8, (byte) 0x4e,
2900         (byte) 0x76, (byte) 0xfe, (byte) 0x89, (byte) 0x82, (byte) 0x7f, (byte) 0x7a, (byte) 0xc5, (byte) 0x3c,
2901         (byte) 0x4e, (byte) 0x0c, (byte) 0x20, (byte) 0x55, (byte) 0x30, (byte) 0x95, (byte) 0x42, (byte) 0x85,
2902         (byte) 0xe1, (byte) 0x40, (byte) 0x7d, (byte) 0x27, (byte) 0x8f, (byte) 0x07, (byte) 0x0d, (byte) 0xe8,
2903         (byte) 0xdc, (byte) 0x99, (byte) 0xef, (byte) 0xb3, (byte) 0x07, (byte) 0x94, (byte) 0x34, (byte) 0xd6,
2904         (byte) 0x7c, (byte) 0xff, (byte) 0x9c, (byte) 0xbe, (byte) 0x69, (byte) 0xd3, (byte) 0xeb, (byte) 0x44,
2905         (byte) 0x37, (byte) 0x50, (byte) 0xef, (byte) 0x49, (byte) 0xf8, (byte) 0xe2, (byte) 0x5b, (byte) 0xd8,
2906         (byte) 0xd1, (byte) 0x10, (byte) 0x84, (byte) 0x97, (byte) 0xea, (byte) 0xe3, (byte) 0xa5, (byte) 0x1c,
2907         (byte) 0xc0, (byte) 0x4e, (byte) 0x69, (byte) 0xca, (byte) 0x70, (byte) 0x3d, (byte) 0x78, (byte) 0xb9,
2908         (byte) 0x16, (byte) 0xe5, (byte) 0xfe, (byte) 0x61, (byte) 0x5d, (byte) 0x8a, (byte) 0x5a, (byte) 0xb3,
2909         (byte) 0x2c, (byte) 0x61, (byte) 0xb6, (byte) 0x01, (byte) 0x3b, (byte) 0xd0, (byte) 0x01, (byte) 0x7c,
2910         (byte) 0x32, (byte) 0x8d, (byte) 0xe1, (byte) 0xf3, (byte) 0x69, (byte) 0x0e, (byte) 0x8b, (byte) 0x58,
2911         (byte) 0xc6, (byte) 0xcf, (byte) 0x00, (byte) 0x94, (byte) 0xf8, (byte) 0x49, (byte) 0x2a, (byte) 0x4b,
2912         (byte) 0xea, (byte) 0xda, (byte) 0x00, (byte) 0xff, (byte) 0x4b, (byte) 0xd0, (byte) 0xbe, (byte) 0x40,
2913         (byte) 0x23,
2914     });
2915 
2916     private static final BigInteger DSA_Q = new BigInteger(new byte[] {
2917         (byte) 0x00, (byte) 0xbf, (byte) 0xee, (byte) 0xaa, (byte) 0x0f, (byte) 0x12, (byte) 0x34, (byte) 0x50,
2918         (byte) 0x72, (byte) 0xf8, (byte) 0x60, (byte) 0x13, (byte) 0xd8, (byte) 0xf1, (byte) 0x41, (byte) 0x01,
2919         (byte) 0x10, (byte) 0xa5, (byte) 0x2f, (byte) 0x57, (byte) 0x5f,
2920     });
2921 
2922     private static final BigInteger DSA_G = new BigInteger(new byte[] {
2923         (byte) 0x77, (byte) 0xd4, (byte) 0x7a, (byte) 0x12, (byte) 0xcc, (byte) 0x81, (byte) 0x7e, (byte) 0x7e,
2924         (byte) 0xeb, (byte) 0x3a, (byte) 0xfb, (byte) 0xe6, (byte) 0x86, (byte) 0x6d, (byte) 0x5a, (byte) 0x10,
2925         (byte) 0x1d, (byte) 0xad, (byte) 0xa9, (byte) 0x4f, (byte) 0xb9, (byte) 0x03, (byte) 0x5d, (byte) 0x21,
2926         (byte) 0x1a, (byte) 0xe4, (byte) 0x30, (byte) 0x95, (byte) 0x75, (byte) 0x8e, (byte) 0xcd, (byte) 0x5e,
2927         (byte) 0xd1, (byte) 0xbd, (byte) 0x0a, (byte) 0x45, (byte) 0xee, (byte) 0xe7, (byte) 0xf7, (byte) 0x6b,
2928         (byte) 0x65, (byte) 0x02, (byte) 0x60, (byte) 0xd0, (byte) 0x2e, (byte) 0xaf, (byte) 0x3d, (byte) 0xbc,
2929         (byte) 0x07, (byte) 0xdd, (byte) 0x2b, (byte) 0x8e, (byte) 0x33, (byte) 0xc0, (byte) 0x93, (byte) 0x80,
2930         (byte) 0xd9, (byte) 0x2b, (byte) 0xa7, (byte) 0x71, (byte) 0x57, (byte) 0x76, (byte) 0xbc, (byte) 0x8e,
2931         (byte) 0xb9, (byte) 0xe0, (byte) 0xd7, (byte) 0xf4, (byte) 0x23, (byte) 0x8d, (byte) 0x41, (byte) 0x1a,
2932         (byte) 0x97, (byte) 0x4f, (byte) 0x2c, (byte) 0x1b, (byte) 0xd5, (byte) 0x4b, (byte) 0x66, (byte) 0xe8,
2933         (byte) 0xfa, (byte) 0xd2, (byte) 0x50, (byte) 0x0d, (byte) 0x17, (byte) 0xab, (byte) 0x34, (byte) 0x31,
2934         (byte) 0x3d, (byte) 0xa4, (byte) 0x88, (byte) 0xd8, (byte) 0x8e, (byte) 0xa8, (byte) 0xa7, (byte) 0x6e,
2935         (byte) 0x17, (byte) 0x03, (byte) 0xb7, (byte) 0x0f, (byte) 0x68, (byte) 0x7c, (byte) 0x64, (byte) 0x7b,
2936         (byte) 0x92, (byte) 0xb8, (byte) 0x63, (byte) 0xe4, (byte) 0x9a, (byte) 0x67, (byte) 0x18, (byte) 0x81,
2937         (byte) 0x27, (byte) 0xd4, (byte) 0x0b, (byte) 0x13, (byte) 0x48, (byte) 0xd3, (byte) 0x7d, (byte) 0x4e,
2938         (byte) 0xf6, (byte) 0xa8, (byte) 0x8f, (byte) 0x56, (byte) 0x17, (byte) 0x2d, (byte) 0x08, (byte) 0x51,
2939     });
2940 
2941     /**
2942      * A possible signature using SHA1withDSA of Vector2Data. Note that DSS is
2943      * randomized, so this won't be the exact signature you'll get out of
2944      * another signing operation unless you use a fixed RNG.
2945      */
2946     private static final byte[] SHA1withDSA_Vector2Signature = new byte[] {
2947             (byte) 0x30,
2948             (byte) 0x2d,
2949             (byte) 0x02,
2950             (byte) 0x15,
2951             (byte) 0x00,
2952             (byte) 0x88,
2953             (byte) 0xef,
2954             (byte) 0xac,
2955             (byte) 0x2b,
2956             (byte) 0x8b,
2957             (byte) 0xe2,
2958             (byte) 0x61,
2959             (byte) 0xc6,
2960             (byte) 0x2b,
2961             (byte) 0xea,
2962             (byte) 0xd5,
2963             (byte) 0x96,
2964             (byte) 0xbc,
2965             (byte) 0xb0,
2966             (byte) 0xa1,
2967             (byte) 0x30,
2968             (byte) 0x0c,
2969             (byte) 0x1f,
2970             (byte) 0xed,
2971             (byte) 0x11,
2972             (byte) 0x02,
2973             (byte) 0x14,
2974             (byte) 0x15,
2975             (byte) 0xc4,
2976             (byte) 0xfc,
2977             (byte) 0x82,
2978             (byte) 0x6f,
2979             (byte) 0x17,
2980             (byte) 0xdc,
2981             (byte) 0x87,
2982             (byte) 0x82,
2983             (byte) 0x75,
2984             (byte) 0x23,
2985             (byte) 0xd4,
2986             (byte) 0x58,
2987             (byte) 0xdc,
2988             (byte) 0x73,
2989             (byte) 0x3d,
2990             (byte) 0xf3,
2991             (byte) 0x51,
2992             (byte) 0xc0,
2993             (byte) 0x57,
2994     };
2995 
2996     /**
2997      * A possible signature using SHA224withDSA of Vector2Data. Note that DSS is
2998      * randomized, so this won't be the exact signature you'll get out of
2999      * another signing operation unless you use a fixed RNG.
3000      */
3001     private static final byte[] SHA224withDSA_Vector2Signature =
3002             new byte[] {(byte) 0x30, (byte) 0x2D, (byte) 0x02, (byte) 0x15, (byte) 0x00,
3003                     (byte) 0xAD, (byte) 0xE5, (byte) 0x6D, (byte) 0xF5, (byte) 0x11, (byte) 0x8D,
3004                     (byte) 0x2E, (byte) 0x62, (byte) 0x5D, (byte) 0x98, (byte) 0x8A, (byte) 0xC4,
3005                     (byte) 0x88, (byte) 0x7E, (byte) 0xE6, (byte) 0xA3, (byte) 0x44, (byte) 0x99,
3006                     (byte) 0xEF, (byte) 0x49, (byte) 0x02, (byte) 0x14, (byte) 0x15, (byte) 0x3E,
3007                     (byte) 0x32, (byte) 0xD6, (byte) 0xF9, (byte) 0x79, (byte) 0x2C, (byte) 0x60,
3008                     (byte) 0x6E, (byte) 0xF9, (byte) 0xA9, (byte) 0x78, (byte) 0xE7, (byte) 0x4B,
3009                     (byte) 0x87, (byte) 0x08, (byte) 0x96, (byte) 0x60, (byte) 0xDE, (byte) 0xB5};
3010 
3011     /**
3012      * A possible signature using SHA256withDSA of Vector2Data. Note that DSS is
3013      * randomized, so this won't be the exact signature you'll get out of
3014      * another signing operation unless you use a fixed RNG.
3015      */
3016     private static final byte[] SHA256withDSA_Vector2Signature =
3017             new byte[] {(byte) 0x30, (byte) 0x2D, (byte) 0x02, (byte) 0x14, (byte) 0x0A,
3018                     (byte) 0xB1, (byte) 0x74, (byte) 0x45, (byte) 0xE1, (byte) 0x63, (byte) 0x43,
3019                     (byte) 0x68, (byte) 0x65, (byte) 0xBC, (byte) 0xCA, (byte) 0x45, (byte) 0x27,
3020                     (byte) 0x11, (byte) 0x4D, (byte) 0x52, (byte) 0xFB, (byte) 0x22, (byte) 0x93,
3021                     (byte) 0xDD, (byte) 0x02, (byte) 0x15, (byte) 0x00, (byte) 0x98, (byte) 0x32,
3022                     (byte) 0x1A, (byte) 0x16, (byte) 0x77, (byte) 0x49, (byte) 0xA7, (byte) 0x78,
3023                     (byte) 0xFD, (byte) 0xE0, (byte) 0xF7, (byte) 0x71, (byte) 0xD4, (byte) 0x80,
3024                     (byte) 0x50, (byte) 0xA7, (byte) 0xDD, (byte) 0x94, (byte) 0xD1, (byte) 0x6C};
3025 
3026     @Test
testSign_SHA1withDSA_Key_Success()3027     public void testSign_SHA1withDSA_Key_Success() throws Exception {
3028         KeyFactory kf = KeyFactory.getInstance("DSA");
3029         DSAPrivateKeySpec keySpec = new DSAPrivateKeySpec(DSA_priv, DSA_P, DSA_Q, DSA_G);
3030         PrivateKey privKey = kf.generatePrivate(keySpec);
3031 
3032         Signature sig = Signature.getInstance("SHA1withDSA");
3033         sig.initSign(privKey);
3034         sig.update(Vector2Data);
3035 
3036         byte[] signature = sig.sign();
3037         assertNotNull("Signature must not be null", signature);
3038 
3039         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3040         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3041         sig.initVerify(pubKey);
3042         sig.update(Vector2Data);
3043         assertTrue("Signature must verify correctly", sig.verify(signature));
3044     }
3045 
3046     @Test
testVerify_SHA1withDSA_Key_Success()3047     public void testVerify_SHA1withDSA_Key_Success() throws Exception {
3048         KeyFactory kf = KeyFactory.getInstance("DSA");
3049         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3050         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3051 
3052         Signature sig = Signature.getInstance("SHA1withDSA");
3053         sig.initVerify(pubKey);
3054         sig.update(Vector2Data);
3055         assertTrue("Signature must verify correctly", sig.verify(SHA1withDSA_Vector2Signature));
3056     }
3057 
3058     @Test
testSign_SHA224withDSA_Key_Success()3059     public void testSign_SHA224withDSA_Key_Success() throws Exception {
3060         TestUtils.assumeSHA2WithDSAAvailable();
3061         KeyFactory kf = KeyFactory.getInstance("DSA");
3062         DSAPrivateKeySpec keySpec = new DSAPrivateKeySpec(DSA_priv, DSA_P, DSA_Q, DSA_G);
3063         PrivateKey privKey = kf.generatePrivate(keySpec);
3064 
3065         Signature sig = Signature.getInstance("SHA224withDSA");
3066         sig.initSign(privKey);
3067         sig.update(Vector2Data);
3068 
3069         byte[] signature = sig.sign();
3070         assertNotNull("Signature must not be null", signature);
3071 
3072         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3073         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3074         sig.initVerify(pubKey);
3075         sig.update(Vector2Data);
3076         assertTrue("Signature must verify correctly", sig.verify(signature));
3077     }
3078 
3079     @Test
testVerify_SHA224withDSA_Key_Success()3080     public void testVerify_SHA224withDSA_Key_Success() throws Exception {
3081         TestUtils.assumeSHA2WithDSAAvailable();
3082         KeyFactory kf = KeyFactory.getInstance("DSA");
3083         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3084         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3085 
3086         Signature sig = Signature.getInstance("SHA224withDSA");
3087         sig.initVerify(pubKey);
3088         sig.update(Vector2Data);
3089         assertTrue("Signature must verify correctly", sig.verify(SHA224withDSA_Vector2Signature));
3090     }
3091 
3092     @Test
testSign_SHA256withDSA_Key_Success()3093     public void testSign_SHA256withDSA_Key_Success() throws Exception {
3094         TestUtils.assumeSHA2WithDSAAvailable();
3095         KeyFactory kf = KeyFactory.getInstance("DSA");
3096         DSAPrivateKeySpec keySpec = new DSAPrivateKeySpec(DSA_priv, DSA_P, DSA_Q, DSA_G);
3097         PrivateKey privKey = kf.generatePrivate(keySpec);
3098 
3099         Signature sig = Signature.getInstance("SHA256withDSA");
3100         sig.initSign(privKey);
3101         sig.update(Vector2Data);
3102 
3103         byte[] signature = sig.sign();
3104         assertNotNull("Signature must not be null", signature);
3105 
3106         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3107         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3108         sig.initVerify(pubKey);
3109         sig.update(Vector2Data);
3110         assertTrue("Signature must verify correctly", sig.verify(signature));
3111     }
3112 
3113     @Test
testVerify_SHA256withDSA_Key_Success()3114     public void testVerify_SHA256withDSA_Key_Success() throws Exception {
3115         TestUtils.assumeSHA2WithDSAAvailable();
3116         KeyFactory kf = KeyFactory.getInstance("DSA");
3117         DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(DSA_pub, DSA_P, DSA_Q, DSA_G);
3118         PublicKey pubKey = kf.generatePublic(pubKeySpec);
3119 
3120         Signature sig = Signature.getInstance("SHA256withDSA");
3121         sig.initVerify(pubKey);
3122         sig.update(Vector2Data);
3123         assertTrue("Signature must verify correctly", sig.verify(SHA256withDSA_Vector2Signature));
3124     }
3125 
3126     private final int THREAD_COUNT = 10;
3127 
testSignature_MultipleThreads_Misuse(final Signature s, final PrivateKey p)3128     private void testSignature_MultipleThreads_Misuse(final Signature s, final PrivateKey p)
3129             throws Exception {
3130         ExecutorService es = Executors.newFixedThreadPool(THREAD_COUNT);
3131 
3132         final CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
3133         final byte[] message = new byte[64];
3134         List<Future<Void>> futures = new ArrayList<Future<Void>>();
3135 
3136         for (int i = 0; i < THREAD_COUNT; i++) {
3137             futures.add(es.submit(new Callable<Void>() {
3138                 @Override
3139                 public Void call() throws Exception {
3140                     // Try to make sure all the threads are ready first.
3141                     latch.countDown();
3142                     latch.await();
3143 
3144                     for (int j = 0; j < 100; j++) {
3145                         s.initSign(p);
3146                         s.update(message);
3147                         s.sign();
3148                     }
3149 
3150                     return null;
3151                 }
3152             }));
3153         }
3154         es.shutdown();
3155         assertTrue("Test should not timeout", es.awaitTermination(1, TimeUnit.MINUTES));
3156 
3157         for (Future<Void> f : futures) {
3158             try {
3159                 f.get();
3160             } catch (ExecutionException expected) {
3161                 // We expect concurrent execution to cause instances to eventually throw, though
3162                 // if they happen to get lucky and execute completely, that's fine.
3163             }
3164         }
3165     }
3166 
3167     private static final byte[] NAMED_CURVE_VECTOR = "Satoshi Nakamoto".getBytes(
3168             Charset.defaultCharset());
3169     // $ echo -n "Satoshi Nakamoto" > signed
3170     // $ openssl dgst -ecdsa-with-SHA1 -sign key.pem -out sig signed
3171     private static final byte[] NAMED_CURVE_SIGNATURE = TestUtils.decodeHex("304402205b41ece6dcc1c5bfcfdae74658d99c08c5e783f3926c11ecc1a8bea5d95cdf27022061a7d5fc687287e2e02dd7c6723e2e27fe0555f789590a37e96b1bb0355b4df0");
3172 
getNamedCurveEcPublicKey()3173     private static PublicKey getNamedCurveEcPublicKey() throws Exception {
3174         // These are the parameters for the BitCoin curve (secp256k1). See
3175         // https://en.bitcoin.it/wiki/Secp256k1.
3176         final BigInteger p = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16);
3177         final BigInteger a = BigInteger.valueOf(0);
3178         final BigInteger b = BigInteger.valueOf(7);
3179         final BigInteger x = new BigInteger("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 16);
3180         final BigInteger y = new BigInteger("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", 16);
3181         final BigInteger order = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", 16);
3182         final int cofactor = 1;
3183 
3184         final ECParameterSpec spec = new ECParameterSpec(new EllipticCurve(new ECFieldFp(p), a, b), new ECPoint(x, y), order, cofactor);
3185 
3186         // $ openssl ecparam -name secp256k1 -genkey > key.pem
3187         // $ openssl ec -text -noout < key.pem
3188         final BigInteger Px = new BigInteger("2d45572747a625db5fd23b30f97044a682f2d42d31959295043c1fa0034c8ed3", 16);
3189         final BigInteger Py = new BigInteger("4d330f52e4bba00145a331041c8bbcf300c4fbfdf3d63d8de7608155b2793808", 16);
3190 
3191         final KeyFactory factory = KeyFactory.getInstance("EC");
3192         ECPublicKeySpec keySpec = new ECPublicKeySpec(new ECPoint(Px, Py), spec);
3193         return factory.generatePublic(keySpec);
3194     }
3195 
3196     @Test
testArbitraryCurve()3197     public void testArbitraryCurve() throws Exception {
3198         final PublicKey pub = getNamedCurveEcPublicKey();
3199 
3200         Signature ecdsaVerify = Signature.getInstance("SHA1withECDSA");
3201         ecdsaVerify.initVerify(pub);
3202         ecdsaVerify.update(NAMED_CURVE_VECTOR);
3203         boolean result = ecdsaVerify.verify(NAMED_CURVE_SIGNATURE);
3204         assertEquals(true, result);
3205 
3206         ecdsaVerify = Signature.getInstance("SHA1withECDSA");
3207         ecdsaVerify.initVerify(pub);
3208         ecdsaVerify.update("Not Satoshi Nakamoto".getBytes("UTF-8"));
3209         result = ecdsaVerify.verify(NAMED_CURVE_SIGNATURE);
3210         assertEquals(false, result);
3211     }
3212 
assertPSSAlgorithmParametersEquals( PSSParameterSpec expectedSpec, AlgorithmParameters actual)3213     private static void assertPSSAlgorithmParametersEquals(
3214             PSSParameterSpec expectedSpec, AlgorithmParameters actual)
3215                     throws InvalidParameterSpecException {
3216         assertNotNull(actual);
3217         assertEqualsIgnoreCase("PSS", actual.getAlgorithm());
3218         PSSParameterSpec actualSpec = actual.getParameterSpec(PSSParameterSpec.class);
3219         assertPSSParameterSpecEquals(expectedSpec, actualSpec);
3220     }
3221 
assertPSSParameterSpecEquals( PSSParameterSpec expected, PSSParameterSpec actual)3222     private static void assertPSSParameterSpecEquals(
3223             PSSParameterSpec expected, PSSParameterSpec actual) {
3224         assertEqualsIgnoreCase(expected.getDigestAlgorithm(), actual.getDigestAlgorithm());
3225         assertEqualsIgnoreCase(expected.getMGFAlgorithm(), actual.getMGFAlgorithm());
3226         if (!"MGF1".equalsIgnoreCase(expected.getMGFAlgorithm())) {
3227             fail("Unsupported MGF algorithm: " + expected.getMGFAlgorithm());
3228         }
3229         MGF1ParameterSpec expectedMgfParams = (MGF1ParameterSpec) expected.getMGFParameters();
3230         MGF1ParameterSpec actualMgfParams = (MGF1ParameterSpec) actual.getMGFParameters();
3231         assertEqualsIgnoreCase(
3232                 expectedMgfParams.getDigestAlgorithm(), actualMgfParams.getDigestAlgorithm());
3233         assertEquals(expected.getSaltLength(), actual.getSaltLength());
3234         assertEquals(expected.getTrailerField(), actual.getTrailerField());
3235     }
3236 
assertEqualsIgnoreCase(String expected, String actual)3237     private static void assertEqualsIgnoreCase(String expected, String actual) {
3238         if (expected == null) {
3239             if (actual == null) {
3240                 return;
3241             }
3242             fail("Expected null, actual: <" + actual + ">");
3243         } else if (actual == null) {
3244             fail("Expected: <" + expected + ">, actual: null");
3245         } else {
3246             if (!expected.equalsIgnoreCase(actual)) {
3247                 fail("Expected: <" + expected + ">, actual: <" + actual + ">");
3248             }
3249         }
3250     }
3251 }
3252