diff options
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r-- | ssh-keygen.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c index 69b16e6f5..a03c6575d 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.165 2008/01/19 22:37:19 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.166 2008/05/19 15:46:31 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -600,12 +600,24 @@ do_fingerprint(struct passwd *pw) | |||
600 | static void | 600 | static void |
601 | print_host(FILE *f, const char *name, Key *public, int hash) | 601 | print_host(FILE *f, const char *name, Key *public, int hash) |
602 | { | 602 | { |
603 | if (hash && (name = host_hash(name, NULL, 0)) == NULL) | 603 | if (print_fingerprint) { |
604 | fatal("hash_host failed"); | 604 | enum fp_rep rep; |
605 | fprintf(f, "%s ", name); | 605 | enum fp_type fptype; |
606 | if (!key_write(public, f)) | 606 | char *fp; |
607 | fatal("key_write failed"); | 607 | |
608 | fprintf(f, "\n"); | 608 | fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5; |
609 | rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX; | ||
610 | fp = key_fingerprint(public, fptype, rep); | ||
611 | printf("%u %s %s\n", key_size(public), fp, name); | ||
612 | xfree(fp); | ||
613 | } else { | ||
614 | if (hash && (name = host_hash(name, NULL, 0)) == NULL) | ||
615 | fatal("hash_host failed"); | ||
616 | fprintf(f, "%s ", name); | ||
617 | if (!key_write(public, f)) | ||
618 | fatal("key_write failed"); | ||
619 | fprintf(f, "\n"); | ||
620 | } | ||
609 | } | 621 | } |
610 | 622 | ||
611 | static void | 623 | static void |
@@ -1231,6 +1243,10 @@ main(int argc, char **argv) | |||
1231 | printf("Can only have one of -p and -c.\n"); | 1243 | printf("Can only have one of -p and -c.\n"); |
1232 | usage(); | 1244 | usage(); |
1233 | } | 1245 | } |
1246 | if (print_fingerprint && (delete_host || hash_hosts)) { | ||
1247 | printf("Cannot use -l with -D or -R.\n"); | ||
1248 | usage(); | ||
1249 | } | ||
1234 | if (delete_host || hash_hosts || find_host) | 1250 | if (delete_host || hash_hosts || find_host) |
1235 | do_known_hosts(pw, rr_hostname); | 1251 | do_known_hosts(pw, rr_hostname); |
1236 | if (print_fingerprint || print_bubblebabble) | 1252 | if (print_fingerprint || print_bubblebabble) |