libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
gf256.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

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).
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.

Function Documentation

◆ gf256_div()

uint8_t gf256_div ( uint8_t a,
uint8_t b )

Divide two elements in GF(2^8).

Parameters
aDividend.
bDivisor (must be non-zero).
Returns
Quotient a/b in GF(2^8).

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().

◆ gf256_inv()

uint8_t gf256_inv ( uint8_t a)

Compute multiplicative inverse in GF(2^8).

Parameters
aElement (must be non-zero).
Returns
Inverse a^(-1) in GF(2^8).

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().

◆ gf256_mul()

uint8_t gf256_mul ( uint8_t a,
uint8_t b )

Multiply two elements in GF(2^8) with polynomial 0x11D.

Parameters
aFirst operand.
bSecond operand.
Returns
Product a*b in GF(2^8).

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().

◆ gf256_mul_region()

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.

Parameters
dstDestination buffer (read-modify-write).
srcSource buffer (read-only).
coeffGF(2^8) coefficient.
lenNumber 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().

◆ gf256_xor_region()

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.

Parameters
dstDestination buffer (read-modify-write).
srcSource buffer (read-only).
lenNumber 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().