You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using AVP 'Tunnel-Password' with python3 I get following error:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyrad/packet.py", line 254, in _EncodeKeyValues
return (key, [tag + self._EncodeValue(attr, v) for v in values])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyrad/packet.py", line 254, in <listcomp>
return (key, [tag + self._EncodeValue(attr, v) for v in values])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyrad/packet.py", line 235, in _EncodeValue
result = self.SaltCrypt(result)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyrad/packet.py", line 567, in SaltCrypt
salt = chr(ord(salt[0]) | 1 << 7)+salt[1]
TypeError: ord() expected string of length 1, but int found
this is due to strict.pack behavior in python3, which returns bytes (instead of string in python 2)
potential fix, which I have tested:
def SaltCrypt(self, value):
"""Salt Encryption
:param value: plaintext value
:type password: unicode string
:return: obfuscated version of the value
:rtype: binary string
"""
if isinstance(value, six.text_type):
value = value.encode('utf-8')
if self.authenticator is None:
# self.authenticator = self.CreateAuthenticator()
self.authenticator = 16 * six.b('\x00')
if six.PY3:
random_value = 32768 + random_generator.randrange(0, 32767)
salt_raw = struct.pack('!H', random_value )
salt_str = chr(salt_raw[0]) + chr(salt_raw[0])
salt = six.b(salt_str)
result = salt
else:
random_value = random_generator.randrange(0, 65535)
salt = struct.pack('!H', random_value )
salt = chr(ord(salt[0]) | 1 << 7)+salt[1]
result = six.b(salt)
#salt = struct.pack('!H', random_generator.randrange(0, 65535))
#salt = chr(ord(salt[0]) | 1 << 7)+salt[1]
length = struct.pack("B", len(value))
buf = length + value
if len(buf) % 16 != 0:
buf += six.b('\x00') * (16 - (len(buf) % 16))
#result = six.b(salt)
last = self.authenticator + salt
while buf:
hash = md5_constructor(self.secret + last).digest()
if six.PY3:
for i in range(16):
result += bytes((hash[i] ^ buf[i],))
else:
for i in range(16):
result += chr(ord(hash[i]) ^ ord(buf[i]))
last = result[-16:]
buf = buf[16:]
return result
regards Stefan
The text was updated successfully, but these errors were encountered:
Hi Istvan, Hi Christian
when using AVP 'Tunnel-Password' with python3 I get following error:
this is due to strict.pack behavior in python3, which returns bytes (instead of string in python 2)
potential fix, which I have tested:
regards Stefan
The text was updated successfully, but these errors were encountered: