Ejemplo n.º 1
0
def test_build_cipher():
    key_ = b"1234523451234545"  # 16 byte key
    iv_ = os.urandom(16)

    cipher, iv = build_cipher(key_, iv_)
    assert iv == iv_
    assert isinstance(cipher, CbcMode)
Ejemplo n.º 2
0
def test_build_cipher_mismatch_key_lenth():
    key_ = b"1234523451234545"  # 16 byte key

    with pytest.raises(AESError):
        build_cipher(key_, '', alg='aes_192_cbc')
Ejemplo n.º 3
0
def test_build_cipher_wrong_key_lenth():
    key_ = b"1234523451234545"  # 16 byte key

    with pytest.raises(AESError):
        build_cipher(key_, '', alg='aes_384_cbc')
Ejemplo n.º 4
0
def test_build_cipher_no_iv():
    key_ = b"1234523451234545"  # 16 byte key

    cipher, iv = build_cipher(key_, '')
    assert iv
    assert isinstance(cipher, CbcMode)
Ejemplo n.º 5
0
def test_build_cipher_wrong_mode():
    key_ = b"1234523451234545"  # 16 byte key

    with pytest.raises(AESError):
        build_cipher(key_, '', alg='aes_128_abc')