author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 7526 | 78a87adede1e |
permissions | -rw-r--r-- |
7526
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
1 |
/* |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
4 |
* |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
8 |
* |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
14 |
* |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
18 |
* |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
21 |
* questions. |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
22 |
*/ |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
23 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
24 |
/* @test |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
25 |
* @summary Validation of signatures succeed when it should fail |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
26 |
* @bug 6896700 |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
27 |
*/ |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
28 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
29 |
import java.io.InputStream; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
30 |
import java.io.ByteArrayInputStream; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
31 |
import java.security.cert.Certificate; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
32 |
import java.security.cert.CertificateFactory; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
33 |
import java.security.PublicKey; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
34 |
import java.security.SignatureException; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
35 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
36 |
public class InvalidBitString { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
37 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
38 |
// Test cert for CN=CA |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
39 |
static String signerCertStr = |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
40 |
"-----BEGIN CERTIFICATE-----\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
41 |
"MIIBtDCCAR2gAwIBAgIEemxRHjANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDEwJDQTAeFw0xMDA2\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
42 |
"MDMwODA2MjlaFw0xMDA5MDEwODA2MjlaMA0xCzAJBgNVBAMTAkNBMIGfMA0GCSqGSIb3DQEBAQUA\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
43 |
"A4GNADCBiQKBgQCp2G7pGwMOw4oM7zFFeRKrByuPLNAXClGsh+itdRiOeUgEby6OB9IAgXm93086\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
44 |
"Z9dWCfRYbzJbDRSnUE7FS1iQsIRIeOEuFMIMogcBK+sOf364ONwMXsI4gtYVmxn4BaaajVWt6C/g\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
45 |
"FBGZQxp81aORDyUIrlCkMIxhZBSsNPIJYwIDAQABoyEwHzAdBgNVHQ4EFgQUKrvzNhJmdKoqq2li\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
46 |
"utCzKkwA1N0wDQYJKoZIhvcNAQEFBQADgYEAEIaegsW7fWWjXk4YOMlcl893vx6tnU8ThuQSjwGI\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
47 |
"rIs93sBYuY7lQIpQw8+XM89WT1XuBB6R2SsnxeW+gHtsU/EE6iJJAEMeCILwEGUL02blwHBQWmpa\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
48 |
"i3YeGXw+IFe/4OAysPT7ZRbUb7mPt37Ht6hIjain71ShR5anXIuawVE=\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
49 |
"-----END CERTIFICATE-----\n"; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
50 |
// Test cert for CN=A, happens to have a zero at the beginning of signature |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
51 |
static String normalCertStr = |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
52 |
"-----BEGIN CERTIFICATE-----\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
53 |
"MIIB1DCCAT2gAwIBAgIEae+u1TANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDEwJDQTAeFw0xMDA2\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
54 |
"MDMwODA2NTNaFw0xMDA5MDEwODA2NTNaMAwxCjAIBgNVBAMTAUEwgZ8wDQYJKoZIhvcNAQEBBQAD\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
55 |
"gY0AMIGJAoGBAKZ7C6bC8AJmXIRNwuPJcgIPW1ygN3rE5PIKPAkeK/dYnPmUJNuiSxOFPJCrLMuL\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
56 |
"sweQh82Dq/viu+KBb27xVzJ4pK02fbcWdJDo7cIms0Wm+HckK5myA6xmqnpmPOjb/vWCLE6pN2Xg\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
57 |
"pJyrdeWV77eBvqE9OiCsMTP8WgHI9zLvAgMBAAGjQjBAMB0GA1UdDgQWBBTtIKqCHnL9QeFn+YrX\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
58 |
"+k00NUk9mjAfBgNVHSMEGDAWgBQqu/M2EmZ0qiqraWK60LMqTADU3TANBgkqhkiG9w0BAQUFAAOB\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
59 |
"gQAAOcQsEruDAY/z3eXJ7OtWSZlLC0yTVNVdUVNLQ58xNqPrmKNBXNpj/72N8xrTB++ApW+DLgLy\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
60 |
"cwGU5PVRtsYeiV6prUkpqUf62SQgwI4guAQy1ileeP1CNQJI3cHQExMAHvQT8fJtlD0WZD3nfesq\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
61 |
"mmQDOpoJLkmO/73Z7IibVA==\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
62 |
"-----END CERTIFICATE-----\n"; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
63 |
// normalCertStr with an extra zero at the beginning of signature |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
64 |
static String longerCertStr = |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
65 |
"-----BEGIN CERTIFICATE-----\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
66 |
"MIIB1TCCAT2gAwIBAgIEae+u1TANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDEwJDQTAeFw0xMDA2\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
67 |
"MDMwODA2NTNaFw0xMDA5MDEwODA2NTNaMAwxCjAIBgNVBAMTAUEwgZ8wDQYJKoZIhvcNAQEBBQAD\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
68 |
"gY0AMIGJAoGBAKZ7C6bC8AJmXIRNwuPJcgIPW1ygN3rE5PIKPAkeK/dYnPmUJNuiSxOFPJCrLMuL\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
69 |
"sweQh82Dq/viu+KBb27xVzJ4pK02fbcWdJDo7cIms0Wm+HckK5myA6xmqnpmPOjb/vWCLE6pN2Xg\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
70 |
"pJyrdeWV77eBvqE9OiCsMTP8WgHI9zLvAgMBAAGjQjBAMB0GA1UdDgQWBBTtIKqCHnL9QeFn+YrX\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
71 |
"+k00NUk9mjAfBgNVHSMEGDAWgBQqu/M2EmZ0qiqraWK60LMqTADU3TANBgkqhkiG9w0BAQUFAAOB\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
72 |
"ggAAADnELBK7gwGP893lyezrVkmZSwtMk1TVXVFTS0OfMTaj65ijQVzaY/+9jfMa0wfvgKVvgy4C\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
73 |
"8nMBlOT1UbbGHoleqa1JKalH+tkkIMCOILgEMtYpXnj9QjUCSN3B0BMTAB70E/HybZQ9FmQ9533r\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
74 |
"KppkAzqaCS5Jjv+92eyIm1Q=\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
75 |
"-----END CERTIFICATE-----\n"; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
76 |
// normalCertStr without the initial zero at the beginning of signature |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
77 |
static String shorterCertStr = |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
78 |
"-----BEGIN CERTIFICATE-----\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
79 |
"MIIB0zCCAT2gAwIBAgIEae+u1TANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDEwJDQTAeFw0xMDA2\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
80 |
"MDMwODA2NTNaFw0xMDA5MDEwODA2NTNaMAwxCjAIBgNVBAMTAUEwgZ8wDQYJKoZIhvcNAQEBBQAD\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
81 |
"gY0AMIGJAoGBAKZ7C6bC8AJmXIRNwuPJcgIPW1ygN3rE5PIKPAkeK/dYnPmUJNuiSxOFPJCrLMuL\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
82 |
"sweQh82Dq/viu+KBb27xVzJ4pK02fbcWdJDo7cIms0Wm+HckK5myA6xmqnpmPOjb/vWCLE6pN2Xg\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
83 |
"pJyrdeWV77eBvqE9OiCsMTP8WgHI9zLvAgMBAAGjQjBAMB0GA1UdDgQWBBTtIKqCHnL9QeFn+YrX\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
84 |
"+k00NUk9mjAfBgNVHSMEGDAWgBQqu/M2EmZ0qiqraWK60LMqTADU3TANBgkqhkiG9w0BAQUFAAOB\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
85 |
"gAA5xCwSu4MBj/Pd5cns61ZJmUsLTJNU1V1RU0tDnzE2o+uYo0Fc2mP/vY3zGtMH74Clb4MuAvJz\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
86 |
"AZTk9VG2xh6JXqmtSSmpR/rZJCDAjiC4BDLWKV54/UI1AkjdwdATEwAe9BPx8m2UPRZkPed96yqa\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
87 |
"ZAM6mgkuSY7/vdnsiJtU\n" + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
88 |
"-----END CERTIFICATE-----\n"; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
89 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
90 |
public static void main(String args[]) throws Exception { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
91 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
92 |
Certificate signer = generate(signerCertStr); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
93 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
94 |
// the valid certificate |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
95 |
Certificate normal = generate(normalCertStr); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
96 |
// the invalid certificate with extra signature bits |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
97 |
Certificate longer = generate(longerCertStr); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
98 |
// the invalid certificate without enough signature bits |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
99 |
Certificate shorter = generate(shorterCertStr); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
100 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
101 |
if (!test(normal, signer, " normal", true) || |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
102 |
!test(longer, signer, " longer", false) || |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
103 |
!test(shorter, signer, "shorter", false)) { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
104 |
throw new Exception("Test failed."); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
105 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
106 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
107 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
108 |
private static Certificate generate(String certStr) throws Exception { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
109 |
InputStream is = null; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
110 |
try { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
111 |
CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
112 |
is = new ByteArrayInputStream(certStr.getBytes()); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
113 |
return cf.generateCertificate(is); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
114 |
} finally { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
115 |
if (is != null) { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
116 |
is.close(); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
117 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
118 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
119 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
120 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
121 |
private static boolean test(Certificate target, Certificate signer, |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
122 |
String title, boolean expected) throws Exception { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
123 |
System.out.print("Checking " + title + ": expected: " + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
124 |
(expected ? " verified" : "NOT verified")); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
125 |
boolean actual; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
126 |
try { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
127 |
PublicKey pubKey = signer.getPublicKey(); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
128 |
target.verify(pubKey); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
129 |
actual = true; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
130 |
} catch (SignatureException se) { |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
131 |
actual = false; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
132 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
133 |
System.out.println(", actual: " + |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
134 |
(actual ? " verified" : "NOT verified")); |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
135 |
return actual == expected; |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
136 |
} |
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
137 |
|
78a87adede1e
6896700: Validation of signatures succeed when it should fail
weijun
parents:
diff
changeset
|
138 |
} |