Skip to main content

SessionKeys10

Struct SessionKeys10 

Source
pub struct SessionKeys10 {
    pub app_s_key: AppSKey,
    pub nwk_s_key: NwkSKey,
}
Expand description

LoRaWAN 1.0 session keys derived during OTAA.

The two keys cover all 1.0 session needs:

  • AppSKey encrypts FRMPayload when FPort > 0.
  • NwkSKey computes the Data MIC and encrypts FRMPayload when FPort == 0.

Build with SessionKeys10::derive given the device’s AppKey and the join exchange’s NetId, AppNonce, and DevNonce.

Fields§

§app_s_key: AppSKey

Application session key.

§nwk_s_key: NwkSKey

Network session key.

Implementations§

Source§

impl SessionKeys10

Source

pub fn derive( app_key: &AppKey, net_id: &NetId, app_nonce: &AppNonce, dev_nonce: &DevNonce, ) -> Self

Derive AppSKey and NwkSKey from the OTAA root key and join nonces.

The derivation is AES-ECB-encrypt(AppKey, 0x0? || AppNonce_LE || NetID_LE || DevNonce_LE || padding) with 0x01 for NwkSKey and 0x02 for AppSKey.

§Examples
use lora_packet::{SessionKeys10, AppKey, NetId, AppNonce, DevNonce};

let app_key = AppKey::new([0u8; 16]);
let keys = SessionKeys10::derive(
  &app_key,
  &NetId::new([0, 0, 0]),
  &AppNonce::new([0, 0, 0]),
  &DevNonce::new([0, 0]),
);
assert_ne!(keys.app_s_key.as_bytes(), keys.nwk_s_key.as_bytes());

Trait Implementations§

Source§

impl Clone for SessionKeys10

Source§

fn clone(&self) -> SessionKeys10

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionKeys10

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.