I am simulating a mini AES encryption/decryption algorithm using C++.
For this I need to multiply two 4-bit numbers
while treating them as polynomials.
It goes through some stages that are converting them to polynomials, multiplying the two polynomials, then doing the polynomial reduction to lower power if needed using a predefined irreducible polynomial, and it finally converts them back to 4-bit format.
For instance, multiplying 1011 ⊗ 0111
is analogous to x3+x+1 ⊗ x2+x+1
The answer is, if x5+x4+1
has a power of 5
then you need to reduce it by dividing on the predefined polynomial x4+x+1
. The answer will be x2
that is 0100
.
Many thanks in advance!