aboutsummaryrefslogtreecommitdiff
path: root/test/src/util/test_bits.c
diff options
context:
space:
mode:
authorJ08nY2017-09-13 00:40:13 +0200
committerJ08nY2017-09-13 00:40:13 +0200
commit607fe7b39f4e2ea579c935509c6e4dc68b43c457 (patch)
treea27bf266515b6495c836de9a1ccb1f6398b1ecde /test/src/util/test_bits.c
parentcceec4063e74bb29c79500f38aa40fc466180a0b (diff)
downloadecgen-607fe7b39f4e2ea579c935509c6e4dc68b43c457.tar.gz
ecgen-607fe7b39f4e2ea579c935509c6e4dc68b43c457.tar.zst
ecgen-607fe7b39f4e2ea579c935509c6e4dc68b43c457.zip
Diffstat (limited to 'test/src/util/test_bits.c')
-rw-r--r--test/src/util/test_bits.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/src/util/test_bits.c b/test/src/util/test_bits.c
index 1a408b1..c383660 100644
--- a/test/src/util/test_bits.c
+++ b/test/src/util/test_bits.c
@@ -377,6 +377,20 @@ Test(bits, test_bits_shorten) {
bits_free(&shorter);
}
+Test(bits, test_bits_sha1) {
+ char *text = "The quick brown fox jumps over the lazy dog";
+ bits_t *bits = bits_from_raw((unsigned char *)text, strlen(text) * 8);
+ unsigned char hashout[20] = {};
+ bits_sha1(bits, hashout);
+
+ unsigned char expected[] = {0x2f, 0xd4, 0xe1, 0xc6, 0x7a, 0x2d, 0x28, 0xfc,
+ 0xed, 0x84, 0x9e, 0xe1, 0xbb, 0x76, 0xe7, 0x39,
+ 0x1b, 0x93, 0xeb, 0x12};
+ for (size_t i = 0; i < 20; ++i) {
+ cr_assert_eq(hashout[i], expected[i],);
+ }
+}
+
Test(bits, test_bits_eq) {
bits_t *bits = bits_new(6);
bits->bits[0] = 0b10000000;