oconnor663 / blake3-py

Python bindings for the BLAKE3 cryptographic hash function
Other
139 stars 12 forks source link

c_impl: fix usedforsecurity argument variable type, fixes #34 #35

Closed ThomasWaldmann closed 2 years ago

ThomasWaldmann commented 2 years ago

the python docs state that this must be int (not: bool).

as seen in #34, using the wrong type here seems to overflow the variable and leads to a wrong value in max_threads, which leads to that strange test failure.

ThomasWaldmann commented 2 years ago

After rebasing this on top of my apple-build-fix PR:

============================================================= test session starts ==============================================================
platform darwin -- Python 3.9.10, pytest-7.1.1, pluggy-1.0.0 -- /Users/tw/w/blake3-py-env/bin/python3.9
cachedir: .pytest_cache
rootdir: /Users/tw/w/blake3-py
collected 25 items                                                                                                                             

tests/test_blake3.py::test_vectors PASSED                                                                                                [  4%]
tests/test_blake3.py::test_buffer_types PASSED                                                                                           [  8%]
tests/test_blake3.py::test_key_types PASSED                                                                                              [ 12%]
tests/test_blake3.py::test_invalid_key_lengths PASSED                                                                                    [ 16%]
tests/test_blake3.py::test_int_array_fails PASSED                                                                                        [ 20%]
tests/test_blake3.py::test_strided_array_fails PASSED                                                                                    [ 24%]
tests/test_blake3.py::test_string_fails PASSED                                                                                           [ 28%]
tests/test_blake3.py::test_constants PASSED                                                                                              [ 32%]
tests/test_blake3.py::test_example_dot_py PASSED                                                                                         [ 36%]
tests/test_blake3.py::test_xof PASSED                                                                                                    [ 40%]
tests/test_blake3.py::test_max_threads_value PASSED                                                                                      [ 44%]
tests/test_blake3.py::test_max_threads_auto PASSED                                                                                       [ 48%]
tests/test_blake3.py::test_key_context_incompatible PASSED                                                                               [ 52%]
tests/test_blake3.py::test_name PASSED                                                                                                   [ 56%]
tests/test_blake3.py::test_copy_basic PASSED                                                                                             [ 60%]
tests/test_blake3.py::test_copy_with_threads PASSED                                                                                      [ 64%]
tests/test_blake3.py::test_version PASSED                                                                                                [ 68%]
tests/test_blake3.py::test_invalid_max_threads PASSED                                                                                    [ 72%]
tests/test_blake3.py::test_positional_only_arguments PASSED                                                                              [ 76%]
tests/test_blake3.py::test_keyword_only_arguments PASSED                                                                                 [ 80%]
tests/test_blake3.py::test_usedforsecurity_ignored PASSED                                                                                [ 84%]
tests/test_blake3.py::test_context_must_be_str PASSED                                                                                    [ 88%]
tests/test_blake3.py::test_buffers_released PASSED                                                                                       [ 92%]
tests/test_blake3.py::test_reset PASSED                                                                                                  [ 96%]
tests/test_blake3.py::test_output_overflows_isize PASSED                                                                                 [100%]

============================================================== 25 passed in 0.52s ==============================================================