MCPcopy Create free account
hub / github.com/secdev/scapy / ZigbeeSecurityHeader

Class ZigbeeSecurityHeader

scapy/layers/zigbee.py:593–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591
592
593class ZigbeeSecurityHeader(Packet):
594 name = "Zigbee Security Header"
595 fields_desc = [
596 # Security control (1 octet)
597 FlagsField("reserved1", 0, 2, ['reserved1', 'reserved2']),
598 BitField("extended_nonce", 1, 1), # set to 1 if the sender address field is present (source) # noqa: E501
599 # Key identifier
600 BitEnumField("key_type", 1, 2, {
601 0: 'data_key',
602 1: 'network_key',
603 2: 'key_transport_key',
604 3: 'key_load_key'
605 }),
606 # Security level (3 bits)
607 BitEnumField("nwk_seclevel", 0, 3, {
608 0: "None",
609 1: "MIC-32",
610 2: "MIC-64",
611 3: "MIC-128",
612 4: "ENC",
613 5: "ENC-MIC-32",
614 6: "ENC-MIC-64",
615 7: "ENC-MIC-128"
616 }),
617 # Frame counter (4 octets)
618 XLEIntField("fc", 0), # provide frame freshness and prevent duplicate frames # noqa: E501
619 # Source address (0/8 octets)
620 ConditionalField(dot15d4AddressField("source", 0, adjust=lambda pkt, x: 8), lambda pkt: pkt.extended_nonce), # noqa: E501
621 # Key sequence number (0/1 octet): only present when key identifier is 1 (network key) # noqa: E501
622 ConditionalField(ByteField("key_seqnum", 0), lambda pkt: pkt.getfieldval("key_type") == 1), # noqa: E501
623 # Payload
624 # the length of the encrypted data is the payload length minus the MIC
625 StrField("data", ""), # noqa: E501
626 # Message Integrity Code (0/variable in size), length depends on nwk_seclevel # noqa: E501
627 XStrField("mic", ""),
628 ]
629
630 def post_dissect(self, s):
631 # Get the mic dissected correctly
632 mic_length = util_mic_len(self)
633 if mic_length > 0: # Slice "data" into "data + mic"
634 _data, _mic = self.data[:-mic_length], self.data[-mic_length:]
635 self.data, self.mic = _data, _mic
636 return s
637
638
639class ZigbeeAppDataPayload(Packet):

Callers

nothing calls this directly

Calls 10

FlagsFieldClass · 0.90
BitFieldClass · 0.90
BitEnumFieldClass · 0.90
XLEIntFieldClass · 0.90
ConditionalFieldClass · 0.90
dot15d4AddressFieldClass · 0.90
ByteFieldClass · 0.90
StrFieldClass · 0.90
XStrFieldClass · 0.90
getfieldvalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…