Add support for DAP-1325 decryption#10
Conversation
📝 WalkthroughWalkthroughAdds AES-128-ECB block decryption and PKCS#7 unpadding helpers to ChangesDAP-1325/DAP-1610 Decryption Support
Sequence Diagram(s)sequenceDiagram
participant decryptor as decryptor::decrypt
participant dap1325 as dap1325::decrypt
participant aes as aes_128_ecb_decrypt_pkcs7
participant Aes128
decryptor->>dap1325: encrypted_data
dap1325->>dap1325: check len >= 0x40
dap1325->>dap1325: validate header magic (DAP-1325 or DAP-1610)
dap1325->>aes: encrypted_data[0x40..], hardcoded key
aes->>aes: validate len % 16 == 0, truncate key
loop each 16-byte block
aes->>Aes128: decrypt_block
Aes128-->>aes: plaintext block
end
aes->>aes: strip and validate PKCS#7 padding
aes-->>dap1325: decrypted body
dap1325->>dap1325: verify ustar at offset 0x101
dap1325-->>decryptor: Ok(header + decrypted body)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/aes.rs`:
- Around line 198-219: The aes_128_ecb_decrypt function uses the is_multiple_of
method which requires Rust 1.87 to be available. Add rust-version = "1.87" to
the Cargo.toml file to explicitly document the Minimum Supported Rust Version
(MSRV) requirement for this project, ensuring it matches the stabilization
version of the is_multiple_of method used in the code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e499cf72-525b-4dd3-b0c1-76ec38ba2bba
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
README.mdsrc/aes.rssrc/dap1325.rssrc/decryptor.rssrc/lib.rs
| pub fn aes_128_ecb_decrypt(encrypted_data: &[u8], key: &[u8]) -> Result<Vec<u8>, DecryptError> { | ||
| if !encrypted_data.len().is_multiple_of(16) { | ||
| return Err(DecryptError::InvalidInputLength); | ||
| } | ||
|
|
||
| let key_bytes: &[u8; 16] = key | ||
| .get(..16) | ||
| .and_then(|slice| slice.try_into().ok()) | ||
| .ok_or(DecryptError::InvalidKeySize(key.len()))?; | ||
| let cipher = aes::Aes128::new(key_bytes.into()); | ||
|
|
||
| let mut decrypted = Vec::with_capacity(encrypted_data.len()); | ||
| for chunk in encrypted_data.chunks(16) { | ||
| let mut block: Array<u8, typenum::U16> = chunk | ||
| .try_into() | ||
| .map_err(|_| DecryptError::InvalidInputLength)?; | ||
| cipher.decrypt_block(&mut block); | ||
| decrypted.extend_from_slice(&block); | ||
| } | ||
|
|
||
| Ok(decrypted) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Look for MSRV / toolchain declarations
fd -H -t f 'rust-toolchain*'
rg -n 'rust-version|edition' Cargo.toml
cat rust-toolchain.toml 2>/dev/null || trueRepository: binwalk-ng/delink
Length of output: 174
🏁 Script executed:
cat Cargo.tomlRepository: binwalk-ng/delink
Length of output: 573
🌐 Web query:
is_multiple_of Rust stabilization version 1.87
💡 Result:
The is_multiple_of method for unsigned integer types was stabilized in Rust 1.87.0, which was released on May 15, 2025 [1][2][3]. This method, which returns true if self is an integer multiple of rhs, was introduced to provide a way to check for multiples without the risk of panicking when rhs is zero [4][5]. Unlike the standard remainder operator (%), which panics if the divisor is zero, n.is_multiple_of(0) returns false (for non-zero n) and 0.is_multiple_of(0) returns true [4][5]. Prior to this stabilization, similar functionality was commonly found in external crates like num [6].
Citations:
- 1: https://github.com/rust-lang/rust/releases/tag/1.87.0
- 2: https://blog.rust-lang.org/2025/05/15/Rust-1.87.0/
- 3: https://releases.rs/docs/1.87.0/
- 4: Tracking Issue for
unsigned_is_multiple_ofrust-lang/rust#128101 - 5: add
is_multiple_offor unsigned integer types rust-lang/rust#128103 - 6: https://docs.rs/num/latest/num/trait.Integer.html
🌐 Web query:
Rust 2024 edition official release
💡 Result:
The Rust 2024 edition was officially released as stable on February 20, 2025, alongside the release of Rust version 1.85.0 [1][2]. It was introduced as the largest edition since Rust 2015, featuring various improvements to language consistency, ergonomics, and safety [1][3]. Migration to the 2024 edition is supported by automated tooling, specifically through the cargo fix command [1][4].
Citations:
- 1: https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/
- 2: https://blog.rust-lang.org/releases/
- 3: https://blog.rust-lang.org/2024/11/27/Rust-2024-public-testing/
- 4: https://blog.rust-lang.org/2025/01/22/rust-2024-beta/
Add rust-version = "1.87" to Cargo.toml to document the MSRV requirement.
The code uses is_multiple_of (line 199), which was stabilized in Rust 1.87. While the project declares edition = "2024" (released with 1.85), this does not guarantee Rust 1.87+ is available. Explicitly declare the MSRV to match the code's requirement.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/aes.rs` around lines 198 - 219, The aes_128_ecb_decrypt function uses the
is_multiple_of method which requires Rust 1.87 to be available. Add rust-version
= "1.87" to the Cargo.toml file to explicitly document the Minimum Supported
Rust Version (MSRV) requirement for this project, ensuring it matches the
stabilization version of the is_multiple_of method used in the code.
Closes #7
Summary by CodeRabbit
New Features
Documentation