Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Tyley <roberto.tyley@gmail.com>2014-07-15 01:38:01 +0400
committerRoberto Tyley <roberto.tyley@gmail.com>2014-07-26 11:23:17 +0400
commit7cb752aaf746dc0b473afeb9e892b7fbc12666c5 (patch)
treecc4f91ddc18332b5adbe82e3fcb040d976c90105 /core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java
parent551830f8ea5177042af2c7dd1fc90888bc67387d (diff)
Execute become-spongy.sh
https://github.com/rtyley/spongycastle/blob/3040af/become-spongy.sh
Diffstat (limited to 'core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java')
-rw-r--r--core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java b/core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java
new file mode 100644
index 00000000..548ca1fb
--- /dev/null
+++ b/core/src/test/java/org/spongycastle/crypto/test/SHA256DigestTest.java
@@ -0,0 +1,60 @@
+package org.spongycastle.crypto.test;
+
+import org.spongycastle.crypto.Digest;
+import org.spongycastle.crypto.digests.SHA256Digest;
+
+/**
+ * standard vector test for SHA-256 from FIPS Draft 180-2.
+ *
+ * Note, the first two vectors are _not_ from the draft, the last three are.
+ */
+public class SHA256DigestTest
+ extends DigestTest
+{
+ private static String[] messages =
+ {
+ "",
+ "a",
+ "abc",
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ };
+
+ private static String[] digests =
+ {
+ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
+ "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
+ };
+
+ // 1 million 'a'
+ static private String million_a_digest = "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0";
+
+ SHA256DigestTest()
+ {
+ super(new SHA256Digest(), messages, digests);
+ }
+
+ public void performTest()
+ {
+ super.performTest();
+
+ millionATest(million_a_digest);
+ }
+
+ protected Digest cloneDigest(Digest digest)
+ {
+ return new SHA256Digest((SHA256Digest)digest);
+ }
+
+ protected Digest cloneDigest(byte[] encodedState)
+ {
+ return new SHA256Digest(encodedState);
+ }
+
+ public static void main(
+ String[] args)
+ {
+ runTest(new SHA256DigestTest());
+ }
+}