-#define FIELDOP(op) GLUE(FIELD, _##op)
-
-#define f25519_FESZ 32u
-#define fgoldi_FESZ 56u
-
-/* Define some global variables we shouldn't need.
- *
- * Annoyingly, `secnet.h' declares static pointers and initializes them to
- * point to some external variables. At `-O0', GCC doesn't optimize these
- * away, so there's a link-time dependency on these variables. Define them
- * here, so that `f25519.c' and `f448.c' can find them.
- *
- * (Later GCC has `-Og', which optimizes without making debugging a
- * nightmare, but I'm not running that version here. Note that `serpent.c'
- * doesn't have this problem because it defines its own word load and store
- * operations to cope with its endian weirdness, whereas the field arithmetic
- * uses `unaligned.h' which manages to include `secnet.h'.)
- */
-uint64_t now_global;
-struct timeval tv_now_global;
-
-union reg {
- long i;
- unsigned long u;
- uint8_t fe[FIELDOP(FESZ)];
-};
-
-struct regty {
- void (*parse)(union reg *r, char *p);
- void (*dump)(FILE *fp, const union reg *r);
- int (*eq)(const union reg *r, const union reg *rr);
-};
-
-struct regdef {
- const char *name;
- const struct regty *ty;
- int r;
-};
-
-struct test {
- const char *name;
- void (*fn)(union reg *out, const union reg *in);
- const struct regdef *regs;
-};
-
-static int lno;
-
-static void bail(const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
- fprintf(stderr, "unexpected error (line %d): ", lno);
- vfprintf(stderr, msg, ap);
- va_end(ap);
- fputc('\n', stderr);
- exit(3);
-}
-
-static void parse_hex(uint8_t *b, size_t sz, char *p)
-{
- size_t n = strlen(p);
- unsigned i;
- char bb[3];
-
- if (n%2) bail("bad hex (odd number of nibbles)");
- else if (n/2 != sz) bail("bad hex (want %zu bytes, found %zu", sz, n/2);
- while (sz) {
- for (i = 0; i < 2; i++) {
- if (!isxdigit((unsigned char)p[i]))
- bail("bad hex digit `%c'", p[i]);
- bb[i] = p[i];
- }
- bb[2] = 0;
- p += 2;
- *b++ = strtoul(bb, 0, 16); sz--;
- }
-}
-
-static void dump_hex(FILE *fp, const uint8_t *b, size_t sz)
- { while (sz--) fprintf(fp, "%02x", *b++); fputc('\n', fp); }
-
-static void parse_int(union reg *r, char *p)
-{
- char *q;
-
- errno = 0;
- r->i = strtol(p, &q, 0);
- if (*q || errno) bail("bad integer `%s'", p);
-}
-
-static void dump_int(FILE *fp, const union reg *r)
- { fprintf(fp, "%ld\n", r->i); }
-
-static int eq_int(const union reg *r, const union reg *rr)
- { return (r->i == rr->i); }
-
-static const struct regty regty_int = { parse_int, dump_int, eq_int };