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

Function gfmultword

freebsd/opencrypto/gfmult.c:137–163  ·  view source on GitHub ↗

* Calculate: * (x*2^4 + word[3,0]*h) * * 2^4 + word[7,4]*h) * * ... * 2^4 + word[63,60]*h */

Source from the content-addressed store, hash-verified

135 * 2^4 + word[63,60]*h
136 */
137static struct gf128
138gfmultword(uint64_t word, struct gf128 x, struct gf128table *tbl)
139{
140 struct gf128 row;
141 unsigned bits;
142 unsigned redbits;
143 int i;
144
145 for (i = 0; i < 64; i += 4) {
146 bits = word % 16;
147
148 /* fetch row */
149 row = readrow(tbl, bits);
150
151 /* x * 2^4 */
152 redbits = x.v[1] % 16;
153 x.v[1] = (x.v[1] >> 4) | (x.v[0] % 16) << 60;
154 x.v[0] >>= 4;
155 x.v[0] ^= (uint64_t)reduction[redbits] << (64 - 16);
156
157 word >>= 4;
158
159 x = gf128_add(x, row);
160 }
161
162 return x;
163}
164
165/*
166 * Calculate

Callers 1

gf128_mulFunction · 0.85

Calls 2

readrowFunction · 0.85
gf128_addFunction · 0.85

Tested by

no test coverage detected