summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-11-22 11:48:13 -0500
committerrsiddharth <s@ricketyspace.net>2020-11-22 11:48:13 -0500
commit0fb8e1716dca936bc905bb9042f316e294cf0227 (patch)
treea32253986228f61ae50048d01a92e918dab2ec6c /lib
parent3e2a965ae1f92e429c22d2f069c4070bd335dc9d (diff)
lib: aes: add InvMixColumns
Diffstat (limited to 'lib')
-rw-r--r--lib/aes.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/aes.go b/lib/aes.go
index a9493c4..476b366 100644
--- a/lib/aes.go
+++ b/lib/aes.go
@@ -3,6 +3,25 @@
package lib
+func InvMixColumns(state [][]byte) [][]byte {
+
+ // Initialize new state.
+ n_state := make([][]byte, 4)
+ nb := 4
+ for r := 0; r < 4; r++ {
+ n_state[r] = make([]byte, nb)
+ }
+
+ // Inverse mix columns transformation.
+ for c := 0; c < nb; c++ {
+ n_state[0][c] = GFMultiply(0x0e, state[0][c]) ^ GFMultiply(0x0b, state[1][c]) ^ GFMultiply(0x0d, state[2][c]) ^ GFMultiply(0x09, state[3][c])
+ n_state[1][c] = GFMultiply(0x09, state[0][c]) ^ GFMultiply(0x0e, state[1][c]) ^ GFMultiply(0x0b, state[2][c]) ^ GFMultiply(0x0d, state[3][c])
+ n_state[2][c] = GFMultiply(0x0d, state[0][c]) ^ GFMultiply(0x09, state[1][c]) ^ GFMultiply(0x0e, state[2][c]) ^ GFMultiply(0x0b, state[3][c])
+ n_state[3][c] = GFMultiply(0x0b, state[0][c]) ^ GFMultiply(0x0d, state[1][c]) ^ GFMultiply(0x09, state[2][c]) ^ GFMultiply(0x0e, state[3][c])
+ }
+ return n_state
+}
+
func InvSubBytes(state [][]byte) [][]byte {
nb := 4
for r := 0; r < 4; r++ {