hostkeys
struct hostkeys *hostkeys;
hostkeys = init_hostkeys();
load_hostkeys(hostkeys, host, sysfile, 0);
load_hostkeys(hostkeys, host, user_hostfile, 0);
host_status = check_key_in_hostkeys(hostkeys, key, &found);
free_hostkeys(hostkeys);
struct hostkeys *
struct hostkeys *ret = xcalloc(1, sizeof(*ret));
struct hostkeys *hostkeys;
struct hostkeys *hostkeys = ctx->hostkeys;
if ((tmp = recallocarray(hostkeys->entries, hostkeys->num_entries,
hostkeys->num_entries + 1, sizeof(*hostkeys->entries))) == NULL)
hostkeys->entries = tmp;
hostkeys->entries[hostkeys->num_entries].host = xstrdup(ctx->host);
hostkeys->entries[hostkeys->num_entries].file = xstrdup(l->path);
hostkeys->entries[hostkeys->num_entries].line = l->linenum;
hostkeys->entries[hostkeys->num_entries].key = l->key;
hostkeys->entries[hostkeys->num_entries].marker = l->marker;
hostkeys->entries[hostkeys->num_entries].note = l->note;
hostkeys->num_entries++;
load_hostkeys_file(struct hostkeys *hostkeys, const char *host,
ctx.hostkeys = hostkeys;
load_hostkeys(struct hostkeys *hostkeys, const char *host, const char *path,
load_hostkeys_file(hostkeys, host, path, f, note);
free_hostkeys(struct hostkeys *hostkeys)
for (i = 0; i < hostkeys->num_entries; i++) {
free(hostkeys->entries[i].host);
free(hostkeys->entries[i].file);
sshkey_free(hostkeys->entries[i].key);
explicit_bzero(hostkeys->entries + i, sizeof(*hostkeys->entries));
free(hostkeys->entries);
freezero(hostkeys, sizeof(*hostkeys));
check_key_not_revoked(struct hostkeys *hostkeys, struct sshkey *k)
for (i = 0; i < hostkeys->num_entries; i++) {
if (hostkeys->entries[i].marker != MRK_REVOKE)
if (sshkey_equal_public(k, hostkeys->entries[i].key))
hostkeys->entries[i].key))
check_hostkeys_by_key_or_type(struct hostkeys *hostkeys,
for (i = 0; i < hostkeys->num_entries; i++) {
if (hostkeys->entries[i].marker != want_marker)
if (hostkeys->entries[i].key->type != keytype)
hostkeys->entries[i].key->ecdsa_nid != nid)
*found = hostkeys->entries + i;
k = hostkeys->entries[i].key;
hostkeys->entries[i].key)) {
*found = hostkeys->entries + i;
if (sshkey_equal(k, hostkeys->entries[i].key)) {
*found = hostkeys->entries + i;
*found = hostkeys->entries + i;
if (check_key_not_revoked(hostkeys, k) != 0) {
check_key_in_hostkeys(struct hostkeys *hostkeys, struct sshkey *key,
return check_hostkeys_by_key_or_type(hostkeys, key, 0, -1, found);
lookup_key_in_hostkeys_by_type(struct hostkeys *hostkeys, int keytype, int nid,
return (check_hostkeys_by_key_or_type(hostkeys, NULL, keytype, nid,
lookup_marker_in_hostkeys(struct hostkeys *hostkeys, int want_marker)
for (i = 0; i < hostkeys->num_entries; i++) {
if (hostkeys->entries[i].marker == (HostkeyMarker)want_marker)
struct hostkeys *init_hostkeys(void);
void load_hostkeys(struct hostkeys *, const char *,
void load_hostkeys_file(struct hostkeys *, const char *,
void free_hostkeys(struct hostkeys *);
HostStatus check_key_in_hostkeys(struct hostkeys *, struct sshkey *,
int lookup_key_in_hostkeys_by_type(struct hostkeys *, int, int,
int lookup_marker_in_hostkeys(struct hostkeys *, int);
struct sshbuf *m = NULL, *inc = NULL, *hostkeys = NULL;
hostkeys = pack_hostkeys();
(r = sshbuf_put_stringb(m, hostkeys)) != 0 ||
sshbuf_free(hostkeys);
struct hostkeys *hostkeys;
hostkeys = init_hostkeys();
load_hostkeys(hostkeys, host, path, 0);
for (i = 0; i < hostkeys->num_entries; i++) {
hke = hostkeys->entries + i;
free_hostkeys(hostkeys);
show_other_keys(struct hostkeys *hostkeys, struct sshkey *key)
if (!lookup_key_in_hostkeys_by_type(hostkeys, type[i],
static int show_other_keys(struct hostkeys *, struct sshkey *);
load_hostkeys_command(struct hostkeys *hostkeys, const char *command_template,
load_hostkeys_file(hostkeys, hostfile_hostname, tag, f, 1);
struct hostkeys *host_hostkeys, *ip_hostkeys;
struct hostkeys;
void load_hostkeys_command(struct hostkeys *, const char *,
struct hostkeys *hostkeys = NULL;
hostkeys = init_hostkeys();
load_hostkeys(hostkeys, hostname, options.user_hostfiles[i], 0);
load_hostkeys(hostkeys, hostname,
load_hostkeys_command(hostkeys, options.known_hosts_command,
if (lookup_key_in_hostkeys_by_type(hostkeys,
lookup_marker_in_hostkeys(hostkeys, MRK_CA)) {
if (lookup_key_in_hostkeys_by_type(hostkeys,
free_hostkeys(hostkeys);
parse_hostkeys(struct sshbuf *hostkeys)
while (sshbuf_len(hostkeys) != 0) {
if ((r = sshbuf_get_string_direct(hostkeys, &cp, &len)) != 0)
if ((r = sshbuf_get_string_direct(hostkeys, &cp, &len)) != 0)
struct sshbuf *hostkeys;
&hostkeys, NULL, NULL, NULL, NULL);
parse_hostkeys(hostkeys);
sshbuf_free(hostkeys);
struct sshbuf *keybuf = NULL, *hostkeys = NULL;
if ((hostkeys = sshbuf_new()) == NULL)
hostkeys)) != 0)
if ((r = sshbuf_put_string(hostkeys, NULL, 0)) != 0)
hostkeys)) != 0)
if ((r = sshbuf_put_string(hostkeys, NULL, 0)) != 0)
return hostkeys;
parse_hostkeys(struct sshbuf *hostkeys)
while (sshbuf_len(hostkeys) != 0) {
if ((r = sshbuf_froms(hostkeys, &kbuf)) != 0)
if ((r = sshbuf_get_string_direct(hostkeys, &cp, &len)) != 0)
if ((r = sshbuf_get_string_direct(hostkeys, &cp, &len)) != 0)
struct sshbuf *m, *inc, *hostkeys;
(r = sshbuf_froms(m, &hostkeys)) != 0)
parse_hostkeys(hostkeys);
sshbuf_free(hostkeys);
struct sshbuf *m = NULL, *keybuf = NULL, *hostkeys = NULL;
(hostkeys = sshbuf_new()) == NULL)
if ((r = sshbuf_put_stringb(hostkeys, keybuf)) != 0)
hostkeys)) != 0)
if ((r = sshbuf_put_string(hostkeys, NULL, 0)) != 0)
hostkeys)) != 0)
if ((r = sshbuf_put_string(hostkeys, NULL, 0)) != 0)
(r = sshbuf_put_stringb(m, hostkeys)) != 0)
sshbuf_free(hostkeys);