summaryrefslogtreecommitdiff
path: root/regress/misc/fuzz-harness/sshsig_fuzz.cc
blob: fe09ccb8737ac41d0fbce11b5e5fbb75f7578bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// cc_fuzz_target test for sshsig verification.

#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

extern "C" {

#include "includes.h"
#include "sshkey.h"
#include "ssherr.h"
#include "sshbuf.h"
#include "sshsig.h"
#include "log.h"

int LLVMFuzzerTestOneInput(const uint8_t* sig, size_t slen)
{
  static const char *data = "If everyone started announcing his nose had "
      "run away, I don’t know how it would all end";
  struct sshbuf *signature = sshbuf_from(sig, slen);
  struct sshbuf *message = sshbuf_from(data, strlen(data));
  struct sshkey *k = NULL;
  extern char *__progname;

  log_init(__progname, SYSLOG_LEVEL_QUIET, SYSLOG_FACILITY_USER, 1);
  sshsig_verifyb(signature, message, "castle", &k);
  sshkey_free(k);
  sshbuf_free(signature);
  sshbuf_free(message);
  return 0;
}

} // extern