Lines Matching +full:1 +full:st

25 /* #define STANDALONE 1 */
27 static int prepare_key(struct shared_state *st, int keytype, int bits);
123 store_key(struct shared_state *st, struct sshkey *pubkey, in store_key() argument
126 if (st == NULL || pubkey->type < 0 || pubkey->type > INT_MAX || in store_key()
128 ((size_t)pubkey->type < st->nkeys && in store_key()
129 st->pubkeys[pubkey->type] != NULL)) in store_key()
131 if ((size_t)pubkey->type >= st->nkeys) { in store_key()
132 st->pubkeys = (struct sshkey **)xrecallocarray(st->pubkeys, in store_key()
133 st->nkeys, pubkey->type + 1, sizeof(*st->pubkeys)); in store_key()
134 st->privkeys = (struct sshkey **)xrecallocarray(st->privkeys, in store_key()
135 st->nkeys, privkey->type + 1, sizeof(*st->privkeys)); in store_key()
136 st->nkeys = privkey->type + 1; in store_key()
139 st->pubkeys[pubkey->type] = pubkey; in store_key()
140 st->privkeys[privkey->type] = privkey; in store_key()
144 prepare_keys(struct shared_state *st) in prepare_keys() argument
146 if (prepare_key(st, KEY_RSA, 2048) != 0 || in prepare_keys()
147 prepare_key(st, KEY_ECDSA, 256) != 0 || in prepare_keys()
148 prepare_key(st, KEY_ED25519, 256) != 0) { in prepare_keys()
150 return -1; in prepare_keys()
156 get_pubkey(struct shared_state *st, int keytype) in get_pubkey() argument
158 if (st == NULL || keytype < 0 || (size_t)keytype >= st->nkeys || in get_pubkey()
159 st->pubkeys == NULL || st->pubkeys[keytype] == NULL) in get_pubkey()
161 return st->pubkeys[keytype]; in get_pubkey()
165 get_privkey(struct shared_state *st, int keytype) in get_privkey() argument
167 if (st == NULL || keytype < 0 || (size_t)keytype >= st->nkeys || in get_privkey()
168 st->privkeys == NULL || st->privkeys[keytype] == NULL) in get_privkey()
170 return st->privkeys[keytype]; in get_privkey()
174 do_kex_with_key(struct shared_state *st, struct test_state *ts, in do_kex_with_key() argument
193 pubkey = get_pubkey(st, keytype); in do_kex_with_key()
194 privkey = get_privkey(st, keytype); in do_kex_with_key()
225 if ((r = ssh_init(&server, 1, &kex_params)) != 0) { in do_kex_with_key()
252 prepare_key(struct shared_state *st, int kt, int bits) in prepare_key() argument
293 store_key(st, pubkey, privkey); in prepare_key()
301 prepare_key(struct shared_state *st, int keytype, int bits)
314 store_key(st, pubkey, privkey);
321 static struct shared_state *st; in main() local
323 const int keytypes[] = { KEY_RSA, KEY_ECDSA, KEY_ED25519, -1 }; in main()
336 log_init("kex_fuzz", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 1); in main()
338 if (st == NULL) { in main()
339 st = (struct shared_state *)xcalloc(1, sizeof(*st)); in main()
340 prepare_keys(st); in main()
343 for (i = 0; keytypes[i] != -1; i++) { in main()
345 ts = (struct test_state *)xcalloc(1, sizeof(*ts)); in main()
348 do_kex_with_key(st, ts, kextypes[j], keytypes[i]); in main()
350 kextypes[j], sshkey_type(st->pubkeys[keytypes[i]])); in main()
354 if (fwrite(sshbuf_ptr(ts->smsgs), 1, in main()
361 kextypes[j], sshkey_type(st->pubkeys[keytypes[i]])); in main()
365 if (fwrite(sshbuf_ptr(ts->cmsgs), 1, in main()
376 for (i = 0; keytypes[i] != -1; i++) { in main()
378 sshkey_type(st->privkeys[keytypes[i]])); in main()
380 if (sshkey_save_private(st->privkeys[keytypes[i]], path, in main()
385 sshkey_type(st->pubkeys[keytypes[i]])); in main()
387 if (sshkey_save_public(st->pubkeys[keytypes[i]], path, "") != 0) in main()
394 do_kex(struct shared_state *st, struct test_state *ts, const char *kex) in do_kex() argument
396 do_kex_with_key(st, ts, kex, KEY_RSA); in do_kex()
397 do_kex_with_key(st, ts, kex, KEY_ECDSA); in do_kex()
398 do_kex_with_key(st, ts, kex, KEY_ED25519); in do_kex()
402 kex_tests(struct shared_state *st, struct test_state *ts) in kex_tests() argument
404 do_kex(st, ts, "sntrup761x25519-sha512@openssh.com"); in kex_tests()
405 do_kex(st, ts, "curve25519-sha256@libssh.org"); in kex_tests()
406 do_kex(st, ts, "ecdh-sha2-nistp256"); in kex_tests()
407 do_kex(st, ts, "diffie-hellman-group1-sha1"); in kex_tests()
408 do_kex(st, ts, "diffie-hellman-group-exchange-sha1"); in kex_tests()
413 static struct shared_state *st; in LLVMFuzzerTestOneInput() local
419 if (st == NULL) { in LLVMFuzzerTestOneInput()
423 loglevel, SYSLOG_FACILITY_AUTH, 1); in LLVMFuzzerTestOneInput()
424 st = (struct shared_state *)xcalloc(1, sizeof(*st)); in LLVMFuzzerTestOneInput()
425 prepare_keys(st); in LLVMFuzzerTestOneInput()
431 ts = (struct test_state *)xcalloc(1, sizeof(*ts)); in LLVMFuzzerTestOneInput()
437 kex_tests(st, ts); in LLVMFuzzerTestOneInput()
441 ts = (struct test_state *)xcalloc(1, sizeof(*ts)); in LLVMFuzzerTestOneInput()
447 kex_tests(st, ts); in LLVMFuzzerTestOneInput()