1. Pypy
  2. Untitled project
  3. pypy

Commits

Amaury Forgeot d'Arc  committed 63a819f

Line up md5 and sha modules with CPython.
Should fix a warning in hmac.py

+ fix tests after rename.

  • Participants
  • Parent commits 996ceae
  • Branches fast-forward

Comments (0)

Files changed (9)

File lib_pypy/_md5.py

View file
     "An implementation of the MD5 hash function in pure Python."
 
     digest_size = digestsize = 16
+    block_size = 64
 
     def __init__(self):
         "Initialisation."
 
 # ======================================================================
 # Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
+# for consistency with the _md5 module of the standard library.
 # ======================================================================
 
-digest_size = digestsize = 16
-blocksize = 1
-
-def new(arg=None):
-    """Return a new md5 crypto object.
-
-    If arg is present, the method call update(arg) is made.
-    """
-
-    crypto = MD5Type()
-    if arg:
-        crypto.update(arg)
-
-    return crypto
-
+digest_size = 16
 
 def md5(arg=None):
     """Same as new().

File lib_pypy/_sha.py

View file
     "An implementation of the MD5 hash function in pure Python."
 
     digest_size = digestsize = 20
+    block_size = 1
 
     def __init__(self):
         "Initialisation."
 
 # ======================================================================
 # Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
+# for consistency with the _sha module of the standard library.
 # ======================================================================
 
 # These are mandatory variables in the module. They have constant values
 # in the SHA standard.
 
-digest_size = digestsize = 20
+digest_size = 20
+digestsize = 20
 blocksize = 1
 
 def new(arg=None):

File lib_pypy/ctypes_config_cache/test/test_cache.py

View file
     d = run('syslog.ctc.py', '_syslog_cache.py')
     assert 'LOG_NOTICE' in d
 
-def test_hashlib():
-    d = run('hashlib.ctc.py', '_hashlib_cache.py')
-    assert hasattr(d['EVP_MD_CTX'], 'digest')
-
 def test_resource():
     d = run('resource.ctc.py', '_resource_cache.py')
     assert 'RLIM_NLIMITS' in d

File lib_pypy/pypy_test/test_md5_extra.py

View file
 
 from __future__ import absolute_import
 import md5                              # CPython's implementation in C.
-from .. import md5 as pymd5  
+from .. import _md5 as pymd5  
 
 
 # Helpers...

File lib_pypy/pypy_test/test_sha_extra.py

View file
 # Publication 180-1, Secure Hash Standard,  1995 April 17
 # http://www.itl.nist.gov/div897/pubs/fip180-1.htm
 from __future__ import absolute_import
-from .. import sha 
+from .. import _sha 
 
 class TestSHA: 
     def check(self, data, digest):

File pypy/module/_md5/__init__.py

View file
 far using the digest() method."""
 
     interpleveldefs = {
-        'md5': 'interp_md5.W_MD5',
         'new': 'interp_md5.W_MD5',
         'MD5Type': 'interp_md5.W_MD5',
         'digest_size': 'space.wrap(16)',
-        'digestsize': 'space.wrap(16)',
-        'blocksize': 'space.wrap(1)',
         }
 
     appleveldefs = {

File pypy/module/_md5/interp_md5.py

View file
     copy      = interp2app(W_MD5.copy_w, unwrap_spec=['self']),
     digest_size = 16,
     digestsize = 16,
+    block_size = 64,
     __doc__   = """md5(arg) -> return new md5 object.
 
 If arg is present, the method call update(arg) is made.""")

File pypy/module/_sha/__init__.py

View file
 bits instead of MD5's 128 bits."""
 
     interpleveldefs = {
-        'sha': 'interp_sha.W_SHA',
         'new': 'interp_sha.W_SHA',
         'SHAType': 'interp_sha.W_SHA',
         'blocksize': 'space.wrap(1)',

File pypy/module/_sha/interp_sha.py

View file
     copy      = interp2app(W_SHA.copy_w, unwrap_spec=['self']),
     digest_size = 20,
     digestsize = 20,
+    block_size = 64,
     __doc__   = """sha(arg) -> return new sha object.
 
 If arg is present, the method call update(arg) is made.""")