tests: Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h #18783

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:fuzzers-message changing 2 files +55 −0
  1. practicalswift commented at 5:09 PM on April 27, 2020: contributor

    Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h.

    See doc/fuzzing.md for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the Bitcoin Core fuzzing corpus repo.

    Happy fuzzing :)

  2. tests: Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h 38e49ded8b
  3. in src/test/fuzz/message.cpp:34 in 38e49ded8b
      29 | +    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      30 | +    const std::string random_message = fuzzed_data_provider.ConsumeRandomLengthString(1024);
      31 | +    {
      32 | +        const std::vector<uint8_t> random_bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
      33 | +        CKey private_key;
      34 | +        private_key.Set(random_bytes.begin(), random_bytes.end(), fuzzed_data_provider.ConsumeBool());
    


    MarcoFalke commented at 5:28 PM on April 27, 2020:
            private_key.Set(random_bytes.begin(), random_bytes.end(), /* compressed */ fuzzed_data_provider.ConsumeBool());
    

    nit


    vasild commented at 5:38 PM on April 27, 2020:

    ConsumeRandomLengthByteVector() will return a result with a length between 0 and 4096. The private key will only be valid if the length is 32.

    Is it the case that we will test with a valid private key in 1 of 4097 cases?

    If yes, then does it make sense to add one more iteration with exactly 32 bytes, so that we (likely) end up with a valid private key?


    practicalswift commented at 12:34 PM on May 4, 2020:

    A modern coverage-guided fuzzer like libFuzzer will quickly figure out which lengths that are meaningful to test in the sense that they increase coverage, so luckily no need to hard code anything :)

  4. MarcoFalke approved
  5. MarcoFalke commented at 5:28 PM on April 27, 2020: member

    ACK

  6. DrahtBot added the label Build system on Apr 27, 2020
  7. DrahtBot added the label Tests on Apr 27, 2020
  8. fanquake removed the label Build system on Apr 27, 2020
  9. vasild approved
  10. vasild commented at 1:01 PM on May 4, 2020: member

    utACK 38e49ded8bd079f8da8b270b39f81cc5cf3ada11

  11. MarcoFalke merged this on May 4, 2020
  12. MarcoFalke closed this on May 4, 2020

  13. sidhujag referenced this in commit ea40fbe2b8 on May 4, 2020
  14. Fabcien referenced this in commit 15eb13e423 on Jan 25, 2021
  15. practicalswift deleted the branch on Apr 10, 2021
  16. PastaPastaPasta referenced this in commit 16e04a7d34 on Jul 17, 2022
  17. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:14 UTC

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