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:11:26 +0100 |
commit | 70c54d94458c052e1bac3ed437dec5675200f2ab (patch) | |
tree | a0149c3b7aadb16887b1f744998a67534c7ad860 /examples | |
parent | e52ff2c8ff44a8d62f1f78e38786546548778ea6 (diff) | |
download | libssh-70c54d94458c052e1bac3ed437dec5675200f2ab.tar.gz libssh-70c54d94458c052e1bac3ed437dec5675200f2ab.tar.xz libssh-70c54d94458c052e1bac3ed437dec5675200f2ab.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 37c0ba4e..5097cd93 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 */ |