From 89238b1ebae839fb6d22d70dbe32dcdf205db158 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 6 Dec 2020 14:47:21 -0500 Subject: lib/aes: add aesSubBytes --- 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 a388db8..bd0a86b 100644 --- a/lib/aes.go +++ b/lib/aes.go @@ -85,6 +85,19 @@ func aesInvMixColumns(state [][]byte) [][]byte { return n_state } +func aesSubBytes(state [][]byte) [][]byte { + nb := 4 + for r := 0; r < 4; r++ { + for c := 0; c < nb; c++ { + x := state[r][c] >> 4 + y := state[r][c] & 0x0f + + state[r][c] = sbox[x][y] + } + } + return state +} + func aesInvSubBytes(state [][]byte) [][]byte { nb := 4 for r := 0; r < 4; r++ { -- cgit v1.2.3