Skip to main content

root_wor_s_key

Function root_wor_s_key 

Source
pub fn root_wor_s_key(network_key: &[u8; 16]) -> [u8; 16]
Expand description

Derives the root relay session key of an end device, TS011-1.0.1 section 4.4.

RootWorSKey = aes128_encrypt(Key, 0x01 | pad16), where the key is the network session key: NwkSKey under LoRaWAN 1.0.x and NwkSEncKey from 1.1. An over-the-air device derives it after each join, and a network sends it to a relay in UpdateUplinkListReq.

§Arguments

  • network_key - the end device’s network session key.

§Returns

The root relay session key.

§Examples

use pamoja_lorawan::relay::root_wor_s_key;

// The vector The Things Stack tests its derivation with.
let nwk_s_enc_key = [
    0xCE, 0x07, 0xA0, 0x09, 0xA3, 0x97, 0x0A, 0xC0, 0x51, 0x9A, 0x09, 0x9E, 0xD5, 0x3E, 0x55,
    0x0B,
];
assert_eq!(
    root_wor_s_key(&nwk_s_enc_key),
    [
        0xEE, 0x91, 0xDC, 0x1A, 0x66, 0x66, 0xC0, 0x6E, 0x82, 0x77, 0xDE, 0x6D, 0xB4, 0xDB,
        0x94, 0x5F
    ]
);