- Rust 98.2%
- Just 1.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitattributes | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| comparison_results.md | ||
| justfile | ||
| README.md | ||
🏎️ vpkg2zip
A blistering-fast, memory-safe PlayStation Vita, PSP, and PSX package decrypter and extractor, written in Rust.
vpkg2zip is a complete, highly optimized Rust rewrite of the classic C-based pkg2zip tool. While traditional rewrites focus solely on memory safety, vpkg2zip was engineered from the ground up to achieve absolute platform parity, flawless portability, maximum maintainability, and next-generation execution speed.
This repository is maintained alongside cpkg2zip (Optimized C Partner Fork) to enable strict byte-for-byte correctness testing and direct hardware-level performance comparisons.
🚀 Key Features
- 🎮 Complete Console Coverage:
- Full support for PlayStation Vita packages (Main Applications, DLCs, Patches, Themes, and PSM).
- Seamless support for PlayStation Portable (PSP) packages (ISOs, CSOs, and EBOOT.PBP extraction).
- Robust support for PlayStation 1 (PSX) packages for Adrenaline.
- 🔒 Modern Cryptography & Decompressors:
- Clean, native port of the PSP Kirk Cryptography Engine (AES & CMAC keys 38, 39, and 63).
- Safe port of the custom PSP range-coder decompression algorithm (LZRC Decoder).
- Auto-generation of
work.bin/FAKE.riffake licenses using decryptedzRIFstrings.
- 📂 Optimized CLI & Safety:
- Comprehensive
-o/--outputCLI flag support to target custom directories with automatic parent directory creation. - 100% byte-for-byte output equivalence validated via automatic deep recursive diff testing.
- Comprehensive
⚡ Performance Benchmarks
All benchmarks were executed on an Apple Silicon (ARM64 / AArch64) macOS machine using hyperfine with a clean file cache before each run (--prepare 'rm -rf ...').
Test Case 1: ⚽ Table Soccer (140 MB PKG)
Demonstrates performance on small, high-density asset collections.
| Metric | Original Upstream C (Unoptimized) | cpkg2zip (Optimized C Fork) | vpkg2zip (Rust Rewrite) |
|---|---|---|---|
| Execution Time (Mean) | 3702.4 ms | 896.2 ms | 166.8 ms |
| User CPU Time | 2891.1 ms | 730.2 ms | 28.6 ms |
| System CPU Time | 811.3 ms | 118.2 ms | 138.2 ms |
| Speedup Ratio | Baseline (1.0x) | 4.13x Faster | 22.20x Faster 🚀 |
Test Case 2: 🌌 Gravity Rush (gr.pkg - Full Game)
Demonstrates performance and I/O scaling under real-world gigabyte game loads.
| Metric | Original Upstream C (Unoptimized) | cpkg2zip (Optimized C Fork) | vpkg2zip (Rust Rewrite) |
|---|---|---|---|
| Execution Time (Mean) | ~6.07 s | 2.58 s | 0.63 s (630 ms) |
| User CPU Time | ~5.60 s | 2.13 s | 0.20 s (198 ms) |
| System CPU Time | ~0.47 s | 0.41 s | 0.41 s (408 ms) |
| Speedup Ratio | Baseline (1.0x) | 2.36x Faster | 9.63x Faster 🚀 |
Note
- The Cryptographic Win: The optimized C fork (
cpkg2zip) uses single-block hardware loops.vpkg2zip(Rust) processes 8 blocks (128 bytes) in a single parallel step, saturating modern processor execution pipelines and dropping User CPU overhead by up to 25x!- The I/O Win: Rust sequentially loads the entire PKG metadata head into memory at startup in a single system read, and tracks created directories inside a
HashSetcache, cutting filesystem system call latency by over 80%.
🛠️ Build and Usage
Requirements
- Rust 1.75+ (or the Edition 2024 compiler toolchain)
just(optional, for developer commands)hyperfine(optional, for benchmarking)
Building
Compile in the size-optimized profile, or build the screamingly fast speed-optimized target using Thin LTO and hardware vectorization:
# Standard Release (Optimized for size: ~475 KB)
cargo build --release
# Speed-Optimized Release (Maximum throughput, stripped: ~562 KB)
cargo build --profile release-fast
Basic Commands
- Vita Decryption & Custom Output Directory:
./target/release-fast/vpkg2zip -o /path/to/output_dir package.pkg [zRIF_STRING] - PSP CSO Compression (Fastest c1 to Strongest c9):
./target/release-fast/vpkg2zip -c9 -o /path/to/output_dir package.pkg - Extract Only (Skip ZIP archiving):
./target/release-fast/vpkg2zip -x -o /path/to/output_dir package.pkg [zRIF_STRING]
👨💻 Developer Workflows
Use the provided justfile to run tests and benchmarks instantly:
- Verify Byte-for-Byte Output Parity:
just test-compare - Run Hyperfine Benchmarks:
just bench
📜 Architectural Differences & Highlights
A detailed technical deep-dive analyzing memory safety, SIMD vector pipeline acceleration, I/O caches, and dependency size optimizations is documented in our comprehensive Comparison Results (comparison_results.md).