summaryrefslogtreecommitdiffstats
path: root/pym/portage/checksum.py
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2011-10-01 07:40:52 +0000
committerZac Medico <zmedico@gentoo.org>2011-10-01 22:35:12 -0700
commitf3b05d6eed63e19cdfa7f645cf0190ee8019dd90 (patch)
tree414d0d2a5776124b6ec4acff09c29d1d7aa309e2 /pym/portage/checksum.py
parentf27473d04e6dee44983d1e5ac32ea9d4d375b5a2 (diff)
downloadportage-f3b05d6eed63e19cdfa7f645cf0190ee8019dd90.tar.gz
portage-f3b05d6eed63e19cdfa7f645cf0190ee8019dd90.tar.bz2
portage-f3b05d6eed63e19cdfa7f645cf0190ee8019dd90.zip
Manifest2 hash: Whirlpool
Provide public-domain implementation of the Whirlpool hash algorithm to be used as new Manifest2 hash. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'pym/portage/checksum.py')
-rw-r--r--pym/portage/checksum.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 8daefbcb9..a4cf8de3c 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -76,6 +76,10 @@ except ImportError:
sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
+# Bundled WHIRLPOOL implementation
+from portage.util.whirlpool import new as _new_whirlpool
+whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
+
# Use pycrypto when available, prefer it over the internal fallbacks
try:
from Crypto.Hash import SHA256, RIPEMD
@@ -85,14 +89,14 @@ except ImportError as e:
pass
# Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
-# Need special handling for RMD160 as it may not always be provided by hashlib.
+# Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
try:
import hashlib, functools
md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
- for local_name, hash_name in (("rmd160", "ripemd160"), ):
+ for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
try:
hashlib.new(hash_name)
except ValueError: