public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-portage-dev] [PATCH 3/3] checksum: Add blake2* and sha3 hashes from hashlib 3.6+
  @ 2017-02-28  9:01 99% ` Michał Górny
  0 siblings, 0 replies; 1+ results
From: Michał Górny @ 2017-02-28  9:01 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Add initial support for using the new SHA3_256 and SHA3_512, as well
as competetive BLAKE2b and BLAKE2s hashes that are now provided
in hashlib module of Python 3.6.
---
 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"
 
-- 
2.12.0



^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-02-28  9:01     [gentoo-portage-dev] [PATCHES] Little cleanup of checksum + BLAKE2*/SHA3 Michał Górny
2017-02-28  9:01 99% ` [gentoo-portage-dev] [PATCH 3/3] checksum: Add blake2* and sha3 hashes from hashlib 3.6+ Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox