From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RAF1o-00056r-54 for garchives@archives.gentoo.org; Sun, 02 Oct 2011 05:55:56 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8C18521C0E3; Sun, 2 Oct 2011 05:55:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5821721C0E3 for ; Sun, 2 Oct 2011 05:55:48 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6CA101B4005 for ; Sun, 2 Oct 2011 05:55:47 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 88ECA80042 for ; Sun, 2 Oct 2011 05:55:46 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/checksum.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: faf87ba9877e3b5a7866c6649f956f15950e789a Date: Sun, 2 Oct 2011 05:55:46 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 86d3681594920cfbf11a1c90e617bb37 commit: faf87ba9877e3b5a7866c6649f956f15950e789a Author: Robin H. Johnson gentoo org> AuthorDate: Sat Oct 1 07:40:54 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Oct 2 05:55:02 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dfaf87ba9 Manifest2 hash backend provider: mhash Offer mhash as a provider for Manifest2 hash generation and validation. This is important as either of pycrypto or fchksum offer an accelerated Whirlpool implementation, and hashlib might not offer it. Additionally, the mhash implementation is accelerated and ships with a rigorious testsuite. Signed-off-by: Robin H. Johnson gentoo.org> --- pym/portage/checksum.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 6bace4d..a4a744b 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -80,6 +80,25 @@ sha1hash =3D _generate_hash_function("SHA1", _new_sha1= , origin=3D"internal") from portage.util.whirlpool import new as _new_whirlpool whirlpoolhash =3D _generate_hash_function("WHIRLPOOL", _new_whirlpool, o= rigin=3D"bundled") =20 +# Try to use mhash if available +# mhash causes GIL presently, so it gets less priority than hashlib and +# pycrypto. However, it might be the only accelerated implementation of +# WHIRLPOOL available. +try: + import mhash, functools + md5hash =3D _generate_hash_function("MD5", functools.partial(mhash.MHAS= H, mhash.MHASH_MD5), origin=3D"mhash") + sha1hash =3D _generate_hash_function("SHA1", functools.partial(mhash.MH= ASH, mhash.MHASH_SHA1), origin=3D"mhash") + sha256hash =3D _generate_hash_function("SHA256", functools.partial(mhas= h.MHASH, mhash.MHASH_SHA256), origin=3D"mhash") + sha512hash =3D _generate_hash_function("SHA512", functools.partial(mhas= h.MHASH, mhash.MHASH_SHA512), origin=3D"mhash") + for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "w= hirlpool")): + if hasattr(mhash, 'MHASH_%s' % local_name.upper()): + globals()['%shash' % local_name] =3D \ + _generate_hash_function(local_name.upper(), \ + functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name= .upper())), \ + origin=3D'mhash') +except ImportError: + pass + # Use pycrypto when available, prefer it over the internal fallbacks try: from Crypto.Hash import SHA256, RIPEMD