TestDSA.java revision 2362
0N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @bug 4815057 4839277 0N/A * @author Andreas Sterbenz 0N/A // values of the keys we use for the tests 0N/A "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669" +
0N/A "455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b7" +
0N/A "6b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb" +
0N/A "83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7";
0N/A "9760508f15230bccb292b982a2eb840bf0581cf5";
0N/A "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d078267" +
0N/A "5159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e1" +
0N/A "3c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243b" +
0N/A "cca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a";
0N/A "2952afd9aef9527f9b40d23c8916f7d046028f9d";
0N/A "b16ddb0f9394c328c983ecf23b20014ace368a1af5728dffbf1162de9ed8ebf6" +
0N/A "384f323930e091503035caa797e3674221fc16136240b5474799ede2b7b11313" +
0N/A "7574a9c26bcf900940027b4bcd511ef1d1daf2e69c416aebaf3bdf39f02473b9" +
0N/A "d963f99414c09d97bb0830d9fbdcf7bb9dad8a2179fcdf296838c4cfab8f4d8f";
0N/A // data for test 1, original and SHA-1 hashed 0N/A private final static byte[]
data1Raw = b(
"0102030405060708090a0b0c0d0e0f10111213");
0N/A private final static byte[]
data1SHA = b(
"00:e2:5f:c9:1c:8f:d6:8c:6a:dc:c6:bd:f0:46:60:5e:a2:cd:8d:ad");
1968N/A // valid signatures of data1. sig1b uses incorrect ASN.1 encoding, 0N/A // which we want to accept anyway for compatibility 0N/A private final static byte[]
sig1a = b(
"30:2d:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:15:00:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13");
private final static byte[]
sig1b = b(
"30:2c:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:14:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13");
// data for test 2 (invalid signatures) private final static byte[]
data2Raw = {};
private final static byte[]
data2SHA = b(
"da:39:a3:ee:5e:6b:4b:0d:32:55:bf:ef:95:60:18:90:af:d8:07:09");
throw new Exception(
"Result mismatch, actual: " + r);
throw new Exception(
"Result mismatch, actual: " + r);
// verify known-good and known-bad signatures using SHA1withDSA and RawDSA byte[]
data =
new byte[
2048];
// sign random data using SHA1withDSA and verify using // SHA1withDSA and RawDSA // sign random data using RawDSA and verify using // SHA1withDSA and RawDSA // test behavior if data of incorrect length is passed throw new Exception(
"No error RawDSA signing long data");
for (
int i =
0; i < b.
length; i++) {
public static byte[] b(
String s) {
}
else if ((
ch >=
'0') && (
ch <=
'9')) {
}
else if ((
ch >=
'a') && (
ch <=
'f')) {
}
else if ((
ch >=
'A') && (
ch <=
'F')) {