-static int execute_poly1305(SIMPLE_FIXTURE fixture)
-{
- POLY1305 poly1305;
- unsigned int i = fixture.test_num;
- const TESTDATA *test = fixture.test_data;
- const unsigned char *in = test->input.data;
- size_t inlen = test->input.size;
- const unsigned char *key = test->key.data;
- const unsigned char *expected = test->expected.data;
- size_t expectedlen = test->expected.size;
- unsigned char out[16];
-
- if (expectedlen != sizeof(out))
- return 0;
-
- Poly1305_Init(&poly1305, key);
- Poly1305_Update(&poly1305, in, inlen);
- Poly1305_Final(&poly1305, out);
-
- if (memcmp(out, expected, expectedlen) != 0) {
- fprintf(stderr, "Poly1305 test #%d failed.\n", i);
- fprintf(stderr, "got: ");
- hexdump(out, sizeof(out));
- fprintf(stderr, "\nexpected: ");
- hexdump(expected, expectedlen);
- fprintf(stderr, "\n");
- return 0;
- }
-
- if (inlen > 16) {
- Poly1305_Init(&poly1305, key);
- Poly1305_Update(&poly1305, in, 1);
- Poly1305_Update(&poly1305, in+1, inlen-1);
- Poly1305_Final(&poly1305, out);
-
- if (memcmp(out, expected, expectedlen) != 0) {
- fprintf(stderr, "Poly1305 test #%d/1+(N-1) failed.\n", i);
- fprintf(stderr, "got: ");
- hexdump(out, sizeof(out));
- fprintf(stderr, "\nexpected: ");
- hexdump(expected, expectedlen);
- fprintf(stderr, "\n");
- return 0;
- }
- }
-
- if (inlen > 32) {
- size_t half = inlen / 2;
-
- Poly1305_Init(&poly1305, key);
- Poly1305_Update(&poly1305, in, half);
- Poly1305_Update(&poly1305, in+half, inlen-half);
- Poly1305_Final(&poly1305, out);
-
- if (memcmp(out, expected, expectedlen) != 0) {
- fprintf(stderr, "Poly1305 test #%d/2 failed.\n", i);
- fprintf(stderr, "got: ");
- hexdump(out, sizeof(out));
- fprintf(stderr, "\nexpected: ");
- hexdump(expected, expectedlen);
- fprintf(stderr, "\n");
- return 0;
- }
-
- for (half = 16; half < inlen; half += 16) {
- Poly1305_Init(&poly1305, key);
- Poly1305_Update(&poly1305, in, half);
- Poly1305_Update(&poly1305, in+half, inlen-half);
- Poly1305_Final(&poly1305, out);
-
- if (memcmp(out, expected, expectedlen) != 0) {
- fprintf(stderr, "Poly1305 test #%d/%" OSSLzu "+%" OSSLzu " failed.\n",
- i, half, inlen-half);
- fprintf(stderr, "got: ");
- hexdump(out, sizeof(out));
- fprintf(stderr, "\nexpected: ");
- hexdump(expected, expectedlen);
- fprintf(stderr, "\n");
- return 0;
- }
- }
- }
-
- return 1;
-}
-
-static void teardown_poly1305(SIMPLE_FIXTURE fixture)
-{
-}
-