[HN Gopher] Rijndael S-box in 512 bytes of Python
___________________________________________________________________
Rijndael S-box in 512 bytes of Python
Author : juliusgeo
Score : 20 points
Date : 2023-01-04 16:12 UTC (1 days ago)
(HTM) web link (gist.github.com)
(TXT) w3m dump (gist.github.com)
| pxeger1 wrote:
| Some explanation of the context, and some more solutions, can be
| found at https://codegolf.stackexchange.com/q/3766, including a
| 176 byte solution in Python.
| juliusgeo wrote:
| Thanks! I took some inspiration from discussion on that page,
| however my solution differs because instead of hard coding
| everything it instead calculates the multiplicative inverse and
| affine transformation separately. This is worse in terms of
| space but it lets you more clearly represent the two s-boxes as
| those two operations composed applied element wise to [0, 256].
| You can also use this code to do multiplicative inverses over
| any field GF(2^n), just change the parameters and supply a new
| irreducible polynomial. I implement the totality of binary
| finite field arithmetic here:
| https://gist.github.com/juliusgeo/9e4eff4c0519f7f7b9af122d59...
| juliusgeo wrote:
| Code golf style implementation of AES S-box and inverse in the
| same number of bytes as just pre-calculating the tables.
___________________________________________________________________
(page generated 2023-01-05 23:02 UTC)