diff options
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r-- | ssh-keygen.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c index f4f700f79..45a511477 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.48 2001/03/11 16:39:03 deraadt Exp $"); | 15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.49 2001/03/11 22:33:24 markus Exp $"); |
16 | 16 | ||
17 | #include <openssl/evp.h> | 17 | #include <openssl/evp.h> |
18 | #include <openssl/pem.h> | 18 | #include <openssl/pem.h> |
@@ -46,6 +46,7 @@ int quiet = 0; | |||
46 | 46 | ||
47 | /* Flag indicating that we just want to see the key fingerprint */ | 47 | /* Flag indicating that we just want to see the key fingerprint */ |
48 | int print_fingerprint = 0; | 48 | int print_fingerprint = 0; |
49 | int print_bubblebabble = 0; | ||
49 | 50 | ||
50 | /* The identity file name, given on the command line or entered by the user. */ | 51 | /* The identity file name, given on the command line or entered by the user. */ |
51 | char identity_file[1024]; | 52 | char identity_file[1024]; |
@@ -64,7 +65,6 @@ char *identity_comment = NULL; | |||
64 | int convert_to_ssh2 = 0; | 65 | int convert_to_ssh2 = 0; |
65 | int convert_from_ssh2 = 0; | 66 | int convert_from_ssh2 = 0; |
66 | int print_public = 0; | 67 | int print_public = 0; |
67 | int print_verbose = 0; | ||
68 | 68 | ||
69 | /* default to RSA for SSH-1 */ | 69 | /* default to RSA for SSH-1 */ |
70 | char *key_type_name = "rsa1"; | 70 | char *key_type_name = "rsa1"; |
@@ -326,13 +326,15 @@ do_print_public(struct passwd *pw) | |||
326 | void | 326 | void |
327 | do_fingerprint(struct passwd *pw) | 327 | do_fingerprint(struct passwd *pw) |
328 | { | 328 | { |
329 | |||
330 | FILE *f; | 329 | FILE *f; |
331 | Key *public; | 330 | Key *public; |
332 | char *comment = NULL, *cp, *ep, line[16*1024]; | 331 | char *comment = NULL, *cp, *ep, line[16*1024], *fp; |
333 | int i, skip = 0, num = 1, invalid = 1, success = 0; | 332 | int i, skip = 0, num = 1, invalid = 1, success = 0, rep, type; |
334 | struct stat st; | 333 | struct stat st; |
335 | 334 | ||
335 | type = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5; | ||
336 | rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX; | ||
337 | |||
336 | if (!have_identity) | 338 | if (!have_identity) |
337 | ask_filename(pw, "Enter file in which the key is"); | 339 | ask_filename(pw, "Enter file in which the key is"); |
338 | if (stat(identity_file, &st) < 0) { | 340 | if (stat(identity_file, &st) < 0) { |
@@ -351,26 +353,12 @@ do_fingerprint(struct passwd *pw) | |||
351 | debug("try_load_public_key KEY_UNSPEC failed"); | 353 | debug("try_load_public_key KEY_UNSPEC failed"); |
352 | } | 354 | } |
353 | if (success) { | 355 | if (success) { |
354 | char *digest_md5, *digest_bubblebabble; | 356 | fp = key_fingerprint_ex(public, type, rep); |
355 | 357 | printf("%d %s %s\n", key_size(public), | |
356 | digest_md5 = key_fingerprint_ex(public, SSH_FP_MD5, SSH_FP_HEX); | 358 | fp, comment); |
357 | digest_bubblebabble = key_fingerprint_ex(public, SSH_FP_SHA1, | ||
358 | SSH_FP_BUBBLEBABBLE); | ||
359 | |||
360 | if (print_verbose) { | ||
361 | printf("comment: %s\n", comment); | ||
362 | printf("size: %d\n", key_size(public)); | ||
363 | printf("md5: %s\n", digest_md5); | ||
364 | printf("bubblebabble: %s\n", digest_bubblebabble); | ||
365 | } else { | ||
366 | printf("%d %s %s\n", key_size(public), digest_md5, comment); | ||
367 | } | ||
368 | |||
369 | key_free(public); | 359 | key_free(public); |
370 | xfree(comment); | 360 | xfree(comment); |
371 | xfree(digest_md5); | 361 | xfree(fp); |
372 | xfree(digest_bubblebabble); | ||
373 | |||
374 | exit(0); | 362 | exit(0); |
375 | } | 363 | } |
376 | 364 | ||
@@ -421,9 +409,10 @@ do_fingerprint(struct passwd *pw) | |||
421 | } | 409 | } |
422 | } | 410 | } |
423 | comment = *cp ? cp : comment; | 411 | comment = *cp ? cp : comment; |
424 | printf("%d %s %s\n", key_size(public), | 412 | fp = key_fingerprint_ex(public, type, rep); |
425 | key_fingerprint(public), | 413 | printf("%d %s %s\n", key_size(public), fp, |
426 | comment ? comment : "no comment"); | 414 | comment ? comment : "no comment"); |
415 | xfree(fp); | ||
427 | invalid = 0; | 416 | invalid = 0; |
428 | } | 417 | } |
429 | fclose(f); | 418 | fclose(f); |
@@ -664,7 +653,7 @@ main(int ac, char **av) | |||
664 | exit(1); | 653 | exit(1); |
665 | } | 654 | } |
666 | 655 | ||
667 | while ((opt = getopt(ac, av, "dqpclRxXyvb:f:t:P:N:C:")) != -1) { | 656 | while ((opt = getopt(ac, av, "dqpclBRxXyb:f:t:P:N:C:")) != -1) { |
668 | switch (opt) { | 657 | switch (opt) { |
669 | case 'b': | 658 | case 'b': |
670 | bits = atoi(optarg); | 659 | bits = atoi(optarg); |
@@ -678,6 +667,10 @@ main(int ac, char **av) | |||
678 | print_fingerprint = 1; | 667 | print_fingerprint = 1; |
679 | break; | 668 | break; |
680 | 669 | ||
670 | case 'B': | ||
671 | print_bubblebabble = 1; | ||
672 | break; | ||
673 | |||
681 | case 'p': | 674 | case 'p': |
682 | change_passphrase = 1; | 675 | change_passphrase = 1; |
683 | break; | 676 | break; |
@@ -724,10 +717,6 @@ main(int ac, char **av) | |||
724 | print_public = 1; | 717 | print_public = 1; |
725 | break; | 718 | break; |
726 | 719 | ||
727 | case 'v': | ||
728 | print_verbose = 1; | ||
729 | break; | ||
730 | |||
731 | case 'd': | 720 | case 'd': |
732 | key_type_name = "dsa"; | 721 | key_type_name = "dsa"; |
733 | break; | 722 | break; |
@@ -749,7 +738,7 @@ main(int ac, char **av) | |||
749 | printf("Can only have one of -p and -c.\n"); | 738 | printf("Can only have one of -p and -c.\n"); |
750 | usage(); | 739 | usage(); |
751 | } | 740 | } |
752 | if (print_fingerprint) | 741 | if (print_fingerprint || print_bubblebabble) |
753 | do_fingerprint(pw); | 742 | do_fingerprint(pw); |
754 | if (change_passphrase) | 743 | if (change_passphrase) |
755 | do_change_passphrase(pw); | 744 | do_change_passphrase(pw); |