Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
54822f9f
Commit
54822f9f
authored
Sep 23, 2016
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test cases for internal SHA3 helpers
parent
48ee0469
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
Lib/test/test_hashlib.py
Lib/test/test_hashlib.py
+21
-0
No files found.
Lib/test/test_hashlib.py
View file @
54822f9f
...
...
@@ -339,6 +339,9 @@ class HashLibTestCase(unittest.TestCase):
self
.
check_blocksize_name
(
'sha256'
,
64
,
32
)
self
.
check_blocksize_name
(
'sha384'
,
128
,
48
)
self
.
check_blocksize_name
(
'sha512'
,
128
,
64
)
@
requires_sha3
def
test_blocksize_name_sha3
(
self
):
self
.
check_blocksize_name
(
'sha3_224'
,
144
,
28
)
self
.
check_blocksize_name
(
'sha3_256'
,
136
,
32
)
self
.
check_blocksize_name
(
'sha3_384'
,
104
,
48
)
...
...
@@ -346,6 +349,24 @@ class HashLibTestCase(unittest.TestCase):
self
.
check_blocksize_name
(
'shake_128'
,
168
,
0
,
32
)
self
.
check_blocksize_name
(
'shake_256'
,
136
,
0
,
64
)
def
check_sha3
(
self
,
name
,
capacity
,
rate
,
suffix
):
constructors
=
self
.
constructors_to_test
[
name
]
for
hash_object_constructor
in
constructors
:
m
=
hash_object_constructor
()
self
.
assertEqual
(
capacity
+
rate
,
1600
)
self
.
assertEqual
(
m
.
_capacity_bits
,
capacity
)
self
.
assertEqual
(
m
.
_rate_bits
,
rate
)
self
.
assertEqual
(
m
.
_suffix
,
suffix
)
@
requires_sha3
def
test_extra_sha3
(
self
):
self
.
check_sha3
(
'sha3_224'
,
448
,
1152
,
b'
\
x06
'
)
self
.
check_sha3
(
'sha3_256'
,
512
,
1088
,
b'
\
x06
'
)
self
.
check_sha3
(
'sha3_384'
,
768
,
832
,
b'
\
x06
'
)
self
.
check_sha3
(
'sha3_512'
,
1024
,
576
,
b'
\
x06
'
)
self
.
check_sha3
(
'shake_128'
,
256
,
1344
,
b'
\
x1f
'
)
self
.
check_sha3
(
'shake_256'
,
512
,
1088
,
b'
\
x1f
'
)
@
requires_blake2
def
test_blocksize_name_blake2
(
self
):
self
.
check_blocksize_name
(
'blake2b'
,
128
,
64
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment