You are browsing as a guest. Sign up (or log in) to start making projects!

2h 0m logged

Implement archive packaging pipeline and client networking module

Add the archive packaging pipeline to pwr-core. The create_archive function
builds an encrypted project archive through a four-stage streaming
pipeline. First, the project directory is walked recursively and added to a
tar archive via the tar crate, excluding .project.toml metadata files.
Second, the tar stream is gzip-compressed using flate2 at default
compression level and written to a temporary file to bound memory usage
independent of project size. Third, the compressed tarball is read back and
encrypted using the age X25519 public key from the project’s metadata,
producing an opaque encrypted blob the server cannot read. Fourth, the
SHA-256 hash of the encrypted blob is computed for integrity verification
after transfer. Symlinks are preserved in the archive. The reverse
pipeline, extract_archive, first verifies the SHA-256 hash against the
expected value, then age-decrypts, gunzips, and untars into the target
directory. Two tests verify create-extract round-trip fidelity
(README.md, src/main.rs, and Cargo.toml are restored with correct content)
and that hash mismatch prevents extraction.

Add the protocol client module to the pwr binary. PwrClient manages a
connection to pwr-server with TCP socket setup, configurable timeouts, PSK
handshake authentication with mutual server proof verification, and framed
message send/receive via the core frame module. The archive_project method
sends an ArchiveRequest, receives acceptance, streams archive data in 1 MiB
chunks with 4-byte length prefixes and a zero-length EOF marker, and sends
ArchiveComplete with the SHA-256 hash. The restore_project method requests
a project by UUID, receives a RestoreAccept with size metadata, streams
chunks back from the server, and returns the complete encrypted blob.
get_status queries the server for project listings with optional UUID
filtering. The handshake helper generates a 32-byte CSPRNG nonce, computes
the HMAC-SHA256 client proof, sends the Handshake message, verifies the
server’s HandshakeAck success flag, and performs mutual authentication by
validating the server proof against the expected value using constant-time
comparison.

0
0

Comments 0

No comments yet. Be the first!