def encryption_oracle(input): key = ''.join(random.sample(string.printable, 16)) mode = random.choice((AES.MODE_CBC, AES.MODE_ECB)) prepad = ''.join(random.sample(string.printable, random.randint(5, 10))) sufpad = ''.join(random.sample(string.printable, random.randint(5, 10))) if mode == AES.MODE_CBC: iv = ''.join(random.sample(string.printable, 16)) cipher = AES.new(key, AES.MODE_CBC, iv) else: cipher = AES.new(key, AES.MODE_ECB) plaintext = padlib.pad_pkcs7(prepad + input + sufpad, 16) return cipher.encrypt(plaintext), mode
def encryption_oracle(plaintext, suffix=SUFFIX, key=KEY): cipher = AES.new(key, AES.MODE_ECB) plaintext = padlib.pad_pkcs7(plaintext + suffix, BLOCKSIZE) return cipher.encrypt(plaintext)