]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Encode Disconnect-Request attributes in sorted order for python3
authorJouni Malinen <j@w1.fi>
Mon, 4 Feb 2019 17:27:57 +0000 (19:27 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 4 Feb 2019 18:03:29 +0000 (20:03 +0200)
This is needed to fix issues with dict iteration resulting in different
order of attributes when trying to calculate Message-Authenticator
externally to pyrad.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/radius_das.py
tests/hwsim/test_radius.py

index 300681a7129ed5e7ecf1880c6409549676c30d52..58dc9d6fab6cb083a13fd8e3a1edcfb843bbc6ea 100644 (file)
@@ -16,7 +16,10 @@ class DisconnectPacket(pyrad.packet.Packet):
                                      **attributes)
 
     def RequestPacket(self):
-        attr = self._PktEncodeAttributes()
+        attr = b''
+        for code,datalst in sorted(self.items()):
+            for data in datalst:
+                attr += self._PktEncodeAttribute(code, data)
 
         if self.id is None:
             self.id = random.randrange(0, 256)
index 144ad83b34ebe5fc9ddf099ed210029b5d2c6c6a..1ab343f5acd9436c1a6ff9e2302e6a22f9c9e88b 100644 (file)
@@ -730,7 +730,10 @@ def add_message_auth_req(req):
 
     # request attributes
     req.AddAttribute("Message-Authenticator", 16*b"\x00")
-    attrs = req._PktEncodeAttributes()
+    attrs = b''
+    for code,datalst in sorted(req.items()):
+        for data in datalst:
+            attrs += req._PktEncodeAttribute(code, data)
 
     # Length
     flen = 4 + 16 + len(attrs)