57 uint32_t z0 = be32(h), z1 = be32(h + 4), z2 = be32(h + 8), z3 = be32(h + 12);
62 t->
M[0][0] = t->
M[0][1] = t->
M[0][2] = t->
M[0][3] = 0;
63 for (
int i = 4; i > 0; i >>= 1)
65 uint32_t lsb = z3 & 1u;
66 z3 = (z3 >> 1) | (z2 << 31);
67 z2 = (z2 >> 1) | (z1 << 31);
68 z1 = (z1 >> 1) | (z0 << 31);
69 z0 = (z0 >> 1) ^ (lsb ? 0xe1000000u : 0u);
76 for (
int i = 2; i < 16; i <<= 1)
77 for (
int j = 1; j < i; j++)
79 t->
M[i + j][0] = t->
M[i][0] ^ t->
M[j][0];
80 t->
M[i + j][1] = t->
M[i][1] ^ t->
M[j][1];
81 t->
M[i + j][2] = t->
M[i][2] ^ t->
M[j][2];
82 t->
M[i + j][3] = t->
M[i][3] ^ t->
M[j][3];
90 static const uint16_t LAST4[16] = {0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0,
91 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0};
92 uint8_t idx = acc[15] & 0x0f;
93 uint32_t z0 = t->
M[idx][0], z1 = t->
M[idx][1], z2 = t->
M[idx][2], z3 = t->
M[idx][3];
94 for (
int i = 15; i >= 0; i--)
96 uint8_t lo = acc[i] & 0x0f;
97 uint8_t hi = (acc[i] >> 4) & 0x0f;
100 uint32_t rem = z3 & 0x0f;
101 z3 = (z3 >> 4) | (z2 << 28);
102 z2 = (z2 >> 4) | (z1 << 28);
103 z1 = (z1 >> 4) | (z0 << 28);
104 z0 = (z0 >> 4) ^ ((uint32_t)LAST4[rem] << 16);
110 uint32_t rem = z3 & 0x0f;
111 z3 = (z3 >> 4) | (z2 << 28);
112 z2 = (z2 >> 4) | (z1 << 28);
113 z1 = (z1 >> 4) | (z0 << 28);
114 z0 = (z0 >> 4) ^ ((uint32_t)LAST4[rem] << 16);
void ghash_update(const GhashKey *t, uint8_t acc[16], const uint8_t *data, size_t len)
Fold len bytes of data into acc: acc = (acc XOR block) * H per 16 bytes, a final short block MSB-zero...
void ghash_mul(const GhashKey *t, uint8_t acc[16])
acc = acc * H in GF(2^128) with the GCM reduction, using the precomputed table t.