From 8f1561128068526e511775af3f5150875ed544a3 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 5 Dec 2020 13:35:03 -0500 Subject: lib/aes.go: add AESDecryptCBC --- lib/aes.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/aes.go') 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 -- cgit v1.2.3