commit: 5f0f383c852ede3368ede31f05eb6880a2f29455 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Tue Feb 28 08:17:51 2017 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Tue Feb 28 22:07:10 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5f0f383c
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 <AT> gentoo.org> pym/portage/checksum.py | 14 +++++++++++++- 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"