01: package org.bouncycastle.crypto.test;
02:
03: import org.bouncycastle.crypto.Digest;
04: import org.bouncycastle.crypto.digests.SHA512Digest;
05:
06: /**
07: * standard vector test for SHA-512 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 SHA512DigestTest extends DigestTest {
12: private static String[] messages = {
13: "",
14: "a",
15: "abc",
16: "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" };
17:
18: private static String[] digests = {
19: "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
20: "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75",
21: "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",
22: "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" };
23:
24: // 1 million 'a'
25: static private String million_a_digest = "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b";
26:
27: SHA512DigestTest() {
28: super (new SHA512Digest(), messages, digests);
29: }
30:
31: public void performTest() {
32: super .performTest();
33:
34: millionATest(million_a_digest);
35: }
36:
37: protected Digest cloneDigest(Digest digest) {
38: return new SHA512Digest((SHA512Digest) digest);
39: }
40:
41: public static void main(String[] args) {
42: runTest(new SHA512DigestTest());
43: }
44: }
|