Coverage Report

Created: 2025-07-02 06:56

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