1 |
pysha3 provides a stand-alone FIPS-compliant SHA3 implementation that |
2 |
can be used as a fallback for Python < 3.6. |
3 |
--- |
4 |
pym/portage/checksum.py | 14 ++++++++++++-- |
5 |
1 file changed, 12 insertions(+), 2 deletions(-) |
6 |
|
7 |
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
8 |
index ac11d3f4b..3e61acdec 100644 |
9 |
--- a/pym/portage/checksum.py |
10 |
+++ b/pym/portage/checksum.py |
11 |
@@ -10,6 +10,7 @@ from portage import _encodings |
12 |
from portage import _unicode_decode, _unicode_encode |
13 |
import errno |
14 |
import stat |
15 |
+import sys |
16 |
import subprocess |
17 |
import tempfile |
18 |
|
19 |
@@ -26,8 +27,8 @@ import tempfile |
20 |
# WHIRLPOOL: hashlib, mhash, bundled |
21 |
# BLAKE2B (512): hashlib (3.6+), pycrypto |
22 |
# BLAKE2S (512): hashlib (3.6+), pycrypto |
23 |
-# SHA3_256: hashlib (3.6+), pycrypto |
24 |
-# SHA3_512: hashlib (3.6+), pycrypto |
25 |
+# SHA3_256: hashlib (3.6+), pysha3, pycrypto |
26 |
+# SHA3_512: hashlib (3.6+), pysha3, pycrypto |
27 |
|
28 |
|
29 |
#dict of all available hash functions |
30 |
@@ -138,6 +139,15 @@ try: |
31 |
except ImportError: |
32 |
pass |
33 |
|
34 |
+# Support using pysha3 as fallback for python<3.6 |
35 |
+try: |
36 |
+ import sha3 |
37 |
+ |
38 |
+ sha3_256hash = _generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3") |
39 |
+ sha3_512hash = _generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3") |
40 |
+except ImportError: |
41 |
+ pass |
42 |
+ |
43 |
# Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks. |
44 |
# Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib. |
45 |
try: |
46 |
-- |
47 |
2.12.0 |