Bug 484473 - needs updating to use hashlib instead of deprecated md5 and sha modules
Summary: needs updating to use hashlib instead of deprecated md5 and sha modules
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-crypto
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Thorsten Leemhuis
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-02-07 00:02 UTC by Henrik Nordström
Modified: 2009-02-18 19:25 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-02-18 19:25:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Henrik Nordström 2009-02-07 00:02:55 UTC
Description of problem:

Applications using python-crypto may get the following warning:

/usr/lib64/python2.6/site-packages/Crypto/Hash/SHA.py:6: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  from sha import *
/usr/lib64/python2.6/site-packages/Crypto/Hash/MD5.py:6: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  from md5 import *

Version-Release number of selected component (if applicable):

python-crypto-2.0.1-14.1.x86_64
python-2.6-4.fc11.x86_64


How reproducible:

Always

Steps to Reproduce:
1. 
2.
3.
  
Actual results:

/usr/lib64/python2.6/site-packages/Crypto/Hash/SHA.py:6: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  from sha import *
/usr/lib64/python2.6/site-packages/Crypto/Hash/MD5.py:6: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  from md5 import *


Expected results:

No warnings about deprecated functions.

Additional info:

From a quick grep it also applies to Crypto/Hash/HMAC.py


It seems the fix is simply changing as follows

From:
 from md5 import *
 import mf5
To:
 from hashlib import md5

and similar for SHA.

Comment 1 Stewart Adam 2009-02-07 14:39:09 UTC
Can you confirm this is fixed in 2.0.1-15? I haven't setup my rawhide VM to test yet...

http://koji.fedoraproject.org/koji/taskinfo?taskID=1111208

Comment 2 Henrik Nordström 2009-02-07 16:33:18 UTC
Same problem in 2.0.1-15.

Comment 3 Henrik Nordström 2009-02-07 16:36:57 UTC
The patch in CVS looks about right, but is not added to the spec file so not part of the build..

Needs to be both a Patch0: source line, and a %patch0 statement in %prep

Comment 4 Stewart Adam 2009-02-07 18:07:31 UTC
Sorry about that, fixed now. Rebuilding now: http://koji.fedoraproject.org/koji/taskinfo?taskID=1111411

I've also changed the patch a bit, as to remain compatible with PEP 247 we can't simply replace the md5/sha modules with their hashlib equivalents - hashlib provides a function and not a module with the digest_size and blocksize properties. The SHA and MD5 functions will now contain the correct values for digest_size and blocksize (the same values as the objects from hashlib have) as before there were hardcoded from the Python sha and md5 modules.

Comment 5 Thorsten Leemhuis 2009-02-12 19:10:22 UTC
Stewart, upstream has a report reg. this as well:

     https://bugs.launchpad.net/pycrypto/+bug/269429

There are also fixes in git:

     http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.x.git;a=commitdiff;h=d2311689910240e425741a546576129f4c9735e2
     http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.x.git;a=commitdiff;h=84b793416b52311643bfd456a4544444afbfb5da

Should we use those just to be on the safe side?

BTW: Steward, would you be interested to take over python-crypto? I don#t need it anymore

Comment 6 Stewart Adam 2009-02-18 19:25:26 UTC
Fixed in 2.0.1-17: http://koji.fedoraproject.org/koji/buildinfo?buildID=82882


Note You need to log in before you can comment on or make changes to this bug.