tests: Add regression tests for ec_privkey_import_der() rejecting malformed input #1895

pull cavdarahmet wants to merge 1 commits into bitcoin-core:master from cavdarahmet:test-privkey-import-der-invalid changing 1 files +54 −0
  1. cavdarahmet commented at 8:00 PM on July 22, 2026: none

    ec_privkey_import_der() has 8 distinct structural checks that reject malformed DER private key encodings (wrong sequence tag, bad length encoding, wrong version field, bad octet string tag/length, and truncation at any point). None of these rejection paths were covered by any existing test -- only the successful round-trip path was exercised.

    I fuzzed this function extensively (truncation at every length, single-bit mutation at every byte position, all under ASan/UBSan) and found no memory-safety or logic bugs -- the checks are correct as written. This PR only adds regression coverage so that a future refactor can't silently reintroduce a parsing bug here.

  2. tests: Add regression tests for ec_privkey_import_der() rejecting malformed input
    The function's structural validation checks (sequence tag, length
    encoding, version field, octet string tag/length, truncation) were
    never exercised by any test -- only the success path was covered.
    
    Add a test that verifies each rejection path triggers on the
    corresponding malformed input, plus full-truncation coverage at
    every length.
    03ec050a3e
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-03 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me