]> git.ozlabs.org Git - ccan/blobdiff - ccan/crypto/sha512/test/run-lotsa-data.c
Add a SHA512 implementation
[ccan] / ccan / crypto / sha512 / test / run-lotsa-data.c
diff --git a/ccan/crypto/sha512/test/run-lotsa-data.c b/ccan/crypto/sha512/test/run-lotsa-data.c
new file mode 100644 (file)
index 0000000..fddde65
--- /dev/null
@@ -0,0 +1,23 @@
+#include <ccan/crypto/sha512/sha512.h>
+/* Include the C files directly. */
+#include <ccan/crypto/sha512/sha512.c>
+#include <ccan/tap/tap.h>
+
+int main(void)
+{
+       struct sha512 h, expected;
+       static const char zeroes[1000];
+       size_t i;
+
+       plan_tests(63);
+
+       /* Test different alignments. */
+       sha512(&expected, zeroes, sizeof(zeroes) - 64);
+       for (i = 1; i < 64; i++) {
+               sha512(&h, zeroes + i, sizeof(zeroes) - 64);
+               ok1(memcmp(&h, &expected, sizeof(h)) == 0);
+       }
+
+       /* This exits depending on whether all tests passed */
+       return exit_status();
+}