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

Diff for /src/usr.bin/ssh/authfile.c between version 1.108 and 1.109

version 1.108, 2014/12/04 02:24:32 version 1.109, 2015/01/08 10:14:08
Line 93 
Line 93 
   
 /* Load a key from a fd into a buffer */  /* Load a key from a fd into a buffer */
 int  int
 sshkey_load_file(int fd, const char *filename, struct sshbuf *blob)  sshkey_load_file(int fd, struct sshbuf *blob)
 {  {
         u_char buf[1024];          u_char buf[1024];
         size_t len;          size_t len;
Line 140 
Line 140 
  * otherwise.   * otherwise.
  */   */
 static int  static int
 sshkey_load_public_rsa1(int fd, const char *filename,  sshkey_load_public_rsa1(int fd, struct sshkey **keyp, char **commentp)
     struct sshkey **keyp, char **commentp)  
 {  {
         struct sshbuf *b = NULL;          struct sshbuf *b = NULL;
         int r;          int r;
Line 152 
Line 151 
   
         if ((b = sshbuf_new()) == NULL)          if ((b = sshbuf_new()) == NULL)
                 return SSH_ERR_ALLOC_FAIL;                  return SSH_ERR_ALLOC_FAIL;
         if ((r = sshkey_load_file(fd, filename, b)) != 0)          if ((r = sshkey_load_file(fd, b)) != 0)
                 goto out;                  goto out;
         if ((r = sshkey_parse_public_rsa1_fileblob(b, keyp, commentp)) != 0)          if ((r = sshkey_parse_public_rsa1_fileblob(b, keyp, commentp)) != 0)
                 goto out;                  goto out;
Line 163 
Line 162 
 }  }
 #endif /* WITH_SSH1 */  #endif /* WITH_SSH1 */
   
 #ifdef WITH_OPENSSL  
 /* XXX Deprecate? */  
 int  
 sshkey_load_private_pem(int fd, int type, const char *passphrase,  
     struct sshkey **keyp, char **commentp)  
 {  
         struct sshbuf *buffer = NULL;  
         int r;  
   
         *keyp = NULL;  
         if (commentp != NULL)  
                 *commentp = NULL;  
   
         if ((buffer = sshbuf_new()) == NULL)  
                 return SSH_ERR_ALLOC_FAIL;  
         if ((r = sshkey_load_file(fd, NULL, buffer)) != 0)  
                 goto out;  
         if ((r = sshkey_parse_private_pem_fileblob(buffer, type, passphrase,  
             keyp, commentp)) != 0)  
                 goto out;  
         r = 0;  
  out:  
         sshbuf_free(buffer);  
         return r;  
 }  
 #endif /* WITH_OPENSSL */  
   
 /* XXX remove error() calls from here? */  /* XXX remove error() calls from here? */
 int  int
 sshkey_perm_ok(int fd, const char *filename)  sshkey_perm_ok(int fd, const char *filename)
Line 222 
Line 194 
     struct sshkey **keyp, char **commentp, int *perm_ok)      struct sshkey **keyp, char **commentp, int *perm_ok)
 {  {
         int fd, r;          int fd, r;
         struct sshbuf *buffer = NULL;  
   
         *keyp = NULL;          *keyp = NULL;
         if (commentp != NULL)          if (commentp != NULL)
Line 242 
Line 213 
         if (perm_ok != NULL)          if (perm_ok != NULL)
                 *perm_ok = 1;                  *perm_ok = 1;
   
           r = sshkey_load_private_type_fd(fd, type, passphrase, keyp, commentp);
    out:
           close(fd);
           return r;
   }
   
   int
   sshkey_load_private_type_fd(int fd, int type, const char *passphrase,
       struct sshkey **keyp, char **commentp)
   {
           struct sshbuf *buffer = NULL;
           int r;
   
         if ((buffer = sshbuf_new()) == NULL) {          if ((buffer = sshbuf_new()) == NULL) {
                 r = SSH_ERR_ALLOC_FAIL;                  r = SSH_ERR_ALLOC_FAIL;
                 goto out;                  goto out;
         }          }
         if ((r = sshkey_load_file(fd, filename, buffer)) != 0)          if ((r = sshkey_load_file(fd, buffer)) != 0 ||
               (r = sshkey_parse_private_fileblob_type(buffer, type,
               passphrase, keyp, commentp)) != 0)
                 goto out;                  goto out;
         if ((r = sshkey_parse_private_fileblob_type(buffer, type, passphrase,  
             keyp, commentp)) != 0)          /* success */
                 goto out;  
         r = 0;          r = 0;
  out:   out:
         close(fd);  
         if (buffer != NULL)          if (buffer != NULL)
                 sshbuf_free(buffer);                  sshbuf_free(buffer);
         return r;          return r;
Line 282 
Line 266 
                 r = SSH_ERR_ALLOC_FAIL;                  r = SSH_ERR_ALLOC_FAIL;
                 goto out;                  goto out;
         }          }
         if ((r = sshkey_load_file(fd, filename, buffer)) != 0 ||          if ((r = sshkey_load_file(fd, buffer)) != 0 ||
             (r = sshkey_parse_private_fileblob(buffer, passphrase, filename,              (r = sshkey_parse_private_fileblob(buffer, passphrase, filename,
             keyp, commentp)) != 0)              keyp, commentp)) != 0)
                 goto out;                  goto out;
Line 358 
Line 342 
                 goto skip;                  goto skip;
 #ifdef WITH_SSH1  #ifdef WITH_SSH1
         /* try rsa1 private key */          /* try rsa1 private key */
         r = sshkey_load_public_rsa1(fd, filename, keyp, commentp);          r = sshkey_load_public_rsa1(fd, keyp, commentp);
         close(fd);          close(fd);
         switch (r) {          switch (r) {
         case SSH_ERR_INTERNAL_ERROR:          case SSH_ERR_INTERNAL_ERROR:

Legend:
Removed from v.1.108  
changed lines
  Added in v.1.109