digest = b"0x" + binascii.hexlify(digest)
reply.AddAttribute("Message-Authenticator", digest)
+def build_message_auth(pkt, reply):
+ hmac_obj = hmac.new(reply.secret, digestmod=hashlib.md5)
+ hmac_obj.update(struct.pack("B", reply.code))
+ hmac_obj.update(struct.pack("B", reply.id))
+
+ reply.AddAttribute("Message-Authenticator", 16*b'\x00')
+ attrs = reply._PktEncodeAttributes()
+
+ # Length
+ flen = 4 + 16 + len(attrs)
+ hmac_obj.update(struct.pack(">H", flen))
+ hmac_obj.update(pkt.authenticator)
+ hmac_obj.update(attrs)
+ del reply[80]
+ add_message_authenticator_attr(reply, hmac_obj.digest())
+
def run_pyrad_server(srv, t_stop, eap_handler):
srv.RunWithStop(t_stop, eap_handler)
logger.info("No EAP request available")
reply.code = pyrad.packet.AccessChallenge
- hmac_obj = hmac.new(reply.secret, digestmod=hashlib.md5)
- hmac_obj.update(struct.pack("B", reply.code))
- hmac_obj.update(struct.pack("B", reply.id))
-
# reply attributes
- reply.AddAttribute("Message-Authenticator", 16*b'\x00')
- attrs = reply._PktEncodeAttributes()
-
- # Length
- flen = 4 + 16 + len(attrs)
- hmac_obj.update(struct.pack(">H", flen))
- hmac_obj.update(pkt.authenticator)
- hmac_obj.update(attrs)
- del reply[80]
- add_message_authenticator_attr(reply, hmac_obj.digest())
+ build_message_auth(pkt, reply)
self.SendReplyPacket(pkt.fd, reply)
from utils import *
from test_ap_hs20 import build_dhcp_ack
from test_ap_ft import ft_params1
-from test_eap_proto import add_message_authenticator_attr
+from test_eap_proto import add_message_authenticator_attr, build_message_auth
def connect(dev, ssid, wait_connect=True):
dev.connect(ssid, key_mgmt="WPA-EAP", scan_freq="2412",
if self.t_events['session_timeout']:
reply.AddAttribute("Session-Timeout",
self.t_events['session_timeout'])
+ build_message_auth(pkt, reply)
+
self.SendReplyPacket(pkt.fd, reply)
def RunWithStop(self, t_events):
reply.AddAttribute("Tunnel-Type", 13)
reply.AddAttribute("Tunnel-Medium-Type", 6)
reply.AddAttribute("Tunnel-Private-Group-ID", "1")
+ build_message_auth(pkt, reply)
self.SendReplyPacket(pkt.fd, reply)
def RunWithStop(self, t_events):