- ssh_pkt_getstring(pktin, &str, &len); /* client->server mac */
- if (!str) {
- bombout(("KEXINIT packet was incomplete"));
- crStopV;
- }
- for (i = 0; i < s->nmacs; i++) {
- if (in_commasep_string(s->maclist[i]->name, str, len)) {
- s->csmac_tobe = s->maclist[i];
- s->csmac_etm_tobe = FALSE;
- break;
- }
- }
- if (!s->csmac_tobe) {
- for (i = 0; i < s->nmacs; i++) {
- if (s->maclist[i]->etm_name &&
- in_commasep_string(s->maclist[i]->etm_name, str, len)) {
- s->csmac_tobe = s->maclist[i];
- s->csmac_etm_tobe = TRUE;
- break;
- }
- }
- }
- if (!s->csmac_tobe) {
- bombout(("Couldn't agree a client-to-server MAC"
- " (available: %.*s)", len, str));
- crStopV;
- }
- ssh_pkt_getstring(pktin, &str, &len); /* server->client mac */
- if (!str) {
- bombout(("KEXINIT packet was incomplete"));
- crStopV;
- }
- for (i = 0; i < s->nmacs; i++) {
- if (in_commasep_string(s->maclist[i]->name, str, len)) {
- s->scmac_tobe = s->maclist[i];
- s->scmac_etm_tobe = FALSE;
- break;
- }
- }
- if (!s->scmac_tobe) {
- for (i = 0; i < s->nmacs; i++) {
- if (s->maclist[i]->etm_name &&
- in_commasep_string(s->maclist[i]->etm_name, str, len)) {
- s->scmac_tobe = s->maclist[i];
- s->scmac_etm_tobe = TRUE;
- break;
- }
- }
- }
- if (!s->scmac_tobe) {
- bombout(("Couldn't agree a server-to-client MAC"
- " (available: %.*s)", len, str));
- crStopV;
- }
- ssh_pkt_getstring(pktin, &str, &len); /* client->server compression */
- if (!str) {
- bombout(("KEXINIT packet was incomplete"));
- crStopV;
- }
- for (i = 0; i < lenof(compressions) + 1; i++) {
- const struct ssh_compress *c =
- i == 0 ? s->preferred_comp : compressions[i - 1];
- if (in_commasep_string(c->name, str, len)) {
- s->cscomp_tobe = c;
- break;
- } else if (in_commasep_string(c->delayed_name, str, len)) {
- if (s->userauth_succeeded) {
- s->cscomp_tobe = c;
- break;
- } else {
- s->pending_compression = TRUE; /* try this later */
- }
- }
- }
- ssh_pkt_getstring(pktin, &str, &len); /* server->client compression */
- if (!str) {
- bombout(("KEXINIT packet was incomplete"));
- crStopV;
- }
- for (i = 0; i < lenof(compressions) + 1; i++) {
- const struct ssh_compress *c =
- i == 0 ? s->preferred_comp : compressions[i - 1];
- if (in_commasep_string(c->name, str, len)) {
- s->sccomp_tobe = c;
- break;
- } else if (in_commasep_string(c->delayed_name, str, len)) {
- if (s->userauth_succeeded) {
- s->sccomp_tobe = c;
- break;
- } else {
- s->pending_compression = TRUE; /* try this later */
- }
- }
- }