aboutsummaryrefslogtreecommitdiff
path: root/tests/cavp-tests
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2024-02-24 01:42:49 -0500
committerPaul Duncan <pabs@pablotron.org>2024-02-24 01:42:49 -0500
commit60414bc5ac5bedef6e9c975220c4ec971cb56450 (patch)
treecfd7eac724f830aa7c8ed43576219babadd50cfd /tests/cavp-tests
parentec79fdfeb88d863108e6b5cbd161163a60c7fd18 (diff)
downloadsha3-60414bc5ac5bedef6e9c975220c4ec971cb56450.tar.bz2
sha3-60414bc5ac5bedef6e9c975220c4ec971cb56450.zip
tests/cavp-tests/main.c: regenerate
Diffstat (limited to 'tests/cavp-tests')
-rw-r--r--tests/cavp-tests/main.c102
1 files changed, 52 insertions, 50 deletions
diff --git a/tests/cavp-tests/main.c b/tests/cavp-tests/main.c
index dd16cce..2f206e6 100644
--- a/tests/cavp-tests/main.c
+++ b/tests/cavp-tests/main.c
@@ -1,11 +1,13 @@
// Run test vectors for FIPS202 hash functions and XOFs.
// (generated by `gen-main.rb`)
+
#include <stdint.h> // uint8_t
#include <stdio.h> // printf()
#include <string.h> // memcmp()
#include "hex.h" // hex_write()
#include "sha3.h"
+// test failure
typedef struct {
const char *test_fn; // test function name
size_t test_i; // test case index
@@ -6275,14 +6277,14 @@ static void test_sha3_224(void) {
// check for expected result
if (memcmp(got, exp, sizeof(got))) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = sizeof(got),
- .exp = exp,
- .exp_len = sizeof(got),
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = sizeof(got), // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = sizeof(got), // expected result length, in bytes
});
}
}
@@ -12201,14 +12203,14 @@ static void test_sha3_256(void) {
// check for expected result
if (memcmp(got, exp, sizeof(got))) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = sizeof(got),
- .exp = exp,
- .exp_len = sizeof(got),
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = sizeof(got), // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = sizeof(got), // expected result length, in bytes
});
}
}
@@ -16795,14 +16797,14 @@ static void test_sha3_384(void) {
// check for expected result
if (memcmp(got, exp, sizeof(got))) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = sizeof(got),
- .exp = exp,
- .exp_len = sizeof(got),
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = sizeof(got), // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = sizeof(got), // expected result length, in bytes
});
}
}
@@ -20057,14 +20059,14 @@ static void test_sha3_512(void) {
// check for expected result
if (memcmp(got, exp, sizeof(got))) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = sizeof(got),
- .exp = exp,
- .exp_len = sizeof(got),
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = sizeof(got), // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = sizeof(got), // expected result length, in bytes
});
}
}
@@ -29786,19 +29788,19 @@ static void test_shake128(void) {
// hash data into "got"
uint8_t got[140] = { 0 };
- shake128_xof_once(DATA + TESTS[i].src_ofs, TESTS[i].src_len, got, exp_len);
+ shake128(DATA + TESTS[i].src_ofs, TESTS[i].src_len, got, exp_len);
// check for expected result
if (memcmp(got, exp, exp_len)) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = exp_len,
- .exp = exp,
- .exp_len = exp_len,
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = exp_len, // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = exp_len, // expected result length, in bytes
});
}
}
@@ -38886,19 +38888,19 @@ static void test_shake256(void) {
// hash data into "got"
uint8_t got[250] = { 0 };
- shake256_xof_once(DATA + TESTS[i].src_ofs, TESTS[i].src_len, got, exp_len);
+ shake256(DATA + TESTS[i].src_ofs, TESTS[i].src_len, got, exp_len);
// check for expected result
if (memcmp(got, exp, exp_len)) {
fail(stderr, (failure_t) {
- .test_fn = __func__,
- .test_i = i,
- .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs],
- .rsp_line = TESTS[i].rsp_file_line,
- .got = got,
- .got_len = exp_len,
- .exp = exp,
- .exp_len = exp_len,
+ .test_fn = __func__, // test function
+ .test_i = i, // test case index in TESTS
+ .rsp_file = RSP_FILES[TESTS[i].rsp_file_ofs], // response file
+ .rsp_line = TESTS[i].rsp_file_line, // start line of test case
+ .got = got, // result
+ .got_len = exp_len, // result length, in bytes
+ .exp = exp, // expected result
+ .exp_len = exp_len, // expected result length, in bytes
});
}
}