[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.196 and 1.198

version 1.196, 2010/08/04 05:40:39 version 1.198, 2010/08/12 23:34:38
Line 138 
Line 138 
   
 char *key_type_name = NULL;  char *key_type_name = NULL;
   
   /* Load key from this PKCS#11 provider */
   char *pkcs11provider = NULL;
   
 /* argv0 */  /* argv0 */
 extern char *__progname;  extern char *__progname;
Line 647 
Line 649 
 }  }
   
 static void  static void
 do_download(struct passwd *pw, char *pkcs11provider)  do_download(struct passwd *pw)
 {  {
 #ifdef ENABLE_PKCS11  #ifdef ENABLE_PKCS11
         Key **keys = NULL;          Key **keys = NULL;
Line 1310 
Line 1312 
                 add_string_option(c, "source-address", certflags_src_addr);                  add_string_option(c, "source-address", certflags_src_addr);
 }  }
   
   static Key *
   load_pkcs11_key(char *path)
   {
   #ifdef ENABLE_PKCS11
           Key **keys = NULL, *public, *private = NULL;
           int i, nkeys;
   
           if ((public = key_load_public(path, NULL)) == NULL)
                   fatal("Couldn't load CA public key \"%s\"", path);
   
           nkeys = pkcs11_add_provider(pkcs11provider, identity_passphrase, &keys);
           debug3("%s: %d keys", __func__, nkeys);
           if (nkeys <= 0)
                   fatal("cannot read public key from pkcs11");
           for (i = 0; i < nkeys; i++) {
                   if (key_equal_public(public, keys[i])) {
                           private = keys[i];
                           continue;
                   }
                   key_free(keys[i]);
           }
           xfree(keys);
           key_free(public);
           return private;
   #else
           fatal("no pkcs11 support");
   #endif /* ENABLE_PKCS11 */
   }
   
 static void  static void
 do_ca_sign(struct passwd *pw, int argc, char **argv)  do_ca_sign(struct passwd *pw, int argc, char **argv)
 {  {
Line 1320 
Line 1351 
         FILE *f;          FILE *f;
         int v00 = 0; /* legacy keys */          int v00 = 0; /* legacy keys */
   
         tmp = tilde_expand_filename(ca_key_path, pw->pw_uid);  
         if ((ca = load_identity(tmp)) == NULL)  
                 fatal("Couldn't load CA key \"%s\"", tmp);  
         xfree(tmp);  
   
         if (key_type_name != NULL) {          if (key_type_name != NULL) {
                 switch (key_type_from_name(key_type_name)) {                  switch (key_type_from_name(key_type_name)) {
                 case KEY_RSA_CERT_V00:                  case KEY_RSA_CERT_V00:
Line 1344 
Line 1370 
                 }                  }
         }          }
   
           pkcs11_init(1);
           tmp = tilde_expand_filename(ca_key_path, pw->pw_uid);
           if (pkcs11provider != NULL) {
                   if ((ca = load_pkcs11_key(tmp)) == NULL)
                           fatal("No PKCS#11 key matching %s found", ca_key_path);
           } else if ((ca = load_identity(tmp)) == NULL)
                   fatal("Couldn't load CA key \"%s\"", tmp);
           xfree(tmp);
   
         for (i = 0; i < argc; i++) {          for (i = 0; i < argc; i++) {
                 /* Split list of principals */                  /* Split list of principals */
                 n = 0;                  n = 0;
Line 1416 
Line 1451 
                 key_free(public);                  key_free(public);
                 xfree(out);                  xfree(out);
         }          }
           pkcs11_terminate();
         exit(0);          exit(0);
 }  }
   
Line 1717 
Line 1753 
 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], *pkcs11provider = NULL;          char out_file[MAXPATHLEN], *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;
Line 1736 
Line 1771 
         /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */          /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
         sanitise_stdfd();          sanitise_stdfd();
   
         SSLeay_add_all_algorithms();          OpenSSL_add_all_algorithms();
         log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);          log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);
   
         /* we need this for the home * directory.  */          /* we need this for the home * directory.  */
Line 1988 
Line 2023 
                 }                  }
         }          }
         if (pkcs11provider != NULL)          if (pkcs11provider != NULL)
                 do_download(pw, pkcs11provider);                  do_download(pw);
   
         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.196  
changed lines
  Added in v.1.198