def test_auth_tag_packet_encoding_decoding(tag, auth_tag, encrypted_message_size):
    encrypted_message = b"\x00" * encrypted_message_size
    original_packet = AuthTagPacket(
        tag=tag,
        auth_tag=auth_tag,
        encrypted_message=encrypted_message,
    )
    encoded_packet = original_packet.to_wire_bytes()
    decoded_packet = decode_message_packet(encoded_packet)
    assert isinstance(decoded_packet, AuthTagPacket)
    assert decoded_packet == original_packet
def test_auth_header_packet_encoding_decoding(tag, auth_tag, id_nonce,
                                              ephemeral_public_key,
                                              encrypted_auth_response,
                                              encrypted_message_size):
    auth_header = AuthHeaderFactory(
        auth_tag=auth_tag,
        id_nonce=id_nonce,
        ephemeral_public_key=ephemeral_public_key,
        encrypted_auth_response=encrypted_auth_response,
    )
    encrypted_message = b"\x00" * encrypted_message_size
    original_packet = AuthHeaderPacketFactory(
        tag=tag,
        auth_header=auth_header,
        encrypted_message=encrypted_message,
    )
    encoded_packet = original_packet.to_wire_bytes()
    decoded_packet = decode_message_packet(encoded_packet)
    assert isinstance(decoded_packet, AuthHeaderPacket)
    assert decoded_packet == original_packet
def test_auth_header_packet_encoding_decoding(tag,
                                              auth_tag,
                                              ephemeral_pubkey,
                                              encrypted_auth_response,
                                              encrypted_message_size):
    auth_header = AuthHeader(
        auth_tag=auth_tag,
        auth_scheme_name=AUTH_SCHEME_NAME,
        ephemeral_pubkey=ephemeral_pubkey,
        encrypted_auth_response=encrypted_auth_response,
    )
    encrypted_message = b"\x00" * encrypted_message_size
    original_packet = AuthHeaderPacket(
        tag=tag,
        auth_header=auth_header,
        encrypted_message=encrypted_message,
    )
    encoded_packet = original_packet.to_wire_bytes()
    decoded_packet = decode_message_packet(encoded_packet)
    assert isinstance(decoded_packet, AuthHeaderPacket)
    assert decoded_packet == original_packet
def test_invalid_message_packet_decoding(encoded_packet):
    with pytest.raises(ValidationError):
        decode_message_packet(encoded_packet)