diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-09-02 15:47:41 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-09-20 16:35:13 +0200 |
commit | 92aa2cf4963b714d0f30d4fb0f9e609200224f7a (patch) | |
tree | 5039843c97b6eac81559f01e34e3daab7ad4779c | |
parent | bbed139ecab26cb46b0bb3a21fa4cd2a4f12dadd (diff) | |
download | libssh-92aa2cf4963b714d0f30d4fb0f9e609200224f7a.tar.gz libssh-92aa2cf4963b714d0f30d4fb0f9e609200224f7a.tar.xz libssh-92aa2cf4963b714d0f30d4fb0f9e609200224f7a.zip |
dh: Use ssh_get_fingerprint_hash() in ssh_print_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | src/dh.c | 29 |
1 files changed, 6 insertions, 23 deletions
@@ -1589,35 +1589,18 @@ char *ssh_get_fingerprint_hash(enum ssh_publickey_hash_type type, */ void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char *hash, - size_t len) { - const char *prefix = "UNKNOWN"; + size_t len) +{ char *fingerprint = NULL; - switch (type) { - case SSH_PUBLICKEY_HASH_SHA1: - case SSH_PUBLICKEY_HASH_SHA256: - fingerprint = ssh_get_b64_unpadded(hash, len); - break; - case SSH_PUBLICKEY_HASH_MD5: - fingerprint = ssh_get_hexa(hash, len); - break; - } + fingerprint = ssh_get_fingerprint_hash(type, + hash, + len); if (fingerprint == NULL) { return; } - switch (type) { - case SSH_PUBLICKEY_HASH_MD5: - prefix = "MD5"; - break; - case SSH_PUBLICKEY_HASH_SHA1: - prefix = "SHA1"; - break; - case SSH_PUBLICKEY_HASH_SHA256: - prefix = "SHA256"; - break; - } - fprintf(stderr, "%s:%s\n", prefix, fingerprint); + fprintf(stderr, "%s\n", fingerprint); SAFE_FREE(fingerprint); } |