summaryrefslogtreecommitdiff
path: root/lib/Crypto/Hash/MD5.py
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2011-02-03 01:21:12 +0100
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2011-02-03 01:35:46 +0100
commit0d14809acd61782e1e024ca7119b6e4b10dcf7fc (patch)
tree524a623d95111970732537e1c25f6e1ae0bb8421 /lib/Crypto/Hash/MD5.py
parent1a51197542f0e22f145a3ba9cbd090a602e05132 (diff)
downloadpycrypto-0d14809acd61782e1e024ca7119b6e4b10dcf7fc.tar.gz
Add OID to each hash algorithm.
Diffstat (limited to 'lib/Crypto/Hash/MD5.py')
-rw-r--r--lib/Crypto/Hash/MD5.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Crypto/Hash/MD5.py b/lib/Crypto/Hash/MD5.py
index 6838f9b..7a48a02 100644
--- a/lib/Crypto/Hash/MD5.py
+++ b/lib/Crypto/Hash/MD5.py
@@ -24,19 +24,30 @@ __revision__ = "$Id$"
__all__ = ['new', 'digest_size']
+from Crypto.Util.wrapper import Wrapper
+
+# The OID for MD5 is:
+#
+# id-md5 OBJECT IDENTIFIER ::= {
+# iso(1) member-body(2) us(840) rsadsi(113549)
+# digestAlgorithm(2) 5
+# }
+oid = '\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05'
+
+def new(data=""):
+ obj = Wrapper(hashFactory, data)
+ obj.oid = oid
+ return obj
+
try:
# The md5 module is deprecated in Python 2.6, so use hashlib when possible.
import hashlib
- def new(data=""):
- return hashlib.md5(data)
+ hashFactory = hashlib.md5
digest_size = new().digest_size
except ImportError:
- from md5 import *
-
import md5
+ hashFactory = md5
if hasattr(md5, 'digestsize'):
- digest_size = digestsize
- del digestsize
- del md5
+ digest_size = md5.digestsize