From 32a0b4c2f0e1fd38058b22b23acc8180229be3e6 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 21 Nov 2020 11:47:54 -0500 Subject: lib: aes: add InvShiftRows --- lib/aes.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/aes.go') 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 -- cgit v1.2.3