예제 #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)