Beispiel #1
0
def decrypt_file(filename, keyfile, ivfile, decrypted_filename=None):
    if not decrypted_filename:
        decrypted_filename = filename.rstrip(".aes256")

    ciphertext = load(filename)

    key = load(keyfile)
    plaintext = block.decrypt(key, ciphertext)

    print "[+] decrypted %s to %s..." % (filename, decrypted_filename)
    dump(decrypted_filename, plaintext)
    print "[+] file written..."
Beispiel #2
0
def test_random_key():
    key         = block.generate_aes_key()
    message     = 'This is a sample message. 1234567890ABCDEF'

    print '\t[+] test message:  \'%s\'' % message
    assert( len(key) == 32 )
    
    iv          = block.generate_nonce()
    ct          = block.encrypt( key, message, iv )
    pt          = block.decrypt( key, ct, iv )

    assert( pt == message )
    print '\t[+] successfully decrypted!'
Beispiel #3
0
def test_armoured():
    key         = block.generate_aes_key()
    message     = 'This is a sample message. 0123456789ABCDEF'

    print '\t[+] test message: \'%s\'' % message
    assert( len(key) == 32 )

    iv          = block.generate_nonce()
    ct          = block.encrypt( key, message, iv, armour = True )
    print_ct    = ct.replace('\n', '\n\t').rstrip()
    print '\t[+] ciphertext: \n\t%s' % print_ct

    pt          = block.decrypt( key, ct )
    assert( pt == message )

    print '\t[+] successfully decrypted!'