MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gf128_genmultable

Function gf128_genmultable

freebsd/opencrypto/gfmult.c:61–81  ·  view source on GitHub ↗

* Generate a table for 0-16 * h. Store the results in the table w/ indexes * bit reversed, and the words striped across the values. */

Source from the content-addressed store, hash-verified

59 * bit reversed, and the words striped across the values.
60 */
61void
62gf128_genmultable(struct gf128 h, struct gf128table *t)
63{
64 struct gf128 tbl[16];
65 int i;
66
67 tbl[0] = MAKE_GF128(0, 0);
68 tbl[1] = h;
69
70 for (i = 2; i < 16; i += 2) {
71 tbl[i] = gf128_mulalpha(tbl[i / 2]);
72 tbl[i + 1] = gf128_add(tbl[i], h);
73 }
74
75 for (i = 0; i < 16; i++) {
76 t->a[nib_rev[i]] = tbl[i].v[0] >> 32;
77 t->b[nib_rev[i]] = tbl[i].v[0];
78 t->c[nib_rev[i]] = tbl[i].v[1] >> 32;
79 t->d[nib_rev[i]] = tbl[i].v[1];
80 }
81}
82
83/*
84 * Generate tables containing h, h^2, h^3 and h^4, starting at 0.

Callers 1

gf128_genmultable4Function · 0.85

Calls 2

gf128_mulalphaFunction · 0.85
gf128_addFunction · 0.85

Tested by

no test coverage detected