From 7aa72dc6182d1747930568796af953ca69a8a0b3 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Wed, 29 Apr 2020 07:55:23 -0400 Subject: [PATCH] Remove unnecessary RomFS context members. --- source/nca.h | 2 +- source/romfs.c | 18 ++++++------------ source/romfs.h | 2 -- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/source/nca.h b/source/nca.h index bfb0ac8..910851c 100644 --- a/source/nca.h +++ b/source/nca.h @@ -125,7 +125,7 @@ typedef enum { NcaEncryptionType_AesXts = 2, NcaEncryptionType_AesCtr = 3, NcaEncryptionType_AesCtrEx = 4, - NcaEncryptionType_Nca0 = 5 ///< Only used to represent NCA0 AES XTS FS section crypto - not actually used as a possible value for this field. + NcaEncryptionType_Nca0 = 5 ///< Only used to represent NCA0 AES-XTS FS section crypto - not actually used as a possible value for this field. } NcaEncryptionType; typedef struct { diff --git a/source/romfs.c b/source/romfs.c index d846b3c..db15107 100644 --- a/source/romfs.c +++ b/source/romfs.c @@ -51,29 +51,23 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *nca_ if (nca_fs_ctx->section_type == NcaFsSectionType_Nca0RomFs) { - out->sha256_hash_info = &(nca_fs_ctx->header->hash_info.hierarchical_sha256); - out->integrity_hash_info = NULL; - - if (!ncaValidateHierarchicalSha256Offsets(out->sha256_hash_info, nca_fs_ctx->section_size)) + if (!ncaValidateHierarchicalSha256Offsets(&(nca_fs_ctx->header->hash_info.hierarchical_sha256), nca_fs_ctx->section_size)) { LOGFILE("Invalid HierarchicalSha256 block!"); return false; } - out->offset = out->sha256_hash_info->hash_target_layer_info.offset; - out->size = out->sha256_hash_info->hash_target_layer_info.size; + out->offset = nca_fs_ctx->header->hash_info.hierarchical_sha256.hash_target_layer_info.offset; + out->size = nca_fs_ctx->header->hash_info.hierarchical_sha256.hash_target_layer_info.size; } else { - out->sha256_hash_info = NULL; - out->integrity_hash_info = &(nca_fs_ctx->header->hash_info.hierarchical_integrity); - - if (!ncaValidateHierarchicalIntegrityOffsets(out->integrity_hash_info, nca_fs_ctx->section_size)) + if (!ncaValidateHierarchicalIntegrityOffsets(&(nca_fs_ctx->header->hash_info.hierarchical_integrity), nca_fs_ctx->section_size)) { LOGFILE("Invalid HierarchicalIntegrity block!"); return false; } - out->offset = out->integrity_hash_info->hash_target_layer_info.offset; - out->size = out->integrity_hash_info->hash_target_layer_info.size; + out->offset = nca_fs_ctx->header->hash_info.hierarchical_integrity.hash_target_layer_info.offset; + out->size = nca_fs_ctx->header->hash_info.hierarchical_integrity.hash_target_layer_info.size; } /* Read RomFS header */ diff --git a/source/romfs.h b/source/romfs.h index 387d2f6..cfcaf04 100644 --- a/source/romfs.h +++ b/source/romfs.h @@ -90,8 +90,6 @@ typedef struct { typedef struct { NcaFsSectionContext *nca_fs_ctx; ///< Used to read NCA FS section data. - NcaHierarchicalSha256 *sha256_hash_info; ///< HierarchicalSha256 hash table information. Used with NCA0 RomFS sections. - NcaHierarchicalIntegrity *integrity_hash_info; ///< HierarchicalIntegrity hash table information. Used with NCA2/NCA3 RomFS sections. u64 offset; ///< RomFS offset (relative to the start of the NCA FS section). u64 size; ///< RomFS size. RomFileSystemHeader header; ///< RomFS header.