mirror of
https://github.com/espressif/openthread.git
synced 2026-10-18 13:38:07 +00:00
[tests] fix mac key id mode parsing (#3448)
This commit is contained in:
@@ -231,12 +231,12 @@ class MacFrame:
|
|||||||
security_level = security_control & 0x07
|
security_level = security_control & 0x07
|
||||||
key_id_mode = (security_control & 0x18) >> 3
|
key_id_mode = (security_control & 0x18) >> 3
|
||||||
|
|
||||||
if key_id_mode == 1:
|
if key_id_mode == 0:
|
||||||
|
key_id = data.read(9)
|
||||||
|
elif key_id_mode == 1:
|
||||||
key_id = data.read(1)
|
key_id = data.read(1)
|
||||||
elif key_id_mode == 2:
|
elif key_id_mode == 2:
|
||||||
key_id = data.read(5)
|
key_id = data.read(5)
|
||||||
elif key_id_mode == 3:
|
|
||||||
key_id = data.read(9)
|
|
||||||
else:
|
else:
|
||||||
key_source = None
|
key_source = None
|
||||||
key_index = None
|
key_index = None
|
||||||
|
|||||||
@@ -271,6 +271,9 @@ class AuxiliarySecurityHeader:
|
|||||||
def sequence_counter(self):
|
def sequence_counter(self):
|
||||||
""" Compute or extract sequence counter based on currently set Key Index Mode. """
|
""" Compute or extract sequence counter based on currently set Key Index Mode. """
|
||||||
|
|
||||||
|
if self.key_id_mode == 0:
|
||||||
|
key_source = self.key_id[:8]
|
||||||
|
format = ">Q" if self._big_endian else "<Q"
|
||||||
if self.key_id_mode == 1:
|
if self.key_id_mode == 1:
|
||||||
# Try to guess valid Key Sequence Counter based on Key Index. This one should work for now.
|
# Try to guess valid Key Sequence Counter based on Key Index. This one should work for now.
|
||||||
return self.key_index - 1
|
return self.key_index - 1
|
||||||
@@ -278,10 +281,6 @@ class AuxiliarySecurityHeader:
|
|||||||
# In this mode sequence counter is stored on the first four bytes of Key ID.
|
# In this mode sequence counter is stored on the first four bytes of Key ID.
|
||||||
key_source = self.key_id[:4]
|
key_source = self.key_id[:4]
|
||||||
format = ">I" if self._big_endian else "<I"
|
format = ">I" if self._big_endian else "<I"
|
||||||
elif self.key_id_mode == 3:
|
|
||||||
key_source = self.key_id[:8]
|
|
||||||
format = ">Q" if self._big_endian else "<Q"
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unsupported Key Index Mode: {}".format(self.key_id_mode))
|
raise ValueError("Unsupported Key Index Mode: {}".format(self.key_id_mode))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user