╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────────╮ │src/serve_ssh_protocol.zig│ ╰──────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1427 // signature verifies against the offered pubkey. │ │1428 var auth_attempts: u32 = 0; │ │1429 while (true) { │ │1438 - const req = try readSessionPacket(io, allocator, reader, writer, cs_cipher, sc_cipher, rekey);│ │1430 + const req = try readSessionPacket(conn); │ │1431 defer allocator.free(req); │ │1432 if (req.len < 1 or req[0] != SSH_MSG_USERAUTH_REQUEST) return error.UnexpectedMessage; │ │1433 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │1443 if (!std.mem.eql(u8, service_name, "ssh-connection")) { │ │1444 auth_attempts += 1; │ │1445 if (auth_attempts >= max_auth_attempts) return error.TooManyAuthAttempts;│ │1454 - try sendUserauthFailure(io, allocator, sc_cipher, writer); │ │1446 + try sendUserauthFailure(conn); │ │1447 continue; │ │1448 } │ │1449 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │1450 if (!std.mem.eql(u8, method, "publickey")) { │ │1451 auth_attempts += 1; │ │1452 if (auth_attempts >= max_auth_attempts) return error.TooManyAuthAttempts;│ │1461 - try sendUserauthFailure(io, allocator, sc_cipher, writer); │ │1453 + try sendUserauthFailure(conn); │ │1454 continue; │ │1455 } │ │1456 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │1463 if (!std.mem.eql(u8, algo, "ssh-ed25519")) { │ │1464 auth_attempts += 1; │ │1465 if (auth_attempts >= max_auth_attempts) return error.TooManyAuthAttempts;│ │1474 - try sendUserauthFailure(io, allocator, sc_cipher, writer); │ │1466 + try sendUserauthFailure(conn); │ │1467 continue; │ │1468 } │ │1469 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │1478 try pk_ok.append(allocator, SSH_MSG_USERAUTH_PK_OK); │ │1479 try writeStringField(&pk_ok, allocator, algo); │ │1480 try writeStringField(&pk_ok, allocator, pubkey_blob); │ │1489 - try sc_cipher.writePacket(io, writer, pk_ok.items); │ │1481 + try conn.sc_cipher.writePacket(conn.io, conn.writer, pk_ok.items);│ │1482 continue; │ │1483 } │ │1484 │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────╮ │1488 │ │1489 const ok = verifyUserauthSignature(│ │1490 allocator, │ │1499 - &rekey.session_id, │ │1491 + &conn.rekey.session_id, │ │1492 user_name, │ │1493 service_name, │ │1494 algo, │ ╰─────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │1499 if (!ok) { │ │1500 auth_attempts += 1; │ │1501 if (auth_attempts >= max_auth_attempts) return error.TooManyAuthAttempts;│ │1510 - try sendUserauthFailure(io, allocator, sc_cipher, writer); │ │1502 + try sendUserauthFailure(conn); │ │1503 continue; │ │1504 } │ │1505 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1514 - try sc_cipher.writePacket(io, writer, &[_]u8{SSH_MSG_USERAUTH_SUCCESS}); │ │1506 + try conn.sc_cipher.writePacket(conn.io, conn.writer, &[_]u8{SSH_MSG_USERAUTH_SUCCESS});│ │1507 return formatFingerprint(pubkey_blob); │ │1508 } │ │1509 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │1510 │ │1519 -fn sendUserauthFailure( │ │1520 - io: std.Io, │ │1521 - allocator: std.mem.Allocator, │ │1522 - sc_cipher: *Cipher, │ │1523 - writer: *std.Io.Writer, │ │1524 -) !void { │ │1511 +fn sendUserauthFailure(conn: *Conn) !void { │ │1512 var buf: std.ArrayList(u8) = .empty; │ │1526 - defer buf.deinit(allocator); │ │1527 - try buf.append(allocator, SSH_MSG_USERAUTH_FAILURE); │ │1528 - try writeNameList(&buf, allocator, &.{"publickey"}); // allowed methods │ │1529 - try buf.append(allocator, 0); // partial_success = false │ │1530 - try sc_cipher.writePacket(io, writer, buf.items); │ │1513 + defer buf.deinit(conn.allocator); │ │1514 + try buf.append(conn.allocator, SSH_MSG_USERAUTH_FAILURE); │ │1515 + try writeNameList(&buf, conn.allocator, &.{"publickey"}); // allowed methods│ │1516 + try buf.append(conn.allocator, 0); // partial_success = false │ │1517 + try conn.sc_cipher.writePacket(conn.io, conn.writer, buf.items); │ │1518 } │ │1519 │ │1520 /// Append the canonical publickey-signed-data bytes (RFC 4252 §7) to `buf`. │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────╮ │1609 } │ │1610 │ │1611 fn runChannelLayer( │ │1625 - io: std.Io, │ │1626 - allocator: std.mem.Allocator, │ │1627 - reader: *std.Io.Reader, │ │1628 - writer: *std.Io.Writer, │ │1629 - cs_cipher: *Cipher, │ │1630 - sc_cipher: *Cipher, │ │1631 - rekey: *const RekeyState, │ │1612 + conn: *Conn, │ │1613 fingerprint: *const [fingerprint_len]u8,│ │1614 handler: anytype, │ │1615 ) !void { │ ╰──────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯