Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 2/2] checksum: Add pycryptodome fallbacks for SHA3 and BLAKE2
Date: Wed, 01 Mar 2017 07:58:18
Message-Id: d3058087-0bcf-9655-ea1b-e5f8e6ec8b71@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 2/2] checksum: Add pycryptodome fallbacks for SHA3 and BLAKE2 by "Michał Górny"
1 On 02/28/2017 11:34 PM, Michał Górny wrote:
2 > ---
3 > pym/portage/checksum.py | 22 ++++++++++++++++++++++
4 > 1 file changed, 22 insertions(+)
5 >
6 > diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
7 > index fc38417a7..042a0a745 100644
8 > --- a/pym/portage/checksum.py
9 > +++ b/pym/portage/checksum.py
10 > @@ -116,6 +116,28 @@ try:
11 > except ImportError:
12 > pass
13 >
14 > +try:
15 > + # added in pycryptodome
16 > + from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
17 > + blake2bhash_ = getattr(BLAKE2b, 'new', None)
18 > + if blake2bhash_ is not None:
19 > + blake2bhash = _generate_hash_function("BLAKE2B",
20 > + blake2bhash_, origin="pycrypto")
21 > + blake2shash_ = getattr(BLAKE2s, 'new', None)
22 > + if blake2shash_ is not None:
23 > + blake2shash = _generate_hash_function("BLAKE2S",
24 > + blake2shash_, origin="pycrypto")
25 > + sha3_256hash_ = getattr(SHA3_256, 'new', None)
26 > + if sha3_256hash_ is not None:
27 > + sha3_256hash = _generate_hash_function("SHA3_256",
28 > + sha3_256hash_, origin="pycrypto")
29 > + sha3_512hash_ = getattr(SHA3_512, 'new', None)
30 > + if sha3_512hash_ is not None:
31 > + sha3_512hash = _generate_hash_function("SHA3_512",
32 > + sha3_512hash_, origin="pycrypto")
33 > +except ImportError:
34 > + pass
35 > +
36 > # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
37 > # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
38 > try:
39 >
40
41 Looks good.
42 --
43 Thanks,
44 Zac