From 92aa2cf4963b714d0f30d4fb0f9e609200224f7a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 2 Sep 2018 15:47:41 +0200 Subject: [PATCH] dh: Use ssh_get_fingerprint_hash() in ssh_print_hash() Signed-off-by: Andreas Schneider --- src/dh.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/dh.c b/src/dh.c index 40d0b614..90c1813c 100644 --- a/src/dh.c +++ b/src/dh.c @@ -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); }