Reference

gf256(3)

Routines to do arithmetic in the Galois Field GF(256).

delim $$

NAME

gf256_log_2, gf256_antilog_2, gf256_power_of_2, gf256_add, gf256_minus, gf256_subtract, gf256_mul, gf256_inv, gf256_div, gf256_product, gf256_exp, gf256_term, gfmul, gfadd, gfinv, gfexp - Routines to do arithmetic in the Galois Field GF(256).

SYNOPSIS


        
    

    
        
            

#include <gf256.h>

cc ... -lecc

GF256 x;

r= gf256_log_2 (x) GF256 r, x;

GF256 gf256_antilog_2 (x) GF256 x;

GF256 gf256_power_of_2 (n) GF256 n;

GF256 gf255_add (a, b) GF256 a, b;

r= gf256_minus (a) GF256 r, a;

GF256 gf256_subtract (a, b) GF256 a, b;

GF256 gf256_mul (x, y) GF256 x, y;

r= gf256_inv (x) GF256 r, x;

GF256 gf256_div (x, y) GF256 x, y;

GF256 gf256_product (x, y, z) GF256 x, y, z;

GF256 gf256_exp (a, n) GF256 a; int n;

GF256 gf256_term (c, i, n) GF256 c; int i, n;

unsigned char gfmul (x, y) unsigned char x, y;

unsigned char gfadd (a, b) unsigned char a, b;

r= gfinv (x) unsigned char r, x;

unsigned char gfexp (a, n) unsigned char a, n;

DESCRIPTION

This manual page documents the GNU ecc library - routines to do arithmetic in the Galois Field GF($2 sup 8$).

The representation of GF($2 sup 8$) used in this library is isomorphic to $GF(2)[X] ~ modulo ~ P (x)$ where

P (x) = x sup 8 + x sup 4 + x sup 3 + x sup 2 + 1

which is a primitive polynomial. The polynomials chosen are

f sub 1 ( x ) = 1
f sub 2 ( x ) = x cdot f sub 1 ( x ) ~ modulo ~ P ( x )
f sub 3 ( x ) = x cdot f sub 2 ( x ) ~ modulo ~ P ( x )

f sub n ( x ) = x cdot f sub {n-1} ( x ) ~ modulo ~ P ( x )

where the modulo is done in $GF(2)[X]$.

A Discrete Antilogrithm table is formed by evaluating these polynomials at $x = 2$ which is a cyclic element of GF($2 sup 8$). This representation can be found in many textbooks; see, for instance, ``Theory and Practice of Error Control Codes'' by Richard Blahut.

gf256_log_2() returns the discrete logarithm of x such that $2 sup r = x$ for non-zero value of $x$.

gf256_antilog_2() returns the discrete antilogrithm of x such that

gf256_antilog_2 (gf256_log_2 (a)) $==$ a
gf256_log_2 (gf256_antilog_2 (a)) $==$ a

for all non-zero $a$ in GF($2 sup 8$).

gf256_power_of_2() returns the $2 sup n$. The range of n is restricted to GF256.

gf256_add() and gfadd() return the sum of their arguments.

gf256_minus() returns the additive inverse of its argument. That is, $a + r = 0$.

gf256_subtract() returns $a - b$.

gf256_mul() and gfmul() return the product of their arguments.

gf256_inv() and gfinv() return the multiplicative inverse of their argument, which must have non-zero value. That is, $x cdot r = 1$.

gf256_div() returns $x / y$ for non-zero value of $y$.

gf256_product() returns the products of the 3 arguments.

gf256_exp() and gfexp() return $a sup n$.

gf256_term() returns the value of the $x sup n$ term which has coefficient $c$ in the evaluation of a polynomial at $x = 2 sup i$. In short, it returns $c cdot 2 sup {i cdot n}$.

CAVEATS

Note that most of the functions are C-preprocessor macros. Please, do not have side-effects in the arguments. Avoid functional compositions, instead use temporary variables. For instance, instead of

y = gf256_add (gf256_mul (s2, s4), gf256_mul (s3, s3));

write

y = gf256_mul (s2, s4);
p = gf256_mul (s3, s3);
y = gf256_add (y, p);

The values of gf256_log_2(), gf256_inv(), and gf256_div() are undefined for invalid argument values; programs may continue to run, but the results may be wrong.

WARNING

The 4 functions gfmul(), gfadd(), gfinv(), and gfexp() are included in the library for backward-compatibility to earlier versions of this library. They may be removed in future releases.

SEE ALSO

rsff-f9(3)