Mathias Ertl - 2009-06-15

I have created a patch that would get rid of the auth.py DeprecationWarnings while still staying compatible with python2.4 (the hashlib module is only available in python >= 2.5). Here is the patch:

mati@lt:/usr/lib/python2.6/dist-packages/xmpp $ diff auth.py.orig auth.py
24c24
< import sha,base64,random,dispatcher,re
---
> import base64,random,dispatcher,re
26,28c26,35
< import md5
< def HH(some): return md5.new(some).hexdigest()
< def H(some): return md5.new(some).digest()
---
> try:
> from hashlib import md5, sha1
> except ImportError:
> import sha as sha_tmp
> import md5 as md5_tmp
> sha1 = sha.new
> md5 = md5.new
>
> def HH(some): return md5(some).hexdigest()
> def H(some): return md5(some).digest()
57c64
< query.setTagData('digest',sha.new(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest())
---
> query.setTagData('digest',sha1(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest())
64,65c71,72
< hash = sha.new(sha.new(self.password).hexdigest()+token).hexdigest()
< for foo in xrange(int(seq)): hash = sha.new(hash).hexdigest()
---
> hash = sha1(sha1(self.password).hexdigest()+token).hexdigest()
> for foo in xrange(int(seq)): hash = sha1(hash).hexdigest()
84c91
< owner.send(Node(NS_COMPONENT_ACCEPT+' handshake',payload=[sha.new(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest()]))
---
> owner.send(Node(NS_COMPONENT_ACCEPT+' handshake',payload=[sha1(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest()]))

Since I'm not sure that posting a patch in this style works well, so the patch is also here: http://fsinf.at/~mati/auth.py.patch

greetings, mati