aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.h12
-rw-r--r--t/blake224.c2
-rw-r--r--t/blake256.c2
-rw-r--r--t/blake384.c2
-rw-r--r--t/blake512.c2
-rw-r--r--t/keccak.c1
-rw-r--r--t/keccak_224.c2
-rw-r--r--t/keccak_256.c2
-rw-r--r--t/keccak_384.c2
-rw-r--r--t/keccak_512.c2
-rw-r--r--t/md2.c2
-rw-r--r--t/md4.c2
-rw-r--r--t/md5.c2
-rw-r--r--t/rawshake128.c2
-rw-r--r--t/rawshake256.c2
-rw-r--r--t/rawshake512.c2
-rw-r--r--t/ripemd-128.c2
-rw-r--r--t/ripemd-160.c2
-rw-r--r--t/ripemd-256.c2
-rw-r--r--t/ripemd-320.c2
-rw-r--r--t/sha0.c2
-rw-r--r--t/sha1.c2
-rw-r--r--t/sha3_224.c2
-rw-r--r--t/sha3_256.c2
-rw-r--r--t/sha3_384.c2
-rw-r--r--t/sha3_512.c2
-rw-r--r--t/sha_224.c2
-rw-r--r--t/sha_256.c2
-rw-r--r--t/sha_384.c2
-rw-r--r--t/sha_512.c2
-rw-r--r--t/sha_512_224.c2
-rw-r--r--t/sha_512_256.c2
-rw-r--r--t/shake128.c2
-rw-r--r--t/shake256.c2
-rw-r--r--t/shake512.c2
35 files changed, 43 insertions, 36 deletions
diff --git a/common.h b/common.h
index 18d817c..c784f1b 100644
--- a/common.h
+++ b/common.h
@@ -109,7 +109,8 @@ escape(const char *s, size_t n)
static int
run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_size,
- struct testcase *testcases, size_t ntestcases, char hexsum[])
+ struct testcase *testcases, size_t ntestcases, char hexsum[],
+ unsigned char supports_non_whole_bytes)
{
struct libhashsum_hasher hasher, hasher2;
unsigned char custom_hashbuffer[2048];
@@ -161,6 +162,10 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz
fprintf(stderr, "libhashsum_init_hasher returned non-NULL pointer in .stretch\n");
return 2;
}
+ if (hasher.supports_non_whole_bytes != supports_non_whole_bytes) {
+ fprintf(stderr, "libhashsum_init_hasher returned unexpected value in .supports_non_whole_bytes\n");
+ return 2;
+ }
input_string_len = strlen(testcases[i].input);
bits = testcases[i].extra_bits;
if (bits) {
@@ -260,10 +265,11 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz
return !ok;
}
-# define TEST_MAIN(NAME, ID)\
+# define TEST_MAIN(NAME, ID, SUPPORTS_NON_WHOLE_BYTES)\
char hexsum[LIBHASHSUM_##ID##_HASH_SIZE * 2 + 1];\
return run_tests(NAME, LIBHASHSUM_##ID, LIBHASHSUM_##ID##_HASH_SIZE,\
- testcases, sizeof(testcases) / sizeof(*testcases), hexsum)
+ testcases, sizeof(testcases) / sizeof(*testcases), hexsum,\
+ (SUPPORTS_NON_WHOLE_BYTES))
# define ASSERT(ASSERTION)\
do {\
diff --git a/t/blake224.c b/t/blake224.c
index 5605033..95e0f45 100644
--- a/t/blake224.c
+++ b/t/blake224.c
@@ -72,7 +72,7 @@ static struct testcase testcases[] = {
static int
kat_test(void)
{
- TEST_MAIN("BLAKE224", BLAKE224);
+ TEST_MAIN("BLAKE224", BLAKE224, 1);
}
diff --git a/t/blake256.c b/t/blake256.c
index e42cec7..cf89256 100644
--- a/t/blake256.c
+++ b/t/blake256.c
@@ -72,7 +72,7 @@ static struct testcase testcases[] = {
static int
kat_test(void)
{
- TEST_MAIN("BLAKE256", BLAKE256);
+ TEST_MAIN("BLAKE256", BLAKE256, 1);
}
diff --git a/t/blake384.c b/t/blake384.c
index b2f5478..1499f74 100644
--- a/t/blake384.c
+++ b/t/blake384.c
@@ -122,7 +122,7 @@ static struct testcase testcases[] = {
static int
kat_test(void)
{
- TEST_MAIN("BLAKE384", BLAKE384);
+ TEST_MAIN("BLAKE384", BLAKE384, 1);
}
diff --git a/t/blake512.c b/t/blake512.c
index 7166769..2a65a23 100644
--- a/t/blake512.c
+++ b/t/blake512.c
@@ -191,7 +191,7 @@ static struct testcase testcases[] = {
static int
kat_test(void)
{
- TEST_MAIN("BLAKE512", BLAKE512);
+ TEST_MAIN("BLAKE512", BLAKE512, 1);
}
diff --git a/t/keccak.c b/t/keccak.c
index 6e4a900..cb8923a 100644
--- a/t/keccak.c
+++ b/t/keccak.c
@@ -96,6 +96,7 @@ main(void)
ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 224, 1));
ASSERT(!libhashsum_init_keccak_224_hasher(&h2));
+ ASSERT(h1.supports_non_whole_bytes == 1U);
ASSERT(!h1.finalise_const(&h1, NULL, 0, 0));
ASSERT(!h2.finalise_const(&h2, NULL, 0, 0));
ASSERT(h1.hash_size == h2.hash_size);
diff --git a/t/keccak_224.c b/t/keccak_224.c
index 2120d1c..eca5786 100644
--- a/t/keccak_224.c
+++ b/t/keccak_224.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("Keccak-224", KECCAK_224);
+ TEST_MAIN("Keccak-224", KECCAK_224, 1);
}
diff --git a/t/keccak_256.c b/t/keccak_256.c
index 1ab7a76..7d155db 100644
--- a/t/keccak_256.c
+++ b/t/keccak_256.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("Keccak-256", KECCAK_256);
+ TEST_MAIN("Keccak-256", KECCAK_256, 1);
}
diff --git a/t/keccak_384.c b/t/keccak_384.c
index 9ac068b..1146ff6 100644
--- a/t/keccak_384.c
+++ b/t/keccak_384.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("Keccak-384", KECCAK_384);
+ TEST_MAIN("Keccak-384", KECCAK_384, 1);
}
diff --git a/t/keccak_512.c b/t/keccak_512.c
index 93943d1..9ca03ed 100644
--- a/t/keccak_512.c
+++ b/t/keccak_512.c
@@ -38,5 +38,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("Keccak-512", KECCAK_512);
+ TEST_MAIN("Keccak-512", KECCAK_512, 1);
}
diff --git a/t/md2.c b/t/md2.c
index e5f12d0..eeb1578 100644
--- a/t/md2.c
+++ b/t/md2.c
@@ -29,5 +29,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("MD2", MD2);
+ TEST_MAIN("MD2", MD2, 0);
}
diff --git a/t/md4.c b/t/md4.c
index 61e7691..22def4c 100644
--- a/t/md4.c
+++ b/t/md4.c
@@ -34,5 +34,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("MD4", MD4);
+ TEST_MAIN("MD4", MD4, 1);
}
diff --git a/t/md5.c b/t/md5.c
index 514a164..02ba566 100644
--- a/t/md5.c
+++ b/t/md5.c
@@ -125,5 +125,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("MD5", MD5);
+ TEST_MAIN("MD5", MD5, 1);
}
diff --git a/t/rawshake128.c b/t/rawshake128.c
index 5abc8cf..0800a7f 100644
--- a/t/rawshake128.c
+++ b/t/rawshake128.c
@@ -25,7 +25,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("RawSHAKE128", RAWSHAKE128);
+ TEST_MAIN("RawSHAKE128", RAWSHAKE128, 1);
}
diff --git a/t/rawshake256.c b/t/rawshake256.c
index 6a03448..46ccecd 100644
--- a/t/rawshake256.c
+++ b/t/rawshake256.c
@@ -25,7 +25,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("RawSHAKE256", RAWSHAKE256);
+ TEST_MAIN("RawSHAKE256", RAWSHAKE256, 1);
}
diff --git a/t/rawshake512.c b/t/rawshake512.c
index 710514d..a4fc16d 100644
--- a/t/rawshake512.c
+++ b/t/rawshake512.c
@@ -29,7 +29,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("RawSHAKE512", RAWSHAKE512);
+ TEST_MAIN("RawSHAKE512", RAWSHAKE512, 1);
}
diff --git a/t/ripemd-128.c b/t/ripemd-128.c
index 199bdcf..923e111 100644
--- a/t/ripemd-128.c
+++ b/t/ripemd-128.c
@@ -32,5 +32,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("RIPEMD-128", RIPEMD_128);
+ TEST_MAIN("RIPEMD-128", RIPEMD_128, 1);
}
diff --git a/t/ripemd-160.c b/t/ripemd-160.c
index 326cc18..a4acb22 100644
--- a/t/ripemd-160.c
+++ b/t/ripemd-160.c
@@ -32,5 +32,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("RIPEMD-160", RIPEMD_160);
+ TEST_MAIN("RIPEMD-160", RIPEMD_160, 1);
}
diff --git a/t/ripemd-256.c b/t/ripemd-256.c
index 6706b6c..ffa33e8 100644
--- a/t/ripemd-256.c
+++ b/t/ripemd-256.c
@@ -47,5 +47,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("RIPEMD-256", RIPEMD_256);
+ TEST_MAIN("RIPEMD-256", RIPEMD_256, 1);
}
diff --git a/t/ripemd-320.c b/t/ripemd-320.c
index 49e3bd1..4abfde0 100644
--- a/t/ripemd-320.c
+++ b/t/ripemd-320.c
@@ -47,5 +47,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("RIPEMD-320", RIPEMD_320);
+ TEST_MAIN("RIPEMD-320", RIPEMD_320, 1);
}
diff --git a/t/sha0.c b/t/sha0.c
index 3905c91..48ecc2f 100644
--- a/t/sha0.c
+++ b/t/sha0.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA0", SHA0);
+ TEST_MAIN("SHA0", SHA0, 1);
}
diff --git a/t/sha1.c b/t/sha1.c
index 7523dd6..5b3e9cc 100644
--- a/t/sha1.c
+++ b/t/sha1.c
@@ -46,5 +46,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA1", SHA1);
+ TEST_MAIN("SHA1", SHA1, 1);
}
diff --git a/t/sha3_224.c b/t/sha3_224.c
index 2519053..66e4cd9 100644
--- a/t/sha3_224.c
+++ b/t/sha3_224.c
@@ -354,5 +354,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA3-224", SHA3_224);
+ TEST_MAIN("SHA3-224", SHA3_224, 1);
}
diff --git a/t/sha3_256.c b/t/sha3_256.c
index 72546bb..6f02242 100644
--- a/t/sha3_256.c
+++ b/t/sha3_256.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA3-256", SHA3_256);
+ TEST_MAIN("SHA3-256", SHA3_256, 1);
}
diff --git a/t/sha3_384.c b/t/sha3_384.c
index 7dff983..3f4d6d3 100644
--- a/t/sha3_384.c
+++ b/t/sha3_384.c
@@ -24,5 +24,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA3-384", SHA3_384);
+ TEST_MAIN("SHA3-384", SHA3_384, 1);
}
diff --git a/t/sha3_512.c b/t/sha3_512.c
index 356516f..b4e628d 100644
--- a/t/sha3_512.c
+++ b/t/sha3_512.c
@@ -38,5 +38,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA3-512", SHA3_512);
+ TEST_MAIN("SHA3-512", SHA3_512, 1);
}
diff --git a/t/sha_224.c b/t/sha_224.c
index 4abcd28..38b5787 100644
--- a/t/sha_224.c
+++ b/t/sha_224.c
@@ -46,5 +46,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-224", SHA_224);
+ TEST_MAIN("SHA-224", SHA_224, 1);
}
diff --git a/t/sha_256.c b/t/sha_256.c
index 6dc1b3d..c977d99 100644
--- a/t/sha_256.c
+++ b/t/sha_256.c
@@ -42,5 +42,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-256", SHA_256);
+ TEST_MAIN("SHA-256", SHA_256, 1);
}
diff --git a/t/sha_384.c b/t/sha_384.c
index 95b4079..53e272f 100644
--- a/t/sha_384.c
+++ b/t/sha_384.c
@@ -53,5 +53,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-384", SHA_384);
+ TEST_MAIN("SHA-384", SHA_384, 1);
}
diff --git a/t/sha_512.c b/t/sha_512.c
index f98685f..806718b 100644
--- a/t/sha_512.c
+++ b/t/sha_512.c
@@ -80,5 +80,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-512", SHA_512);
+ TEST_MAIN("SHA-512", SHA_512, 1);
}
diff --git a/t/sha_512_224.c b/t/sha_512_224.c
index 3c0d33b..f60bc55 100644
--- a/t/sha_512_224.c
+++ b/t/sha_512_224.c
@@ -22,5 +22,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-512/224", SHA_512_224);
+ TEST_MAIN("SHA-512/224", SHA_512_224, 1);
}
diff --git a/t/sha_512_256.c b/t/sha_512_256.c
index bc4b56a..c6647c2 100644
--- a/t/sha_512_256.c
+++ b/t/sha_512_256.c
@@ -22,5 +22,5 @@ static struct testcase testcases[] = {
int
main(void)
{
- TEST_MAIN("SHA-512/256", SHA_512_256);
+ TEST_MAIN("SHA-512/256", SHA_512_256, 1);
}
diff --git a/t/shake128.c b/t/shake128.c
index 10c24b3..014d0b0 100644
--- a/t/shake128.c
+++ b/t/shake128.c
@@ -33,7 +33,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("SHAKE128", SHAKE128);
+ TEST_MAIN("SHAKE128", SHAKE128, 1);
}
diff --git a/t/shake256.c b/t/shake256.c
index 0ddf9b3..3ab9262 100644
--- a/t/shake256.c
+++ b/t/shake256.c
@@ -33,7 +33,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("SHAKE256", SHAKE256);
+ TEST_MAIN("SHAKE256", SHAKE256, 1);
}
diff --git a/t/shake512.c b/t/shake512.c
index f9f0a54..705e3b4 100644
--- a/t/shake512.c
+++ b/t/shake512.c
@@ -29,7 +29,7 @@ static struct testcase testcases[] = {
static int
main_test(void)
{
- TEST_MAIN("SHAKE512", SHAKE512);
+ TEST_MAIN("SHAKE512", SHAKE512, 1);
}