mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-05-14 20:15:08 +03:00
dh: Use ssh_get_fingerprint_hash() in ssh_print_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
bbed139eca
commit
92aa2cf496
29
src/dh.c
29
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,
|
void ssh_print_hash(enum ssh_publickey_hash_type type,
|
||||||
unsigned char *hash,
|
unsigned char *hash,
|
||||||
size_t len) {
|
size_t len)
|
||||||
const char *prefix = "UNKNOWN";
|
{
|
||||||
char *fingerprint = NULL;
|
char *fingerprint = NULL;
|
||||||
|
|
||||||
switch (type) {
|
fingerprint = ssh_get_fingerprint_hash(type,
|
||||||
case SSH_PUBLICKEY_HASH_SHA1:
|
hash,
|
||||||
case SSH_PUBLICKEY_HASH_SHA256:
|
len);
|
||||||
fingerprint = ssh_get_b64_unpadded(hash, len);
|
|
||||||
break;
|
|
||||||
case SSH_PUBLICKEY_HASH_MD5:
|
|
||||||
fingerprint = ssh_get_hexa(hash, len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (fingerprint == NULL) {
|
if (fingerprint == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
fprintf(stderr, "%s\n", fingerprint);
|
||||||
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);
|
|
||||||
|
|
||||||
SAFE_FREE(fingerprint);
|
SAFE_FREE(fingerprint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user