[][src]Struct lorawan::parser::DecryptedJoinAcceptPayload

pub struct DecryptedJoinAcceptPayload<T, F>(_, _);

DecryptedJoinAcceptPayload represents a decrypted JoinAccept.

It can be built either directly through the new or using the EncryptedJoinAcceptPayload.decrypt function.

Implementations

impl<T: AsRef<[u8]>, F: CryptoFactory> DecryptedJoinAcceptPayload<T, F>[src]

pub fn validate_mic(&self, key: &AES128) -> bool[src]

Verifies that the JoinAccept has correct MIC.

pub fn derive_newskey<TT: AsRef<[u8]>>(
    &self,
    dev_nonce: &DevNonce<TT>,
    key: &AES128
) -> AES128
[src]

Computes the network session key for a given device.

Argument

  • app_nonce - the network server nonce.
  • nwk_addr - the address of the network.
  • dev_nonce - the nonce from the device.
  • key - the app key.

Examples

let dev_nonce = vec![0xcc, 0xdd];
let data = vec![0x20, 0x49, 0x3e, 0xeb, 0x51, 0xfb, 0xa2, 0x11, 0x6f, 0x81, 0x0e, 0xdb, 0x37,
    0x42, 0x97, 0x51, 0x42];
let app_key = lorawan::keys::AES128([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]);
let join_accept = lorawan::parser::DecryptedJoinAcceptPayload::new(data, &app_key).unwrap();

let nwk_skey = join_accept.derive_newskey(
    &lorawan::parser::DevNonce::new(&dev_nonce[..]).unwrap(),
    &app_key,
);

pub fn derive_appskey<TT: AsRef<[u8]>>(
    &self,
    dev_nonce: &DevNonce<TT>,
    key: &AES128
) -> AES128
[src]

Computes the application session key for a given device.

Argument

  • app_nonce - the network server nonce.
  • nwk_addr - the address of the network.
  • dev_nonce - the nonce from the device.
  • key - the app key.

Examples

let dev_nonce = vec![0xcc, 0xdd];
let data = vec![0x20, 0x49, 0x3e, 0xeb, 0x51, 0xfb, 0xa2, 0x11, 0x6f, 0x81, 0x0e, 0xdb, 0x37,
    0x42, 0x97, 0x51, 0x42];
let app_key = lorawan::keys::AES128([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
    0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]);
let join_accept = lorawan::parser::DecryptedJoinAcceptPayload::new(data, &app_key).unwrap();

let app_skey = join_accept.derive_appskey(
    &lorawan::parser::DevNonce::new(&dev_nonce[..]).unwrap(),
    &app_key,
);

impl<T: AsRef<[u8]>, F> DecryptedJoinAcceptPayload<T, F>[src]

pub fn app_nonce(&self) -> AppNonce<&[u8]>[src]

Gives the app nonce of the JoinAccept.

pub fn net_id(&self) -> NwkAddr<&[u8]>[src]

Gives the net ID of the JoinAccept.

pub fn dev_addr(&self) -> DevAddr<&[u8]>[src]

Gives the dev address of the JoinAccept.

pub fn dl_settings(&self) -> DLSettings[src]

Gives the downlink configuration of the JoinAccept.

pub fn rx_delay(&self) -> u8[src]

Gives the RX delay of the JoinAccept.

pub fn c_f_list(&self) -> Option<[Frequency; 5]>[src]

Gives the channel frequency list of the JoinAccept.

impl<T: AsRef<[u8]> + AsMut<[u8]>, F: CryptoFactory> DecryptedJoinAcceptPayload<T, F>[src]

pub fn new_with_factory<'a, 'b>(
    data: T,
    key: &'a AES128,
    factory: F
) -> Result<Self, &'b str>
[src]

Creates a DecryptedJoinAcceptPayload from the bytes of a JoinAccept.

The JoinAccept payload is automatically decrypted and the mic is verified using the suplied crypto factory implementation.

Argument

  • bytes - the data from which the PhyPayload is to be built.
  • key - the key that is to be used to decrypt the payload.
  • factory - the factory that shall be used to create object for crypto functions.

impl<T: AsRef<[u8]> + AsMut<[u8]>> DecryptedJoinAcceptPayload<T, DefaultFactory>[src]

pub fn new<'a, 'b>(data: T, key: &'a AES128) -> Result<Self, &'b str>[src]

Creates a DecryptedJoinAcceptPayload from the bytes of a JoinAccept.

The JoinAccept payload is automatically decrypted and the mic is verified.

Argument

  • bytes - the data from which the PhyPayload is to be built.
  • key - the key that is to be used to decrypt the payload.

Examples

let mut data = vec![0x20u8, 0x49u8, 0x3eu8, 0xebu8, 0x51u8, 0xfbu8,
    0xa2u8, 0x11u8, 0x6fu8, 0x81u8, 0x0eu8, 0xdbu8, 0x37u8, 0x42u8,
    0x97u8, 0x51u8, 0x42u8];
let key = lorawan::keys::AES128([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
    0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]);
let phy = lorawan::parser::DecryptedJoinAcceptPayload::new(&mut data[..], &key);

Trait Implementations

impl<T: AsRef<[u8]>, F> AsPhyPayloadBytes for DecryptedJoinAcceptPayload<T, F>[src]

impl<T: Debug, F: Debug> Debug for DecryptedJoinAcceptPayload<T, F>[src]

impl<T: PartialEq, F: PartialEq> PartialEq<DecryptedJoinAcceptPayload<T, F>> for DecryptedJoinAcceptPayload<T, F>[src]

impl<T, F> StructuralPartialEq for DecryptedJoinAcceptPayload<T, F>[src]

Auto Trait Implementations

impl<T, F> RefUnwindSafe for DecryptedJoinAcceptPayload<T, F> where
    F: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, F> Send for DecryptedJoinAcceptPayload<T, F> where
    F: Send,
    T: Send

impl<T, F> Sync for DecryptedJoinAcceptPayload<T, F> where
    F: Sync,
    T: Sync

impl<T, F> Unpin for DecryptedJoinAcceptPayload<T, F> where
    F: Unpin,
    T: Unpin

impl<T, F> UnwindSafe for DecryptedJoinAcceptPayload<T, F> where
    F: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsPhyPayloadBytes for T where
    T: DataHeader
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MHDRAble for T where
    T: AsPhyPayloadBytes
[src]

impl<T> MICAble for T where
    T: AsPhyPayloadBytes
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.