summaryrefslogtreecommitdiffstats
path: root/lib/aes.go
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-12-06 16:11:49 -0500
committerrsiddharth <s@ricketyspace.net>2020-12-06 16:11:49 -0500
commitf1297ed8020ad97495f38583dbdb4a35ae3c678d (patch)
tree434537d716385b9ff5c63e954adeb040c19da0d7 /lib/aes.go
parentdb55bba1430939130be9aad3e4d54f901b0fac79 (diff)
lib/aes: add AESEncryptCBC
Diffstat (limited to 'lib/aes.go')
-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