diff --git a/pyrad/packet.py b/pyrad/packet.py index ecaa5a2..82902af 100644 --- a/pyrad/packet.py +++ b/pyrad/packet.py @@ -740,7 +740,7 @@ def VerifyChapPasswd(self, userpwd): challenge = self.authenticator if 'CHAP-Challenge' in self: challenge = self['CHAP-Challenge'][0] - return password == md5_constructor(b'%s%s%s' % (chapid, userpwd, challenge)).digest() + return password == md5_constructor(chapid + userpwd + challenge).digest() def VerifyAuthRequest(self): """Verify request authenticator. diff --git a/pyrad/tools.py b/pyrad/tools.py index 8d2b37f..3ddb33e 100644 --- a/pyrad/tools.py +++ b/pyrad/tools.py @@ -110,10 +110,10 @@ def EncodeAscendBinary(str): terms[key] = struct.pack('B', int(value)) trailer = 8 * b'\x00' - result = b'%s%s%s\x00%s%s%s%s%s\x00%s%s%s%s\x00\x00' % ( - terms['family'], terms['action'], terms['direction'], terms['src'], - terms['dst'], terms['srcl'], terms['dstl'], terms['proto'], - terms['sport'], terms['dport'], terms['sportq'], terms['dportq']) + trailer + + result = b''.join((terms['family'], terms['action'], terms['direction'], b'\x00', + terms['src'], terms['dst'], terms['srcl'], terms['dstl'], terms['proto'], b'\x00', + terms['sport'], terms['dport'], terms['sportq'], terms['dportq'], b'\x00\x00', trailer)) return result