I am trying to find out the inverse of and SBox, but in vain, I have seen multiple questions over StackExchange, But I cant be able to solve my issue. As in this question, How are the AES inverse S-Boxes calculated? As in this link I followed all the procedure and I made a 16x16 Matrix of inverse. But When I multiplied two(Multiplication in GF-2^8) corresponding entries against a SBox value to a inverse SBox value. If this is true in that question then my multiplication would be resulted into 1. But it is not resulting into 1. I used X = 0x52. Sbox Generated with C = 0x63 is given Below
2 Answers
S-Box's are invertible. The inverse S-box is simply the S-box run in reverse.
One way to calculate the inverse of an S-box is; all you need to use the S-Box itself to find an element's inverse.
For example; look at the Wikipedia example.
00maps to63in the S-box,63maps to00in the inverse S-Box54maps to43in the S-box,42maps to64in the inverse S-Box
This can be executed by passing only once the elements of the S-Box. The complexity will be $\mathcal{O}(n^2)$ where $n$ is the $row=column$ size of the matrix.
- 49,797
- 12
- 123
- 211
You missed the most important step in s-box generation, the nonlinear step.
I tested both s-boxes you generated, they are both 100% linear (nonlinearity of 0), which means you did not perform the finite field inversion as the final step in generating your inverse s-box.
As for your forward s-box, I do not know what affine transform you used, but since 0x00 before the affine transform is 0x00 after, your vector addition was 0x77, rather than 0x63, or you may possibly have other problems in the calculation
- 13,278
- 1
- 26
- 42


