feat(02-02): implement pack, unpack, and inspect archive commands

- pack: two-pass algorithm reads/hashes/compresses/encrypts files then writes header+TOC+data
- inspect: reads header and TOC, displays all metadata (sizes, offsets, IVs, HMACs, SHA-256)
- unpack: HMAC-first verification, AES-256-CBC decryption, optional gzip decompression, SHA-256 check
- CLI dispatch wired from main.rs to archive module
- Directory traversal protection: rejects filenames starting with / or containing ..
- Compression auto-detection: .apk/.zip/etc stored without gzip (flags=0x00 when no file compressed)
- Round-trip verified: pack+unpack produces byte-identical files
- HMAC tamper detection verified: flipped ciphertext byte triggers rejection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
NikitolProject
2026-02-25 00:03:28 +03:00
parent d6bc92ee48
commit be507070b6
2 changed files with 333 additions and 16 deletions

View File

@@ -17,27 +17,18 @@ fn main() -> anyhow::Result<()> {
output,
no_compress,
} => {
println!(
"Pack: {} files -> {:?} (no_compress: {:?})",
files.len(),
output,
no_compress
);
println!("Not implemented yet");
Ok(())
archive::pack(&files, &output, &no_compress)?;
}
Commands::Unpack {
archive,
output_dir,
} => {
println!("Unpack: {:?} -> {:?}", archive, output_dir);
println!("Not implemented yet");
Ok(())
archive::unpack(&archive, &output_dir)?;
}
Commands::Inspect { archive } => {
println!("Inspect: {:?}", archive);
println!("Not implemented yet");
Ok(())
archive::inspect(&archive)?;
}
}
Ok(())
}