Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit b9518ac28 (add support for octets starting with 0x) what for? #49

Open
kixiro opened this issue Mar 28, 2017 · 3 comments
Open
Assignees
Labels
bug feedback feedback required

Comments

@kixiro
Copy link

kixiro commented Mar 28, 2017

When I generate an attribute User-Password (CHAP), I get string start with '0x'. This leads to error:

  File "/usr/local/lib/python2.7/dist-packages/pyrad/packet.py", line 150, in _EncodeKeyValues
    return (key, [self._EncodeValue(attr, v) for v in values])
  File "/usr/local/lib/python2.7/dist-packages/pyrad/packet.py", line 123, in _EncodeValue
    result = tools.EncodeAttr(attr.type, value)
  File "/usr/local/lib/python2.7/dist-packages/pyrad/tools.py", line 178, in EncodeAttr
    return EncodeOctets(value)
  File "/usr/local/lib/python2.7/dist-packages/pyrad/tools.py", line 26, in EncodeOctets
    return binascii.unhexlify(hexstring)
TypeError: Odd-length string

Can this exception be put into a separate function?

@kixiro
Copy link
Author

kixiro commented Apr 4, 2017

I did not correctly generate CHAP ID
can be closed

@kixiro
Copy link
Author

kixiro commented Apr 4, 2017

No...

IF CHAP ID = 48
then

struct.pack('B', 48)
'0'

And first code md5 password = 'x' (code 120)
Attribute CHAP-Password startswith(b'0x') and get error "Odd-length string"
tools.py:

 24     if str.startswith(b'0x'):
 25         hexstring = str.split(b'0x')[1]
 26         return binascii.unhexlify(hexstring)

@GIC-de
Copy link
Collaborator

GIC-de commented Jul 5, 2018

Can you please share some example code?

@GIC-de GIC-de self-assigned this Jul 5, 2018
@GIC-de GIC-de added bug feedback feedback required labels Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feedback feedback required
Projects
None yet
Development

No branches or pull requests

2 participants