summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-12-09 20:17:04 -0500
committerrsiddharth <s@ricketyspace.net>2020-12-09 20:17:04 -0500
commitcba2c0023d0e21128193ed222fd2f9f9e2ec075a (patch)
treee1a69c9caa64b67aecc59c871d705e1dfb1b3323
parent0afdf0f2d20aa22baacfc8c75d0004a0dd3d09d4 (diff)
lib/aes: update AESEncryptECB
Add padding.
-rw-r--r--lib/aes.go7
1 files changed, 7 insertions, 0 deletions
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
}