]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
support for running kex fuzzer with null cipher
authorDamien Miller <djm@mindrot.org>
Fri, 29 Jan 2021 00:03:35 +0000 (11:03 +1100)
committerDamien Miller <djm@mindrot.org>
Fri, 29 Jan 2021 00:03:35 +0000 (11:03 +1100)
regress/misc/fuzz-harness/kex_fuzz.cc

index 68ed892ca7d49950e6397fad27dc64574d17cac3..0c89bdd3e292c926580f769603bffb60d8788c9c 100644 (file)
@@ -21,7 +21,7 @@ extern "C" {
 #include "log.h"
 
 // Define if you want to generate traces.
-// #define STANDALONE 1
+/* #define STANDALONE 1 */
 
 #define PRIV_RSA \
 "-----BEGIN OPENSSH PRIVATE KEY-----\n"\
@@ -269,11 +269,21 @@ do_kex_with_key(struct shared_state *st, struct test_state *ts,
        pubkey = get_pubkey(st, keytype);
        privkey = get_privkey(st, keytype);
        keyname = xstrdup(sshkey_ssh_name(privkey));
-       debug_f("%s %s clobber %s %zu", kex, keyname,
-           ts->cin == NULL ? "server" : "client",
-           ts->cin == NULL ? sshbuf_len(ts->sin) : sshbuf_len(ts->cin));
+       if (ts->cin != NULL) {
+               debug_f("%s %s clobber client %zu", kex, keyname,
+                   sshbuf_len(ts->cin));
+       } else if (ts->sin != NULL) {
+               debug_f("%s %s clobber server %zu", kex, keyname,
+                   sshbuf_len(ts->sin));
+       } else
+               debug_f("%s %s noclobber", kex, keyname);
+
        for (i = 0; i < PROPOSAL_MAX; i++) {
                ccp = proposal[i];
+#ifdef CIPHER_NONE_AVAIL
+               if (i == PROPOSAL_ENC_ALGS_CTOS || i == PROPOSAL_ENC_ALGS_STOC)
+                       ccp = "none";
+#endif
                if (i == PROPOSAL_SERVER_HOST_KEY_ALGS)
                        ccp = keyname;
                else if (i == PROPOSAL_KEX_ALGS && kex != NULL)
@@ -396,12 +406,15 @@ int main(void)
                "curve25519-sha256@libssh.org",
                "ecdh-sha2-nistp256",
                "diffie-hellman-group1-sha1",
+               "diffie-hellman-group-exchange-sha1",
                NULL,
        };
        int i, j;
        char *path;
        FILE *f;
 
+       log_init("kex_fuzz", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 1);
+
        if (st == NULL) {
                st = (struct shared_state *)xcalloc(1, sizeof(*st));
                prepare_keys(st);