Repository navigation
feat(nx-object): read an NCA and the PFS0 archives it carries - #13
Merged
Merged
Conversation
The crate could build both formats but not read either, so a consumer verifying what it packed had to re-derive the layouts itself. These readers close that gap while keeping the crate's no-crypto contract: an NCA arrives already decrypted, and the magic check is what catches a caller who skipped that step. - Add `read::pfs0`, proving the entry table, the string table, and every file's bounds at construction, so a file's bytes come back as a plain slice rather than a `Result` - Add `read::nca`, validating section extents, hash and encryption types, and each superblock's data region, and exposing a section's byte range and AES-CTR counter so a caller can decrypt in place - Model a section's verification structure as a `Superblock` enum rather than two optional fields, since the hash type is what decides which of the two the same `0x138` bytes are - Recover the single key generation the header splits across `crypto_type` and `crypto_type2`, inverting how the builder writes it Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The crate could build both formats but not read either, so a consumer verifying what it packed had to re-derive the layouts itself. These readers close that gap while keeping the crate's no-crypto contract: an NCA arrives already decrypted, and the magic check is what catches a caller who skipped that step.
read::pfs0, proving the entry table, the string table, and every file's bounds at construction, so a file's bytes come back as a plain slice rather than aResultread::nca, validating section extents, hash and encryption types, and each superblock's data region, and exposing a section's byte range and AES-CTR counter so a caller can decrypt in placeSuperblockenum rather than two optional fields, since the hash type is what decides which of the two the same0x138bytes arecrypto_typeandcrypto_type2, inverting how the builder writes it