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

Diff for /src/usr.bin/ssh/sshconnect2.c between version 1.27 and 1.28

version 1.27, 2000/10/19 16:45:16 version 1.28, 2000/11/12 19:50:38
Line 45 
Line 45 
 #include "kex.h"  #include "kex.h"
 #include "myproposal.h"  #include "myproposal.h"
 #include "key.h"  #include "key.h"
 #include "dsa.h"  
 #include "sshconnect.h"  #include "sshconnect.h"
 #include "authfile.h"  #include "authfile.h"
 #include "cli.h"  #include "cli.h"
Line 196 
Line 195 
   
         /* key, cert */          /* key, cert */
         server_host_key_blob = packet_get_string(&sbloblen);          server_host_key_blob = packet_get_string(&sbloblen);
         server_host_key = dsa_key_from_blob(server_host_key_blob, sbloblen);          server_host_key = key_from_blob(server_host_key_blob, sbloblen);
         if (server_host_key == NULL)          if (server_host_key == NULL)
                 fatal("cannot decode server_host_key_blob");                  fatal("cannot decode server_host_key_blob");
   
Line 258 
Line 257 
                 fprintf(stderr, "%02x", (hash[i])&0xff);                  fprintf(stderr, "%02x", (hash[i])&0xff);
         fprintf(stderr, "\n");          fprintf(stderr, "\n");
 #endif  #endif
         if (dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20) != 1)          if (key_verify(server_host_key, (unsigned char *)signature, slen, hash, 20) != 1)
                 fatal("dsa_verify failed for server_host_key");                  fatal("key_verify failed for server_host_key");
         key_free(server_host_key);          key_free(server_host_key);
   
         kex_derive_keys(kex, hash, shared_secret);          kex_derive_keys(kex, hash, shared_secret);
Line 366 
Line 365 
   
         /* key, cert */          /* key, cert */
         server_host_key_blob = packet_get_string(&sbloblen);          server_host_key_blob = packet_get_string(&sbloblen);
         server_host_key = dsa_key_from_blob(server_host_key_blob, sbloblen);          server_host_key = key_from_blob(server_host_key_blob, sbloblen);
         if (server_host_key == NULL)          if (server_host_key == NULL)
                 fatal("cannot decode server_host_key_blob");                  fatal("cannot decode server_host_key_blob");
   
Line 429 
Line 428 
                 fprintf(stderr, "%02x", (hash[i])&0xff);                  fprintf(stderr, "%02x", (hash[i])&0xff);
         fprintf(stderr, "\n");          fprintf(stderr, "\n");
 #endif  #endif
         if (dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20) != 1)          if (key_verify(server_host_key, (unsigned char *)signature, slen, hash, 20) != 1)
                 fatal("dsa_verify failed for server_host_key");                  fatal("key_verify failed for server_host_key");
         key_free(server_host_key);          key_free(server_host_key);
   
         kex_derive_keys(kex, hash, shared_secret);          kex_derive_keys(kex, hash, shared_secret);
Line 485 
Line 484 
 Authmethod authmethods[] = {  Authmethod authmethods[] = {
         {"publickey",          {"publickey",
                 userauth_pubkey,                  userauth_pubkey,
                 &options.dsa_authentication,                  &options.pubkey_authentication,
                 NULL},                  NULL},
         {"password",          {"password",
                 userauth_passwd,                  userauth_passwd,
Line 653 
Line 652 
         int ret = -1;          int ret = -1;
         int have_sig = 1;          int have_sig = 1;
   
         dsa_make_key_blob(k, &blob, &bloblen);          if (key_to_blob(k, &blob, &bloblen) == 0) {
                   /* we cannot handle this key */
                   return 0;
           }
         /* data to be signed */          /* data to be signed */
         buffer_init(&b);          buffer_init(&b);
         if (datafellows & SSH_OLD_SESSIONID) {          if (datafellows & SSH_OLD_SESSIONID) {
Line 672 
Line 673 
             authctxt->service);              authctxt->service);
         buffer_put_cstring(&b, authctxt->method->name);          buffer_put_cstring(&b, authctxt->method->name);
         buffer_put_char(&b, have_sig);          buffer_put_char(&b, have_sig);
         buffer_put_cstring(&b, KEX_DSS);          buffer_put_cstring(&b, key_ssh_name(k));
         buffer_put_string(&b, blob, bloblen);          buffer_put_string(&b, blob, bloblen);
   
         /* generate signature */          /* generate signature */
Line 682 
Line 683 
                 buffer_free(&b);                  buffer_free(&b);
                 return 0;                  return 0;
         }          }
 #ifdef DEBUG_DSS  #ifdef DEBUG_PK
         buffer_dump(&b);          buffer_dump(&b);
 #endif  #endif
         if (datafellows & SSH_BUG_PUBKEYAUTH) {          if (datafellows & SSH_BUG_PUBKEYAUTH) {
Line 693 
Line 694 
                 buffer_put_cstring(&b, authctxt->service);                  buffer_put_cstring(&b, authctxt->service);
                 buffer_put_cstring(&b, authctxt->method->name);                  buffer_put_cstring(&b, authctxt->method->name);
                 buffer_put_char(&b, have_sig);                  buffer_put_char(&b, have_sig);
                 buffer_put_cstring(&b, KEX_DSS);                  buffer_put_cstring(&b, key_ssh_name(k));
                 buffer_put_string(&b, blob, bloblen);                  buffer_put_string(&b, blob, bloblen);
         }          }
         xfree(blob);          xfree(blob);
Line 719 
Line 720 
 }  }
   
 /* sign callback */  /* sign callback */
 int dsa_sign_cb(Authctxt *authctxt, Key *key, unsigned char **sigp, int *lenp,  int key_sign_cb(Authctxt *authctxt, Key *key, unsigned char **sigp, int *lenp,
     unsigned char *data, int datalen)      unsigned char *data, int datalen)
 {  {
         return dsa_sign(key, sigp, lenp, data, datalen);          return key_sign(key, sigp, lenp, data, datalen);
 }  }
   
 int  int
Line 738 
Line 739 
         }          }
         debug("try pubkey: %s", filename);          debug("try pubkey: %s", filename);
   
         k = key_new(KEY_DSA);          k = key_new(KEY_UNSPEC);
         if (!load_private_key(filename, "", k, NULL)) {          if (!load_private_key(filename, "", k, NULL)) {
                 int success = 0;                  int success = 0;
                 char *passphrase;                  char *passphrase;
                 char prompt[300];                  char prompt[300];
                 snprintf(prompt, sizeof prompt,                  snprintf(prompt, sizeof prompt,
                      "Enter passphrase for %s key '%.100s': ",                       "Enter passphrase for key '%.100s': ", filename);
                      key_type(k), filename);  
                 for (i = 0; i < options.number_of_password_prompts; i++) {                  for (i = 0; i < options.number_of_password_prompts; i++) {
                         passphrase = read_passphrase(prompt, 0);                          passphrase = read_passphrase(prompt, 0);
                         if (strcmp(passphrase, "") != 0) {                          if (strcmp(passphrase, "") != 0) {
Line 766 
Line 766 
                         return 0;                          return 0;
                 }                  }
         }          }
         ret = sign_and_send_pubkey(authctxt, k, dsa_sign_cb);          ret = sign_and_send_pubkey(authctxt, k, key_sign_cb);
         key_free(k);          key_free(k);
         return ret;          return ret;
 }  }
Line 782 
Line 782 
 userauth_pubkey_agent(Authctxt *authctxt)  userauth_pubkey_agent(Authctxt *authctxt)
 {  {
         static int called = 0;          static int called = 0;
           int ret = 0;
         char *comment;          char *comment;
         Key *k;          Key *k;
         int ret;  
   
         if (called == 0) {          if (called == 0) {
                 k = ssh_get_first_identity(authctxt->agent, &comment, 2);                  if (ssh_get_num_identities(authctxt->agent, 2) == 0)
                           debug2("userauth_pubkey_agent: no keys at all");
                 called = 1;                  called = 1;
         } else {  
                 k = ssh_get_next_identity(authctxt->agent, &comment, 2);  
         }          }
           k = ssh_get_next_identity(authctxt->agent, &comment, 2);
         if (k == NULL) {          if (k == NULL) {
                 debug2("no more DSA keys from agent");                  debug2("userauth_pubkey_agent: no more keys");
                 return 0;          } else {
                   debug("userauth_pubkey_agent: trying agent key %s", comment);
                   xfree(comment);
                   ret = sign_and_send_pubkey(authctxt, k, agent_sign_cb);
                   key_free(k);
         }          }
         debug("trying DSA agent key %s", comment);          if (ret == 0)
         xfree(comment);                  debug2("userauth_pubkey_agent: no message sent");
         ret = sign_and_send_pubkey(authctxt, k, agent_sign_cb);  
         key_free(k);  
         return ret;          return ret;
 }  }
   
Line 809 
Line 811 
         static int idx = 0;          static int idx = 0;
         int sent = 0;          int sent = 0;
   
         if (authctxt->agent != NULL)          if (authctxt->agent != NULL) {
                 sent = userauth_pubkey_agent(authctxt);                  do {
         while (sent == 0 && idx < options.num_identity_files2)                          sent = userauth_pubkey_agent(authctxt);
                 sent = userauth_pubkey_identity(authctxt, options.identity_files2[idx++]);                  } while(!sent && authctxt->agent->howmany > 0);
           }
           while (!sent && idx < options.num_identity_files) {
                   if (options.identity_files_type[idx] != KEY_RSA1)
                           sent = userauth_pubkey_identity(authctxt,
                               options.identity_files[idx]);
                   idx++;
           }
         return sent;          return sent;
 }  }
   

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28