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