コード例 #1
0
    async def __call__(self, application, arguments):
        if arguments["--grant"]:
            uuid = UUID(arguments["--grant"])
            dev_key = arguments["--devkey"]
            net_key = arguments["--netkey"]

            if not all([dev_key, net_key]):
                try:
                    dev_key = application.network.get_node(
                        uuid=uuid).device_key
                    net_key = application.network.network_keys[0]
                except KeyError:
                    logging.getLogger("acl_grant").warning(
                        "Some key data is missing "
                        "but node could not be found in network configuration to automagically download it."
                    )
                    return
            else:
                dev_key = DeviceKey(bytes.fromhex(dev_key))
                net_key = NetworkKey(bytes.fromhex(net_key))

            await application.acl_grant(uuid=uuid,
                                        dev_key=dev_key,
                                        net_key=net_key)

        if arguments["--revoke"]:
            await application.acl_revoke(uuid=UUID(hex=arguments["--revoke"]))

        for uuid, name, token in self.format(application):
            print("\t%s (%s): %s" % (uuid, name, token))
        print()
コード例 #2
0
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"
コード例 #3
0
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"
コード例 #4
0
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
コード例 #5
0
 def primary_net_key(self):
     return 0, NetworkKey(
         bytes.fromhex("b37e0124a48a406bd2b092e82bea6aed"))
コード例 #6
0
def net_key():
    return NetworkKey(bytes.fromhex("7dd7364cd842ad18c17c2b820c84c3d6"))
コード例 #7
0
 def _to_object(self, data):
     return NetworkKey(bytes.fromhex(data['key']))
コード例 #8
0
 def net_key(self):
     return 0, NetworkKey(secrets.token_bytes(16))