First, I know that .NET libraries defines AES encryption but I can't use them. It is a school project.
I was trying to write some algorithm for operation polynom modulo. I have written one, but it has been too slow, can somebody help me?
How does it work?
Look: The input for this operation are two byte numbers. Each byte number consists of 8 bits. The idea of creating a polynom is, that every bit in it's order we multiply by x powered by the order:
For example: we have numbers that fits in the byte - for example 255 (11111111 in binary format) and 71 (01000111 in binary format).
The polynom for 11111111 is: 1*x^7 + 1*x^6 + 1*x^5 + 1*x^4 + 1*x^3 + 1*x^2 + 1*x^0 + 1*x^0.
The polynom for 01000111 is: 0*x^7 + 1*x^6 + 0*x^5 + 0*x^4 + 0*x^3 + 1*x^2 + 1*x^0 + 1*x^0.
We have to do the modulo operation with these polynoms (forget about it, that Galois field has not declared division). So we have to divide a polynom by a polynom.
Here is a quite fast code how to convert a byte to bits:
byte number = 255;
byte numeralSystem = 2;
string bits = Convert.ToString(number, numeralSystem);
while (bits.Length < 8)
bits = "0" + bits;
Imagine, that you have implemented a method Polynom polynomModulo
(Polynom pol1, Polynom pol2) that returns the rest after division of po1/pol2 and uses these methods:
Member divide(Member x, Member y); Polynom multiply(Polynom divisor, Member result) Polynom subtract(Polynom rest, Polynom newRest)
Please write here some fast algorithm for these methods and implement assistant objects for it.
Or implement polynom modulo completly by your own algorithm.
Thanks a lot!
Pepin z Hané