Skip to main content

zigbee_core/aps/frame/command/
verify_key.rs

1use zigbee_macros::impl_byte;
2use zigbee_types::ByteArray;
3use zigbee_types::IeeeAddress;
4
5impl_byte! {
6    /// Verify-Key Command Frame (4.4.10.8, Table 4-27, command id 0x0f)
7    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8    pub struct VerifyKey {
9        /// Standard key type (0x04 = Trust Center Link Key)
10        pub key_type: u8,
11        /// IEEE address of the Trust Center
12        pub source_address: IeeeAddress,
13        /// HMAC-AES-128-MMO hash proving possession of the link key
14        pub hash: ByteArray<16>,
15    }
16}
17
18#[cfg(test)]
19mod tests {
20    use byte::TryRead;
21    use byte::TryWrite;
22
23    use crate::aps::frame::command::Command;
24
25    #[test]
26    fn round_trip_verify_key() {
27        let frame_buf = [
28            0x0f, // command id: VerifyKey
29            0x04, // key_type: TC Link Key
30            // source_address (8 bytes LE)
31            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // hash (16 bytes)
32            0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
33            0x88, 0x99,
34        ];
35
36        let (cmd, _) = Command::try_read(&frame_buf, ()).unwrap();
37
38        let mut got_buf = [0u8; _];
39        cmd.try_write(&mut got_buf, ()).unwrap();
40
41        assert_eq!(frame_buf, got_buf);
42    }
43}