From 2e81b7e4283b1cc4264d30b06538d03179cbc40f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 6 Dec 2020 14:46:30 -0500 Subject: lib/aes: add aesShiftRows --- lib/aes.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/aes.go') diff --git a/lib/aes.go b/lib/aes.go index 9440b52..a388db8 100644 --- a/lib/aes.go +++ b/lib/aes.go @@ -98,6 +98,20 @@ func aesInvSubBytes(state [][]byte) [][]byte { return state } +func aesShiftRows(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] = state[r][(c+r)%nb] + + } + } + return n_state +} + func aesInvShiftRows(state [][]byte) [][]byte { n_state := make([][]byte, 4) // New state. -- cgit v1.2.3