diff options
author | Damien Miller <djm@mindrot.org> | 2000-04-16 11:18:38 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-04-16 11:18:38 +1000 |
commit | 4af51306d9a51459a5bef922df1037f876ae51fe (patch) | |
tree | 09ecfc215fce82345a3259f8a0f384b9a67906f0 /sshconnect.c | |
parent | 5d1705ecf9bd3216dc99a84242bcdf2e7297d307 (diff) |
- OpenBSD CVS updates.
[ssh.1 ssh.c]
- ssh -2
[auth.c channels.c clientloop.c packet.c packet.h serverloop.c]
[session.c sshconnect.c]
- check payload for (illegal) extra data
[ALL]
- whitespace cleanup
Diffstat (limited to 'sshconnect.c')
-rw-r--r-- | sshconnect.c | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/sshconnect.c b/sshconnect.c index 675de6102..bca0bf43a 100644 --- a/sshconnect.c +++ b/sshconnect.c | |||
@@ -10,7 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | RCSID("$OpenBSD: sshconnect.c,v 1.66 2000/04/12 09:39:10 markus Exp $"); | 13 | RCSID("$OpenBSD: sshconnect.c,v 1.68 2000/04/14 10:30:33 markus Exp $"); |
14 | 14 | ||
15 | #ifdef HAVE_OPENSSL | 15 | #ifdef HAVE_OPENSSL |
16 | #include <openssl/bn.h> | 16 | #include <openssl/bn.h> |
@@ -250,7 +250,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, | |||
250 | debug("Trying again..."); | 250 | debug("Trying again..."); |
251 | 251 | ||
252 | /* Loop through addresses for this host, and try each one in | 252 | /* Loop through addresses for this host, and try each one in |
253 | sequence until the connection succeeds. */ | 253 | sequence until the connection succeeds. */ |
254 | for (ai = aitop; ai; ai = ai->ai_next) { | 254 | for (ai = aitop; ai; ai = ai->ai_next) { |
255 | if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) | 255 | if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) |
256 | continue; | 256 | continue; |
@@ -264,7 +264,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, | |||
264 | host, ntop, strport); | 264 | host, ntop, strport); |
265 | 265 | ||
266 | /* Create a socket for connecting. */ | 266 | /* Create a socket for connecting. */ |
267 | sock = ssh_create_socket(original_real_uid, | 267 | sock = ssh_create_socket(original_real_uid, |
268 | !anonymous && geteuid() == 0 && port < IPPORT_RESERVED, | 268 | !anonymous && geteuid() == 0 && port < IPPORT_RESERVED, |
269 | ai->ai_family); | 269 | ai->ai_family); |
270 | if (sock < 0) | 270 | if (sock < 0) |
@@ -1059,7 +1059,7 @@ ssh_exchange_identification() | |||
1059 | break; | 1059 | break; |
1060 | } | 1060 | } |
1061 | /* FALLTHROUGH */ | 1061 | /* FALLTHROUGH */ |
1062 | default: | 1062 | default: |
1063 | mismatch = 1; | 1063 | mismatch = 1; |
1064 | break; | 1064 | break; |
1065 | } | 1065 | } |
@@ -1363,13 +1363,13 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1363 | 1363 | ||
1364 | debug("Sending KEX init."); | 1364 | debug("Sending KEX init."); |
1365 | if (options.ciphers != NULL) { | 1365 | if (options.ciphers != NULL) { |
1366 | myproposal[PROPOSAL_ENC_ALGS_CTOS] = | 1366 | myproposal[PROPOSAL_ENC_ALGS_CTOS] = |
1367 | myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers; | 1367 | myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers; |
1368 | } else if ( | 1368 | } else if ( |
1369 | options.cipher == SSH_CIPHER_ARCFOUR || | 1369 | options.cipher == SSH_CIPHER_ARCFOUR || |
1370 | options.cipher == SSH_CIPHER_3DES_CBC || | 1370 | options.cipher == SSH_CIPHER_3DES_CBC || |
1371 | options.cipher == SSH_CIPHER_CAST128_CBC || | 1371 | options.cipher == SSH_CIPHER_CAST128_CBC || |
1372 | options.cipher == SSH_CIPHER_BLOWFISH_CBC) { | 1372 | options.cipher == SSH_CIPHER_BLOWFISH_CBC) { |
1373 | myproposal[PROPOSAL_ENC_ALGS_CTOS] = | 1373 | myproposal[PROPOSAL_ENC_ALGS_CTOS] = |
1374 | myproposal[PROPOSAL_ENC_ALGS_STOC] = cipher_name(options.cipher); | 1374 | myproposal[PROPOSAL_ENC_ALGS_STOC] = cipher_name(options.cipher); |
1375 | } | 1375 | } |
@@ -1411,6 +1411,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1411 | debug("first kex follow == %d", i); | 1411 | debug("first kex follow == %d", i); |
1412 | i = packet_get_int(); | 1412 | i = packet_get_int(); |
1413 | debug("reserved == %d", i); | 1413 | debug("reserved == %d", i); |
1414 | packet_done(); | ||
1414 | 1415 | ||
1415 | debug("done read kexinit"); | 1416 | debug("done read kexinit"); |
1416 | kex = kex_choose_conf(cprop, sprop, 0); | 1417 | kex = kex_choose_conf(cprop, sprop, 0); |
@@ -1434,7 +1435,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1434 | fprintf(stderr, "\npub= "); | 1435 | fprintf(stderr, "\npub= "); |
1435 | bignum_print(dh->pub_key); | 1436 | bignum_print(dh->pub_key); |
1436 | fprintf(stderr, "\n"); | 1437 | fprintf(stderr, "\n"); |
1437 | DHparams_print_fp(stderr, dh); | 1438 | DHparams_print_fp(stderr, dh); |
1438 | #endif | 1439 | #endif |
1439 | 1440 | ||
1440 | debug("Wait SSH2_MSG_KEXDH_REPLY."); | 1441 | debug("Wait SSH2_MSG_KEXDH_REPLY."); |
@@ -1466,6 +1467,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1466 | 1467 | ||
1467 | /* signed H */ | 1468 | /* signed H */ |
1468 | signature = packet_get_string(&slen); | 1469 | signature = packet_get_string(&slen); |
1470 | packet_done(); | ||
1469 | 1471 | ||
1470 | if (!dh_pub_is_valid(dh, dh_server_pub)) | 1472 | if (!dh_pub_is_valid(dh, dh_server_pub)) |
1471 | packet_disconnect("bad server public DH value"); | 1473 | packet_disconnect("bad server public DH value"); |
@@ -1475,14 +1477,14 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1475 | kout = DH_compute_key(kbuf, dh_server_pub, dh); | 1477 | kout = DH_compute_key(kbuf, dh_server_pub, dh); |
1476 | #ifdef DEBUG_KEXDH | 1478 | #ifdef DEBUG_KEXDH |
1477 | debug("shared secret: len %d/%d", klen, kout); | 1479 | debug("shared secret: len %d/%d", klen, kout); |
1478 | fprintf(stderr, "shared secret == "); | 1480 | fprintf(stderr, "shared secret == "); |
1479 | for (i = 0; i< kout; i++) | 1481 | for (i = 0; i< kout; i++) |
1480 | fprintf(stderr, "%02x", (kbuf[i])&0xff); | 1482 | fprintf(stderr, "%02x", (kbuf[i])&0xff); |
1481 | fprintf(stderr, "\n"); | 1483 | fprintf(stderr, "\n"); |
1482 | #endif | 1484 | #endif |
1483 | shared_secret = BN_new(); | 1485 | shared_secret = BN_new(); |
1484 | 1486 | ||
1485 | BN_bin2bn(kbuf, kout, shared_secret); | 1487 | BN_bin2bn(kbuf, kout, shared_secret); |
1486 | memset(kbuf, 0, klen); | 1488 | memset(kbuf, 0, klen); |
1487 | xfree(kbuf); | 1489 | xfree(kbuf); |
1488 | 1490 | ||
@@ -1502,10 +1504,10 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1502 | xfree(client_kexinit); | 1504 | xfree(client_kexinit); |
1503 | xfree(server_kexinit); | 1505 | xfree(server_kexinit); |
1504 | #ifdef DEBUG_KEXDH | 1506 | #ifdef DEBUG_KEXDH |
1505 | fprintf(stderr, "hash == "); | 1507 | fprintf(stderr, "hash == "); |
1506 | for (i = 0; i< 20; i++) | 1508 | for (i = 0; i< 20; i++) |
1507 | fprintf(stderr, "%02x", (hash[i])&0xff); | 1509 | fprintf(stderr, "%02x", (hash[i])&0xff); |
1508 | fprintf(stderr, "\n"); | 1510 | fprintf(stderr, "\n"); |
1509 | #endif | 1511 | #endif |
1510 | dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20); | 1512 | dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20); |
1511 | key_free(server_host_key); | 1513 | key_free(server_host_key); |
@@ -1518,6 +1520,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) | |||
1518 | 1520 | ||
1519 | debug("Wait SSH2_MSG_NEWKEYS."); | 1521 | debug("Wait SSH2_MSG_NEWKEYS."); |
1520 | packet_read_expect(&payload_len, SSH2_MSG_NEWKEYS); | 1522 | packet_read_expect(&payload_len, SSH2_MSG_NEWKEYS); |
1523 | packet_done(); | ||
1521 | debug("GOT SSH2_MSG_NEWKEYS."); | 1524 | debug("GOT SSH2_MSG_NEWKEYS."); |
1522 | 1525 | ||
1523 | debug("send SSH2_MSG_NEWKEYS."); | 1526 | debug("send SSH2_MSG_NEWKEYS."); |
@@ -1551,7 +1554,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key, | |||
1551 | char *server_user, *local_user; | 1554 | char *server_user, *local_user; |
1552 | char *auths; | 1555 | char *auths; |
1553 | char *password; | 1556 | char *password; |
1554 | char *service = "ssh-connection"; // service name | 1557 | char *service = "ssh-connection"; /* service name */ |
1555 | 1558 | ||
1556 | debug("send SSH2_MSG_SERVICE_REQUEST"); | 1559 | debug("send SSH2_MSG_SERVICE_REQUEST"); |
1557 | packet_start(SSH2_MSG_SERVICE_REQUEST); | 1560 | packet_start(SSH2_MSG_SERVICE_REQUEST); |
@@ -1563,8 +1566,15 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key, | |||
1563 | if (type != SSH2_MSG_SERVICE_ACCEPT) { | 1566 | if (type != SSH2_MSG_SERVICE_ACCEPT) { |
1564 | fatal("denied SSH2_MSG_SERVICE_ACCEPT: %d", type); | 1567 | fatal("denied SSH2_MSG_SERVICE_ACCEPT: %d", type); |
1565 | } | 1568 | } |
1566 | /* payload empty for ssh-2.0.13 ?? */ | 1569 | if (packet_remaining() > 0) { |
1567 | /* reply = packet_get_string(&payload_len); */ | 1570 | char *reply = packet_get_string(&plen); |
1571 | debug("service_accept: %s", reply); | ||
1572 | xfree(reply); | ||
1573 | } else { | ||
1574 | /* payload empty for ssh-2.0.13 ?? */ | ||
1575 | log("buggy server: service_accept w/o service"); | ||
1576 | } | ||
1577 | packet_done(); | ||
1568 | debug("got SSH2_MSG_SERVICE_ACCEPT"); | 1578 | debug("got SSH2_MSG_SERVICE_ACCEPT"); |
1569 | 1579 | ||
1570 | /*XX COMMONCODE: */ | 1580 | /*XX COMMONCODE: */ |
@@ -1593,6 +1603,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key, | |||
1593 | auths = packet_get_string(&dlen); | 1603 | auths = packet_get_string(&dlen); |
1594 | debug("authentications that can continue: %s", auths); | 1604 | debug("authentications that can continue: %s", auths); |
1595 | partial = packet_get_char(); | 1605 | partial = packet_get_char(); |
1606 | packet_done(); | ||
1596 | if (partial) | 1607 | if (partial) |
1597 | debug("partial success"); | 1608 | debug("partial success"); |
1598 | if (strstr(auths, "password") == NULL) | 1609 | if (strstr(auths, "password") == NULL) |
@@ -1613,6 +1624,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key, | |||
1613 | packet_send(); | 1624 | packet_send(); |
1614 | packet_write_wait(); | 1625 | packet_write_wait(); |
1615 | } | 1626 | } |
1627 | packet_done(); | ||
1616 | debug("ssh-userauth2 successfull"); | 1628 | debug("ssh-userauth2 successfull"); |
1617 | } | 1629 | } |
1618 | 1630 | ||