- for (ip = szs; *ip; ip++) { \
- i = *ip; \
- csz = v[0].len; \
- if (i == -1) \
- i = csz; \
- if (i > csz) \
- continue; \
- p = (octet *)v[0].buf; \
- pre##_macinit(&cctx, &ckey); \
- while (csz) { \
- if (i > csz) \
- i = csz; \
- pre##_mac(&cctx, p, i); \
- p += i; \
- csz -= i; \
- } \
- pre##_macdone(&cctx, d.buf); \
- if (memcmp(d.buf, v[2].buf, PRE##_HASHSZ) != 0) { \
- printf("\nfail:\n\tstep = %i\n\tinput = `%s'\n\tkey = ", \
- *ip, v[0].buf); \
- type_hex.dump(&v[1], stdout); \
- fputs("\n\texpected = ", stdout); \
- type_hex.dump(&v[2], stdout); \
- fputs("\n\tcomputed = ", stdout); \
- type_hex.dump(&d, stdout); \
- putchar('\n'); \
- ok = 0; \
- } \
- } \
- \
- dstr_destroy(&d); \
- return (ok); \
-} \
- \
-static test_chunk macdefs[] = { \
- { #pre "-hmac", macverify, \
- { &type_string, &type_hex, &type_hex, 0 } }, \
- { 0, 0, { 0 } } \
-}; \
- \
-int main(int argc, char *argv[]) \
-{ \
- ego(argv[0]); \
- test_run(argc, argv, macdefs, SRCDIR"/tests/" #pre); \
- return (0); \
-}
-
-#else
-# define HMAC_TEST(PRE, pre)
-#endif