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