Skip to content

Commit c79c437

Browse files
committed
fix st_fuzzed_sig
in case all the bytes of the signature were removed, there are no bytes to change, so the selection of which bytes to change fails run that code only if there is anything left of the old signature
1 parent ca11bcb commit c79c437

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ecdsa/test_malformed_sigs.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ def st_fuzzed_sig(draw, keys_and_sigs):
8282
note("Remove bytes: {0}".format(to_remove))
8383

8484
# decide which bytes of the original signature should be changed
85-
xors = draw(st.dictionaries(
86-
st.integers(min_value=0, max_value=len(sig)-1),
87-
st.integers(min_value=1, max_value=255)))
88-
for i, val in xors.items():
89-
sig[i] ^= val
90-
note("xors: {0}".format(xors))
85+
if sig:
86+
xors = draw(st.dictionaries(
87+
st.integers(min_value=0, max_value=len(sig)-1),
88+
st.integers(min_value=1, max_value=255)))
89+
for i, val in xors.items():
90+
sig[i] ^= val
91+
note("xors: {0}".format(xors))
9192

9293
# decide where new data should be inserted
9394
insert_pos = draw(st.integers(min_value=0, max_value=len(sig)))

0 commit comments

Comments
 (0)