Ejemplo n.º 1
0
def test_keygen():
    print '\t[+] generating 1024 test keys... ',
    for i in range(1024):
        key = block.generate_aes_key()
        assert( len(key) == 32 )

    print 'OK!'
Ejemplo n.º 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!'
Ejemplo n.º 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!'
Ejemplo n.º 4
0
def gen_key(filename):
    key = block.generate_aes_key()

    dump(filename, key)