diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-02-28 09:17:51 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-02-28 23:07:10 +0100 |
commit | 5f0f383c852ede3368ede31f05eb6880a2f29455 (patch) | |
tree | 542caf6f9446d77be726c5442aa83604bba99c98 | |
parent | checksum: Remove redundant internal fallbacks (diff) | |
download | portage-5f0f383c852ede3368ede31f05eb6880a2f29455.tar.gz portage-5f0f383c852ede3368ede31f05eb6880a2f29455.tar.bz2 portage-5f0f383c852ede3368ede31f05eb6880a2f29455.zip |
checksum: Add blake2* and sha3 hashes from hashlib 3.6+
Add initial support for using the new SHA3_256 and SHA3_512, as well
as competitive BLAKE2b and BLAKE2s hashes that are now provided
in hashlib module of Python 3.6.
Approved-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r-- | pym/portage/checksum.py | 14 | ||||
-rw-r--r-- | pym/portage/const.py | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 8b4d96e30..a46b820af 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -24,6 +24,10 @@ import tempfile # SHA512: hashlib, mhash # RMD160: hashlib, pycrypto, mhash # WHIRLPOOL: hashlib, mhash, bundled +# BLAKE2B (512): hashlib (3.6+) +# BLAKE2S (512): hashlib (3.6+) +# SHA3_256: hashlib (3.6+) +# SHA3_512: hashlib (3.6+) #dict of all available hash functions @@ -121,7 +125,15 @@ try: sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib") sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib") sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib") - for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")): + for local_name, hash_name in ( + ("rmd160", "ripemd160"), + ("whirlpool", "whirlpool"), + # available since Python 3.6 + ("BLAKE2B", "blake2b"), + ("BLAKE2S", "blake2s"), + ("SHA3_256", "sha3_256"), + ("SHA3_512", "sha3_512"), + ): try: hashlib.new(hash_name) except ValueError: diff --git a/pym/portage/const.py b/pym/portage/const.py index 179efce98..0cef2e8ae 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -224,9 +224,6 @@ MANIFEST1_REQUIRED_HASH = "MD5" # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows: # manifest-hashes = SHA512 WHIRLPOOL # -# After SHA-3 is approved: -# - Add new hashes to MANIFEST2_HASH_*. -# # After SHA-3 is supported in stable portage: # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows: # manifest-hashes = SHA3 SHA512 WHIRLPOOL @@ -234,7 +231,8 @@ MANIFEST1_REQUIRED_HASH = "MD5" # After layout.conf settings correspond to defaults in stable portage: # - Remove redundant settings from gentoo-x86/metadata/layout.conf. -MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL") +MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL", + "BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512") MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"]) MANIFEST2_REQUIRED_HASH = "SHA256" |