aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-12-30 11:47:55 +0100
committerSam James <sam@gentoo.org>2022-12-31 13:33:04 +0000
commit9ef4e24ba6ff64bb1addb3112ebdf3b3e58bdb07 (patch)
tree6333c8a5d81ebe46fde42f59aac512a6b34de938
parentTest C whirlpool implementation separately from Python impl (diff)
downloadportage-9ef4e24b.tar.gz
portage-9ef4e24b.tar.bz2
portage-9ef4e24b.zip
checksum: Consider C implementation of Whirlpool accelerated
Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--lib/portage/checksum.py9
-rw-r--r--lib/portage/util/whirlpool.py13
2 files changed, 6 insertions, 16 deletions
diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
index f23897d91..3bdb2bc53 100644
--- a/lib/portage/checksum.py
+++ b/lib/portage/checksum.py
@@ -310,10 +310,13 @@ if "STREEBOG256" not in hashfunc_map or "STREEBOG512" not in hashfunc_map:
_whirlpool_unaccelerated = False
if "WHIRLPOOL" not in hashfunc_map:
# Bundled WHIRLPOOL implementation
- _whirlpool_unaccelerated = True
- from portage.util.whirlpool import new as _new_whirlpool
+ from portage.util.whirlpool import CWhirlpool, PyWhirlpool
- _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
+ if CWhirlpool.is_available:
+ _generate_hash_function("WHIRLPOOL", CWhirlpool, origin="bundled-c")
+ else:
+ _whirlpool_unaccelerated = True
+ _generate_hash_function("WHIRLPOOL", PyWhirlpool, origin="bundled-py")
# There is only one implementation for size
diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
index 7caa20f6e..8454a874a 100644
--- a/lib/portage/util/whirlpool.py
+++ b/lib/portage/util/whirlpool.py
@@ -110,19 +110,6 @@ class CWhirlpool:
return tempstr
-if WhirlpoolExt is not None:
- Whirlpool = CWhirlpool
-else:
- Whirlpool = PyWhirlpool
-
-
-def new(init=b""):
- """Return a new Whirlpool object. An optional string argument
- may be provided; if present, this string will be automatically
- hashed."""
- return Whirlpool(init)
-
-
#
# Private.
#