# Galois Multiplication

• 01-04-2012, 12:17 AM
christopherx
Galois Multiplication
Righto! I've been writing my implementation of the Rijndal cipher, and I've got stuck on one particular part. the "mixColumns()" method to be exact. Basically,
at first i was using lookup tables from wikipedia. Then I was having problems with the values my implementation was churning out. Anyhow, after some headache I wrote a function that multiplies over Rijndael's finite field, GF(2^8), and implemented it. Then to test it, I compared it to a step by step guide that I found here. Now I'm having a bit of an issue. The lookup tables, and my function for multiplying in GF(2^8) are churning out the same numbers, and the guide is showing me something different. Basically, according to the guide:

d4 * 02 = 04 in Rijndael's finite field, however to the lookup table and my function, it's b3. I'm assuming the guide is right, it's from the cs website, so it's a credible source. I just want to know what I'm doing wrong.

Code:

```private int galoisMultiply(int a, int b) {                                   int p = 0;                                     for (int n=0; n<8; n++) {                                                 p = ((b & 0x01) > 0) ? p^a : p;                                             boolean ho = ((a & 0x80) > 0);                                             a = ((a<<1) & 0xFE);                                             if (ho)                         a = a ^ 0x1b;                                             b = ((b>>1) & 0x7F);                   }                   return p;                 }```
Above is my multiplication function. I reckon that works fine, and that is returning b3 for my values as well, same with my lookup table, which can be found here. In this case, it's the table for multiplying by 2.

I need either someone to talk me through Galois Multiplication, or perhaps someone can help me by looking at the tables and vouching for their credibility. Seriously am stuck for ideas at the moment and I would really love it if you guys could help me out here!
• 01-04-2012, 03:13 PM
christopherx
Re: Galois Multiplication
Solved it. I was performing galois multiplication, just didn't take into account that it was matrix multiplication :)