01: package org.bouncycastle.crypto.test;
02:
03: import org.bouncycastle.crypto.Digest;
04: import org.bouncycastle.crypto.digests.SHA256Digest;
05:
06: /**
07: * standard vector test for SHA-256 from FIPS Draft 180-2.
08: *
09: * Note, the first two vectors are _not_ from the draft, the last three are.
10: */
11: public class SHA256DigestTest extends DigestTest {
12: private static String[] messages = { "", "a", "abc",
13: "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" };
14:
15: private static String[] digests = {
16: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
17: "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
18: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
19: "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" };
20:
21: // 1 million 'a'
22: static private String million_a_digest = "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0";
23:
24: SHA256DigestTest() {
25: super (new SHA256Digest(), messages, digests);
26: }
27:
28: public void performTest() {
29: super .performTest();
30:
31: millionATest(million_a_digest);
32: }
33:
34: protected Digest cloneDigest(Digest digest) {
35: return new SHA256Digest((SHA256Digest) digest);
36: }
37:
38: public static void main(String[] args) {
39: runTest(new SHA256DigestTest());
40: }
41: }
|