Merge pull request #20 from thekix/master

Updated cram-md5 authentication
This commit is contained in:
Rodolfo García Peñas (kix) 2020-10-31 00:12:42 +01:00 committed by GitHub
commit 24a3692b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import datetime
import hashlib
import hmac
import socket
import json
@ -184,7 +185,9 @@ class IMAPServer():
self.ui.debug('imap', '__md5handler: got challenge %s' % challenge)
passwd = self.__getpassword()
retval = self.username + ' ' + hmac.new(passwd, challenge).hexdigest()
retval = self.username + ' ' +\
hmac.new(bytes(passwd, encoding='utf-8'), challenge,
digestmod=hashlib.md5).hexdigest()
self.ui.debug('imap', '__md5handler: returning %s' % retval)
return retval