[BACK]Return to ssh-keygen.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ssh-keygen.c between version 1.14 and 1.15

version 1.14, 1999/11/24 19:53:52 version 1.15, 2000/02/04 13:16:16
Line 76 
Line 76 
 void  void
 do_fingerprint(struct passwd *pw)  do_fingerprint(struct passwd *pw)
 {  {
         char *comment;          FILE *f;
           BIGNUM *e, *n;
         RSA *public_key;          RSA *public_key;
           char *comment = NULL, char *cp, *ep, line[16*1024];
           int i, skip = 0, num = 1, invalid = 1;
         struct stat st;          struct stat st;
   
         if (!have_identity)          if (!have_identity)
Line 86 
Line 89 
                 perror(identity_file);                  perror(identity_file);
                 exit(1);                  exit(1);
         }          }
   
         public_key = RSA_new();          public_key = RSA_new();
         if (!load_public_key(identity_file, public_key, &comment)) {          if (load_public_key(identity_file, public_key, &comment)) {
                 char *cp, line[1024];                  printf("%d %s %s\n", BN_num_bits(public_key->n),
                 BIGNUM *e, *n;                      fingerprint(public_key->e, public_key->n),
                 int dummy, invalid = 0;                      comment);
                 FILE *f = fopen(identity_file, "r");                  RSA_free(public_key);
                   exit(0);
           }
           RSA_free(public_key);
   
           f = fopen(identity_file, "r");
           if (f != NULL) {
                 n = BN_new();                  n = BN_new();
                 e = BN_new();                  e = BN_new();
                 if (f && fgets(line, sizeof(line), f)) {                  while (fgets(line, sizeof(line), f)) {
                         cp = line;                          i = strlen(line) - 1;
                         line[strlen(line) - 1] = '\0';                          if (line[i] != '\n') {
                         if (auth_rsa_read_key(&cp, &dummy, e, n)) {                                  error("line %d too long: %.40s...", num, line);
                                 public_key->e = e;                                  skip = 1;
                                 public_key->n = n;                                  continue;
                                 comment = xstrdup(cp ? cp : "no comment");  
                         } else {  
                                 invalid = 1;  
                         }                          }
                 } else {                          num++;
                         invalid = 1;                          if (skip) {
                                   skip = 0;
                                   continue;
                           }
                           line[i] = '\0';
   
                           /* Skip leading whitespace, empty and comment lines. */
                           for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
                                   ;
                           if (!*cp || *cp == '\n' || *cp == '#')
                                   continue ;
                           i = strtol(cp, &ep, 10);
                           if (i == 0 || ep == NULL || (*ep != ' ' && *ep != '\t')) {
                                   int quoted = 0;
                                   comment = cp;
                                   for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
                                           if (*cp == '\\' && cp[1] == '"')
                                                   cp++;   /* Skip both */
                                           else if (*cp == '"')
                                                   quoted = !quoted;
                                   }
                                   if (!*cp)
                                           continue;
                                   *cp++ = '\0';
                           }
                           ep = cp;
                           if (auth_rsa_read_key(&cp, &i, e, n)) {
                                   invalid = 0;
                                   comment = *cp ? cp : comment;
                                   printf("%d %s %s\n", BN_num_bits(n),
                                       fingerprint(e, n),
                                       comment ? comment : "no comment");
                           }
                 }                  }
                 if (invalid) {                  BN_free(e);
                         printf("%s is not a valid key file.\n", identity_file);                  BN_free(n);
                         BN_free(e);                  fclose(f);
                         BN_free(n);  
                         exit(1);  
                 }  
         }          }
         printf("%d %s %s\n", BN_num_bits(public_key->n),          if (invalid) {
                fingerprint(public_key->e, public_key->n),                  printf("%s is not a valid key file.\n", identity_file);
                comment);                  exit(1);
         RSA_free(public_key);          }
         exit(0);          exit(0);
 }  }
   
Line 310 
Line 346 
 usage(void)  usage(void)
 {  {
         printf("ssh-keygen version %s\n", SSH_VERSION);          printf("ssh-keygen version %s\n", SSH_VERSION);
         printf("Usage: %s [-b bits] [-p] [-c] [-f file] [-P pass] [-N new-pass] [-C comment]\n", __progname);          printf("Usage: %s [-b bits] [-p] [-c] [-l] [-f file] [-P pass] [-N new-pass] [-C comment]\n", __progname);
         exit(1);          exit(1);
 }  }
   

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15