2 * GF-Complete: A Comprehensive Open Source Library for Galois Field Arithmetic
3 * James S. Plank, Ethan L. Miller, Kevin M. Greenan,
4 * Benjamin A. Arnold, John A. Burnum, Adam W. Disney, Allen C. McBride.
8 * Identical to example_3 except it works in GF(2^128)
18 #include "gf_complete.h"
21 #define LLUI (long long unsigned int)
25 fprintf(stderr, "usage: gf_example_3\n");
29 int main(int argc, char **argv)
31 uint64_t a[2], b[2], c[2];
36 if (argc != 1) usage(NULL);
38 /* Get two random numbers in a and b */
44 /* Create the proper instance of the gf_t object using defaults: */
46 gf_init_easy(&gf, 128);
48 /* And multiply a and b using the galois field: */
50 gf.multiply.w128(&gf, a, b, c);
51 printf("%016llx%016llx * %016llx%016llx =\n%016llx%016llx\n",
52 LLUI a[0], LLUI a[1], LLUI b[0], LLUI b[1], LLUI c[0], LLUI c[1]);
54 r1 = (uint64_t *) malloc(32);
55 r2 = (uint64_t *) malloc(32);
57 for (i = 0; i < 4; i++) r1[i] = MOA_Random_64();
59 gf.multiply_region.w128(&gf, r1, r2, a, 32, 0);
61 printf("\nmultiply_region by %016llx%016llx\n\n", LLUI a[0], LLUI a[1]);
62 printf("R1 (the source): ");
63 for (i = 0; i < 4; i += 2) printf(" %016llx%016llx", LLUI r1[i], LLUI r1[i+1]);
65 printf("\nR2 (the product): ");
66 for (i = 0; i < 4; i += 2) printf(" %016llx%016llx", LLUI r2[i], LLUI r2[i+1]);