summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/aes.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/aes.go b/lib/aes.go
index 83bd028..44f2350 100644
--- a/lib/aes.go
+++ b/lib/aes.go
@@ -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