sshsig_fuzz.cc 950 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // cc_fuzz_target test for sshsig verification.
  2. #include <stddef.h>
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. extern "C" {
  8. #include "includes.h"
  9. #include "sshkey.h"
  10. #include "ssherr.h"
  11. #include "sshbuf.h"
  12. #include "sshsig.h"
  13. #include "log.h"
  14. int LLVMFuzzerTestOneInput(const uint8_t* sig, size_t slen)
  15. {
  16. static const char *data = "If everyone started announcing his nose had "
  17. "run away, I don’t know how it would all end";
  18. struct sshbuf *signature = sshbuf_from(sig, slen);
  19. struct sshbuf *message = sshbuf_from(data, strlen(data));
  20. struct sshkey *k = NULL;
  21. struct sshkey_sig_details *details = NULL;
  22. extern char *__progname;
  23. log_init(__progname, SYSLOG_LEVEL_QUIET, SYSLOG_FACILITY_USER, 1);
  24. sshsig_verifyb(signature, message, "castle", &k, &details);
  25. sshkey_sig_details_free(details);
  26. sshkey_free(k);
  27. sshbuf_free(signature);
  28. sshbuf_free(message);
  29. return 0;
  30. }
  31. } // extern