summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-11-21 11:47:54 -0500
committerrsiddharth <s@ricketyspace.net>2020-11-21 11:47:54 -0500
commit32a0b4c2f0e1fd38058b22b23acc8180229be3e6 (patch)
tree58340a5e9f60e6ed021f2f5e3909d360113cfa3e /lib
parent1523fdf8bfa5e6b02f9b541714130f910c106202 (diff)
lib: aes: add InvShiftRows
Diffstat (limited to 'lib')
-rw-r--r--lib/aes.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/aes.go b/lib/aes.go
index 389dc44..7d98a60 100644
--- a/lib/aes.go
+++ b/lib/aes.go
@@ -3,6 +3,19 @@
package lib
+func InvShiftRows(state [][]byte) [][]byte {
+ n_state := make([][]byte, 4) // New state.
+
+ nb := 4
+ for r := 0; r < 4; r++ {
+ n_state[r] = make([]byte, nb)
+ for c := 0; c < nb; c++ {
+ n_state[r][(c+r)%nb] = state[r][c]
+ }
+ }
+ return n_state
+}
+
func AddRoundKey(state, ks [][]byte) [][]byte {
if len(ks) != 4 {
return state