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: Wed, 01 Mar 2017 15:43:22
Message-Id: 1488382959.929f27a8ee7025c3ed29715437dc6bbdbba01f21.mgorny@gentoo
1 commit: 929f27a8ee7025c3ed29715437dc6bbdbba01f21
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 28 22:22:43 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 1 15:42:39 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=929f27a8
7
8 checksum: Add pycryptodome fallbacks for SHA3 and BLAKE2
9
10 Approved-by: Zac Medico <zmedico <AT> gentoo.org>
11
12 pym/portage/checksum.py | 22 ++++++++++++++++++++++
13 1 file changed, 22 insertions(+)
14
15 diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
16 index fc38417a7..042a0a745 100644
17 --- a/pym/portage/checksum.py
18 +++ b/pym/portage/checksum.py
19 @@ -116,6 +116,28 @@ try:
20 except ImportError:
21 pass
22
23 +try:
24 + # added in pycryptodome
25 + from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
26 + blake2bhash_ = getattr(BLAKE2b, 'new', None)
27 + if blake2bhash_ is not None:
28 + blake2bhash = _generate_hash_function("BLAKE2B",
29 + blake2bhash_, origin="pycrypto")
30 + blake2shash_ = getattr(BLAKE2s, 'new', None)
31 + if blake2shash_ is not None:
32 + blake2shash = _generate_hash_function("BLAKE2S",
33 + blake2shash_, origin="pycrypto")
34 + sha3_256hash_ = getattr(SHA3_256, 'new', None)
35 + if sha3_256hash_ is not None:
36 + sha3_256hash = _generate_hash_function("SHA3_256",
37 + sha3_256hash_, origin="pycrypto")
38 + sha3_512hash_ = getattr(SHA3_512, 'new', None)
39 + if sha3_512hash_ is not None:
40 + sha3_512hash = _generate_hash_function("SHA3_512",
41 + sha3_512hash_, origin="pycrypto")
42 +except ImportError:
43 + pass
44 +
45 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
46 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
47 try: