summaryrefslogtreecommitdiffstats
path: root/lib/aes.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/aes.go')
-rw-r--r--lib/aes.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/aes.go b/lib/aes.go
index ea4a449..cfc06ff 100644
--- a/lib/aes.go
+++ b/lib/aes.go
@@ -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 {