def idea_byte_decrypt(self, input_byte, encrypt_key): pbk = PBKDF2HMAC(hashes.SHA256, self.__salt_size, self.__salt, self.__iteration_count, self._backend) pbk_key = pbk.derive(encrypt_key.encode()) decryptor = Cipher(IDEA(pbk_key), modes.CBC(self.__IV[0:8]), self._backend).decryptor() cipher_text = decryptor.update(input_byte) + decryptor.finalize() un_padder = padding.PKCS7(IDEA.block_size).unpadder() un_padded_data = un_padder.update(cipher_text) + un_padder.finalize() return un_padded_data
def test_invalid_key_type(self): with pytest.raises(TypeError, match="key must be bytes"): IDEA(u"0" * 16)
def test_key_size(self): cipher = IDEA(b"\x00" * 16) assert cipher.key_size == 128
def test_invalid_key_size(self): with pytest.raises(ValueError): IDEA(b"\x00" * 17)
def test_invalid_key_type(self): with pytest.raises(TypeError, match="key must be bytes"): IDEA("0" * 16) # type: ignore[arg-type]