Skip to content

Commit 511d4ec

Browse files
new test cases to check overlong curve name and keytype argument
1 parent b19a33d commit 511d4ec

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/genkey_sign_ver/genkey-sign-ver-test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,5 +392,18 @@ def test_xmss_missing_height_value(self):
392392
"{}".format(r.returncode))
393393

394394

395+
class GenkeyArgvTest(unittest.TestCase):
396+
"""Argument-bounds checks for the genkey subcommand entry point."""
397+
398+
def test_genkey_no_keytype(self):
399+
"""`wolfssl genkey` with no key-type argument must not deref argv[2]."""
400+
r = run_wolfssl("genkey")
401+
self.assertNotEqual(r.returncode, 0,
402+
"expected failure with no key type")
403+
self.assertGreaterEqual(r.returncode, 0,
404+
"genkey with no key type crashed with signal "
405+
"{}".format(r.returncode))
406+
407+
395408
if __name__ == "__main__":
396409
test_main()

tests/pkey/ecparam-test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ def test_fail_bad_curve_name(self):
135135
self.assertFalse(os.path.exists("tmp_ecparam.key"),
136136
"key file should not be created for bad curve")
137137

138+
def test_fail_overlong_curve_name(self):
139+
"""Curve name >= ECC_MAXNAME bytes must not crash (no over-read)."""
140+
self._cleanup("tmp_ecparam.key")
141+
142+
long_name = "A" * 256
143+
r = run_wolfssl("ecparam", "-genkey", "-name", long_name,
144+
"-out", "tmp_ecparam.key")
145+
self.assertNotEqual(r.returncode, 0,
146+
"expected failure for overlong curve name")
147+
self.assertGreaterEqual(r.returncode, 0,
148+
"overlong curve name crashed with signal "
149+
"{}".format(r.returncode))
150+
138151
def test_all_curves_genkey(self):
139152
"""Re-run curve test using the genkey command."""
140153
names = _get_curve_names()

0 commit comments

Comments
 (0)