python3: handle AES padding variations (#31171)

This commit is contained in:
Paul Marillonnet 2019-04-10 14:04:50 +02:00
parent 185e59fdbe
commit 98425ac1ba
1 changed files with 1 additions and 1 deletions

View File

@ -104,7 +104,7 @@ def remove_padding(msg, block_size):
unpadded = msg[2:2 + msg_length]
if msg_length > len(msg) - 2:
raise DecryptionError('wrong padding')
if not all(c == '\0' for c in msg[2 + msg_length:]):
if len(msg[2 + msg_length:].strip(force_bytes('\0'))):
raise DecryptionError('padding is not all zero')
if len(unpadded) != msg_length:
raise DecryptionError('wrong padding')