Skip to content

Commit d38f6b8

Browse files
committed
Implemented padding check is not constant time, so don't pretend it is.
1 parent f264c5f commit d38f6b8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,10 @@ func Decrypt(r io.Reader, w io.Writer, password []byte) error {
132132
if n <= 0 || n > aes.BlockSize {
133133
return ErrCorrupted
134134
}
135-
x := int(n)
136135
for _, v := range out[len(out)-int(n):] {
137-
x -= subtle.ConstantTimeByteEq(v, n)
138-
}
139-
if x != 0 {
140-
return ErrCorrupted
136+
if v != n {
137+
return ErrCorrupted
138+
}
141139
}
142140
out = out[:len(out)-int(n)]
143141

0 commit comments

Comments
 (0)