diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-11-06 16:39:28 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-11-06 17:10:41 +0100 |
commit | aa33d18930f5086f68fdda8e1ec9570ce694ff95 (patch) | |
tree | 5b1c49f788144ba85851b965ce4388c5dcc0062a /examples | |
parent | 8c5777554add5e58add32c932f526ab707d336ae (diff) | |
download | libssh-aa33d18930f5086f68fdda8e1ec9570ce694ff95.tar.gz libssh-aa33d18930f5086f68fdda8e1ec9570ce694ff95.tar.xz libssh-aa33d18930f5086f68fdda8e1ec9570ce694ff95.zip |
example: Use ssh_get_publickey_hash().
Diffstat (limited to 'examples')
-rw-r--r-- | examples/knownhosts.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/examples/knownhosts.c b/examples/knownhosts.c index 37c0ba4..5097cd9 100644 --- a/examples/knownhosts.c +++ b/examples/knownhosts.c @@ -34,14 +34,26 @@ int verify_knownhost(ssh_session session){ int state; char buf[10]; unsigned char *hash = NULL; - int hlen; + size_t hlen; + ssh_key srv_pubkey; + int rc; state=ssh_is_server_known(session); - hlen = ssh_get_pubkey_hash(session, &hash); - if (hlen < 0) { - return -1; + rc = ssh_get_publickey(session, &srv_pubkey); + if (rc < 0) { + return -1; } + + rc = ssh_get_publickey_hash(srv_pubkey, + SSH_PUBLICKEY_HASH_SHA1, + &hash, + &hlen); + ssh_key_free(srv_pubkey); + if (rc < 0) { + return -1; + } + switch(state){ case SSH_SERVER_KNOWN_OK: break; /* ok */ |