Skip to content

Commit 3d25dbc

Browse files
committed
Removes PKCS5 padding after decryption
1 parent cdef16e commit 3d25dbc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

yoti/crypto.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,11 @@ def decipher(key, iv, cipher_text):
5959
mode=modes.CBC(iv),
6060
backend=default_backend()
6161
).decryptor()
62-
return decryptor.update(cipher_text) + decryptor.finalize()
62+
plaintext = decryptor.update(cipher_text) + decryptor.finalize()
63+
64+
return Crypto.strip_pkcs5_padding(plaintext)
65+
66+
@staticmethod
67+
def strip_pkcs5_padding(data):
68+
number_of_padded_bytes = data[-1]
69+
return data[:-number_of_padded_bytes]

0 commit comments

Comments
 (0)