Skip to content

Commit 3209a99

Browse files
remove dependency on M2Crypto.util
1 parent 417b353 commit 3209a99

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

paddingoracle.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,16 @@ def xor(data, key):
259259

260260
def test():
261261
import os
262-
from M2Crypto.util import pkcs7_pad
263262
from Crypto.Cipher import AES
264263

265264
teststring = 'The quick brown fox jumped over the lazy dog'
266265

266+
def pkcs7_pad(data, blklen=16):
267+
if blklen > 255:
268+
raise ValueError('Illegal block size %d' % (blklen, ))
269+
pad = (blklen - (len(data) % blklen))
270+
return data + chr(pad) * pad
271+
267272
class PadBuster(PaddingOracle):
268273
def oracle(self, data):
269274
_cipher = AES.new(key, AES.MODE_CBC, str(iv))

0 commit comments

Comments
 (0)