Lines Matching full:st
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_DSA, 1024) != 0 || in prepare_keys()
148 prepare_key(st, KEY_ECDSA, 256) != 0 || in prepare_keys()
149 prepare_key(st, KEY_ED25519, 256) != 0) { in prepare_keys()
157 get_pubkey(struct shared_state *st, int keytype) in get_pubkey() argument
159 if (st == NULL || keytype < 0 || (size_t)keytype >= st->nkeys || in get_pubkey()
160 st->pubkeys == NULL || st->pubkeys[keytype] == NULL) in get_pubkey()
162 return st->pubkeys[keytype]; in get_pubkey()
166 get_privkey(struct shared_state *st, int keytype) in get_privkey() argument
168 if (st == NULL || keytype < 0 || (size_t)keytype >= st->nkeys || in get_privkey()
169 st->privkeys == NULL || st->privkeys[keytype] == NULL) in get_privkey()
171 return st->privkeys[keytype]; in get_privkey()
175 do_kex_with_key(struct shared_state *st, struct test_state *ts, in do_kex_with_key() argument
194 pubkey = get_pubkey(st, keytype); in do_kex_with_key()
195 privkey = get_privkey(st, keytype); in do_kex_with_key()
253 prepare_key(struct shared_state *st, int kt, int bits) in prepare_key() argument
298 store_key(st, pubkey, privkey); in prepare_key()
306 prepare_key(struct shared_state *st, int keytype, int bits)
319 store_key(st, pubkey, privkey);
326 static struct shared_state *st; in main() local
343 if (st == NULL) { in main()
344 st = (struct shared_state *)xcalloc(1, sizeof(*st)); in main()
345 prepare_keys(st); in main()
353 do_kex_with_key(st, ts, kextypes[j], keytypes[i]); in main()
355 kextypes[j], sshkey_type(st->pubkeys[keytypes[i]])); in main()
366 kextypes[j], sshkey_type(st->pubkeys[keytypes[i]])); in main()
383 sshkey_type(st->privkeys[keytypes[i]])); in main()
385 if (sshkey_save_private(st->privkeys[keytypes[i]], path, in main()
390 sshkey_type(st->pubkeys[keytypes[i]])); in main()
392 if (sshkey_save_public(st->pubkeys[keytypes[i]], path, "") != 0) in main()
399 do_kex(struct shared_state *st, struct test_state *ts, const char *kex) in do_kex() argument
401 do_kex_with_key(st, ts, kex, KEY_RSA); in do_kex()
402 do_kex_with_key(st, ts, kex, KEY_DSA); in do_kex()
403 do_kex_with_key(st, ts, kex, KEY_ECDSA); in do_kex()
404 do_kex_with_key(st, ts, kex, KEY_ED25519); in do_kex()
408 kex_tests(struct shared_state *st, struct test_state *ts) in kex_tests() argument
410 do_kex(st, ts, "sntrup761x25519-sha512@openssh.com"); in kex_tests()
411 do_kex(st, ts, "curve25519-sha256@libssh.org"); in kex_tests()
412 do_kex(st, ts, "ecdh-sha2-nistp256"); in kex_tests()
413 do_kex(st, ts, "diffie-hellman-group1-sha1"); in kex_tests()
414 do_kex(st, ts, "diffie-hellman-group-exchange-sha1"); in kex_tests()
419 static struct shared_state *st; in LLVMFuzzerTestOneInput() local
425 if (st == NULL) { in LLVMFuzzerTestOneInput()
430 st = (struct shared_state *)xcalloc(1, sizeof(*st)); in LLVMFuzzerTestOneInput()
431 prepare_keys(st); in LLVMFuzzerTestOneInput()
443 kex_tests(st, ts); in LLVMFuzzerTestOneInput()
453 kex_tests(st, ts); in LLVMFuzzerTestOneInput()