![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Classes | |
| struct | Block128 |
| 128-bit value stored as two big-endian uint64_t halves. More... | |
| struct | GHashTable |
| 4-bit precomputed table for constant-time GHASH multiplication. More... | |
Functions | |
| Block128 | load_block (const uint8_t src[16]) |
| Load a 16-byte array into a Block128 (big-endian byte order). | |
| void | store_block (uint8_t dst[16], const Block128 &b) |
| Store a Block128 into a 16-byte array (big-endian byte order). | |
| Block128 | xor_blocks (const Block128 &a, const Block128 &b) |
| XOR two Block128 values. | |
| Block128 | gf128_double (const Block128 &V) |
| "Doubling" in GF(2^128): multiply by x (shift right by 1 in GCM bit ordering). | |
| Block128 | ct_table_lookup (const Block128 table[16], uint8_t index) |
| Constant-time 16-entry Block128 table lookup. | |
| uint64_t | ct_reduce4 (uint8_t index) |
| Constant-time 4-bit reduction table lookup. | |
| uint8_t | rev4 (uint8_t n) |
| Bit-reverse a 4-bit nibble value. | |
| Block128 | gf128_mul_ct (const GHashTable &table, const Block128 &X) |
| Constant-time GF(2^128) multiplication using the 4-bit precomputed table. | |
| Block128 | gf128_mul (const Block128 &X, const Block128 &Y) |
| Multiply two elements in GF(2^128) using the schoolbook algorithm. | |
| Block128 | ghash (const Block128 &H, const uint8_t *data, size_t data_size) |
| GHASH: Compute the GHASH function over data using hash subkey H. | |
| void | inc32 (uint8_t counter[16]) |
| Increment the rightmost 32 bits of a 16-byte counter block (big-endian). | |
| void | gctr (const Aes256 &cipher, const uint8_t icb[16], const uint8_t *input, size_t input_size, uint8_t *output) |
| GCTR: AES-CTR encryption with the given initial counter block. | |
|
inline |
Constant-time 4-bit reduction table lookup.
When right-shifting a GF(2^128) element by 4 bits, the 4 bits that fall off the LSB end each contribute a shifted copy of the reducing polynomial R = 0xe1 << 56. This table precomputes the XOR of those contributions for every possible 4-bit value.
Definition at line 181 of file aes_gcm.hpp.
|
inline |
Constant-time 16-entry Block128 table lookup.
Scans all 16 entries on every call, selecting the entry at index via data-independent masking. Prevents cache-timing side channels.
Definition at line 162 of file aes_gcm.hpp.
|
inline |
GCTR: AES-CTR encryption with the given initial counter block.
For each 16-byte block of data:
The last block may be partial (only XOR the relevant bytes).
Definition at line 350 of file aes_gcm.hpp.
"Doubling" in GF(2^128): multiply by x (shift right by 1 in GCM bit ordering).
If the LSB (bit 127 in GCM ordering) was set, XOR with the reducing polynomial R = 0xe1 << 56. Constant-time: no branches on the input.
Definition at line 118 of file aes_gcm.hpp.
|
inline |
Multiply two elements in GF(2^128) using the schoolbook algorithm.
Definition at line 268 of file aes_gcm.hpp.
|
inline |
Constant-time GF(2^128) multiplication using the 4-bit precomputed table.
Processes X nibble-by-nibble using reversed Horner evaluation: bytes are iterated from LAST to FIRST (byte 15 → byte 0), and within each byte the low nibble (higher polynomial degrees) is processed before the high nibble. Both nibble values AND the 4-bit reduction remainder are bit-reversed before table lookup to account for GCM's reflected bit ordering (NIST SP 800-38D §6.2).
All table lookups and shifts are data-independent — no branches or variable-time memory accesses on secret data.
Ref: NIST SP 800-38D §6.3, CWE-208.
Definition at line 229 of file aes_gcm.hpp.
|
inline |
GHASH: Compute the GHASH function over data using hash subkey H.
GHASH processes 16-byte blocks: X_0 = 0 X_i = (X_{i-1} ^ A_i) * H for each block A_i
The input data is padded with zeros to a multiple of 16 bytes.
Definition at line 305 of file aes_gcm.hpp.
|
inline |
Increment the rightmost 32 bits of a 16-byte counter block (big-endian).
Definition at line 330 of file aes_gcm.hpp.
|
inline |
Load a 16-byte array into a Block128 (big-endian byte order).
Definition at line 88 of file aes_gcm.hpp.
|
inline |
Bit-reverse a 4-bit nibble value.
GCM uses a reflected bit ordering where bit 0 of a byte is the MSB (coefficient of x^0). When extracting nibbles from a byte or from the low 4 bits of Z.lo, the bit positions within the nibble are reversed relative to the GF(2^128) polynomial basis used by the precomputed tables (both the H-multiple table and the reduction table). This function maps the nibble back to the correct table index.
Definition at line 211 of file aes_gcm.hpp.
|
inline |
Store a Block128 into a 16-byte array (big-endian byte order).
Definition at line 102 of file aes_gcm.hpp.