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

Diff for /src/usr.bin/ssh/authfd.c between version 1.13 and 1.14

version 1.13, 1999/11/24 00:26:00 version 1.14, 1999/11/24 19:53:44
Line 58 
Line 58 
         return sock;          return sock;
 }  }
   
 /* Closes the agent socket if it should be closed (depends on how it was  /*
    obtained).  The argument must have been returned by   * Closes the agent socket if it should be closed (depends on how it was
    ssh_get_authentication_socket(). */   * obtained).  The argument must have been returned by
    * ssh_get_authentication_socket().
    */
   
 void  void
 ssh_close_authentication_socket(int sock)  ssh_close_authentication_socket(int sock)
Line 69 
Line 71 
                 close(sock);                  close(sock);
 }  }
   
 /* Opens and connects a private socket for communication with the  /*
    authentication agent.  Returns the file descriptor (which must be   * Opens and connects a private socket for communication with the
    shut down and closed by the caller when no longer needed).   * authentication agent.  Returns the file descriptor (which must be
    Returns NULL if an error occurred and the connection could not be   * shut down and closed by the caller when no longer needed).
    opened. */   * Returns NULL if an error occurred and the connection could not be
    * opened.
    */
   
 AuthenticationConnection *  AuthenticationConnection *
 ssh_get_authentication_connection()  ssh_get_authentication_connection()
Line 83 
Line 87 
   
         sock = ssh_get_authentication_socket();          sock = ssh_get_authentication_socket();
   
         /* Fail if we couldn't obtain a connection.  This happens if we          /*
            exited due to a timeout. */           * Fail if we couldn't obtain a connection.  This happens if we
            * exited due to a timeout.
            */
         if (sock < 0)          if (sock < 0)
                 return NULL;                  return NULL;
   
         /* Applocate the connection structure and initialize it. */  
         auth = xmalloc(sizeof(*auth));          auth = xmalloc(sizeof(*auth));
         auth->fd = sock;          auth->fd = sock;
         buffer_init(&auth->packet);          buffer_init(&auth->packet);
Line 98 
Line 103 
         return auth;          return auth;
 }  }
   
 /* Closes the connection to the authentication agent and frees any associated  /*
    memory. */   * Closes the connection to the authentication agent and frees any associated
    * memory.
    */
   
 void  void
 ssh_close_authentication_connection(AuthenticationConnection *ac)  ssh_close_authentication_connection(AuthenticationConnection *ac)
Line 110 
Line 117 
         xfree(ac);          xfree(ac);
 }  }
   
 /* Returns the first authentication identity held by the agent.  /*
    Returns true if an identity is available, 0 otherwise.   * Returns the first authentication identity held by the agent.
    The caller must initialize the integers before the call, and free the   * Returns true if an identity is available, 0 otherwise.
    comment after a successful call (before calling ssh_get_next_identity). */   * The caller must initialize the integers before the call, and free the
    * comment after a successful call (before calling ssh_get_next_identity).
    */
   
 int  int
 ssh_get_first_identity(AuthenticationConnection *auth,  ssh_get_first_identity(AuthenticationConnection *auth,
Line 122 
Line 131 
         unsigned char msg[8192];          unsigned char msg[8192];
         int len, l;          int len, l;
   
         /* Send a message to the agent requesting for a list of the          /*
            identities it can represent. */           * Send a message to the agent requesting for a list of the
            * identities it can represent.
            */
         msg[0] = 0;          msg[0] = 0;
         msg[1] = 0;          msg[1] = 0;
         msg[2] = 0;          msg[2] = 0;
Line 144 
Line 155 
                 len -= l;                  len -= l;
         }          }
   
         /* Extract the length, and check it for sanity.  (We cannot trust          /*
            authentication agents). */           * Extract the length, and check it for sanity.  (We cannot trust
            * authentication agents).
            */
         len = GET_32BIT(msg);          len = GET_32BIT(msg);
         if (len < 1 || len > 256 * 1024)          if (len < 1 || len > 256 * 1024)
                 fatal("Authentication reply message too long: %d\n", len);                  fatal("Authentication reply message too long: %d\n", len);
Line 177 
Line 190 
         return ssh_get_next_identity(auth, e, n, comment);          return ssh_get_next_identity(auth, e, n, comment);
 }  }
   
 /* Returns the next authentication identity for the agent.  Other functions  /*
    can be called between this and ssh_get_first_identity or two calls of this   * Returns the next authentication identity for the agent.  Other functions
    function.  This returns 0 if there are no more identities.  The caller   * can be called between this and ssh_get_first_identity or two calls of this
    must free comment after a successful return. */   * function.  This returns 0 if there are no more identities.  The caller
    * must free comment after a successful return.
    */
   
 int  int
 ssh_get_next_identity(AuthenticationConnection *auth,  ssh_get_next_identity(AuthenticationConnection *auth,
Line 192 
Line 207 
         if (auth->howmany <= 0)          if (auth->howmany <= 0)
                 return 0;                  return 0;
   
         /* Get the next entry from the packet.  These will abort with a          /*
            fatal error if the packet is too short or contains corrupt data. */           * Get the next entry from the packet.  These will abort with a fatal
            * error if the packet is too short or contains corrupt data.
            */
         bits = buffer_get_int(&auth->identities);          bits = buffer_get_int(&auth->identities);
         buffer_get_bignum(&auth->identities, e);          buffer_get_bignum(&auth->identities, e);
         buffer_get_bignum(&auth->identities, n);          buffer_get_bignum(&auth->identities, n);
Line 209 
Line 226 
         return 1;          return 1;
 }  }
   
 /* Generates a random challenge, sends it to the agent, and waits for response  /*
    from the agent.  Returns true (non-zero) if the agent gave the correct   * Generates a random challenge, sends it to the agent, and waits for
    answer, zero otherwise.  Response type selects the style of response   * response from the agent.  Returns true (non-zero) if the agent gave the
    desired, with 0 corresponding to protocol version 1.0 (no longer supported)   * correct answer, zero otherwise.  Response type selects the style of
    and 1 corresponding to protocol version 1.1. */   * response desired, with 0 corresponding to protocol version 1.0 (no longer
    * supported) and 1 corresponding to protocol version 1.1.
    */
   
 int  int
 ssh_decrypt_challenge(AuthenticationConnection *auth,  ssh_decrypt_challenge(AuthenticationConnection *auth,
Line 254 
Line 273 
                 buffer_free(&buffer);                  buffer_free(&buffer);
                 return 0;                  return 0;
         }          }
         /* Wait for response from the agent.  First read the length of the          /*
            response packet. */           * Wait for response from the agent.  First read the length of the
            * response packet.
            */
         len = 4;          len = 4;
         while (len > 0) {          while (len > 0) {
                 l = read(auth->fd, buf + 4 - len, len);                  l = read(auth->fd, buf + 4 - len, len);
Line 298 
Line 319 
         if (buf[0] != SSH_AGENT_RSA_RESPONSE)          if (buf[0] != SSH_AGENT_RSA_RESPONSE)
                 fatal("Bad authentication response: %d", buf[0]);                  fatal("Bad authentication response: %d", buf[0]);
   
         /* Get the response from the packet.  This will abort with a fatal          /*
            error if the packet is corrupt. */           * Get the response from the packet.  This will abort with a fatal
            * error if the packet is corrupt.
            */
         for (i = 0; i < 16; i++)          for (i = 0; i < 16; i++)
                 response[i] = buffer_get_char(&buffer);                  response[i] = buffer_get_char(&buffer);
   
Line 310 
Line 333 
         return 1;          return 1;
 }  }
   
 /* Adds an identity to the authentication server.  This call is not meant to  /*
    be used by normal applications. */   * Adds an identity to the authentication server.  This call is not meant to
    * be used by normal applications.
    */
   
 int  int
 ssh_add_identity(AuthenticationConnection *auth,  ssh_add_identity(AuthenticationConnection *auth,
Line 396 
Line 421 
         return 0;          return 0;
 }  }
   
 /* Removes an identity from the authentication server.  This call is not meant  /*
    to be used by normal applications. */   * Removes an identity from the authentication server.  This call is not
    * meant to be used by normal applications.
    */
   
 int  int
 ssh_remove_identity(AuthenticationConnection *auth, RSA *key)  ssh_remove_identity(AuthenticationConnection *auth, RSA *key)
Line 426 
Line 453 
                 buffer_free(&buffer);                  buffer_free(&buffer);
                 return 0;                  return 0;
         }          }
         /* Wait for response from the agent.  First read the length of the          /*
            response packet. */           * Wait for response from the agent.  First read the length of the
            * response packet.
            */
         len = 4;          len = 4;
         while (len > 0) {          while (len > 0) {
                 l = read(auth->fd, buf + 4 - len, len);                  l = read(auth->fd, buf + 4 - len, len);
Line 475 
Line 504 
         return 0;          return 0;
 }  }
   
 /* Removes all identities from the agent.  This call is not meant  /*
    to be used by normal applications. */   * Removes all identities from the agent.  This call is not meant to be used
    * by normal applications.
    */
   
 int  int
 ssh_remove_all_identities(AuthenticationConnection *auth)  ssh_remove_all_identities(AuthenticationConnection *auth)
Line 494 
Line 525 
                 error("Error writing to authentication socket.");                  error("Error writing to authentication socket.");
                 return 0;                  return 0;
         }          }
         /* Wait for response from the agent.  First read the length of the          /*
            response packet. */           * Wait for response from the agent.  First read the length of the
            * response packet.
            */
         len = 4;          len = 4;
         while (len > 0) {          while (len > 0) {
                 l = read(auth->fd, buf + 4 - len, len);                  l = read(auth->fd, buf + 4 - len, len);

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