1 |
--- |
2 |
.travis.yml | 2 ++ |
3 |
pym/portage/checksum.py | 15 +++++++++++++-- |
4 |
2 files changed, 15 insertions(+), 2 deletions(-) |
5 |
|
6 |
diff --git a/.travis.yml b/.travis.yml |
7 |
index 20078530e..ebcfbeab9 100644 |
8 |
--- a/.travis.yml |
9 |
+++ b/.travis.yml |
10 |
@@ -12,6 +12,8 @@ install: |
11 |
# python3.6+ has sha3 built-in, for older versions install pysha3 |
12 |
# (except for pypy where pysha3 is broken) |
13 |
- "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] || ${TRAVIS_PYTHON_VERSION} == pypy ]] || pip install pysha3" |
14 |
+ # python3.6+ has blake2 built-in, for older versions install pyblake2 |
15 |
+ - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" |
16 |
# always install pygost for Streebog |
17 |
- pip install pygost |
18 |
|
19 |
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
20 |
index ff132751b..ad090ddb3 100644 |
21 |
--- a/pym/portage/checksum.py |
22 |
+++ b/pym/portage/checksum.py |
23 |
@@ -27,8 +27,8 @@ import tempfile |
24 |
# SHA512: hashlib |
25 |
# RMD160: hashlib, pycrypto, mhash |
26 |
# WHIRLPOOL: hashlib, mhash, bundled |
27 |
-# BLAKE2B (512): hashlib (3.6+), pycrypto |
28 |
-# BLAKE2S (512): hashlib (3.6+), pycrypto |
29 |
+# BLAKE2B (512): hashlib (3.6+), pyblake2, pycrypto |
30 |
+# BLAKE2S (512): hashlib (3.6+), pyblake2, pycrypto |
31 |
# SHA3_256: hashlib (3.6+), pysha3, pycrypto |
32 |
# SHA3_512: hashlib (3.6+), pysha3, pycrypto |
33 |
|
34 |
@@ -124,6 +124,17 @@ for local_name, hash_name in ( |
35 |
origin='hashlib') |
36 |
|
37 |
|
38 |
+# Support using pyblake2 as fallback for python<3.6 |
39 |
+if "BLAKE2B" not in hashfunc_map or "BLAKE2S" not in hashfunc_map: |
40 |
+ try: |
41 |
+ import pyblake2 |
42 |
+ |
43 |
+ _generate_hash_function("BLAKE2B", pyblake2.blake2b, origin="pyblake2") |
44 |
+ _generate_hash_function("BLAKE2S", pyblake2.blake2s, origin="pyblake2") |
45 |
+ except ImportError: |
46 |
+ pass |
47 |
+ |
48 |
+ |
49 |
# Support using pysha3 as fallback for python<3.6 |
50 |
if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map: |
51 |
try: |
52 |
-- |
53 |
2.15.0.rc1 |