Bug 503772

Summary: python-hashlib does not work with the Python2.4's hmac module
Product: [Fedora] Fedora EPEL Reporter: Luke Macken <lmacken>
Component: python-hashlibAssignee: Dennis Gilmore <dennis>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: el5CC: dennis, pfrields, toshio
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-06-02 17:39:03 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:
Bug Depends On:    
Bug Blocks: 468230    

Description Luke Macken 2009-06-02 16:05:44 UTC
Description of problem:

This hashlib package does not work with the Python2.4 hmac module.

For more details on this issue, see this ticket.

    http://trac.turbogears.org/ticket/2133

The "solution" proposed is to monkey-patch Python2.4's hmac.HMAC to point to Python2.5's hmac.HMAC25.

The attached package ships Python2.5's hmac.py, and patches hashlib.py to perform this monkey-patching.  I also enabled the test suite, which still passes:

+ /usr/bin/python test/test_hashlib.py
test_case_md5_0 (__main__.HashLibTestCase) ... ok 
test_case_md5_1 (__main__.HashLibTestCase) ... ok 
test_case_md5_2 (__main__.HashLibTestCase) ... ok 
test_case_sha1_0 (__main__.HashLibTestCase) ... ok 
test_case_sha1_1 (__main__.HashLibTestCase) ... ok 
test_case_sha1_2 (__main__.HashLibTestCase) ... ok 
test_case_sha1_3 (__main__.HashLibTestCase) ... ok 
test_case_sha224_0 (__main__.HashLibTestCase) ... ok 
test_case_sha224_1 (__main__.HashLibTestCase) ... ok 
test_case_sha224_2 (__main__.HashLibTestCase) ... ok 
test_case_sha224_3 (__main__.HashLibTestCase) ... ok 
test_case_sha256_0 (__main__.HashLibTestCase) ... ok 
test_case_sha256_1 (__main__.HashLibTestCase) ... ok 
test_case_sha256_2 (__main__.HashLibTestCase) ... ok 
test_case_sha256_3 (__main__.HashLibTestCase) ... ok 
test_case_sha384_0 (__main__.HashLibTestCase) ... ok 
test_case_sha384_1 (__main__.HashLibTestCase) ... ok 
test_case_sha384_2 (__main__.HashLibTestCase) ... ok 
test_case_sha384_3 (__main__.HashLibTestCase) ... ok 
test_case_sha512_0 (__main__.HashLibTestCase) ... ok 
test_case_sha512_1 (__main__.HashLibTestCase) ... ok 
test_case_sha512_2 (__main__.HashLibTestCase) ... ok 
test_case_sha512_3 (__main__.HashLibTestCase) ... ok 
test_hexdigest (__main__.HashLibTestCase) ... ok 
test_large_update (__main__.HashLibTestCase) ... ok 
test_unknown_hash (__main__.HashLibTestCase) ... ok 
----------------------------------------------------------------------
Ran 26 tests in 0.152s 
OK


http://lmacken.fedorapeople.org/rpms/python-hashlib-20081119-5.fc10.src.rpm
http://lmacken.fedorapeople.org/rpms/python-hashlib.spec

* Mon Jun 01 2009 Luke Macken <lmacken> - 20081119-5
- Add python-hashlib-hmac25.patch to work around some Python2.4 hmac / hashlib
  incompatibility
- Include Python2.5's hmac.py as hmac25.py in our site-packages
- Run the hashlib test suite

Comment 1 Luke Macken 2009-06-02 17:17:09 UTC
A more realistic fix could involve removing the hashlib usage in the offending modules (Beaker, Paste), and just default back to the old sha1/md5 modules.  Testing this now with Beaker.

Comment 2 Luke Macken 2009-06-02 17:39:03 UTC
I was able to hack around this issue in Beaker itself, by patching out it's use of hashlib on EL-5.