コード例 #1
0
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
コード例 #2
0
ファイル: test12.py プロジェクト: Renelvon/matasano
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)
コード例 #3
0
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)