Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24e4330

Browse files
committed
* Issue #16113: Remove sha3 module again.
Patch by Christian Heimes, with modifications.
1 parent f3b46b4 commit 24e4330

38 files changed

Lines changed: 5 additions & 8844 deletions

Doc/library/hashlib.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ concatenation of the data fed to it so far using the :meth:`digest` or
6060

6161
Constructors for hash algorithms that are always present in this module are
6262
:func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`,
63-
:func:`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, and
64-
:func:`sha3_512`. Additional algorithms may also be available depending upon
63+
and :func:`sha512`. Additional algorithms may also be available depending upon
6564
the OpenSSL library that Python uses on your platform.
6665

67-
.. versionchanged:: 3.4
68-
Added sha3 family of hash algorithms.
69-
7066
For example, to obtain the digest of the byte string ``b'Nobody inspects the
7167
spammish repetition'``::
7268

Doc/license.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -590,25 +590,6 @@ The :mod:`select` and contains the following notice for the kqueue interface::
590590
SUCH DAMAGE.
591591

592592

593-
SHA-3
594-
-----
595-
596-
The module :mod:`_sha3` and :mod:`hashlib` are using the reference
597-
implementation of Keccak. The files at :file:`Modules/_sha3/keccak/` contain
598-
the following note::
599-
600-
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
601-
Michaël Peeters and Gilles Van Assche. For more information, feedback or
602-
questions, please refer to our website: http://keccak.noekeon.org/
603-
604-
Implementation by the designers,
605-
hereby denoted as "the implementer".
606-
607-
To the extent possible under law, the implementer has waived all copyright
608-
and related or neighboring rights to the source code in this file.
609-
http://creativecommons.org/publicdomain/zero/1.0/
610-
611-
612593
SipHash24
613594
---------
614595

Doc/whatsnew/3.4.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ Significantly Improved Library Modules:
123123
* :ref:`Single-dispatch generic functions <whatsnew-singledispatch>` in
124124
:mod:`functools` (:pep:`443`).
125125
* New :mod:`pickle` :ref:`protocol 4 <whatsnew-protocol-4>` (:pep:`3154`).
126-
* :ref:`SHA-3 (Keccak) support <whatsnew-sha3>` for :mod:`hashlib`
127-
(:issue:`16113`).
128126
* :ref:`TLSv1.1 and TLSv1.2 support <whatsnew-tls-11-12>` for :mod:`ssl`
129127
(:issue:`16692`).
130128
* :mod:`multiprocessing` now has :ref:`an option to avoid using os.fork
@@ -667,12 +665,6 @@ hashlib
667665
New :func:`hashlib.pbkdf2_hmac` function.
668666
(Contributed by Christian Heimes in :issue:`18582`)
669667

670-
.. _whatsnew-sha3:
671-
672-
New :ref:`hash algorithms <hash-algorithms>` ``sha3_224()``, ``sha3_256()``,
673-
``sha3_384()``, and ``sha3_512()``. (Contributed by Christian Heimes in
674-
:issue:`16113`.)
675-
676668

677669
html
678670
----

Lib/hashlib.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454

5555
# This tuple and __get_builtin_constructor() must be modified if a new
5656
# always available algorithm is added.
57-
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
58-
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512')
57+
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
5958

6059
algorithms_guaranteed = set(__always_supported)
6160
algorithms_available = set(__always_supported)
@@ -86,13 +85,6 @@ def __get_builtin_constructor(name):
8685
import _sha512
8786
cache['SHA384'] = cache['sha384'] = _sha512.sha384
8887
cache['SHA512'] = cache['sha512'] = _sha512.sha512
89-
elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
90-
'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512'}:
91-
import _sha3
92-
cache['SHA3_224'] = cache['sha3_224'] = _sha3.sha3_224
93-
cache['SHA3_256'] = cache['sha3_256'] = _sha3.sha3_256
94-
cache['SHA3_384'] = cache['sha3_384'] = _sha3.sha3_384
95-
cache['SHA3_512'] = cache['sha3_512'] = _sha3.sha3_512
9688
except ImportError:
9789
pass # no extension module, this hash is unsupported.
9890

Lib/test/test_hashlib.py

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ def hexstr(s):
3838
class HashLibTestCase(unittest.TestCase):
3939
supported_hash_names = ( 'md5', 'MD5', 'sha1', 'SHA1',
4040
'sha224', 'SHA224', 'sha256', 'SHA256',
41-
'sha384', 'SHA384', 'sha512', 'SHA512',
42-
'sha3_224', 'sha3_256', 'sha3_384',
43-
'sha3_512', 'SHA3_224', 'SHA3_256',
44-
'SHA3_384', 'SHA3_512' )
41+
'sha384', 'SHA384', 'sha512', 'SHA512')
4542

4643
# Issue #14693: fallback modules are always compiled under POSIX
4744
_warn_on_extension_import = os.name == 'posix' or COMPILED_WITH_PYDEBUG
@@ -102,12 +99,6 @@ def add_builtin_constructor(name):
10299
if _sha512:
103100
add_builtin_constructor('sha384')
104101
add_builtin_constructor('sha512')
105-
_sha3 = self._conditional_import_module('_sha3')
106-
if _sha3:
107-
add_builtin_constructor('sha3_224')
108-
add_builtin_constructor('sha3_256')
109-
add_builtin_constructor('sha3_384')
110-
add_builtin_constructor('sha3_512')
111102

112103
super(HashLibTestCase, self).__init__(*args, **kwargs)
113104

@@ -234,10 +225,6 @@ def test_no_unicode(self):
234225
self.check_no_unicode('sha256')
235226
self.check_no_unicode('sha384')
236227
self.check_no_unicode('sha512')
237-
self.check_no_unicode('sha3_224')
238-
self.check_no_unicode('sha3_256')
239-
self.check_no_unicode('sha3_384')
240-
self.check_no_unicode('sha3_512')
241228

242229
def check_blocksize_name(self, name, block_size=0, digest_size=0):
243230
constructors = self.constructors_to_test[name]
@@ -257,10 +244,6 @@ def test_blocksize_name(self):
257244
self.check_blocksize_name('sha256', 64, 32)
258245
self.check_blocksize_name('sha384', 128, 48)
259246
self.check_blocksize_name('sha512', 128, 64)
260-
self.check_blocksize_name('sha3_224', NotImplemented, 28)
261-
self.check_blocksize_name('sha3_256', NotImplemented, 32)
262-
self.check_blocksize_name('sha3_384', NotImplemented, 48)
263-
self.check_blocksize_name('sha3_512', NotImplemented, 64)
264247

265248
def test_case_md5_0(self):
266249
self.check('md5', b'', 'd41d8cd98f00b204e9800998ecf8427e')
@@ -396,27 +379,6 @@ def test_case_sha512_3(self):
396379
"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"+
397380
"de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b")
398381

399-
# SHA-3 family
400-
def test_case_sha3_224_0(self):
401-
self.check('sha3_224', b"",
402-
"F71837502BA8E10837BDD8D365ADB85591895602FC552B48B7390ABD")
403-
404-
def test_case_sha3_224_1(self):
405-
self.check('sha3_224', bytes.fromhex("CC"),
406-
"A9CAB59EB40A10B246290F2D6086E32E3689FAF1D26B470C899F2802")
407-
408-
def test_case_sha3_224_2(self):
409-
self.check('sha3_224', bytes.fromhex("41FB"),
410-
"615BA367AFDC35AAC397BC7EB5D58D106A734B24986D5D978FEFD62C")
411-
412-
def test_case_sha3_224_3(self):
413-
self.check('sha3_224', bytes.fromhex(
414-
"433C5303131624C0021D868A30825475E8D0BD3052A022180398F4CA4423B9"+
415-
"8214B6BEAAC21C8807A2C33F8C93BD42B092CC1B06CEDF3224D5ED1EC29784"+
416-
"444F22E08A55AA58542B524B02CD3D5D5F6907AFE71C5D7462224A3F9D9E53"+
417-
"E7E0846DCBB4CE"),
418-
"62B10F1B6236EBC2DA72957742A8D4E48E213B5F8934604BFD4D2C3A")
419-
420382
@bigmemtest(size=_4G + 5, memuse=1)
421383
def test_case_sha3_224_huge(self, size):
422384
if size == _4G + 5:
@@ -426,78 +388,6 @@ def test_case_sha3_224_huge(self, size):
426388
except OverflowError:
427389
pass # 32-bit arch
428390

429-
430-
def test_case_sha3_256_0(self):
431-
self.check('sha3_256', b"",
432-
"C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470")
433-
434-
def test_case_sha3_256_1(self):
435-
self.check('sha3_256', bytes.fromhex("CC"),
436-
"EEAD6DBFC7340A56CAEDC044696A168870549A6A7F6F56961E84A54BD9970B8A")
437-
438-
def test_case_sha3_256_2(self):
439-
self.check('sha3_256', bytes.fromhex("41FB"),
440-
"A8EACEDA4D47B3281A795AD9E1EA2122B407BAF9AABCB9E18B5717B7873537D2")
441-
442-
def test_case_sha3_256_3(self):
443-
self.check('sha3_256', bytes.fromhex(
444-
"433C5303131624C0021D868A30825475E8D0BD3052A022180398F4CA4423B9"+
445-
"8214B6BEAAC21C8807A2C33F8C93BD42B092CC1B06CEDF3224D5ED1EC29784"+
446-
"444F22E08A55AA58542B524B02CD3D5D5F6907AFE71C5D7462224A3F9D9E53"+
447-
"E7E0846DCBB4CE"),
448-
"CE87A5173BFFD92399221658F801D45C294D9006EE9F3F9D419C8D427748DC41")
449-
450-
451-
def test_case_sha3_384_0(self):
452-
self.check('sha3_384', b"",
453-
"2C23146A63A29ACF99E73B88F8C24EAA7DC60AA771780CCC006AFBFA8FE2479B"+
454-
"2DD2B21362337441AC12B515911957FF")
455-
456-
def test_case_sha3_384_1(self):
457-
self.check('sha3_384', bytes.fromhex("CC"),
458-
"1B84E62A46E5A201861754AF5DC95C4A1A69CAF4A796AE405680161E29572641"+
459-
"F5FA1E8641D7958336EE7B11C58F73E9")
460-
461-
def test_case_sha3_384_2(self):
462-
self.check('sha3_384', bytes.fromhex("41FB"),
463-
"495CCE2714CD72C8C53C3363D22C58B55960FE26BE0BF3BBC7A3316DD563AD1D"+
464-
"B8410E75EEFEA655E39D4670EC0B1792")
465-
466-
def test_case_sha3_384_3(self):
467-
self.check('sha3_384', bytes.fromhex(
468-
"433C5303131624C0021D868A30825475E8D0BD3052A022180398F4CA4423B9"+
469-
"8214B6BEAAC21C8807A2C33F8C93BD42B092CC1B06CEDF3224D5ED1EC29784"+
470-
"444F22E08A55AA58542B524B02CD3D5D5F6907AFE71C5D7462224A3F9D9E53"+
471-
"E7E0846DCBB4CE"),
472-
"135114508DD63E279E709C26F7817C0482766CDE49132E3EDF2EEDD8996F4E35"+
473-
"96D184100B384868249F1D8B8FDAA2C9")
474-
475-
476-
def test_case_sha3_512_0(self):
477-
self.check('sha3_512', b"",
478-
"0EAB42DE4C3CEB9235FC91ACFFE746B29C29A8C366B7C60E4E67C466F36A4304"+
479-
"C00FA9CAF9D87976BA469BCBE06713B435F091EF2769FB160CDAB33D3670680E")
480-
481-
def test_case_sha3_512_1(self):
482-
self.check('sha3_512', bytes.fromhex("CC"),
483-
"8630C13CBD066EA74BBE7FE468FEC1DEE10EDC1254FB4C1B7C5FD69B646E4416"+
484-
"0B8CE01D05A0908CA790DFB080F4B513BC3B6225ECE7A810371441A5AC666EB9")
485-
486-
def test_case_sha3_512_2(self):
487-
self.check('sha3_512', bytes.fromhex("41FB"),
488-
"551DA6236F8B96FCE9F97F1190E901324F0B45E06DBBB5CDB8355D6ED1DC34B3"+
489-
"F0EAE7DCB68622FF232FA3CECE0D4616CDEB3931F93803662A28DF1CD535B731")
490-
491-
def test_case_sha3_512_3(self):
492-
self.check('sha3_512', bytes.fromhex(
493-
"433C5303131624C0021D868A30825475E8D0BD3052A022180398F4CA4423B9"+
494-
"8214B6BEAAC21C8807A2C33F8C93BD42B092CC1B06CEDF3224D5ED1EC29784"+
495-
"444F22E08A55AA58542B524B02CD3D5D5F6907AFE71C5D7462224A3F9D9E53"+
496-
"E7E0846DCBB4CE"),
497-
"527D28E341E6B14F4684ADB4B824C496C6482E51149565D3D17226828884306B"+
498-
"51D6148A72622C2B75F5D3510B799D8BDC03EAEDE453676A6EC8FE03A1AD0EAB")
499-
500-
501391
def test_gil(self):
502392
# Check things work fine with an input larger than the size required
503393
# for multithreaded operation (which is hardwired to 2048).

Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ coverage-lcov:
501501
: # remove 3rd party modules and system headers
502502
@lcov --remove $(COVERAGE_INFO) \
503503
'*/Modules/_ctypes/libffi*/*' \
504-
'*/Modules/_sha3/keccak/*' \
505504
'*/Modules/_decimal/libmpdec/*' \
506505
'*/Modules/expat/*' \
507506
'*/Modules/zlib/*' \

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Core and Builtins
4646
Library
4747
-------
4848

49+
- Issue #16113: Remove sha3 module again.
50+
4951
- Issue #20111: pathlib.Path.with_suffix() now sanity checks the given suffix.
5052

5153
- Fix breakage in TestSuite.countTestCases() introduced by issue #11798.

Modules/_sha3/cleanup.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)