def __init__(self, key): from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers.modes import ECB from cryptography.hazmat.primitives.ciphers.algorithms import Blowfish self.cipher = Cipher( Blowfish(key.encode("ascii")), ECB(), backend=default_backend())
def test_invalid_key_type(self): with pytest.raises(TypeError, match="key must be bytes"): Blowfish(u"0" * 8)
def test_invalid_key_size(self): with pytest.raises(ValueError): Blowfish(binascii.unhexlify(b"0" * 6))
def test_key_size(self, key, keysize): cipher = Blowfish(binascii.unhexlify(key)) assert cipher.key_size == keysize
def test_invalid_key_type(self): with pytest.raises(TypeError, match="key must be bytes"): Blowfish("0" * 8) # type: ignore[arg-type]