aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-09-02 15:47:41 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-10-09 10:16:30 +0200
commite765c1400a724cc5009fd03395ef54b28de9c296 (patch)
tree8f59fcca6eee3a618fc50cd7a1331f1562bc8a67
parent7a7c0a54bc24391fcff0aaccd983de621cb3e60d (diff)
downloadlibssh-e765c1400a724cc5009fd03395ef54b28de9c296.tar.gz
libssh-e765c1400a724cc5009fd03395ef54b28de9c296.tar.xz
libssh-e765c1400a724cc5009fd03395ef54b28de9c296.zip
dh: Use ssh_get_fingerprint_hash() in ssh_print_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 92aa2cf4963b714d0f30d4fb0f9e609200224f7a)
-rw-r--r--src/dh.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/dh.c b/src/dh.c
index 38298b2d..d7182798 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -1254,35 +1254,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);
}