mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-04 14:08:39 +00:00
Add negative zero as an input to automatically generated tests
Although negative zero is officially unsupported, we've had bugs related to it in the past. So do test functions with a negative zero input. There will likely be cases where we don't want to accept negative zero as if it was valid, because it's too hard to handle. We'll add exceptions on a case by case basis. For the functions that are currently tested by the generated tests, the new test cases pass. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
ca6e8aac58
commit
35af02171d
2 changed files with 32 additions and 4 deletions
|
|
@ -38,7 +38,13 @@ def invmod(a: int, n: int) -> int:
|
|||
raise ValueError("Not invertible")
|
||||
|
||||
def hex_to_int(val: str) -> int:
|
||||
return int(val, 16) if val else 0
|
||||
"""Implement the syntax accepted by mbedtls_test_read_mpi().
|
||||
|
||||
This is a superset of what is accepted by mbedtls_test_read_mpi_core().
|
||||
"""
|
||||
if val == '' or val == '-':
|
||||
return 0
|
||||
return int(val, 16)
|
||||
|
||||
def quote_str(val) -> str:
|
||||
return "\"{}\"".format(val)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue