Bug 484473

Summary: needs updating to use hashlib instead of deprecated md5 and sha modules
Product: [Fedora] Fedora Reporter: Henrik Nordström <henrik>
Component: python-cryptoAssignee: Thorsten Leemhuis <fedora>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: fedora, s.adam
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-18 19:25:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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