Class TwoTo8Field

java.lang.Object
  extended by TwoTo8Field
All Implemented Interfaces:
Field, java.lang.Cloneable

public class TwoTo8Field
extends java.lang.Object
implements Field, java.lang.Cloneable

An element of the Field(28) modulo the AES irreducible (x8 + x4 + x3 + x + 1). Each element of the field can be thought of as consisting of eight bits, or a byte.

Unit is the Unit element in the Field. That is, when you multiply any element in the Field with it, you get back the same element. It's actually {01}.

Zero is the Zero element in the Field. That is, when you add it to any element in the Field, you get back the same element. It's actually {00}.


Field Summary
static TwoTo8Field Unit
           
static TwoTo8Field Zero
           
 
Constructor Summary
TwoTo8Field()
          Creates a new Field element and initializes it to Zero.
TwoTo8Field(byte x)
           
TwoTo8Field(int x)
           
TwoTo8Field(java.lang.String x)
          Creates a new Field element from the String which must be either one or two nibbles.
TwoTo8Field(TwoTo8Field y)
           
 
Method Summary
 void add(Field y)
          Add a Field element y to this.
 void add(TwoTo8Field y)
          Adding is just exclusive or'ing the two 8-bit quantities.
 void affine()
          Returns the AES affine transformation described on page 132 of Trappe & Washington.
 void affine(boolean debug)
          Don't use this function.
 TwoTo8Field clone()
           
 boolean equals(java.lang.Object obj)
          Tests whether obj is structurally identical to this.
 TwoTo8Field Inv()
          Find the gcd of this & the irreducible polynomial (x8 + x4 + x3 + x + 1).
static void main(java.lang.String[] args)
           
static void main0(java.lang.String[] args)
           
 void mult(Field y)
          Multiplies a Field element y to this.
 Field mult(Field x, Field y)
          Multiplies two Field elements x and y and returns their product.
 void mult(int z)
           
 void mult(TwoTo8Field y)
           
 byte toByte()
           
 java.lang.String toString()
          Returns the element in GF(28) as a string, for e.g., "0B", "DF" etc.
 TwoTo8Field zero()
          Returns a copy identical to Zero in the Field.
 boolean zerop()
          Tests whether the Field element == Zero
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Unit

public static TwoTo8Field Unit

Zero

public static TwoTo8Field Zero
Constructor Detail

TwoTo8Field

public TwoTo8Field(TwoTo8Field y)

TwoTo8Field

public TwoTo8Field()
Creates a new Field element and initializes it to Zero.


TwoTo8Field

public TwoTo8Field(byte x)

TwoTo8Field

public TwoTo8Field(int x)

TwoTo8Field

public TwoTo8Field(java.lang.String x)
Creates a new Field element from the String which must be either one or two nibbles. For e.g., new TwoTo8Field("AF").

Method Detail

clone

public TwoTo8Field clone()
Specified by:
clone in interface Field
Overrides:
clone in class java.lang.Object

add

public void add(TwoTo8Field y)
Adding is just exclusive or'ing the two 8-bit quantities.

Parameters:
y - may be the this object.

zerop

public boolean zerop()
Tests whether the Field element == Zero

Specified by:
zerop in interface Field

zero

public TwoTo8Field zero()
Returns a copy identical to Zero in the Field. Because it's a copy you can mutate it in your calculations.

Specified by:
zero in interface Field

add

public void add(Field y)
Add a Field element y to this. y should be of type TwoTo8Field. y remains unchanged.

Specified by:
add in interface Field

equals

public boolean equals(java.lang.Object obj)
Tests whether obj is structurally identical to this.

Overrides:
equals in class java.lang.Object

mult

public void mult(Field y)
Multiplies a Field element y to this. y should be of type TwoTo8Field. y remains unchanged. It's provided for convenience when you hold an element of type TwoTo8Field in a variable of type Field.

Specified by:
mult in interface Field

mult

public Field mult(Field x,
                  Field y)
Multiplies two Field elements x and y and returns their product. x and y should be of type TwoTo8Field. Both remain unchanged.

Specified by:
mult in interface Field

mult

public void mult(TwoTo8Field y)

mult

public void mult(int z)
Specified by:
mult in interface Field

Inv

public TwoTo8Field Inv()
Find the gcd of this & the irreducible polynomial (x8 + x4 + x3 + x + 1). thereby finding this-1 in the process. Equation that is solved is
 B0,0 × f + B0,1 × g = A0
 B1,0 × f + B1,1 × g = A1
 
where A0 is initialized to this and A1 is initialized to (x8 + x4 + x3 + x + 1). B0,0 is inititialized to 1, B0,1 to 0, B1,0 to 0 and B1,1 to 1.

This is computing EGCD for polynomials.

Specified by:
Inv in interface Field

toString

public java.lang.String toString()
Returns the element in GF(28) as a string, for e.g., "0B", "DF" etc.

Overrides:
toString in class java.lang.Object

toByte

public byte toByte()

main0

public static void main0(java.lang.String[] args)

affine

public void affine()
Returns the AES affine transformation described on page 132 of Trappe & Washington. To compute ByteSub(x), x ∈ GF(28), call x.Inv() followed by x.affine().


affine

public void affine(boolean debug)
Don't use this function. It's just for debugging. Instead use affine() with no arguments.


main

public static void main(java.lang.String[] args)