Skip to content

Commit

Permalink
Fix verify methods documentation and remove wrong VerifyAuthPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
geaaru committed Jul 6, 2018
1 parent fb805ab commit 23bb1eb
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions pyrad/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def RequestPacket(self):
self.id = self.CreateID()

header = struct.pack('!BBH16s', self.code, self.id,
(20 + len(attr)), self.authenticator)
(20 + len(attr)), self.authenticator)

return header + attr

Expand Down Expand Up @@ -613,17 +613,6 @@ def VerifyChapPasswd(self, userpwd):

return password == md5_constructor("%s%s%s" % (chapid, userpwd, challenge)).digest()

def VerifyAuthRequest(self):
"""Verify request authenticator.
:return: True if verification failed else False
:rtype: boolean
"""
assert(self.raw_packet)
hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') +
self.raw_packet[20:] + self.secret).digest()
return hash == self.authenticator


class AcctPacket(Packet):
"""RADIUS accounting packets. This class is a specialization
Expand Down Expand Up @@ -661,12 +650,14 @@ def CreateReply(self, **attributes):
def VerifyAcctRequest(self):
"""Verify request authenticator.
:return: True if verification failed else False
:return: False if verification failed else True
:rtype: boolean
"""
assert(self.raw_packet)

hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') +
self.raw_packet[20:] + self.secret).digest()
self.raw_packet[20:] + self.secret).digest()

return hash == self.authenticator

def RequestPacket(self):
Expand All @@ -684,8 +675,8 @@ def RequestPacket(self):
self.id = self.CreateID()

header = struct.pack('!BBH', self.code, self.id, (20 + len(attr)))
self.authenticator = md5_constructor(header[0:4] + 16 * six.b('\x00') + attr
+ self.secret).digest()
self.authenticator = md5_constructor(header[0:4] + 16 * six.b('\x00') +
attr + self.secret).digest()
return header + self.authenticator + attr

class CoAPacket(Packet):
Expand Down Expand Up @@ -724,7 +715,7 @@ def CreateReply(self, **attributes):
def VerifyCoARequest(self):
"""Verify request authenticator.
:return: True if verification failed else False
:return: False if verification failed else True
:rtype: boolean
"""
assert(self.raw_packet)
Expand All @@ -747,8 +738,8 @@ def RequestPacket(self):
self.id = self.CreateID()

header = struct.pack('!BBH', self.code, self.id, (20 + len(attr)))
self.authenticator = md5_constructor(header[0:4] + 16 * six.b('\x00') + attr
+ self.secret).digest()
self.authenticator = md5_constructor(header[0:4] + 16 * six.b('\x00') +
attr + self.secret).digest()
return header + self.authenticator + attr

def CreateID():
Expand Down

0 comments on commit 23bb1eb

Please sign in to comment.