+ /* List client->server encryption algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ cipherstr_started = 0;
+ for (i = 0; i < s->n_preferred_ciphers; i++) {
+ const struct ssh2_ciphers *c = s->preferred_ciphers[i];
+ if (!c) continue; /* warning flag */
+ for (j = 0; j < c->nciphers; j++) {
+ if (cipherstr_started)
+ ssh2_pkt_addstring_str(ssh, ",");
+ ssh2_pkt_addstring_str(ssh, c->list[j]->name);
+ cipherstr_started = 1;
+ }
+ }
+ /* List server->client encryption algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ cipherstr_started = 0;
+ for (i = 0; i < s->n_preferred_ciphers; i++) {
+ const struct ssh2_ciphers *c = s->preferred_ciphers[i];
+ if (!c) continue; /* warning flag */
+ for (j = 0; j < c->nciphers; j++) {
+ if (cipherstr_started)
+ ssh2_pkt_addstring_str(ssh, ",");
+ ssh2_pkt_addstring_str(ssh, c->list[j]->name);
+ cipherstr_started = 1;
+ }
+ }
+ /* List client->server MAC algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ for (i = 0; i < s->nmacs; i++) {
+ ssh2_pkt_addstring_str(ssh, s->maclist[i]->name);
+ if (i < s->nmacs - 1)
+ ssh2_pkt_addstring_str(ssh, ",");
+ }
+ /* List server->client MAC algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ for (i = 0; i < s->nmacs; i++) {
+ ssh2_pkt_addstring_str(ssh, s->maclist[i]->name);
+ if (i < s->nmacs - 1)
+ ssh2_pkt_addstring_str(ssh, ",");
+ }
+ /* List client->server compression algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ for (i = 0; i < lenof(compressions) + 1; i++) {
+ const struct ssh_compress *c =
+ i == 0 ? s->preferred_comp : compressions[i - 1];
+ ssh2_pkt_addstring_str(ssh, c->name);
+ if (i < lenof(compressions))
+ ssh2_pkt_addstring_str(ssh, ",");
+ }
+ /* List server->client compression algorithms. */
+ ssh2_pkt_addstring_start(ssh);
+ for (i = 0; i < lenof(compressions) + 1; i++) {
+ const struct ssh_compress *c =
+ i == 0 ? s->preferred_comp : compressions[i - 1];
+ ssh2_pkt_addstring_str(ssh, c->name);
+ if (i < lenof(compressions))
+ ssh2_pkt_addstring_str(ssh, ",");
+ }
+ /* List client->server languages. Empty list. */
+ ssh2_pkt_addstring_start(ssh);
+ /* List server->client languages. Empty list. */
+ ssh2_pkt_addstring_start(ssh);
+ /* First KEX packet does _not_ follow, because we're not that brave. */
+ ssh2_pkt_addbool(ssh, FALSE);
+ /* Reserved. */
+ ssh2_pkt_adduint32(ssh, 0);