summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-12-05 13:35:03 -0500
committerrsiddharth <s@ricketyspace.net>2020-12-05 13:35:03 -0500
commit8f1561128068526e511775af3f5150875ed544a3 (patch)
tree1a35a8e69f262c1daf9dadfff02e382ec69057e3
parentc301e9ee2dfbfb8e10b3fe26480fb15091d26e2d (diff)
lib/aes.go: add AESDecryptCBC
-rw-r--r--lib/aes.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/aes.go b/lib/aes.go
index 6121f41..47c3291 100644
--- a/lib/aes.go
+++ b/lib/aes.go
@@ -3,6 +3,22 @@
package lib
+func AESDecryptCBC(cipher, key, iv []byte) []byte {
+ iter := len(cipher) / 16
+
+ lc := iv
+ output := make([]byte, 0)
+ for i := 0; i < iter; i++ {
+ s := (i * 16)
+ e := (i * 16) + 16
+ c := cipher[s:e]
+ output = append(output, FixedXORBytes(aesInvCipher(c, key), lc)...)
+
+ lc = c
+ }
+ return output
+}
+
func AESDecrypt(cipher, key []byte) []byte {
iter := len(cipher) / 16