From cba2c0023d0e21128193ed222fd2f9f9e2ec075a Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 9 Dec 2020 20:17:04 -0500 Subject: lib/aes: update AESEncryptECB Add padding. --- lib/aes.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/aes.go') diff --git a/lib/aes.go b/lib/aes.go index b00e0b8..4e835e5 100644 --- a/lib/aes.go +++ b/lib/aes.go @@ -37,6 +37,9 @@ func AESDecryptCBC(cipher, key, iv []byte) []byte { } func AESEncryptECB(plain, key []byte) []byte { + // Pad input + plain = Pkcs7Padding(plain, 16) + iter := len(plain) / 16 // Encrypt 16 bytes at a time. @@ -60,6 +63,10 @@ func AESDecryptECB(cipher, key []byte) []byte { e := (i * 16) + 16 output = append(output, aesInvCipher(cipher[s:e], key)...) } + + // Undo padding + output = Pkcs7PaddingUndo(output) + return output } -- cgit v1.2.3