mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue #16113: integrade SHA-3 (Keccak) patch from http://hg.python.org/sandbox/cheimes
This commit is contained in:
parent
8c6db45d3e
commit
4a0270d82b
30 changed files with 7971 additions and 28 deletions
|
@ -54,7 +54,8 @@ More condensed:
|
|||
|
||||
# This tuple and __get_builtin_constructor() must be modified if a new
|
||||
# always available algorithm is added.
|
||||
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
|
||||
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
|
||||
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512')
|
||||
|
||||
algorithms_guaranteed = set(__always_supported)
|
||||
algorithms_available = set(__always_supported)
|
||||
|
@ -85,6 +86,18 @@ def __get_builtin_constructor(name):
|
|||
return _sha512.sha512
|
||||
elif bs == '384':
|
||||
return _sha512.sha384
|
||||
elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
|
||||
'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512'}:
|
||||
import _sha3
|
||||
bs = name[5:]
|
||||
if bs == '224':
|
||||
return _sha3.sha3_224
|
||||
elif bs == '256':
|
||||
return _sha3.sha3_256
|
||||
elif bs == '384':
|
||||
return _sha3.sha3_384
|
||||
elif bs == '512':
|
||||
return _sha3.sha3_512
|
||||
except ImportError:
|
||||
pass # no extension module, this hash is unsupported.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue