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

Diff for /src/usr.bin/ssh/ssh-add.c between version 1.15 and 1.16

version 1.15, 1999/12/02 20:05:40 version 1.16, 2000/04/26 20:56:29
Line 9 
Line 9 
 #include "includes.h"  #include "includes.h"
 RCSID("$Id$");  RCSID("$Id$");
   
   #include <openssl/rsa.h>
   #include <openssl/dsa.h>
   
 #include "rsa.h"  #include "rsa.h"
 #include "ssh.h"  #include "ssh.h"
 #include "xmalloc.h"  #include "xmalloc.h"
 #include "authfd.h"  #include "authfd.h"
 #include "fingerprint.h"  #include "fingerprint.h"
   #include "key.h"
   #include "authfile.h"
   
 void  void
 delete_file(AuthenticationConnection *ac, const char *filename)  delete_file(AuthenticationConnection *ac, const char *filename)
 {  {
         RSA *key;          Key *public;
         char *comment;          char *comment;
   
         key = RSA_new();          public = key_new(KEY_RSA);
         if (!load_public_key(filename, key, &comment)) {          if (!load_public_key(filename, public, &comment)) {
                 printf("Bad key file %s: %s\n", filename, strerror(errno));                  printf("Bad key file %s: %s\n", filename, strerror(errno));
                 return;                  return;
         }          }
         if (ssh_remove_identity(ac, key))          if (ssh_remove_identity(ac, public->rsa))
                 fprintf(stderr, "Identity removed: %s (%s)\n", filename, comment);                  fprintf(stderr, "Identity removed: %s (%s)\n", filename, comment);
         else          else
                 fprintf(stderr, "Could not remove identity: %s\n", filename);                  fprintf(stderr, "Could not remove identity: %s\n", filename);
         RSA_free(key);          key_free(public);
         xfree(comment);          xfree(comment);
 }  }
   
Line 85 
Line 90 
 void  void
 add_file(AuthenticationConnection *ac, const char *filename)  add_file(AuthenticationConnection *ac, const char *filename)
 {  {
         RSA *key;          Key *public;
         RSA *public_key;          Key *private;
         char *saved_comment, *comment, *askpass = NULL;          char *saved_comment, *comment, *askpass = NULL;
         char buf[1024], msg[1024];          char buf[1024], msg[1024];
         int success;          int success;
         int interactive = isatty(STDIN_FILENO);          int interactive = isatty(STDIN_FILENO);
   
         key = RSA_new();          public = key_new(KEY_RSA);
         public_key = RSA_new();          if (!load_public_key(filename, public, &saved_comment)) {
         if (!load_public_key(filename, public_key, &saved_comment)) {  
                 printf("Bad key file %s: %s\n", filename, strerror(errno));                  printf("Bad key file %s: %s\n", filename, strerror(errno));
                 return;                  return;
         }          }
         RSA_free(public_key);          key_free(public);
   
         if (!interactive && getenv("DISPLAY")) {          if (!interactive && getenv("DISPLAY")) {
                 if (getenv(SSH_ASKPASS_ENV))                  if (getenv(SSH_ASKPASS_ENV))
Line 108 
Line 112 
         }          }
   
         /* At first, try empty passphrase */          /* At first, try empty passphrase */
         success = load_private_key(filename, "", key, &comment);          private = key_new(KEY_RSA);
           success = load_private_key(filename, "", private, &comment);
         if (!success) {          if (!success) {
                 printf("Need passphrase for %.200s\n", filename);                  printf("Need passphrase for %.200s\n", filename);
                 if (!interactive && askpass == NULL) {                  if (!interactive && askpass == NULL) {
Line 129 
Line 134 
                                 xfree(saved_comment);                                  xfree(saved_comment);
                                 return;                                  return;
                         }                          }
                         success = load_private_key(filename, pass, key, &comment);                          success = load_private_key(filename, pass, private, &comment);
                         memset(pass, 0, strlen(pass));                          memset(pass, 0, strlen(pass));
                         xfree(pass);                          xfree(pass);
                         if (success)                          if (success)
Line 139 
Line 144 
         }          }
         xfree(saved_comment);          xfree(saved_comment);
   
         if (ssh_add_identity(ac, key, comment))          if (ssh_add_identity(ac, private->rsa, comment))
                 fprintf(stderr, "Identity added: %s (%s)\n", filename, comment);                  fprintf(stderr, "Identity added: %s (%s)\n", filename, comment);
         else          else
                 fprintf(stderr, "Could not add identity: %s\n", filename);                  fprintf(stderr, "Could not add identity: %s\n", filename);
         RSA_free(key);          key_free(private);
         xfree(comment);          xfree(comment);
 }  }
   

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