[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.176 and 1.177

version 1.176, 2010/01/11 10:51:07 version 1.177, 2010/02/08 10:50:20
Line 41 
Line 41 
 #include "hostfile.h"  #include "hostfile.h"
 #include "dns.h"  #include "dns.h"
   
 #ifdef SMARTCARD  #ifdef ENABLE_PKCS11
 #include "scard.h"  #include "ssh-pkcs11.h"
 #endif  #endif
   
 /* Number of bits in the RSA/DSA key.  This value can be set on the command line. */  /* Number of bits in the RSA/DSA key.  This value can be set on the command line. */
Line 451 
Line 451 
         exit(0);          exit(0);
 }  }
   
 #ifdef SMARTCARD  
 static void  static void
 do_upload(struct passwd *pw, const char *sc_reader_id)  do_download(struct passwd *pw, const char *pkcs11provider)
 {  {
         Key *prv = NULL;  #ifdef ENABLE_PKCS11
         struct stat st;  
         int ret;  
   
         if (!have_identity)  
                 ask_filename(pw, "Enter file in which the key is");  
         if (stat(identity_file, &st) < 0) {  
                 perror(identity_file);  
                 exit(1);  
         }  
         prv = load_identity(identity_file);  
         if (prv == NULL) {  
                 error("load failed");  
                 exit(1);  
         }  
         ret = sc_put_key(prv, sc_reader_id);  
         key_free(prv);  
         if (ret < 0)  
                 exit(1);  
         logit("loading key done");  
         exit(0);  
 }  
   
 static void  
 do_download(struct passwd *pw, const char *sc_reader_id)  
 {  
         Key **keys = NULL;          Key **keys = NULL;
         int i;          int i, nkeys;
   
         keys = sc_get_keys(sc_reader_id, NULL);          pkcs11_init(0);
         if (keys == NULL)          nkeys = pkcs11_add_provider(pkcs11provider, NULL, &keys);
                 fatal("cannot read public key from smartcard");          if (nkeys <= 0)
         for (i = 0; keys[i]; i++) {                  fatal("cannot read public key from pkcs11");
           for (i = 0; i < nkeys; i++) {
                 key_write(keys[i], stdout);                  key_write(keys[i], stdout);
                 key_free(keys[i]);                  key_free(keys[i]);
                 fprintf(stdout, "\n");                  fprintf(stdout, "\n");
         }          }
         xfree(keys);          xfree(keys);
           pkcs11_terminate();
         exit(0);          exit(0);
   #else
           fatal("no pkcs11 support");
   #endif /* ENABLE_PKCS11 */
 }  }
 #endif /* SMARTCARD */  
   
 static void  static void
 do_fingerprint(struct passwd *pw)  do_fingerprint(struct passwd *pw)
Line 1036 
Line 1014 
         fprintf(stderr, "  -b bits     Number of bits in the key to create.\n");          fprintf(stderr, "  -b bits     Number of bits in the key to create.\n");
         fprintf(stderr, "  -C comment  Provide new comment.\n");          fprintf(stderr, "  -C comment  Provide new comment.\n");
         fprintf(stderr, "  -c          Change comment in private and public key files.\n");          fprintf(stderr, "  -c          Change comment in private and public key files.\n");
 #ifdef SMARTCARD  #ifdef ENABLE_PKCS11
         fprintf(stderr, "  -D reader   Download public key from smartcard.\n");          fprintf(stderr, "  -D pkcs11   Download public key from pkcs11 token.\n");
 #endif /* SMARTCARD */  #endif
         fprintf(stderr, "  -e          Convert OpenSSH to RFC 4716 key file.\n");          fprintf(stderr, "  -e          Convert OpenSSH to RFC 4716 key file.\n");
         fprintf(stderr, "  -F hostname Find hostname in known hosts file.\n");          fprintf(stderr, "  -F hostname Find hostname in known hosts file.\n");
         fprintf(stderr, "  -f filename Filename of the key file.\n");          fprintf(stderr, "  -f filename Filename of the key file.\n");
Line 1057 
Line 1035 
         fprintf(stderr, "  -S start    Start point (hex) for generating DH-GEX moduli.\n");          fprintf(stderr, "  -S start    Start point (hex) for generating DH-GEX moduli.\n");
         fprintf(stderr, "  -T file     Screen candidates for DH-GEX moduli.\n");          fprintf(stderr, "  -T file     Screen candidates for DH-GEX moduli.\n");
         fprintf(stderr, "  -t type     Specify type of key to create.\n");          fprintf(stderr, "  -t type     Specify type of key to create.\n");
 #ifdef SMARTCARD  
         fprintf(stderr, "  -U reader   Upload private key to smartcard.\n");  
 #endif /* SMARTCARD */  
         fprintf(stderr, "  -v          Verbose.\n");          fprintf(stderr, "  -v          Verbose.\n");
         fprintf(stderr, "  -W gen      Generator to use for generating DH-GEX moduli.\n");          fprintf(stderr, "  -W gen      Generator to use for generating DH-GEX moduli.\n");
         fprintf(stderr, "  -y          Read private key file and print public key.\n");          fprintf(stderr, "  -y          Read private key file and print public key.\n");
Line 1074 
Line 1049 
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
         char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2;          char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2;
         char out_file[MAXPATHLEN], *reader_id = NULL;          char out_file[MAXPATHLEN], *pkcs11provider = NULL;
         char *rr_hostname = NULL;          char *rr_hostname = NULL;
         Key *private, *public;          Key *private, *public;
         struct passwd *pw;          struct passwd *pw;
         struct stat st;          struct stat st;
         int opt, type, fd, download = 0;          int opt, type, fd;
         u_int32_t memory = 0, generator_wanted = 0, trials = 100;          u_int32_t memory = 0, generator_wanted = 0, trials = 100;
         int do_gen_candidates = 0, do_screen_candidates = 0;          int do_gen_candidates = 0, do_screen_candidates = 0;
         BIGNUM *start = NULL;          BIGNUM *start = NULL;
Line 1107 
Line 1082 
         }          }
   
         while ((opt = getopt(argc, argv,          while ((opt = getopt(argc, argv,
             "degiqpclBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) {              "degiqpclBHvxXyF:b:f:t:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) {
                 switch (opt) {                  switch (opt) {
                 case 'b':                  case 'b':
                         bits = (u_int32_t)strtonum(optarg, 768, 32768, &errstr);                          bits = (u_int32_t)strtonum(optarg, 768, 32768, &errstr);
Line 1179 
Line 1154 
                         key_type_name = optarg;                          key_type_name = optarg;
                         break;                          break;
                 case 'D':                  case 'D':
                         download = 1;                          pkcs11provider = optarg;
                         /*FALLTHROUGH*/  
                 case 'U':  
                         reader_id = optarg;  
                         break;                          break;
                 case 'v':                  case 'v':
                         if (log_level == SYSLOG_LEVEL_INFO)                          if (log_level == SYSLOG_LEVEL_INFO)
Line 1290 
Line 1262 
                         exit(0);                          exit(0);
                 }                  }
         }          }
         if (reader_id != NULL) {          if (pkcs11provider != NULL)
 #ifdef SMARTCARD                  do_download(pw, pkcs11provider);
                 if (download)  
                         do_download(pw, reader_id);  
                 else  
                         do_upload(pw, reader_id);  
 #else /* SMARTCARD */  
                 fatal("no support for smartcards.");  
 #endif /* SMARTCARD */  
         }  
   
         if (do_gen_candidates) {          if (do_gen_candidates) {
                 FILE *out = fopen(out_file, "w");                  FILE *out = fopen(out_file, "w");

Legend:
Removed from v.1.176  
changed lines
  Added in v.1.177