diff options
author | rsiddharth <s@ricketyspace.net> | 2020-11-16 20:02:53 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-11-16 20:02:53 -0500 |
commit | adc02291fa658ed47658312ddce8acbaffd2af79 (patch) | |
tree | 2ca4da0e4e28ab74056e75417ea19bc71366e2ba /lib/aes.go | |
parent | d6c2957137c7292845c095cb798826fabd19e527 (diff) |
lib: add MkState
Diffstat (limited to 'lib/aes.go')
-rw-r--r-- | lib/aes.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -3,6 +3,23 @@ package lib +// Make and return initial state array from 16-byte input 'in' +func MkState(in []byte) [][]byte { + if len(in) != 16 { + return [][]byte{} + } + nb := 4 + state := make([][]byte, 4) + + for r := 0; r < 4; r++ { + state[r] = make([]byte, nb) + for c := 0; c < nb; c++ { + state[r][c] = in[r+(4*c)] + } + } + return state +} + // Returns a key schedule (176 bytes, 44 4-byte words) given a key 'k' // (16 bytes, 4 4-byte words). func KeyExpansion(k []byte) [][]byte { |