Ejemplo n.º 1
0
def test_aarq_makes_dlms_waiting_for_aare():
    s = state.DlmsConnectionState()
    s.process_event(
        acse.ApplicationAssociationRequestApdu(
            user_information=UserInformation(
                InitiateRequestApdu(proposed_conformance=Conformance())
            )
        )
    )
    assert s.current_state == state.AWAITING_ASSOCIATION_RESPONSE
Ejemplo n.º 2
0
    def test_encode_no_ciphering_high_security(self):
        data = b"`6\xa1\t\x06\x07`\x85t\x05\x08\x01\x01\x8a\x02\x07\x80\x8b\x07`\x85t\x05\x08\x02\x05\xac\n\x80\x08K56iVagY\xbe\x10\x04\x0e\x01\x00\x00\x00\x06_\x1f\x04\x00\x00~\x1f\x04\xb0"
        aarq = ApplicationAssociationRequest(
            system_title=None,
            public_cert=None,
            authentication=enumerations.AuthenticationMechanism.HLS_GMAC,
            ciphered=False,
            authentication_value=b"K56iVagY",
            user_information=UserInformation(
                content=InitiateRequest(
                    proposed_conformance=Conformance(
                        general_protection=False,
                        general_block_transfer=False,
                        delta_value_encoding=False,
                        attribute_0_supported_with_set=False,
                        priority_management_supported=True,
                        attribute_0_supported_with_get=True,
                        block_transfer_with_get_or_read=True,
                        block_transfer_with_set_or_write=True,
                        block_transfer_with_action=True,
                        multiple_references=True,
                        data_notification=False,
                        access=False,
                        get=True,
                        set=True,
                        selective_access=True,
                        event_notification=True,
                        action=True,
                    ),
                    proposed_quality_of_service=0,
                    client_max_receive_pdu_size=1200,
                    proposed_dlms_version_number=6,
                    response_allowed=True,
                    dedicated_key=None,
                )
            ),
            calling_ae_invocation_identifier=None,
            called_ap_title=None,
            called_ae_qualifier=None,
            called_ap_invocation_identifier=None,
            called_ae_invocation_identifier=None,
            calling_ap_invocation_identifier=None,
            implementation_information=None,
        )

        assert aarq.to_bytes() == data
Ejemplo n.º 3
0
    def test_no_ciher_hls_ok(self):
        data = bytes.fromhex(
            "6142A109060760857405080101A203020100A305A10302010E88020780890760857405080205AA0A8008503677524A323146BE10040E0800065F1F040000501F01F40007"
        )

        aare = acse.ApplicationAssociationResponse(
            result=enumerations.AssociationResult.ACCEPTED,
            result_source_diagnostics=enumerations.AcseServiceUserDiagnostics.AUTHENTICATION_REQUIRED,
            ciphered=False,
            authentication=enumerations.AuthenticationMechanism.HLS_GMAC,
            public_cert=None,
            system_title=None,
            authentication_value=b"P6wRJ21F",
            user_information=UserInformation(
                content=InitiateResponse(
                    negotiated_conformance=Conformance(
                        general_protection=False,
                        general_block_transfer=False,
                        delta_value_encoding=False,
                        attribute_0_supported_with_set=False,
                        priority_management_supported=True,
                        attribute_0_supported_with_get=False,
                        block_transfer_with_get_or_read=True,
                        block_transfer_with_set_or_write=False,
                        block_transfer_with_action=False,
                        multiple_references=False,
                        data_notification=False,
                        access=False,
                        get=True,
                        set=True,
                        selective_access=True,
                        event_notification=True,
                        action=True,
                    ),
                    server_max_receive_pdu_size=500,
                    negotiated_dlms_version_number=6,
                    negotiated_quality_of_service=0,
                )
            ),
            implementation_information=None,
            responding_ap_invocation_id=None,
            responding_ae_invocation_id=None,
        )

        assert aare.to_bytes() == data
Ejemplo n.º 4
0
    def test_decode(self):
        resulting_bytes = bytes.fromhex(
            "601DA109060760857405080101BE10040E01000000065F1F0400001E1DFFFF"
        )
        aarq = ApplicationAssociationRequest(
            ciphered=False,
            system_title=None,
            public_cert=None,
            authentication=None,
            authentication_value=None,
            user_information=UserInformation(
                content=InitiateRequest(
                    proposed_conformance=Conformance(
                        general_protection=False,
                        general_block_transfer=False,
                        delta_value_encoding=False,
                        attribute_0_supported_with_set=False,
                        priority_management_supported=False,
                        attribute_0_supported_with_get=False,
                        block_transfer_with_get_or_read=True,
                        block_transfer_with_set_or_write=True,
                        block_transfer_with_action=True,
                        multiple_references=True,
                        data_notification=False,
                        access=False,
                        get=True,
                        set=True,
                        selective_access=True,
                        event_notification=False,
                        action=True,
                    ),
                    proposed_quality_of_service=0,
                    client_max_receive_pdu_size=65535,
                    proposed_dlms_version_number=6,
                    response_allowed=True,
                    dedicated_key=None,
                )
            ),
        )

        assert aarq.to_bytes() == resulting_bytes
Ejemplo n.º 5
0
with client as c:

    aarq = ApplicationAssociationRequest(user_information=UserInformation(
        content=InitiateRequest(
            proposed_conformance=Conformance(
                general_protection=False,
                general_block_transfer=False,
                delta_value_encoding=False,
                attribute_0_supported_with_set=False,
                priority_management_supported=False,
                attribute_0_supported_with_get=False,
                block_transfer_with_get_or_read=True,
                block_transfer_with_set_or_write=True,
                block_transfer_with_action=True,
                multiple_references=True,
                data_notification=False,
                access=False,
                get=True,
                set=True,
                selective_access=True,
                event_notification=False,
                action=True,
            ),
            client_max_receive_pdu_size=65535,
            proposed_quality_of_service=0,
            proposed_dlms_version_number=6,
            response_allowed=True,
            dedicated_key=None,
        )))

    response = client.send(aarq.to_bytes())