Skip to content

Commit 87ef2b2

Browse files
committed
faster ecdh and malformed_sigs tests in mutation testing
1 parent 8c2531f commit 87ef2b2

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/ecdsa/test_ecdh.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import shutil
34
import subprocess
45
import pytest
@@ -16,6 +17,8 @@
1617
NIST384p,
1718
NIST521p,
1819
BRAINPOOLP160r1,
20+
SECP112r2,
21+
SECP128r1,
1922
)
2023
from .curves import curves
2124
from .ecdh import (
@@ -29,6 +32,10 @@
2932
from .ellipticcurve import CurveEdTw
3033

3134

35+
if "--fast" in sys.argv:
36+
curves = [SECP112r2, SECP128r1]
37+
38+
3239
@pytest.mark.parametrize(
3340
"vcurve",
3441
curves,

src/ecdsa/test_malformed_sigs.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from .keys import BadSignatureError
3232
from .util import sigencode_der, sigencode_string
3333
from .util import sigdecode_der, sigdecode_string
34-
from .curves import curves
34+
from .curves import curves, SECP112r2, SECP128r1
3535
from .der import (
3636
encode_integer,
3737
encode_bitstring,
@@ -55,6 +55,10 @@
5555
bigger than order sizes of curves."""
5656

5757

58+
if "--fast" in sys.argv: # pragma: no cover
59+
curves = [SECP112r2, SECP128r1]
60+
61+
5862
keys_and_sigs = []
5963
"""Name of the curve+hash combination, VerifyingKey and DER signature."""
6064

@@ -91,7 +95,7 @@ def test_signatures(verifying_key, signature):
9195

9296

9397
@st.composite
94-
def st_fuzzed_sig(draw, keys_and_sigs):
98+
def st_fuzzed_sig(draw, keys_and_sigs): # pragma: no cover
9599
"""
96100
Hypothesis strategy that generates pairs of VerifyingKey and malformed
97101
signatures created by fuzzing of a valid signature.
@@ -174,7 +178,7 @@ def test_fuzzed_der_signatures(args):
174178

175179

176180
@st.composite
177-
def st_random_der_ecdsa_sig_value(draw):
181+
def st_random_der_ecdsa_sig_value(draw): # pragma: no cover
178182
"""
179183
Hypothesis strategy for selecting random values and encoding them
180184
to ECDSA-Sig-Value object::
@@ -220,7 +224,7 @@ def test_random_der_ecdsa_sig_value(params):
220224
verifying_key.verify(sig, example_data, sigdecode=sigdecode_der)
221225

222226

223-
def st_der_integer(*args, **kwargs):
227+
def st_der_integer(*args, **kwargs): # pragma: no cover
224228
"""
225229
Hypothesis strategy that returns a random positive integer as DER
226230
INTEGER.
@@ -232,7 +236,7 @@ def st_der_integer(*args, **kwargs):
232236

233237

234238
@st.composite
235-
def st_der_bit_string(draw, *args, **kwargs):
239+
def st_der_bit_string(draw, *args, **kwargs): # pragma: no cover
236240
"""
237241
Hypothesis strategy that returns a random DER BIT STRING.
238242
Parameters are passed to hypothesis.strategy.binary.
@@ -248,23 +252,23 @@ def st_der_bit_string(draw, *args, **kwargs):
248252
return encode_bitstring(data, unused)
249253

250254

251-
def st_der_octet_string(*args, **kwargs):
255+
def st_der_octet_string(*args, **kwargs): # pragma: no cover
252256
"""
253257
Hypothesis strategy that returns a random DER OCTET STRING object.
254258
Parameters are passed to hypothesis.strategy.binary
255259
"""
256260
return st.builds(encode_octet_string, st.binary(*args, **kwargs))
257261

258262

259-
def st_der_null():
263+
def st_der_null(): # pragma: no cover
260264
"""
261265
Hypothesis strategy that returns DER NULL object.
262266
"""
263267
return st.just(b"\x05\x00")
264268

265269

266270
@st.composite
267-
def st_der_oid(draw):
271+
def st_der_oid(draw): # pragma: no cover
268272
"""
269273
Hypothesis strategy that returns DER OBJECT IDENTIFIER objects.
270274
"""
@@ -279,7 +283,7 @@ def st_der_oid(draw):
279283
return encode_oid(first, second, *rest)
280284

281285

282-
def st_der():
286+
def st_der(): # pragma: no cover
283287
"""
284288
Hypothesis strategy that returns random DER structures.
285289

0 commit comments

Comments
 (0)