1 |
Add initial support for using the new SHA3_256 and SHA3_512, as well |
2 |
as competetive BLAKE2b and BLAKE2s hashes that are now provided |
3 |
in hashlib module of Python 3.6. |
4 |
--- |
5 |
pym/portage/checksum.py | 14 +++++++++++++- |
6 |
pym/portage/const.py | 6 ++---- |
7 |
2 files changed, 15 insertions(+), 5 deletions(-) |
8 |
|
9 |
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
10 |
index 8b4d96e30..a46b820af 100644 |
11 |
--- a/pym/portage/checksum.py |
12 |
+++ b/pym/portage/checksum.py |
13 |
@@ -24,6 +24,10 @@ import tempfile |
14 |
# SHA512: hashlib, mhash |
15 |
# RMD160: hashlib, pycrypto, mhash |
16 |
# WHIRLPOOL: hashlib, mhash, bundled |
17 |
+# BLAKE2B (512): hashlib (3.6+) |
18 |
+# BLAKE2S (512): hashlib (3.6+) |
19 |
+# SHA3_256: hashlib (3.6+) |
20 |
+# SHA3_512: hashlib (3.6+) |
21 |
|
22 |
|
23 |
#dict of all available hash functions |
24 |
@@ -121,7 +125,15 @@ try: |
25 |
sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib") |
26 |
sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib") |
27 |
sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib") |
28 |
- for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")): |
29 |
+ for local_name, hash_name in ( |
30 |
+ ("rmd160", "ripemd160"), |
31 |
+ ("whirlpool", "whirlpool"), |
32 |
+ # available since Python 3.6 |
33 |
+ ("BLAKE2B", "blake2b"), |
34 |
+ ("BLAKE2S", "blake2s"), |
35 |
+ ("SHA3_256", "sha3_256"), |
36 |
+ ("SHA3_512", "sha3_512"), |
37 |
+ ): |
38 |
try: |
39 |
hashlib.new(hash_name) |
40 |
except ValueError: |
41 |
diff --git a/pym/portage/const.py b/pym/portage/const.py |
42 |
index 179efce98..0cef2e8ae 100644 |
43 |
--- a/pym/portage/const.py |
44 |
+++ b/pym/portage/const.py |
45 |
@@ -224,9 +224,6 @@ MANIFEST1_REQUIRED_HASH = "MD5" |
46 |
# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows: |
47 |
# manifest-hashes = SHA512 WHIRLPOOL |
48 |
# |
49 |
-# After SHA-3 is approved: |
50 |
-# - Add new hashes to MANIFEST2_HASH_*. |
51 |
-# |
52 |
# After SHA-3 is supported in stable portage: |
53 |
# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows: |
54 |
# manifest-hashes = SHA3 SHA512 WHIRLPOOL |
55 |
@@ -234,7 +231,8 @@ MANIFEST1_REQUIRED_HASH = "MD5" |
56 |
# After layout.conf settings correspond to defaults in stable portage: |
57 |
# - Remove redundant settings from gentoo-x86/metadata/layout.conf. |
58 |
|
59 |
-MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL") |
60 |
+MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL", |
61 |
+ "BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512") |
62 |
MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"]) |
63 |
MANIFEST2_REQUIRED_HASH = "SHA256" |
64 |
|
65 |
-- |
66 |
2.12.0 |