Example #1
0
def encrypt(mode, key, iv, plaintext):
    encryptor = botan.Cipher("SEED/{0}/NoPadding".format(mode), "encrypt",
                             binascii.unhexlify(key))

    cipher_text = encryptor.cipher(binascii.unhexlify(plaintext),
                                   binascii.unhexlify(iv))
    return binascii.hexlify(cipher_text)
Example #2
0
def decrypt(input, salt, passphrase):
    iterations = 10000
    output_size = 16

    key = botan.pbkdf2(passphrase, salt, iterations, output_size, "SHA-1")

    decryptor = botan.Cipher("AES-128/EAX", "decrypt", key)

    return decryptor.cipher(input, salt)
Example #3
0
def encrypt(input, passphrase):
    rng = botan.RandomNumberGenerator()

    # Use as both EAX IV and PBKDF2 salt
    salt = rng.gen_random(10)

    iterations = 10000
    output_size = 16

    key = botan.pbkdf2(passphrase, salt, iterations, output_size, "SHA-1")

    encryptor = botan.Cipher("AES-128/EAX", "encrypt", key)

    ciphertext = encryptor.cipher(input, salt)
    return (ciphertext, salt)