diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-09-02 15:47:41 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-09-20 17:23:41 +0200 |
commit | 95d0c143b3298178821870f119e56f871abbf8aa (patch) | |
tree | 2fc5c4d650ea4b8a8513fd6e68a181146c50d715 | |
parent | 3dcdafa6d79e2c2f0b383fa86aa9ec1dc0545b6b (diff) | |
download | libssh-95d0c143b3298178821870f119e56f871abbf8aa.tar.gz libssh-95d0c143b3298178821870f119e56f871abbf8aa.tar.xz libssh-95d0c143b3298178821870f119e56f871abbf8aa.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.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); } |