diff options
-rw-r--r-- | lib/aes.go | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -3,6 +3,23 @@ package lib +func AESEncryptCBC(plain, key, iv []byte) []byte { + iter := len(plain) / 16 + + lc := iv + output := make([]byte, 0) + for i := 0; i < iter; i++ { + s := (i * 16) + e := (i * 16) + 16 + p := plain[s:e] + c := aesCipher(FixedXORBytes(p, lc), key) + output = append(output, c...) + + lc = c + } + return output +} + func AESDecryptCBC(cipher, key, iv []byte) []byte { iter := len(cipher) / 16 @@ -46,7 +63,6 @@ func AESDecryptECB(cipher, key []byte) []byte { return output } - func aesCipher(in, ky []byte) []byte { nb := 4 nr := 10 |