def test_control_pack_to_network_pdu(control_friend_offer_message, app_key, net_key): network_message = NetworkMessage(control_friend_offer_message) ((seq, network_pdu),) = network_message.pack( app_key, net_key, seq=0x014820, iv_index=0x12345678 ) assert network_pdu.hex() == "68d4c826296d7979d7dbc0c9b4d43eebec129d20a620d01e"
def test_control_segment_ack_message(control_appkey_add_ack_message, app_key, net_key): network_message = NetworkMessage(control_appkey_add_ack_message) ((seq, network_pdu),) = network_message.pack( app_key, net_key, seq=0x014835, iv_index=0x12345678 ) assert network_pdu.hex() == "68e476b5579c980d0d730f94d7f3509df987bb417eb7c05f"
def test_application_network_pdu(health_current_status_message, app_key, net_key): network_message = NetworkMessage(health_current_status_message) (seq, network_pdu), = \ network_message.pack(app_key, net_key, seq=0x000007, iv_index=0x12345678) assert network_pdu.hex( ) == '6848cba437860e5673728a627fb938535508e21a6baf57'
def test_proxy_solicitation_pack_to_network_pdu( proxy_solicitation_message: SolicitationMessage, ): network_message = NetworkMessage(proxy_solicitation_message) net_key_local = NetworkKey(bytes.fromhex("18eed9c2a56add85049ffc3c59ad0e12")) ((seq, network_pdu),) = network_message.pack( app_key, net_key_local, seq=0x000001, iv_index=0x00000000 ) assert network_pdu.hex() == "7415fd26d31ba53425f13b423508c0019a"
def test_proxy_config_pack_to_network_pdu( proxy_use_whitelist_message: ProxyConfigMessage, ): network_message = NetworkMessage(proxy_use_whitelist_message) net_key_local = NetworkKey(bytes.fromhex("d1aafb2a1a3c281cbdb0e960edfad852")) ((seq, network_pdu),) = network_message.pack( app_key, net_key_local, seq=0x000001, iv_index=0x12345678 ) assert network_pdu.hex() == "10386bd60efbbb8b8c28512e792d3711f4b526"
def test_application_network_pdu_segmented_retry( health_current_status_message, app_key, net_key ): network_message = NetworkMessage(health_current_status_message) ((seq, network_pdu),) = network_message.pack( app_key, net_key, seq=0x000017, iv_index=0x12345678, transport_seq=0x000007 ) assert seq == 0x000017 assert network_pdu.hex() == "6860f30170e2192e84fb4385254e9e71657aa1bcf2ca90"
def test_application_pack_to_network_pdu( health_current_status_message: AccessMessage, app_key: ApplicationKey, net_key: NetworkKey, ): network_message = NetworkMessage(health_current_status_message) ((seq, network_pdu),) = network_message.pack( app_key, net_key, seq=0x000007, iv_index=0x12345678 ) assert network_pdu.hex() == "6848cba437860e5673728a627fb938535508e21a6baf57"
def message_encode(self, message, seq, *, device_key=False): network_message = NetworkMessage(message) network_key = self.network_keys[0] if device_key is True: device_key = self.device_keys[message.dst] elif device_key: device_key = self.device_keys[device_key] application_key = device_key or self.application_keys[0] return network_message.pack(application_key, network_key, seq, self.iv_index)
def test_application_pack_to_network_pdu_skip_segments( app_sar_message: AccessMessage, app_key: ApplicationKey, net_key: NetworkKey, ): network_message = NetworkMessage(app_sar_message) ((seq, network_pdu),) = network_message.pack( app_key, net_key, seq=0x000007, iv_index=0x12345678, transport_seq=0x000008, skip_segments=[0], ) assert network_pdu.hex() == "689353e01b0a211f82734ad0c7c92081616414e0f8b7e7048c7e"
def test_control_unpack_from_network_pdu( control_friend_offer_message: ControlMessage, net_key: NetworkKey ): _, _, unpacked_network_message = NetworkMessage.unpack( app_key, net_key, 0x12345678, bytes.fromhex("68d4c826296d7979d7dbc0c9b4d43eebec129d20a620d01e"), ) assert unpacked_network_message.message == control_friend_offer_message
def test_proxy_config_unpack_from_network_pdu( proxy_use_whitelist_message: ProxyConfigMessage, ): net_key_local = NetworkKey(bytes.fromhex("d1aafb2a1a3c281cbdb0e960edfad852")) _, _, unpacked_network_message = NetworkMessage.unpack( app_key, net_key_local, 0x12345678, bytes.fromhex("10386bd60efbbb8b8c28512e792d3711f4b526"), proxy=True, ) assert unpacked_network_message.message == proxy_use_whitelist_message
def test_application_unpack_from_network_pdu( health_current_status_message: AccessMessage, app_key: ApplicationKey, net_key: NetworkKey, ): _, _, unpacked_network_message = NetworkMessage.unpack( app_key, net_key, 0x12345678, bytes.fromhex("6848cba437860e5673728a627fb938535508e21a6baf57"), ) assert unpacked_network_message.message == health_current_status_message