Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: /, pym/portage/
Date: Fri, 20 Oct 2017 21:51:44
Message-Id: 1508536297.3140392cd396a8e76525d95758ec71c8b3871a06.mgorny@gentoo
1 commit: 3140392cd396a8e76525d95758ec71c8b3871a06
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Oct 20 18:58:56 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Fri Oct 20 21:51:37 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3140392c
7
8 portage.checksum: Support pyblake2 fallback for BLAKE2 hashes
9
10 Approved-by: Zac Medico <zmedico <AT> gentoo.org>
11 Closes: https://github.com/gentoo/portage/pull/222
12
13 .travis.yml | 2 ++
14 pym/portage/checksum.py | 15 +++++++++++++--
15 2 files changed, 15 insertions(+), 2 deletions(-)
16
17 diff --git a/.travis.yml b/.travis.yml
18 index 20078530e..ebcfbeab9 100644
19 --- a/.travis.yml
20 +++ b/.travis.yml
21 @@ -12,6 +12,8 @@ install:
22 # python3.6+ has sha3 built-in, for older versions install pysha3
23 # (except for pypy where pysha3 is broken)
24 - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] || ${TRAVIS_PYTHON_VERSION} == pypy ]] || pip install pysha3"
25 + # python3.6+ has blake2 built-in, for older versions install pyblake2
26 + - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2"
27 # always install pygost for Streebog
28 - pip install pygost
29
30
31 diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
32 index ff132751b..ad090ddb3 100644
33 --- a/pym/portage/checksum.py
34 +++ b/pym/portage/checksum.py
35 @@ -27,8 +27,8 @@ import tempfile
36 # SHA512: hashlib
37 # RMD160: hashlib, pycrypto, mhash
38 # WHIRLPOOL: hashlib, mhash, bundled
39 -# BLAKE2B (512): hashlib (3.6+), pycrypto
40 -# BLAKE2S (512): hashlib (3.6+), pycrypto
41 +# BLAKE2B (512): hashlib (3.6+), pyblake2, pycrypto
42 +# BLAKE2S (512): hashlib (3.6+), pyblake2, pycrypto
43 # SHA3_256: hashlib (3.6+), pysha3, pycrypto
44 # SHA3_512: hashlib (3.6+), pysha3, pycrypto
45
46 @@ -124,6 +124,17 @@ for local_name, hash_name in (
47 origin='hashlib')
48
49
50 +# Support using pyblake2 as fallback for python<3.6
51 +if "BLAKE2B" not in hashfunc_map or "BLAKE2S" not in hashfunc_map:
52 + try:
53 + import pyblake2
54 +
55 + _generate_hash_function("BLAKE2B", pyblake2.blake2b, origin="pyblake2")
56 + _generate_hash_function("BLAKE2S", pyblake2.blake2s, origin="pyblake2")
57 + except ImportError:
58 + pass
59 +
60 +
61 # Support using pysha3 as fallback for python<3.6
62 if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map:
63 try: