Gentoo Archives: gentoo-portage-dev

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [GLEP59v2 2/5] Manifest2 hash: Whirlpool
Date: Sat, 01 Oct 2011 07:42:30
Message-Id: 1317454855-2794-3-git-send-email-robbat2@gentoo.org
In Reply to: [gentoo-portage-dev] [GLEP59v2 0/5] GLEP59: Manifest2 hash types by "Robin H. Johnson"
1 From: "Robin H. Johnson" <robbat2@g.o>
2
3 Provide public-domain implementation of the Whirlpool hash algorithm to
4 be used as new Manifest2 hash.
5
6 Signed-off-by: Robin H. Johnson <robbat2@g.o>
7 ---
8 pym/portage/checksum.py | 8 ++++++--
9 1 files changed, 6 insertions(+), 2 deletions(-)
10
11 diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
12 index e5455fa..3593686 100644
13 --- a/pym/portage/checksum.py
14 +++ b/pym/portage/checksum.py
15 @@ -71,6 +71,10 @@ except ImportError:
16
17 sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
18
19 +# Bundled WHIRLPOOL implementation
20 +from portage.util.whirlpool import new as _new_whirlpool
21 +whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
22 +
23 # Use pycrypto when available, prefer it over the internal fallbacks
24 try:
25 from Crypto.Hash import SHA256, RIPEMD
26 @@ -80,14 +84,14 @@ except ImportError as e:
27 pass
28
29 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
30 -# Need special handling for RMD160 as it may not always be provided by hashlib.
31 +# Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
32 try:
33 import hashlib, functools
34
35 md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
36 sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
37 sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
38 - for local_name, hash_name in (("rmd160", "ripemd160"), ):
39 + for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
40 try:
41 hashlib.new(hash_name)
42 except ValueError:
43 --
44 1.7.7

Replies

Subject Author
Re: [gentoo-portage-dev] [GLEP59v2 2/5] Manifest2 hash: Whirlpool Brian Harring <ferringb@×××××.com>