Skip to main content

WorKeys

Struct WorKeys 

Source
pub struct WorKeys;
Expand description

Namespace for Relay / Wake-On-Radio key derivation.

A unit struct that groups WorKeys::root and WorKeys::session without polluting the crate root.

§Examples

Derive a root WOR key then a session pair:

use lora_packet::{WorKeys, NwkSKey, DevAddr};

let nwk_s_key = NwkSKey::new([0u8; 16]);
let root = WorKeys::root(&nwk_s_key);
let session = WorKeys::session(&root, &DevAddr::new([0x01, 0x02, 0x03, 0x04]));
assert_ne!(session.wor_s_int_key.as_bytes(), session.wor_s_enc_key.as_bytes());

Implementations§

Source§

impl WorKeys

Source

pub fn root(nwk_s_key: &NwkSKey) -> RootWorSKey

Derive RootWorSKey from NwkSKey.

RootWorSKey = AES-ECB-encrypt(NwkSKey, 0x01 || 0x00..).

Source

pub fn session(root: &RootWorSKey, dev_addr: &DevAddr) -> WorSessionKeys

Derive WOR session keys from a root key and DevAddr.

Two AES-ECB blocks under the root, with the first byte set to 0x01 for the integrity key and 0x02 for the encryption key. The remainder is DevAddr_LE padded with zeros.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.