diff options
author | rsiddharth <s@ricketyspace.net> | 2020-12-09 20:17:04 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-12-09 20:17:04 -0500 |
commit | cba2c0023d0e21128193ed222fd2f9f9e2ec075a (patch) | |
tree | e1a69c9caa64b67aecc59c871d705e1dfb1b3323 | |
parent | 0afdf0f2d20aa22baacfc8c75d0004a0dd3d09d4 (diff) |
lib/aes: update AESEncryptECB
Add padding.
-rw-r--r-- | lib/aes.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 } |