Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 06/14] portage.checksum: Fix BLAKE2* fallbacks from pycryptodome
Date: Sun, 12 Mar 2017 19:01:56
Message-Id: 20170312190011.3234-7-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCHES] portage.checksum hacking, pt. 4 by "Michał Górny"
1 Fix BLAKE2* fallback functions to explicitly provide digest length as
2 required by pycryptodome.
3 ---
4 pym/portage/checksum.py | 6 ++++--
5 1 file changed, 4 insertions(+), 2 deletions(-)
6
7 diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
8 index 9ba251f29..82e8bec00 100644
9 --- a/pym/portage/checksum.py
10 +++ b/pym/portage/checksum.py
11 @@ -132,14 +132,16 @@ except ImportError:
12 try:
13 # added in pycryptodome
14 from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
15 + import functools
16 +
17 blake2bhash_ = getattr(BLAKE2b, 'new', None)
18 if blake2bhash_ is not None:
19 blake2bhash = _generate_hash_function("BLAKE2B",
20 - blake2bhash_, origin="pycrypto")
21 + functools.partial(blake2bhash_, digest_bytes=64), origin="pycrypto")
22 blake2shash_ = getattr(BLAKE2s, 'new', None)
23 if blake2shash_ is not None:
24 blake2shash = _generate_hash_function("BLAKE2S",
25 - blake2shash_, origin="pycrypto")
26 + functools.partial(blake2shash_, digest_bytes=32), origin="pycrypto")
27 sha3_256hash_ = getattr(SHA3_256, 'new', None)
28 if sha3_256hash_ is not None:
29 sha3_256hash = _generate_hash_function("SHA3_256",
30 --
31 2.12.0