コード例 #1
0
def encryption_oracle(s):
    key = generate_random_bytes(16)
    s = generate_random_bytes(randint(5, 10)) + s + generate_random_bytes(
        randint(5, 10))
    s = padpkcs7(s, 16)
    if randint(0, 1) == 0:
        print('Encrypting with ECB')
        cipher = AES.new(key, AES.MODE_ECB)
        return cipher.encrypt(s)
    else:
        print('Encrypting with CBC')
        iv = generate_random_bytes(16)
        return cbc_encryption(s, key, iv)
コード例 #2
0
def encrypt_profile_for(email):
    cipher = AES.new(key, AES.MODE_ECB)
    encoded_profile = padpkcs7(profile_for(email), 16)
    return cipher.encrypt(encoded_profile)
コード例 #3
0
def encryption_oracle(s):
    cipher = AES.new(key, AES.MODE_ECB)
    s = padpkcs7(s + base64.b64decode(message), 16)
    return cipher.encrypt(s)
コード例 #4
0
def encryptParams(userdata):
    x1 = b'comment1=cooking%20MCs;userdata='
    x2 = b';comment2=%20like%20a%20pound%20of%20bacon'
    params = x1 + userdata.encode('ascii') + x2
    return cbc.cbc_encryption(padpkcs7(params, 16), key, iv)