|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
GF(2^8) arithmetic with SIMD-accelerated region multiply. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include "gf256.h"#include "aaruformat/simd.h"Go to the source code of this file.
Functions | |
| static void | gf256_init_tables (void) |
| Initialize log/antilog tables for GF(2^8) with polynomial 0x11D. | |
| uint8_t | gf256_mul (uint8_t a, uint8_t b) |
| Multiply two elements in GF(2^8) with polynomial 0x11D. | |
| uint8_t | gf256_div (uint8_t a, uint8_t b) |
| Divide two elements in GF(2^8). | |
| uint8_t | gf256_inv (uint8_t a) |
| Compute multiplicative inverse in GF(2^8). | |
| static void | gf256_build_mul_tables (uint8_t coeff, uint8_t low_tbl[16], uint8_t hi_tbl[16]) |
| Build the two 16-byte nibble lookup tables for a given coefficient. | |
| static void | gf256_mul_region_scalar (uint8_t *dst, const uint8_t *src, uint8_t coeff, size_t len) |
| static void | gf256_xor_region_scalar (uint8_t *dst, const uint8_t *src, size_t len) |
| void | gf256_mul_region (uint8_t *dst, const uint8_t *src, uint8_t coeff, size_t len) |
| Multiply-accumulate a region: dst[i] ^= GF_mul(src[i], coeff) for all i. | |
| void | gf256_xor_region (uint8_t *dst, const uint8_t *src, size_t len) |
| XOR a region: dst[i] ^= src[i] for all i. | |
Variables | |
| static uint8_t | gf256_log_table [256] |
| Log table: gf256_log[x] = discrete log base 2 of x in GF(2^8). | |
| static uint8_t | gf256_exp_table [512] |
| Anti-log (exp) table: gf256_exp[i] = 2^i mod P. | |
| static int | gf256_tables_initialized = 0 |
| Flag to ensure tables are initialized exactly once. | |
GF(2^8) arithmetic with SIMD-accelerated region multiply.
Galois Field GF(2^8) with irreducible polynomial x^8 + x^4 + x^3 + x^2 + 1 (0x11D). Uses log/antilog tables for scalar operations and 4-bit nibble split tables with SIMD shuffle for vectorized region multiply-accumulate.
Definition in file gf256.c.
|
static |
Build the two 16-byte nibble lookup tables for a given coefficient.
Definition at line 114 of file gf256.c.
References gf256_build_mul_tables(), gf256_init_tables(), and gf256_mul().
Referenced by gf256_build_mul_tables(), and gf256_mul_region_scalar().
| uint8_t gf256_div | ( | uint8_t | a, |
| uint8_t | b ) |
Divide two elements in GF(2^8).
| a | Dividend. |
| b | Divisor (must be non-zero). |
Definition at line 84 of file gf256.c.
References gf256_div(), gf256_exp_table, gf256_init_tables(), and gf256_log_table.
Referenced by gf256_div().
|
static |
Initialize log/antilog tables for GF(2^8) with polynomial 0x11D.
Definition at line 51 of file gf256.c.
References gf256_exp_table, gf256_init_tables(), gf256_log_table, and gf256_tables_initialized.
Referenced by gf256_build_mul_tables(), gf256_div(), gf256_init_tables(), gf256_inv(), gf256_mul(), and gf256_mul_region().
| uint8_t gf256_inv | ( | uint8_t | a | ) |
Compute multiplicative inverse in GF(2^8).
| a | Element (must be non-zero). |
Definition at line 92 of file gf256.c.
References gf256_exp_table, gf256_init_tables(), gf256_inv(), and gf256_log_table.
Referenced by gf256_inv(), and invert_matrix().
| uint8_t gf256_mul | ( | uint8_t | a, |
| uint8_t | b ) |
Multiply two elements in GF(2^8) with polynomial 0x11D.
| a | First operand. |
| b | Second operand. |
Definition at line 77 of file gf256.c.
References gf256_exp_table, gf256_init_tables(), gf256_log_table, and gf256_mul().
Referenced by build_vandermonde(), gf256_build_mul_tables(), gf256_mul(), invert_matrix(), rs_create(), and rs_decode().
| void gf256_mul_region | ( | uint8_t * | dst, |
| const uint8_t * | src, | ||
| uint8_t | coeff, | ||
| size_t | len ) |
Multiply-accumulate a region: dst[i] ^= GF_mul(src[i], coeff) for all i.
Uses SIMD acceleration when available (AVX2 > SSSE3 > NEON > scalar). If coeff is 0, this is a no-op. If coeff is 1, this is XOR.
| dst | Destination buffer (read-modify-write). |
| src | Source buffer (read-only). |
| coeff | GF(2^8) coefficient. |
| len | Number of bytes to process. |
Definition at line 350 of file gf256.c.
References gf256_init_tables(), gf256_mul_region(), gf256_mul_region_scalar(), and gf256_xor_region().
Referenced by gf256_mul_region(), rs_decode(), and rs_encode_incremental().
|
static |
Definition at line 126 of file gf256.c.
References gf256_build_mul_tables(), and gf256_mul_region_scalar().
Referenced by gf256_mul_region(), and gf256_mul_region_scalar().
| void gf256_xor_region | ( | uint8_t * | dst, |
| const uint8_t * | src, | ||
| size_t | len ) |
XOR a region: dst[i] ^= src[i] for all i.
Uses SIMD acceleration when available.
| dst | Destination buffer (read-modify-write). |
| src | Source buffer (read-only). |
| len | Number of bytes to process. |
Definition at line 370 of file gf256.c.
References gf256_xor_region(), and gf256_xor_region_scalar().
Referenced by gf256_mul_region(), and gf256_xor_region().
|
static |
Definition at line 135 of file gf256.c.
References gf256_xor_region_scalar().
Referenced by gf256_xor_region(), and gf256_xor_region_scalar().
|
static |
Anti-log (exp) table: gf256_exp[i] = 2^i mod P.
Extended to 512 entries to avoid modular reduction.
Definition at line 43 of file gf256.c.
Referenced by gf256_div(), gf256_init_tables(), gf256_inv(), and gf256_mul().
|
static |
Log table: gf256_log[x] = discrete log base 2 of x in GF(2^8).
gf256_log[0] is undefined.
Definition at line 41 of file gf256.c.
Referenced by gf256_div(), gf256_init_tables(), gf256_inv(), and gf256_mul().
|
static |
Flag to ensure tables are initialized exactly once.
Definition at line 46 of file gf256.c.
Referenced by gf256_init_tables().