cocagne / pysrp

Python implementation of the Secure Remote Password protocol (SRP)
MIT License
113 stars 42 forks source link

process_challenge() - TypeError: Can't convert 'bytes' object to str implicitly #28

Closed jonasao closed 6 years ago

jonasao commented 6 years ago

When attempting to use the process_challenge() method it keeps throwing a TypeError (Can't convert 'bytes' object to str implicitly.)

Traced to exception to be thrown from the method: calculate_x(hash_class, dest, salt, username, password) in the file _ctsrp.py

This method fetches the username and password values as str values, but inside this method they are attempted concatenated with a bytes literal, which in turn causes the TypeError.

Altered method, fixing the TypeError issue

def calculate_x( hash_class, dest, salt, username, password ):
    up = hash_class(username.encode() + six.b(':') + password.encode()).digest()
    H_bn_str( hash_class, dest, salt, up )