summaryrefslogtreecommitdiffstats
path: root/lib/blocks.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/blocks.go')
-rw-r--r--lib/blocks.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/blocks.go b/lib/blocks.go
index 9b184d1..c4d8be1 100644
--- a/lib/blocks.go
+++ b/lib/blocks.go
@@ -112,15 +112,15 @@ func Pkcs7Padding(in []byte, k int) []byte {
}
// Removes PKCS#7 Padding from input `in`
-func Pkcs7PaddingUndo(in []byte) []byte {
+func Pkcs7PaddingUndo(in []byte) ([]byte, error) {
pd := in[len(in)-1] // padding character
pl := int(pd) // padding length
// Validate
for i := len(in) - 1; i >= len(in)-pl; i-- {
if in[i] != pd {
- panic("input is not pkcs#7 padded!")
+ return []byte{}, CPError{"input is not pkcs#7 padded"}
}
}
- return in[0:(len(in) - pl)]
+ return in[0:(len(in) - pl)], nil
}