diff options
author | Matt Johnston <matt@ucc.asn.au> | 2004-08-06 16:18:01 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2004-08-06 16:18:01 +0000 |
commit | 0bbe2fa8627de1614b4b6992a7ee4290ec572e4d (patch) | |
tree | 77444ba92dd6eb2e6c968e2447647c35e1ea8f91 /cli-authpubkey.c | |
parent | 68f816e8cf5d0ad253a4a20537ae2bda128e0893 (diff) |
- client pubkey auth works
- rearrange the runopts code for client and server (hostkey reading is needed
by both (if the client is doing pubkey auth. otherwise....))
--HG--
extra : convert_revision : 5420858803bfff1e27dfe7fa877ba6fdd747e0c5
Diffstat (limited to 'cli-authpubkey.c')
-rw-r--r-- | cli-authpubkey.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cli-authpubkey.c b/cli-authpubkey.c index dd5a711..6b6ab51 100644 --- a/cli-authpubkey.c +++ b/cli-authpubkey.c @@ -16,7 +16,7 @@ void cli_pubkeyfail() { TRACE(("enter cli_pubkeyfail")); /* Find the key we failed with, and remove it */ - for (keyitem = cli_ses.pubkeys; keyitem != NULL; keyitem = keyitem->next) { + for (keyitem = cli_opts.pubkeys; keyitem != NULL; keyitem = keyitem->next) { if (keyitem->next == cli_ses.lastpubkey) { keyitem->next = cli_ses.lastpubkey->next; } @@ -40,6 +40,7 @@ void recv_msg_userauth_pk_ok() { algotype = buf_getstring(ses.payload, &algolen); keytype = signkey_type_from_name(algotype, algolen); + TRACE(("recv_msg_userauth_pk_ok: type %d", keytype)); m_free(algotype); keybuf = buf_new(MAX_PUBKEY_SIZE); @@ -48,25 +49,32 @@ void recv_msg_userauth_pk_ok() { /* Iterate through our keys, find which one it was that matched, and * send a real request with that key */ - for (keyitem = cli_ses.pubkeys; keyitem != NULL; keyitem = keyitem->next) { + for (keyitem = cli_opts.pubkeys; keyitem != NULL; keyitem = keyitem->next) { if (keyitem->type != keytype) { /* Types differed */ + TRACE(("types differed")); continue; } /* Now we compare the contents of the key */ keybuf->pos = keybuf->len = 0; buf_put_pub_key(keybuf, keyitem->key, keytype); + buf_setpos(keybuf, 0); + buf_incrpos(keybuf, 4); /* first int is the length of the remainder (ie + remotelen) which has already been taken from + the remote buffer */ - if (keybuf->len != remotelen) { + + if (keybuf->len-4 != remotelen) { + TRACE(("lengths differed: localh %d remote %d", keybuf->len, remotelen)); /* Lengths differed */ continue; } - - if (memcmp(keybuf->data, + if (memcmp(buf_getptr(keybuf, remotelen), buf_getptr(ses.payload, remotelen), remotelen) != 0) { /* Data didn't match this key */ + TRACE(("data differed")); continue; } @@ -133,10 +141,10 @@ int cli_auth_pubkey() { TRACE(("enter cli_auth_pubkey")); - if (cli_ses.pubkeys != NULL) { + if (cli_opts.pubkeys != NULL) { /* Send a trial request */ - send_msg_userauth_pubkey(cli_ses.pubkeys->key, - cli_ses.pubkeys->type, 0); + send_msg_userauth_pubkey(cli_opts.pubkeys->key, + cli_opts.pubkeys->type, 0); TRACE(("leave cli_auth_pubkey-success")); return 1; } else { |