diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-07-17 17:03:37 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-07-17 17:03:37 -0400 |
commit | 73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d (patch) | |
tree | 4d1d988f6714e22e2b991e2f074a15e03667ac7f /run-tests.c | |
parent | 2c9390c10b2f31c87830e0816ca207974ebfc590 (diff) | |
download | sha2-73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d.tar.bz2 sha2-73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d.zip |
add hmac-sha2 and update files
Diffstat (limited to 'run-tests.c')
-rw-r--r-- | run-tests.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/run-tests.c b/run-tests.c new file mode 100644 index 0000000..9ba120d --- /dev/null +++ b/run-tests.c @@ -0,0 +1,34 @@ +#include <stdio.h> // printf() +#include <string.h> // strlen() +#include "sha2.h" +#include "tests.h" + +static void print_hash(const uint8_t * const hash) { + for (size_t i = 0; i < SHA256_HASH_SIZE; i++) { + printf("%02x", hash[i]); + } +} + +static void on_test_fail( + const int algo, + const char * const src, + const uint8_t * const got_hash, + const uint8_t * const expected_hash +) { + printf("sha%d,\"%s\",", algo, src); + print_hash(got_hash); + printf(","); + print_hash(expected_hash); + printf("\n"); +} + +int main(int argc, char *argv[]) { + (void) argc; + (void) argv; + + // run internal tests + printf("algo,input,result,expected\n"); + run_tests(on_test_fail); + + return 0; +} |