From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0848E15A7DA for ; Tue, 21 Mar 2023 02:30:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4556BE07B2; Tue, 21 Mar 2023 02:30:36 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2CFEBE07B2 for ; Tue, 21 Mar 2023 02:30:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 580D9341255 for ; Tue, 21 Mar 2023 02:30:35 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7D8F58F1 for ; Tue, 21 Mar 2023 02:30:32 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1679365824.5804bfcc13b6b35e2bab5d6d93f899f8648bbd89.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/checksum.py X-VCS-Directories: lib/portage/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 5804bfcc13b6b35e2bab5d6d93f899f8648bbd89 X-VCS-Branch: master Date: Tue, 21 Mar 2023 02:30:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9958a0a5-08c7-4bda-be53-b1cb095a3a92 X-Archives-Hash: 89657c2ba7732c52478fb589a3c554bd commit: 5804bfcc13b6b35e2bab5d6d93f899f8648bbd89 Author: Sam James gentoo org> AuthorDate: Mon Mar 20 03:42:21 2023 +0000 Commit: Sam James gentoo org> CommitDate: Tue Mar 21 02:30:24 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5804bfcc checksum: drop mhash usage for WHIRLPOOL; consolidate RIPEMD logic - Drop mhash fallback logic for WHIRLPOOL as we already have: hashlib > pycrypto > bundled C > bundled pure Python - Consolidate the RIPEMD logic accordingly as we don't need to share the mhash fallback logic between WHIRLPOOL and RIPEMD anymore. Signed-off-by: Sam James gentoo.org> lib/portage/checksum.py | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py index 3b9796b32..b10643476 100644 --- a/lib/portage/checksum.py +++ b/lib/portage/checksum.py @@ -26,7 +26,7 @@ from portage.localization import _ # SHA256: hashlib # SHA512: hashlib # RMD160: hashlib, pycrypto, mhash -# WHIRLPOOL: hashlib, mhash, bundled (C), bundled (Python) +# WHIRLPOOL: hashlib, bundled (C), bundled (Python) # BLAKE2B (512): hashlib # BLAKE2S (512): hashlib # SHA3_256: hashlib @@ -141,33 +141,26 @@ if "RMD160" not in hashfunc_map: if rmd160hash_ is not None: _generate_hash_function("RMD160", rmd160hash_, origin="pycrypto") except ImportError: - pass - - pass - - -# 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. -if "RMD160" not in hashfunc_map or "WHIRLPOOL" not in hashfunc_map: - try: - import mhash - - for local_name, hash_name in ( - ("RMD160", "RIPEMD160"), - ("WHIRLPOOL", "WHIRLPOOL"), - ): - if local_name not in hashfunc_map and hasattr(mhash, f"MHASH_{hash_name}"): - _generate_hash_function( - local_name, - functools.partial( - mhash.MHASH, getattr(mhash, f"MHASH_{hash_name}") - ), - origin="mhash", - ) - except ImportError: - pass + # 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 + + for local_name, hash_name in (("RMD160", "RIPEMD160"),): + if local_name not in hashfunc_map and hasattr( + mhash, f"MHASH_{hash_name}" + ): + _generate_hash_function( + local_name, + functools.partial( + mhash.MHASH, getattr(mhash, f"MHASH_{hash_name}") + ), + origin="mhash", + ) + except ImportError: + pass _whirlpool_unaccelerated = False