pamoja.lorawan.multicast

Remote multicast setup, TS005-2.0.0, on port PORT.

A group of devices is given one address and one key, so a firmware image goes out once rather than once per device. The group key travels wrapped under a key each device derives from its own root key and never transmits.

>>> from pamoja.lorawan import multicast
>>> root, group = bytes([0x2B]) * 16, bytes([0x77]) * 16
>>> ke = multicast.ke_key(multicast.root_key(root))
>>> multicast.key(ke, multicast.wrap_key(ke, group)) == group
True
 1"""Remote multicast setup, TS005-2.0.0, on port :data:`PORT`.
 2
 3A group of devices is given one address and one key, so a firmware image goes out once rather
 4than once per device. The group key travels wrapped under a key each device derives from its
 5own root key and never transmits.
 6
 7>>> from pamoja.lorawan import multicast
 8>>> root, group = bytes([0x2B]) * 16, bytes([0x77]) * 16
 9>>> ke = multicast.ke_key(multicast.root_key(root))
10>>> multicast.key(ke, multicast.wrap_key(ke, group)) == group
11True
12"""
13
14from __future__ import annotations
15
16from pamoja._native import LORAWAN_MULTICAST_PORT
17from pamoja._native import lorawan_mc_app_s_key as app_s_key
18from pamoja._native import lorawan_mc_ke_key as ke_key
19from pamoja._native import lorawan_mc_key as key
20from pamoja._native import lorawan_mc_nwk_s_key as nwk_s_key
21from pamoja._native import lorawan_mc_root_key as root_key
22from pamoja._native import lorawan_wrap_mc_key as wrap_key
23
24__all__ = [
25    "PORT",
26    "app_s_key",
27    "ke_key",
28    "key",
29    "nwk_s_key",
30    "root_key",
31    "wrap_key",
32]
33
34#: The port this package is spoken on.
35PORT = LORAWAN_MULTICAST_PORT
PORT = 200
def app_s_key(mc_key, mc_addr):

Derives the key that reads a multicast group's payloads, section 4.3.

def ke_key(mc_root_key):

Derives the key a multicast group's key travels under, section 4.3.

def key(mc_ke_key, wrapped):

Unwraps the group key a setup command carried, section 4.3.

def nwk_s_key(mc_key, mc_addr):

Derives the key that verifies a multicast group's frames, section 4.3.

def root_key(root_key, lorawan11=False):

Derives a device's multicast root key, TS005-2.0.0 section 4.3.

lorawan11 picks the scheme: LoRaWAN 1.0.x devices derive from their GenAppKey, and 1.1 devices from their AppKey under another constant.

def wrap_key(mc_ke_key, mc_key):

Wraps a group key for a device, which is what a server does before sending it.