Substitution Permutation Network (SPN) implementation from: http://www.engr.mun.ca/~howard/PAPERS/ldc_tutorial.pdf