From 00081c6542e4f876a60703c5a2649d2516d1e468 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 11:47:44 +0800 Subject: [PATCH 01/16] Update readmes. --- LICENSE | 2 +- README.md | 25 ++++---------- KEYS.md => SWITCH_KEYS.md | 22 +++++++++--- programs/nstool/README.md | 73 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 24 deletions(-) rename KEYS.md => SWITCH_KEYS.md (75%) create mode 100644 programs/nstool/README.md diff --git a/LICENSE b/LICENSE index cec2ef2..24d91e4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -NXTools +NNTools Copyright (c) 2017-2018 Jack Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 377b1a2..7d6abae 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,22 @@ -# NXTools +# NNTools -Tools & Libraries for NX (Nintendo Switch). +Tools & Libraries for Nintendo devices. [![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE) # Tools - -* __nstool__ - read *.npdm, read/extract PartitionFS (PFS0|HFS0) blobs (including *.nsp), read/extract RomFS blobs, read/extract *.xci, read/extract *.nca, read *.cnmt, read *.nso, read *.nro, read *.nacp +* [__nstool__](/programs/nstool/README.md) - General purpose reading/extraction tool for Nintendo Switch file formats. # Libraries - * __libfnd__ - Foundation library. * __libcrypto__ - Cryptographic functions (AES,SHA,RSA). Wrapper for [mbedTLS](https://github.com/ARMmbed/mbedtls) * __libcompress__ - Compression algorithms (LZ4). Wrapper for [lz4](https://github.com/lz4/lz4) * __libpki__ - Processes Nintendo's proprietary PKI. * __libes__ - Processes Nintendo's eShop file types. -* __libnx__ - Processes NX file types. -* __libnx-hb__ - Processes NX file types (homebrew extensions). +* __libhac__ - Processes Nintendo Switch file types. +* __libhac-hb__ - Processes Nintendo Switch file types (homebrew extensions). # Building - On MacOS/Linux/WSL run `make`. -For Windows, Visual Studio 2017 is supported. - -# External Keys - -Programs/libraries don't embed any keys that are copyright protected. However keys can be imported via a keyset file. - -For programs that support it, the keyset file can be provided via the command line (see program usage for details). Alternatively a keyset file located in ___$HOME/.switch/prod.keys___ (or ___$HOME/.switch/dev.keys___ for dev) will be imported automatically if one is not provided at the command line. - -Keyset files are ASCII text files containing one key per line, in the form "__key_name = HEXADECIMALKEY__". Case and whitespace do not matter, ';' character can be used to insert comments. - -See [KEYS.md](/KEYS.md) for more details. \ No newline at end of file +For Windows, Visual Studio 2017 is supported. \ No newline at end of file diff --git a/KEYS.md b/SWITCH_KEYS.md similarity index 75% rename from KEYS.md rename to SWITCH_KEYS.md index 0a3098b..038dd1e 100644 --- a/KEYS.md +++ b/SWITCH_KEYS.md @@ -1,5 +1,19 @@ -# Format -Programs in NXTools currently recognise the following keys (## represents a hexadecimal number between 00 and 1F): + +# About +Keyset files are ASCII text files containing one key per line, in the form "__key_name = HEXADECIMALKEY__". Case and whitespace do not matter, ';' character can be used to insert comments. + +# Loading keyset files automatically +If a keyset file is located in ___$HOME/.switch/___ it will be loaded automatically. + +# General Keys (prod.keys and dev.keys) +Some switch files formats feature encryption and or cryptographic signatures. In order to process these file formats, some keys are required. These keys can be supplied via a keyfile: ___prod.keys___ (or ___dev.keys___ for devkit variants). + +This keyset file can be provided via the command line (refer to usage for details). + + + +## Format +The following keys are recognised (## represents a hexadecimal number between 00 and 1F): ``` ; Key Sources @@ -47,8 +61,8 @@ acid_sign_key_modulus : RSA2048 Modulus (0x100 bytes) acid_sign_key_private : RSA2048 Private Exponent (0x100 bytes) ``` -# Compatibility with hactool keyset files -NXTools keyset files share the same keyset file format as [hactool](https://github.com/SciresM/hactool/blob/master/KEYS.md), but names of keys may differ. For compatibility, hactool names for equivalent keys are accepted. +## Compatibility with hactool keyset files +`prod.keys` (and `dev.keys`) keyset files share the same keyset file format as [hactool](https://github.com/SciresM/hactool/blob/master/KEYS.md), but names of keys may differ. For compatibility, hactool names for equivalent keys are accepted. ``` titlekek_source : hactool alias for ticket_commonkey_source header_key_source : hactool alias for nca_header_key_source diff --git a/programs/nstool/README.md b/programs/nstool/README.md new file mode 100644 index 0000000..9fb5dab --- /dev/null +++ b/programs/nstool/README.md @@ -0,0 +1,73 @@ +# Nintendo Switch Tool (NSTool) ![DeviceTag](https://img.shields.io/badge/Device-SWITCH-e60012.svg) +General purpose reading/extration tool for Nintendo Switch file formats. + +## Supported File Formats +* NPDM (.npdm) +* PartitionFS (and HashedPartitionFS) (includes raw .nsp) +* RomFS +* GameCard Image (.xci) +* Nintendo Content Archive (.nca) +* Content Metadata (.cnmt) +* Nintendo Software Object (.nso) +* Nintendo Relocatable Software Object (.nro) +* Nintendo Application Control Property (.nacp) +* ES Ticket (v2 only) (.tik) +* PKI Certificate (.cert) + +# Usage +``` +Usage: nstool [options... ] + + General Options: + -d, --dev Use devkit keyset. + -k, --keyset Specify keyset file. + -t, --type Specify input file type. [xci, pfs, romfs, nca, npdm, cnmt, nso, nro, nacp, aset, cert, tik] + -y, --verify Verify file. + + Output Options: + --showkeys Show keys generated. + --showlayout Show layout metadata. + -v, --verbose Verbose output. + + XCI (GameCard Image) + nstool [--listfs] [--update --logo --normal --secure ] <.xci file> + --listfs Print file system in embedded partitions. + --update Extract "update" partition to directory. + --logo Extract "logo" partition to directory. + --normal Extract "normal" partition to directory. + --secure Extract "secure" partition to directory. + + PFS0/HFS0 (PartitionFs), RomFs, NSP (Ninendo Submission Package) + nstool [--listfs] [--fsdir ] + --listfs Print file system. + --fsdir Extract file system to directory. + + NCA (Nintendo Content Archive) + nstool [--listfs] [--bodykey --titlekey ] [--part0 ...] <.nca file> + --listfs Print file system in embedded partitions. + --titlekey Specify title key extracted from ticket. + --bodykey Specify body encryption key. + --tik Specify ticket to source title key. + --part0 Extract "partition 0" to directory. + --part1 Extract "partition 1" to directory. + --part2 Extract "partition 2" to directory. + --part3 Extract "partition 3" to directory. + + NSO (Nintendo Software Object), NRO (Nintendo Relocatable Object) + nstool [--listapi --listsym] [--insttype ] + --listapi Print SDK API List. + --listsym Print Code Symbols. + --insttype Specify instruction type [64bit|32bit] (64bit is assumed). + + ASET (Homebrew Asset Blob) + nstool [--listfs] [--icon --nacp --fsdir ] + --listfs Print filesystem in embedded RomFS partition. + --icon Extract icon partition to file. + --nacp Extract NACP partition to file. + --fsdir Extract RomFS partition to directory. +``` + +# External Keys +NSTool doesn't embed any keys that are copyright protected. However keys can be imported via various keyset files. + +See [SWITCH_KEYS.md](/SWITCH_KEYS.md) for more info. \ No newline at end of file From 383933f9779799ca367aa4f255fbf62c365cdcaf Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 13:28:06 +0800 Subject: [PATCH 02/16] Updated layout of project files. --- .vscode/c_cpp_properties.json | 9 +- NXTools.sln | 72 +++++---- NXTools.vcxproj | 4 +- lib/libcompress/libcompress.vcxproj | 10 +- lib/libcompress/libcompress.vcxproj.filters | 14 +- lib/libcompress/makefile | 6 +- lib/libcrypto/crypto.vcxproj.filters | 114 -------------- .../{crypto.vcxproj => libcrypto.vcxproj} | 28 +--- lib/libcrypto/libcrypto.vcxproj.filters | 51 ++++++ ...to.vcxproj.user => libcrypto.vcxproj.user} | 0 lib/libcrypto/makefile | 10 +- lib/libcrypto/source/libpolarssl/makefile | 37 ----- .../include/{ => nn}/es/SectionHeader_V2.h | 0 lib/libes/include/{ => nn}/es/TicketBody_V2.h | 0 lib/libes/include/{ => nn}/es/ticket.h | 0 lib/libes/{es.vcxproj => libes.vcxproj} | 2 - ....vcxproj.filters => libes.vcxproj.filters} | 0 .../{es.vcxproj.user => libes.vcxproj.user} | 0 lib/libfnd/{fnd.vcxproj => libfnd.vcxproj} | 2 - ...vcxproj.filters => libfnd.vcxproj.filters} | 0 .../{fnd.vcxproj.user => libfnd.vcxproj.user} | 0 .../include/nn/hac}/AssetHeader.h | 0 .../nx => libhac-hb/include/nn/hac}/aset.h | 0 .../nx => libhac-hb/include/nn/hac}/nro-hb.h | 0 .../libhac-hb.vcxproj} | 15 +- .../libhac-hb.vcxproj.filters} | 6 +- .../libhac-hb.vcxproj.user} | 0 lib/{libnx-hb => libhac-hb}/makefile | 0 .../source/AssetHeader.cpp | 0 .../include/nn/hac}/AccessControlInfoBinary.h | 0 .../nn/hac}/AccessControlInfoDescBinary.h | 0 .../nx => libhac/include/nn/hac}/AesKeygen.h | 0 .../hac}/ApplicationControlPropertyBinary.h | 0 .../nn/hac}/ApplicationControlPropertyUtils.h | 0 .../include/nn/hac}/ContentMetaBinary.h | 0 .../nn/hac}/FileSystemAccessControlBinary.h | 0 .../include/nn/hac}/HandleTableSizeEntry.h | 0 .../include/nn/hac}/HandleTableSizeHandler.h | 0 .../nn/hac}/HierarchicalIntegrityHeader.h | 0 .../nn/hac}/HierarchicalSha256Header.h | 0 .../nn/hac}/IKernelCapabilityHandler.h | 0 .../include/nn/hac}/InteruptEntry.h | 0 .../include/nn/hac}/InteruptHandler.h | 0 .../include/nn/hac}/KernelCapabilityBinary.h | 0 .../include/nn/hac}/KernelCapabilityEntry.h | 0 .../include/nn/hac}/KernelVersionEntry.h | 0 .../include/nn/hac}/KernelVersionHandler.h | 0 .../include/nn/hac}/MemoryMappingHandler.h | 0 .../include/nn/hac}/MemoryPageEntry.h | 0 .../include/nn/hac}/MiscFlagsEntry.h | 0 .../include/nn/hac}/MiscFlagsHandler.h | 0 .../include/nn/hac}/MiscParamsEntry.h | 0 .../include/nn/hac}/MiscParamsHandler.h | 0 .../nx => libhac/include/nn/hac}/NcaHeader.h | 0 .../nx => libhac/include/nn/hac}/NcaUtils.h | 0 .../nx => libhac/include/nn/hac}/NpdmBinary.h | 0 .../nx => libhac/include/nn/hac}/NroHeader.h | 0 .../nx => libhac/include/nn/hac}/NsoHeader.h | 0 .../nx => libhac/include/nn/hac}/PfsHeader.h | 0 .../nn/hac}/ServiceAccessControlBinary.h | 0 .../nn/hac}/ServiceAccessControlEntry.h | 0 .../include/nn/hac}/SystemCallEntry.h | 0 .../include/nn/hac}/SystemCallHandler.h | 0 .../include/nn/hac}/ThreadInfoEntry.h | 0 .../include/nn/hac}/ThreadInfoHandler.h | 0 .../nx => libhac/include/nn/hac}/XciHeader.h | 0 .../nx => libhac/include/nn/hac}/XciUtils.h | 0 .../nx => libhac/include/nn/hac}/aci.h | 0 .../nx => libhac/include/nn/hac}/cnmt.h | 0 .../nx => libhac/include/nn/hac}/elf.h | 0 .../nx => libhac/include/nn/hac}/fac.h | 0 .../include/nn/hac}/hierarchicalintegrity.h | 0 .../include/nn/hac}/hierarchicalsha256.h | 0 .../include/nx => libhac/include/nn/hac}/kc.h | 0 .../nx => libhac/include/nn/hac}/macro.h | 0 .../nx => libhac/include/nn/hac}/nacp.h | 0 .../nx => libhac/include/nn/hac}/nca.h | 0 .../nx => libhac/include/nn/hac}/npdm.h | 0 .../nx => libhac/include/nn/hac}/nro.h | 0 .../nx => libhac/include/nn/hac}/nrr.h | 0 .../nx => libhac/include/nn/hac}/nso.h | 0 .../nx => libhac/include/nn/hac}/pfs.h | 0 .../nx => libhac/include/nn/hac}/romfs.h | 0 .../nx => libhac/include/nn/hac}/xci.h | 0 .../nx.vcxproj => libhac/libhac.vcxproj} | 122 +++++++-------- .../libhac.vcxproj.filters} | 110 ++++++------- .../libhac.vcxproj.user} | 0 lib/{libnx => libhac}/makefile | 0 .../source/AccessControlInfoBinary.cpp | 0 .../source/AccessControlInfoDescBinary.cpp | 0 lib/{libnx => libhac}/source/AesKeygen.cpp | 0 .../ApplicationControlPropertyBinary.cpp | 0 .../ApplicationControlPropertyUtils.cpp | 0 .../source/ContentMetaBinary.cpp | 0 .../source/FileSystemAccessControlBinary.cpp | 0 .../source/HandleTableSizeEntry.cpp | 0 .../source/HandleTableSizeHandler.cpp | 0 .../source/HierarchicalIntegrityHeader.cpp | 0 .../source/HierarchicalSha256Header.cpp | 0 .../source/InteruptEntry.cpp | 0 .../source/InteruptHandler.cpp | 0 .../source/KernelCapabilityBinary.cpp | 0 .../source/KernelCapabilityEntry.cpp | 0 .../source/KernelVersionEntry.cpp | 0 .../source/KernelVersionHandler.cpp | 0 .../source/MemoryMappingHandler.cpp | 0 .../source/MemoryPageEntry.cpp | 0 .../source/MiscFlagsEntry.cpp | 0 .../source/MiscFlagsHandler.cpp | 0 .../source/MiscParamsEntry.cpp | 0 .../source/MiscParamsHandler.cpp | 0 lib/{libnx => libhac}/source/NcaHeader.cpp | 0 lib/{libnx => libhac}/source/NcaUtils.cpp | 0 lib/{libnx => libhac}/source/NpdmBinary.cpp | 0 lib/{libnx => libhac}/source/NroHeader.cpp | 0 lib/{libnx => libhac}/source/NsoHeader.cpp | 0 lib/{libnx => libhac}/source/PfsHeader.cpp | 0 .../source/ServiceAccessControlBinary.cpp | 0 .../source/ServiceAccessControlEntry.cpp | 0 .../source/SystemCallEntry.cpp | 0 .../source/SystemCallHandler.cpp | 0 .../source/ThreadInfoEntry.cpp | 0 .../source/ThreadInfoHandler.cpp | 0 lib/{libnx => libhac}/source/XciHeader.cpp | 0 lib/{libnx => libhac}/source/XciUtils.cpp | 0 .../source/lz4 => liblz4/include}/lz4.h | 0 lib/liblz4/liblz4.vcxproj | 132 ++++++++++++++++ lib/liblz4/liblz4.vcxproj.filters | 30 ++++ lib/liblz4/liblz4.vcxproj.user | 4 + lib/liblz4/makefile | 43 +++++ .../source/lz4 => liblz4/source}/lz4.c | 0 .../include/{ => nn}/pki/CertificateBody.h | 0 lib/libpki/include/{ => nn}/pki/SignUtils.h | 0 .../include/{ => nn}/pki/SignatureBlock.h | 0 lib/libpki/include/{ => nn}/pki/SignedData.h | 0 lib/libpki/include/{ => nn}/pki/cert.h | 0 lib/libpki/include/{ => nn}/pki/sign.h | 0 lib/libpki/libpki.vcxproj | 13 +- lib/libpki/libpki.vcxproj.filters | 12 +- .../libpolarssl/include/polarssl/aes.h | 0 .../libpolarssl/include/polarssl/base64.h | 0 .../libpolarssl/include/polarssl/bignum.h | 0 .../libpolarssl/include/polarssl/bn_mul.h | 0 .../libpolarssl/include/polarssl/config.h | 0 .../libpolarssl/include/polarssl/md.h | 0 .../libpolarssl/include/polarssl/md_wrap.h | 0 .../libpolarssl/include/polarssl/rsa.h | 0 .../libpolarssl/include/polarssl/sha1.h | 0 .../libpolarssl/include/polarssl/sha2.h | 0 lib/libpolarssl/libpolarssl.vcxproj | 148 ++++++++++++++++++ lib/libpolarssl/libpolarssl.vcxproj.filters | 78 +++++++++ lib/libpolarssl/libpolarssl.vcxproj.user | 4 + lib/libpolarssl/makefile | 43 +++++ .../source => }/libpolarssl/source/aes.c | 0 .../source => }/libpolarssl/source/base64.c | 0 .../source => }/libpolarssl/source/bignum.c | 0 .../source => }/libpolarssl/source/md.c | 0 .../source => }/libpolarssl/source/md_wrap.c | 0 .../source => }/libpolarssl/source/rsa.c | 0 .../source => }/libpolarssl/source/sha1.c | 0 .../source => }/libpolarssl/source/sha2.c | 0 programs/nstool/nstool.vcxproj | 16 +- 162 files changed, 748 insertions(+), 387 deletions(-) delete mode 100644 lib/libcrypto/crypto.vcxproj.filters rename lib/libcrypto/{crypto.vcxproj => libcrypto.vcxproj} (80%) create mode 100644 lib/libcrypto/libcrypto.vcxproj.filters rename lib/libcrypto/{crypto.vcxproj.user => libcrypto.vcxproj.user} (100%) delete mode 100644 lib/libcrypto/source/libpolarssl/makefile rename lib/libes/include/{ => nn}/es/SectionHeader_V2.h (100%) rename lib/libes/include/{ => nn}/es/TicketBody_V2.h (100%) rename lib/libes/include/{ => nn}/es/ticket.h (100%) rename lib/libes/{es.vcxproj => libes.vcxproj} (98%) rename lib/libes/{es.vcxproj.filters => libes.vcxproj.filters} (100%) rename lib/libes/{es.vcxproj.user => libes.vcxproj.user} (100%) rename lib/libfnd/{fnd.vcxproj => libfnd.vcxproj} (98%) rename lib/libfnd/{fnd.vcxproj.filters => libfnd.vcxproj.filters} (100%) rename lib/libfnd/{fnd.vcxproj.user => libfnd.vcxproj.user} (100%) rename lib/{libnx-hb/include/nx => libhac-hb/include/nn/hac}/AssetHeader.h (100%) rename lib/{libnx-hb/include/nx => libhac-hb/include/nn/hac}/aset.h (100%) rename lib/{libnx-hb/include/nx => libhac-hb/include/nn/hac}/nro-hb.h (100%) rename lib/{libnx-hb/libnx-hb.vcxproj => libhac-hb/libhac-hb.vcxproj} (92%) rename lib/{libnx-hb/libnx-hb.vcxproj.filters => libhac-hb/libhac-hb.vcxproj.filters} (88%) rename lib/{libnx-hb/libnx-hb.vcxproj.user => libhac-hb/libhac-hb.vcxproj.user} (100%) rename lib/{libnx-hb => libhac-hb}/makefile (100%) rename lib/{libnx-hb => libhac-hb}/source/AssetHeader.cpp (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/AccessControlInfoBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/AccessControlInfoDescBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/AesKeygen.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ApplicationControlPropertyBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ApplicationControlPropertyUtils.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ContentMetaBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/FileSystemAccessControlBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/HandleTableSizeEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/HandleTableSizeHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/HierarchicalIntegrityHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/HierarchicalSha256Header.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/IKernelCapabilityHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/InteruptEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/InteruptHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/KernelCapabilityBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/KernelCapabilityEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/KernelVersionEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/KernelVersionHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MemoryMappingHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MemoryPageEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MiscFlagsEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MiscFlagsHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MiscParamsEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/MiscParamsHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/NcaHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/NcaUtils.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/NpdmBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/NroHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/NsoHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/PfsHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ServiceAccessControlBinary.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ServiceAccessControlEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/SystemCallEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/SystemCallHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ThreadInfoEntry.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/ThreadInfoHandler.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/XciHeader.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/XciUtils.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/aci.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/cnmt.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/elf.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/fac.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/hierarchicalintegrity.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/hierarchicalsha256.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/kc.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/macro.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/nacp.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/nca.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/npdm.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/nro.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/nrr.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/nso.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/pfs.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/romfs.h (100%) rename lib/{libnx/include/nx => libhac/include/nn/hac}/xci.h (100%) rename lib/{libnx/nx.vcxproj => libhac/libhac.vcxproj} (70%) rename lib/{libnx/nx.vcxproj.filters => libhac/libhac.vcxproj.filters} (71%) rename lib/{libnx/nx.vcxproj.user => libhac/libhac.vcxproj.user} (100%) rename lib/{libnx => libhac}/makefile (100%) rename lib/{libnx => libhac}/source/AccessControlInfoBinary.cpp (100%) rename lib/{libnx => libhac}/source/AccessControlInfoDescBinary.cpp (100%) rename lib/{libnx => libhac}/source/AesKeygen.cpp (100%) rename lib/{libnx => libhac}/source/ApplicationControlPropertyBinary.cpp (100%) rename lib/{libnx => libhac}/source/ApplicationControlPropertyUtils.cpp (100%) rename lib/{libnx => libhac}/source/ContentMetaBinary.cpp (100%) rename lib/{libnx => libhac}/source/FileSystemAccessControlBinary.cpp (100%) rename lib/{libnx => libhac}/source/HandleTableSizeEntry.cpp (100%) rename lib/{libnx => libhac}/source/HandleTableSizeHandler.cpp (100%) rename lib/{libnx => libhac}/source/HierarchicalIntegrityHeader.cpp (100%) rename lib/{libnx => libhac}/source/HierarchicalSha256Header.cpp (100%) rename lib/{libnx => libhac}/source/InteruptEntry.cpp (100%) rename lib/{libnx => libhac}/source/InteruptHandler.cpp (100%) rename lib/{libnx => libhac}/source/KernelCapabilityBinary.cpp (100%) rename lib/{libnx => libhac}/source/KernelCapabilityEntry.cpp (100%) rename lib/{libnx => libhac}/source/KernelVersionEntry.cpp (100%) rename lib/{libnx => libhac}/source/KernelVersionHandler.cpp (100%) rename lib/{libnx => libhac}/source/MemoryMappingHandler.cpp (100%) rename lib/{libnx => libhac}/source/MemoryPageEntry.cpp (100%) rename lib/{libnx => libhac}/source/MiscFlagsEntry.cpp (100%) rename lib/{libnx => libhac}/source/MiscFlagsHandler.cpp (100%) rename lib/{libnx => libhac}/source/MiscParamsEntry.cpp (100%) rename lib/{libnx => libhac}/source/MiscParamsHandler.cpp (100%) rename lib/{libnx => libhac}/source/NcaHeader.cpp (100%) rename lib/{libnx => libhac}/source/NcaUtils.cpp (100%) rename lib/{libnx => libhac}/source/NpdmBinary.cpp (100%) rename lib/{libnx => libhac}/source/NroHeader.cpp (100%) rename lib/{libnx => libhac}/source/NsoHeader.cpp (100%) rename lib/{libnx => libhac}/source/PfsHeader.cpp (100%) rename lib/{libnx => libhac}/source/ServiceAccessControlBinary.cpp (100%) rename lib/{libnx => libhac}/source/ServiceAccessControlEntry.cpp (100%) rename lib/{libnx => libhac}/source/SystemCallEntry.cpp (100%) rename lib/{libnx => libhac}/source/SystemCallHandler.cpp (100%) rename lib/{libnx => libhac}/source/ThreadInfoEntry.cpp (100%) rename lib/{libnx => libhac}/source/ThreadInfoHandler.cpp (100%) rename lib/{libnx => libhac}/source/XciHeader.cpp (100%) rename lib/{libnx => libhac}/source/XciUtils.cpp (100%) rename lib/{libcompress/source/lz4 => liblz4/include}/lz4.h (100%) create mode 100644 lib/liblz4/liblz4.vcxproj create mode 100644 lib/liblz4/liblz4.vcxproj.filters create mode 100644 lib/liblz4/liblz4.vcxproj.user create mode 100644 lib/liblz4/makefile rename lib/{libcompress/source/lz4 => liblz4/source}/lz4.c (100%) rename lib/libpki/include/{ => nn}/pki/CertificateBody.h (100%) rename lib/libpki/include/{ => nn}/pki/SignUtils.h (100%) rename lib/libpki/include/{ => nn}/pki/SignatureBlock.h (100%) rename lib/libpki/include/{ => nn}/pki/SignedData.h (100%) rename lib/libpki/include/{ => nn}/pki/cert.h (100%) rename lib/libpki/include/{ => nn}/pki/sign.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/aes.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/base64.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/bignum.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/bn_mul.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/config.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/md.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/md_wrap.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/rsa.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/sha1.h (100%) rename lib/{libcrypto/source => }/libpolarssl/include/polarssl/sha2.h (100%) create mode 100644 lib/libpolarssl/libpolarssl.vcxproj create mode 100644 lib/libpolarssl/libpolarssl.vcxproj.filters create mode 100644 lib/libpolarssl/libpolarssl.vcxproj.user create mode 100644 lib/libpolarssl/makefile rename lib/{libcrypto/source => }/libpolarssl/source/aes.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/base64.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/bignum.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/md.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/md_wrap.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/rsa.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/sha1.c (100%) rename lib/{libcrypto/source => }/libpolarssl/source/sha2.c (100%) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e996876..263f098 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,14 +9,15 @@ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", "/usr/include", "${workspaceRoot}", + "${workspaceRoot}/lib/libfnd/include", + "${workspaceRoot}/lib/libpolarssl/include", + "${workspaceRoot}/lib/liblz4/include", "${workspaceRoot}/lib/libcrypto/include", - "${workspaceRoot}/lib/libcrypto/source/polarssl/libinclude", "${workspaceRoot}/lib/libcompress/include", "${workspaceRoot}/lib/libes/include", "${workspaceRoot}/lib/libpki/include", - "${workspaceRoot}/lib/libfnd/include", - "${workspaceRoot}/lib/libnx/include", - "${workspaceRoot}/lib/libnx-hb/include" + "${workspaceRoot}/lib/libhac/include", + "${workspaceRoot}/lib/libhac-hb/include" ], "defines": [], "intelliSenseMode": "clang-x64", diff --git a/NXTools.sln b/NXTools.sln index 2305e4c..d196221 100644 --- a/NXTools.sln +++ b/NXTools.sln @@ -3,16 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27428.2015 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\fnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\libcrypto\crypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnx", "lib\libnx\nx.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}" - ProjectSection(ProjectDependencies) = postProject - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} - {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{170B4A09-1B67-4A62-93AB-116EBCFF4A8C}" ProjectSection(SolutionItems) = preProject lib\makefile = lib\makefile @@ -26,26 +16,32 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8F6C846D-35E2-47FD-AF42-7A3FD036346E}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore - KEYS.md = KEYS.md - LICENSE = LICENSE makefile = makefile README.md = README.md + SWITCH_KEYS.md = SWITCH_KEYS.md + LICENSE = LICENSE EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\es.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\libfnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}" - ProjectSection(ProjectDependencies) = postProject - {CF01B5B7-730A-447F-9BB2-5EDA9B082177} = {CF01B5B7-730A-447F-9BB2-5EDA9B082177} - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "lib\libpolarssl\libpolarssl.vcxproj", "{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "lib\liblz4\liblz4.vcxproj", "{AB0C3362-63AB-480A-ADBC-2EF7D859778B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\libcrypto\libcrypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcompress", "lib\libcompress\libcompress.vcxproj", "{CF01B5B7-730A-447F-9BB2-5EDA9B082177}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnx-hb", "lib\libnx-hb\libnx-hb.vcxproj", "{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpki", "lib\libpki\libpki.vcxproj", "{B9113734-6E84-44FF-8CF7-58199AA815C5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\libes.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac", "lib\libhac\libhac.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac-hb", "lib\libhac-hb\libhac-hb.vcxproj", "{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -62,6 +58,22 @@ Global {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x64.Build.0 = Release|x64 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x86.ActiveCfg = Release|Win32 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x86.Build.0 = Release|Win32 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x64.ActiveCfg = Debug|x64 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x64.Build.0 = Debug|x64 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x86.ActiveCfg = Debug|Win32 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x86.Build.0 = Debug|Win32 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x64.ActiveCfg = Release|x64 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x64.Build.0 = Release|x64 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x86.ActiveCfg = Release|Win32 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x86.Build.0 = Release|Win32 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x64.ActiveCfg = Debug|x64 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x64.Build.0 = Debug|x64 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x86.ActiveCfg = Debug|Win32 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x86.Build.0 = Debug|Win32 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.ActiveCfg = Release|x64 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.Build.0 = Release|x64 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.ActiveCfg = Release|Win32 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.Build.0 = Release|Win32 {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.ActiveCfg = Debug|x64 {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.Build.0 = Debug|x64 {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x86.ActiveCfg = Debug|Win32 @@ -86,14 +98,6 @@ Global {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64 {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32 {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.Build.0 = Debug|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.ActiveCfg = Release|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.Build.0 = Release|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.ActiveCfg = Release|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.Build.0 = Release|Win32 {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.ActiveCfg = Debug|x64 {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.Build.0 = Debug|x64 {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x86.ActiveCfg = Debug|Win32 @@ -118,19 +122,29 @@ Global {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x64.Build.0 = Release|x64 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x86.ActiveCfg = Release|Win32 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x86.Build.0 = Release|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.Build.0 = Debug|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.ActiveCfg = Release|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.Build.0 = Release|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.ActiveCfg = Release|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} {CF01B5B7-730A-447F-9BB2-5EDA9B082177} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {B9113734-6E84-44FF-8CF7-58199AA815C5} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {07DCCACC-D10D-47C9-85AE-FB9C54DB7D62} diff --git a/NXTools.vcxproj b/NXTools.vcxproj index 647aa09..d764e1b 100644 --- a/NXTools.vcxproj +++ b/NXTools.vcxproj @@ -21,9 +21,9 @@ 15.0 {0A4197A1-76AD-4BF7-A29D-5CED369B72FD} - NXTools + NNTools 10.0.15063.0 - libnx + NNTools diff --git a/lib/libcompress/libcompress.vcxproj b/lib/libcompress/libcompress.vcxproj index 820d6cf..56a6671 100644 --- a/lib/libcompress/libcompress.vcxproj +++ b/lib/libcompress/libcompress.vcxproj @@ -76,7 +76,7 @@ Disabled true true - ..\libcompress\include;..\libcompress\source\lz4; + ..\libcompress\include;..\liblz4\include; @@ -85,7 +85,7 @@ Disabled true true - ..\libcompress\include;..\libcompress\source\lz4; + ..\libcompress\include;..\liblz4\include; @@ -96,7 +96,7 @@ true true true - ..\libcompress\include;..\libcompress\source\lz4; + ..\libcompress\include;..\liblz4\include; true @@ -111,7 +111,7 @@ true true true - ..\libcompress\include;..\libcompress\source\lz4; + ..\libcompress\include;..\liblz4\include; true @@ -120,11 +120,9 @@ - - diff --git a/lib/libcompress/libcompress.vcxproj.filters b/lib/libcompress/libcompress.vcxproj.filters index 2967ba3..ef951e4 100644 --- a/lib/libcompress/libcompress.vcxproj.filters +++ b/lib/libcompress/libcompress.vcxproj.filters @@ -13,25 +13,13 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - {8b967d21-0d8f-4bf9-aa1c-54d33abdcec6} - - - {73860001-f667-4a56-a6e3-9007611f7da7} - - Header Files\compress - - - Source Files\lz4 + Header Files - - Source Files\lz4 - Source Files diff --git a/lib/libcompress/makefile b/lib/libcompress/makefile index d639e86..931617a 100644 --- a/lib/libcompress/makefile +++ b/lib/libcompress/makefile @@ -1,11 +1,11 @@ # Sources -SRC_DIR = source source/lz4 +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = +DEPENDS = lz4 LIB_DIR = .. -INCS = -I"include" -I"source/lz4" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") # Compiler Settings diff --git a/lib/libcrypto/crypto.vcxproj.filters b/lib/libcrypto/crypto.vcxproj.filters deleted file mode 100644 index 0110282..0000000 --- a/lib/libcrypto/crypto.vcxproj.filters +++ /dev/null @@ -1,114 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {c24d0e3f-1a38-486c-9bad-b7db5b39eee2} - - - {50821199-d06b-4e82-b424-3f17b60f1a9e} - - - {012a6f22-d10a-4ca3-b7c3-4c31c6ff1cc1} - - - - - Header Files\crypto - - - Header Files\crypto - - - Header Files\crypto - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\polarssl - - - Header Files\crypto - - - Header Files\crypto - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files\polarssl - - - Source Files - - - - - - \ No newline at end of file diff --git a/lib/libcrypto/crypto.vcxproj b/lib/libcrypto/libcrypto.vcxproj similarity index 80% rename from lib/libcrypto/crypto.vcxproj rename to lib/libcrypto/libcrypto.vcxproj index 06dfa98..c401526 100644 --- a/lib/libcrypto/crypto.vcxproj +++ b/lib/libcrypto/libcrypto.vcxproj @@ -21,9 +21,7 @@ 15.0 {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} - crypto 10.0.15063.0 - libcrypto @@ -76,7 +74,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -85,7 +83,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -96,7 +94,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -111,7 +109,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -125,28 +123,10 @@ - - - - - - - - - - - - - - - - - - diff --git a/lib/libcrypto/libcrypto.vcxproj.filters b/lib/libcrypto/libcrypto.vcxproj.filters new file mode 100644 index 0000000..3c65bd5 --- /dev/null +++ b/lib/libcrypto/libcrypto.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/lib/libcrypto/crypto.vcxproj.user b/lib/libcrypto/libcrypto.vcxproj.user similarity index 100% rename from lib/libcrypto/crypto.vcxproj.user rename to lib/libcrypto/libcrypto.vcxproj.user diff --git a/lib/libcrypto/makefile b/lib/libcrypto/makefile index 07909d3..d1bf049 100644 --- a/lib/libcrypto/makefile +++ b/lib/libcrypto/makefile @@ -1,16 +1,15 @@ # Sources -SRC_DIR = source source/libpolarssl/source -OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) +SRC_DIR = source +OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) # External dependencies -DEPENDS = fnd +DEPENDS = fnd polarssl LIB_DIR = .. -INCS = -I"include" -I"source/libpolarssl/include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value -CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value ARFLAGS = cr -o ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs @@ -30,7 +29,6 @@ else CFLAGS += -Wno-unused-but-set-variable CXXFLAGS += -Wno-unused-but-set-variable endif - endif # Output diff --git a/lib/libcrypto/source/libpolarssl/makefile b/lib/libcrypto/source/libpolarssl/makefile deleted file mode 100644 index f2d86c3..0000000 --- a/lib/libcrypto/source/libpolarssl/makefile +++ /dev/null @@ -1,37 +0,0 @@ -# Sources -SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) - -# External dependencies -DEPENDS = -LIB_DIR = .. -INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - - -# Compiler Settings -CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value -CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value -ifeq ($(OS),Windows_NT) - # Windows Only Flags/Libs - CC = x86_64-w64-mingw32-gcc - CXX = x86_64-w64-mingw32-g++ - CFLAGS += - CXXFLAGS += -else - # *nix Only Flags/Libs - CFLAGS += - CXXFLAGS += -endif - -# Output -OUTPUT = $(shell basename $(CURDIR)).a - -main: build - -rebuild: clean build - -build: $(OBJS) - ar cr -o $(OUTPUT) $(OBJS) - -clean: - rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libes/include/es/SectionHeader_V2.h b/lib/libes/include/nn/es/SectionHeader_V2.h similarity index 100% rename from lib/libes/include/es/SectionHeader_V2.h rename to lib/libes/include/nn/es/SectionHeader_V2.h diff --git a/lib/libes/include/es/TicketBody_V2.h b/lib/libes/include/nn/es/TicketBody_V2.h similarity index 100% rename from lib/libes/include/es/TicketBody_V2.h rename to lib/libes/include/nn/es/TicketBody_V2.h diff --git a/lib/libes/include/es/ticket.h b/lib/libes/include/nn/es/ticket.h similarity index 100% rename from lib/libes/include/es/ticket.h rename to lib/libes/include/nn/es/ticket.h diff --git a/lib/libes/es.vcxproj b/lib/libes/libes.vcxproj similarity index 98% rename from lib/libes/es.vcxproj rename to lib/libes/libes.vcxproj index ae9f9c3..2373da0 100644 --- a/lib/libes/es.vcxproj +++ b/lib/libes/libes.vcxproj @@ -20,9 +20,7 @@ {7BE99936-0D40-410D-944B-4513C2EFF8DC} - es 8.1 - libes diff --git a/lib/libes/es.vcxproj.filters b/lib/libes/libes.vcxproj.filters similarity index 100% rename from lib/libes/es.vcxproj.filters rename to lib/libes/libes.vcxproj.filters diff --git a/lib/libes/es.vcxproj.user b/lib/libes/libes.vcxproj.user similarity index 100% rename from lib/libes/es.vcxproj.user rename to lib/libes/libes.vcxproj.user diff --git a/lib/libfnd/fnd.vcxproj b/lib/libfnd/libfnd.vcxproj similarity index 98% rename from lib/libfnd/fnd.vcxproj rename to lib/libfnd/libfnd.vcxproj index 703f93b..ae0fc8a 100644 --- a/lib/libfnd/fnd.vcxproj +++ b/lib/libfnd/libfnd.vcxproj @@ -21,9 +21,7 @@ 15.0 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} - fnd 10.0.15063.0 - libfnd diff --git a/lib/libfnd/fnd.vcxproj.filters b/lib/libfnd/libfnd.vcxproj.filters similarity index 100% rename from lib/libfnd/fnd.vcxproj.filters rename to lib/libfnd/libfnd.vcxproj.filters diff --git a/lib/libfnd/fnd.vcxproj.user b/lib/libfnd/libfnd.vcxproj.user similarity index 100% rename from lib/libfnd/fnd.vcxproj.user rename to lib/libfnd/libfnd.vcxproj.user diff --git a/lib/libnx-hb/include/nx/AssetHeader.h b/lib/libhac-hb/include/nn/hac/AssetHeader.h similarity index 100% rename from lib/libnx-hb/include/nx/AssetHeader.h rename to lib/libhac-hb/include/nn/hac/AssetHeader.h diff --git a/lib/libnx-hb/include/nx/aset.h b/lib/libhac-hb/include/nn/hac/aset.h similarity index 100% rename from lib/libnx-hb/include/nx/aset.h rename to lib/libhac-hb/include/nn/hac/aset.h diff --git a/lib/libnx-hb/include/nx/nro-hb.h b/lib/libhac-hb/include/nn/hac/nro-hb.h similarity index 100% rename from lib/libnx-hb/include/nx/nro-hb.h rename to lib/libhac-hb/include/nn/hac/nro-hb.h diff --git a/lib/libnx-hb/libnx-hb.vcxproj b/lib/libhac-hb/libhac-hb.vcxproj similarity index 92% rename from lib/libnx-hb/libnx-hb.vcxproj rename to lib/libhac-hb/libhac-hb.vcxproj index 927d5d9..06ec389 100644 --- a/lib/libnx-hb/libnx-hb.vcxproj +++ b/lib/libhac-hb/libhac-hb.vcxproj @@ -21,7 +21,6 @@ 15.0 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} - libnxhb 10.0.16299.0 @@ -78,7 +77,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include;..\libnx-hb\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; true @@ -91,7 +90,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include;..\libnx-hb\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; @@ -100,7 +99,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include;..\libnx-hb\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; @@ -111,7 +110,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include;..\libnx-hb\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; true @@ -119,9 +118,9 @@ - - - + + + diff --git a/lib/libnx-hb/libnx-hb.vcxproj.filters b/lib/libhac-hb/libhac-hb.vcxproj.filters similarity index 88% rename from lib/libnx-hb/libnx-hb.vcxproj.filters rename to lib/libhac-hb/libhac-hb.vcxproj.filters index 01df9d5..02e64c2 100644 --- a/lib/libnx-hb/libnx-hb.vcxproj.filters +++ b/lib/libhac-hb/libhac-hb.vcxproj.filters @@ -15,13 +15,13 @@ - + Header Files - + Header Files - + Header Files diff --git a/lib/libnx-hb/libnx-hb.vcxproj.user b/lib/libhac-hb/libhac-hb.vcxproj.user similarity index 100% rename from lib/libnx-hb/libnx-hb.vcxproj.user rename to lib/libhac-hb/libhac-hb.vcxproj.user diff --git a/lib/libnx-hb/makefile b/lib/libhac-hb/makefile similarity index 100% rename from lib/libnx-hb/makefile rename to lib/libhac-hb/makefile diff --git a/lib/libnx-hb/source/AssetHeader.cpp b/lib/libhac-hb/source/AssetHeader.cpp similarity index 100% rename from lib/libnx-hb/source/AssetHeader.cpp rename to lib/libhac-hb/source/AssetHeader.cpp diff --git a/lib/libnx/include/nx/AccessControlInfoBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoBinary.h similarity index 100% rename from lib/libnx/include/nx/AccessControlInfoBinary.h rename to lib/libhac/include/nn/hac/AccessControlInfoBinary.h diff --git a/lib/libnx/include/nx/AccessControlInfoDescBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h similarity index 100% rename from lib/libnx/include/nx/AccessControlInfoDescBinary.h rename to lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h diff --git a/lib/libnx/include/nx/AesKeygen.h b/lib/libhac/include/nn/hac/AesKeygen.h similarity index 100% rename from lib/libnx/include/nx/AesKeygen.h rename to lib/libhac/include/nn/hac/AesKeygen.h diff --git a/lib/libnx/include/nx/ApplicationControlPropertyBinary.h b/lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h similarity index 100% rename from lib/libnx/include/nx/ApplicationControlPropertyBinary.h rename to lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h diff --git a/lib/libnx/include/nx/ApplicationControlPropertyUtils.h b/lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h similarity index 100% rename from lib/libnx/include/nx/ApplicationControlPropertyUtils.h rename to lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h diff --git a/lib/libnx/include/nx/ContentMetaBinary.h b/lib/libhac/include/nn/hac/ContentMetaBinary.h similarity index 100% rename from lib/libnx/include/nx/ContentMetaBinary.h rename to lib/libhac/include/nn/hac/ContentMetaBinary.h diff --git a/lib/libnx/include/nx/FileSystemAccessControlBinary.h b/lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h similarity index 100% rename from lib/libnx/include/nx/FileSystemAccessControlBinary.h rename to lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h diff --git a/lib/libnx/include/nx/HandleTableSizeEntry.h b/lib/libhac/include/nn/hac/HandleTableSizeEntry.h similarity index 100% rename from lib/libnx/include/nx/HandleTableSizeEntry.h rename to lib/libhac/include/nn/hac/HandleTableSizeEntry.h diff --git a/lib/libnx/include/nx/HandleTableSizeHandler.h b/lib/libhac/include/nn/hac/HandleTableSizeHandler.h similarity index 100% rename from lib/libnx/include/nx/HandleTableSizeHandler.h rename to lib/libhac/include/nn/hac/HandleTableSizeHandler.h diff --git a/lib/libnx/include/nx/HierarchicalIntegrityHeader.h b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h similarity index 100% rename from lib/libnx/include/nx/HierarchicalIntegrityHeader.h rename to lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h diff --git a/lib/libnx/include/nx/HierarchicalSha256Header.h b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h similarity index 100% rename from lib/libnx/include/nx/HierarchicalSha256Header.h rename to lib/libhac/include/nn/hac/HierarchicalSha256Header.h diff --git a/lib/libnx/include/nx/IKernelCapabilityHandler.h b/lib/libhac/include/nn/hac/IKernelCapabilityHandler.h similarity index 100% rename from lib/libnx/include/nx/IKernelCapabilityHandler.h rename to lib/libhac/include/nn/hac/IKernelCapabilityHandler.h diff --git a/lib/libnx/include/nx/InteruptEntry.h b/lib/libhac/include/nn/hac/InteruptEntry.h similarity index 100% rename from lib/libnx/include/nx/InteruptEntry.h rename to lib/libhac/include/nn/hac/InteruptEntry.h diff --git a/lib/libnx/include/nx/InteruptHandler.h b/lib/libhac/include/nn/hac/InteruptHandler.h similarity index 100% rename from lib/libnx/include/nx/InteruptHandler.h rename to lib/libhac/include/nn/hac/InteruptHandler.h diff --git a/lib/libnx/include/nx/KernelCapabilityBinary.h b/lib/libhac/include/nn/hac/KernelCapabilityBinary.h similarity index 100% rename from lib/libnx/include/nx/KernelCapabilityBinary.h rename to lib/libhac/include/nn/hac/KernelCapabilityBinary.h diff --git a/lib/libnx/include/nx/KernelCapabilityEntry.h b/lib/libhac/include/nn/hac/KernelCapabilityEntry.h similarity index 100% rename from lib/libnx/include/nx/KernelCapabilityEntry.h rename to lib/libhac/include/nn/hac/KernelCapabilityEntry.h diff --git a/lib/libnx/include/nx/KernelVersionEntry.h b/lib/libhac/include/nn/hac/KernelVersionEntry.h similarity index 100% rename from lib/libnx/include/nx/KernelVersionEntry.h rename to lib/libhac/include/nn/hac/KernelVersionEntry.h diff --git a/lib/libnx/include/nx/KernelVersionHandler.h b/lib/libhac/include/nn/hac/KernelVersionHandler.h similarity index 100% rename from lib/libnx/include/nx/KernelVersionHandler.h rename to lib/libhac/include/nn/hac/KernelVersionHandler.h diff --git a/lib/libnx/include/nx/MemoryMappingHandler.h b/lib/libhac/include/nn/hac/MemoryMappingHandler.h similarity index 100% rename from lib/libnx/include/nx/MemoryMappingHandler.h rename to lib/libhac/include/nn/hac/MemoryMappingHandler.h diff --git a/lib/libnx/include/nx/MemoryPageEntry.h b/lib/libhac/include/nn/hac/MemoryPageEntry.h similarity index 100% rename from lib/libnx/include/nx/MemoryPageEntry.h rename to lib/libhac/include/nn/hac/MemoryPageEntry.h diff --git a/lib/libnx/include/nx/MiscFlagsEntry.h b/lib/libhac/include/nn/hac/MiscFlagsEntry.h similarity index 100% rename from lib/libnx/include/nx/MiscFlagsEntry.h rename to lib/libhac/include/nn/hac/MiscFlagsEntry.h diff --git a/lib/libnx/include/nx/MiscFlagsHandler.h b/lib/libhac/include/nn/hac/MiscFlagsHandler.h similarity index 100% rename from lib/libnx/include/nx/MiscFlagsHandler.h rename to lib/libhac/include/nn/hac/MiscFlagsHandler.h diff --git a/lib/libnx/include/nx/MiscParamsEntry.h b/lib/libhac/include/nn/hac/MiscParamsEntry.h similarity index 100% rename from lib/libnx/include/nx/MiscParamsEntry.h rename to lib/libhac/include/nn/hac/MiscParamsEntry.h diff --git a/lib/libnx/include/nx/MiscParamsHandler.h b/lib/libhac/include/nn/hac/MiscParamsHandler.h similarity index 100% rename from lib/libnx/include/nx/MiscParamsHandler.h rename to lib/libhac/include/nn/hac/MiscParamsHandler.h diff --git a/lib/libnx/include/nx/NcaHeader.h b/lib/libhac/include/nn/hac/NcaHeader.h similarity index 100% rename from lib/libnx/include/nx/NcaHeader.h rename to lib/libhac/include/nn/hac/NcaHeader.h diff --git a/lib/libnx/include/nx/NcaUtils.h b/lib/libhac/include/nn/hac/NcaUtils.h similarity index 100% rename from lib/libnx/include/nx/NcaUtils.h rename to lib/libhac/include/nn/hac/NcaUtils.h diff --git a/lib/libnx/include/nx/NpdmBinary.h b/lib/libhac/include/nn/hac/NpdmBinary.h similarity index 100% rename from lib/libnx/include/nx/NpdmBinary.h rename to lib/libhac/include/nn/hac/NpdmBinary.h diff --git a/lib/libnx/include/nx/NroHeader.h b/lib/libhac/include/nn/hac/NroHeader.h similarity index 100% rename from lib/libnx/include/nx/NroHeader.h rename to lib/libhac/include/nn/hac/NroHeader.h diff --git a/lib/libnx/include/nx/NsoHeader.h b/lib/libhac/include/nn/hac/NsoHeader.h similarity index 100% rename from lib/libnx/include/nx/NsoHeader.h rename to lib/libhac/include/nn/hac/NsoHeader.h diff --git a/lib/libnx/include/nx/PfsHeader.h b/lib/libhac/include/nn/hac/PfsHeader.h similarity index 100% rename from lib/libnx/include/nx/PfsHeader.h rename to lib/libhac/include/nn/hac/PfsHeader.h diff --git a/lib/libnx/include/nx/ServiceAccessControlBinary.h b/lib/libhac/include/nn/hac/ServiceAccessControlBinary.h similarity index 100% rename from lib/libnx/include/nx/ServiceAccessControlBinary.h rename to lib/libhac/include/nn/hac/ServiceAccessControlBinary.h diff --git a/lib/libnx/include/nx/ServiceAccessControlEntry.h b/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h similarity index 100% rename from lib/libnx/include/nx/ServiceAccessControlEntry.h rename to lib/libhac/include/nn/hac/ServiceAccessControlEntry.h diff --git a/lib/libnx/include/nx/SystemCallEntry.h b/lib/libhac/include/nn/hac/SystemCallEntry.h similarity index 100% rename from lib/libnx/include/nx/SystemCallEntry.h rename to lib/libhac/include/nn/hac/SystemCallEntry.h diff --git a/lib/libnx/include/nx/SystemCallHandler.h b/lib/libhac/include/nn/hac/SystemCallHandler.h similarity index 100% rename from lib/libnx/include/nx/SystemCallHandler.h rename to lib/libhac/include/nn/hac/SystemCallHandler.h diff --git a/lib/libnx/include/nx/ThreadInfoEntry.h b/lib/libhac/include/nn/hac/ThreadInfoEntry.h similarity index 100% rename from lib/libnx/include/nx/ThreadInfoEntry.h rename to lib/libhac/include/nn/hac/ThreadInfoEntry.h diff --git a/lib/libnx/include/nx/ThreadInfoHandler.h b/lib/libhac/include/nn/hac/ThreadInfoHandler.h similarity index 100% rename from lib/libnx/include/nx/ThreadInfoHandler.h rename to lib/libhac/include/nn/hac/ThreadInfoHandler.h diff --git a/lib/libnx/include/nx/XciHeader.h b/lib/libhac/include/nn/hac/XciHeader.h similarity index 100% rename from lib/libnx/include/nx/XciHeader.h rename to lib/libhac/include/nn/hac/XciHeader.h diff --git a/lib/libnx/include/nx/XciUtils.h b/lib/libhac/include/nn/hac/XciUtils.h similarity index 100% rename from lib/libnx/include/nx/XciUtils.h rename to lib/libhac/include/nn/hac/XciUtils.h diff --git a/lib/libnx/include/nx/aci.h b/lib/libhac/include/nn/hac/aci.h similarity index 100% rename from lib/libnx/include/nx/aci.h rename to lib/libhac/include/nn/hac/aci.h diff --git a/lib/libnx/include/nx/cnmt.h b/lib/libhac/include/nn/hac/cnmt.h similarity index 100% rename from lib/libnx/include/nx/cnmt.h rename to lib/libhac/include/nn/hac/cnmt.h diff --git a/lib/libnx/include/nx/elf.h b/lib/libhac/include/nn/hac/elf.h similarity index 100% rename from lib/libnx/include/nx/elf.h rename to lib/libhac/include/nn/hac/elf.h diff --git a/lib/libnx/include/nx/fac.h b/lib/libhac/include/nn/hac/fac.h similarity index 100% rename from lib/libnx/include/nx/fac.h rename to lib/libhac/include/nn/hac/fac.h diff --git a/lib/libnx/include/nx/hierarchicalintegrity.h b/lib/libhac/include/nn/hac/hierarchicalintegrity.h similarity index 100% rename from lib/libnx/include/nx/hierarchicalintegrity.h rename to lib/libhac/include/nn/hac/hierarchicalintegrity.h diff --git a/lib/libnx/include/nx/hierarchicalsha256.h b/lib/libhac/include/nn/hac/hierarchicalsha256.h similarity index 100% rename from lib/libnx/include/nx/hierarchicalsha256.h rename to lib/libhac/include/nn/hac/hierarchicalsha256.h diff --git a/lib/libnx/include/nx/kc.h b/lib/libhac/include/nn/hac/kc.h similarity index 100% rename from lib/libnx/include/nx/kc.h rename to lib/libhac/include/nn/hac/kc.h diff --git a/lib/libnx/include/nx/macro.h b/lib/libhac/include/nn/hac/macro.h similarity index 100% rename from lib/libnx/include/nx/macro.h rename to lib/libhac/include/nn/hac/macro.h diff --git a/lib/libnx/include/nx/nacp.h b/lib/libhac/include/nn/hac/nacp.h similarity index 100% rename from lib/libnx/include/nx/nacp.h rename to lib/libhac/include/nn/hac/nacp.h diff --git a/lib/libnx/include/nx/nca.h b/lib/libhac/include/nn/hac/nca.h similarity index 100% rename from lib/libnx/include/nx/nca.h rename to lib/libhac/include/nn/hac/nca.h diff --git a/lib/libnx/include/nx/npdm.h b/lib/libhac/include/nn/hac/npdm.h similarity index 100% rename from lib/libnx/include/nx/npdm.h rename to lib/libhac/include/nn/hac/npdm.h diff --git a/lib/libnx/include/nx/nro.h b/lib/libhac/include/nn/hac/nro.h similarity index 100% rename from lib/libnx/include/nx/nro.h rename to lib/libhac/include/nn/hac/nro.h diff --git a/lib/libnx/include/nx/nrr.h b/lib/libhac/include/nn/hac/nrr.h similarity index 100% rename from lib/libnx/include/nx/nrr.h rename to lib/libhac/include/nn/hac/nrr.h diff --git a/lib/libnx/include/nx/nso.h b/lib/libhac/include/nn/hac/nso.h similarity index 100% rename from lib/libnx/include/nx/nso.h rename to lib/libhac/include/nn/hac/nso.h diff --git a/lib/libnx/include/nx/pfs.h b/lib/libhac/include/nn/hac/pfs.h similarity index 100% rename from lib/libnx/include/nx/pfs.h rename to lib/libhac/include/nn/hac/pfs.h diff --git a/lib/libnx/include/nx/romfs.h b/lib/libhac/include/nn/hac/romfs.h similarity index 100% rename from lib/libnx/include/nx/romfs.h rename to lib/libhac/include/nn/hac/romfs.h diff --git a/lib/libnx/include/nx/xci.h b/lib/libhac/include/nn/hac/xci.h similarity index 100% rename from lib/libnx/include/nx/xci.h rename to lib/libhac/include/nn/hac/xci.h diff --git a/lib/libnx/nx.vcxproj b/lib/libhac/libhac.vcxproj similarity index 70% rename from lib/libnx/nx.vcxproj rename to lib/libhac/libhac.vcxproj index 9d72230..3ea2410 100644 --- a/lib/libnx/nx.vcxproj +++ b/lib/libhac/libhac.vcxproj @@ -22,61 +22,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -120,9 +120,9 @@ 15.0 {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} - nx + hac 10.0.15063.0 - libnx + libhac @@ -175,7 +175,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libnx\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -184,7 +184,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libnx\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -195,7 +195,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -210,7 +210,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libnx\include; + ..\libfnd\include;..\libcrypto\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/lib/libnx/nx.vcxproj.filters b/lib/libhac/libhac.vcxproj.filters similarity index 71% rename from lib/libnx/nx.vcxproj.filters rename to lib/libhac/libhac.vcxproj.filters index 5147ede..3c44384 100644 --- a/lib/libnx/nx.vcxproj.filters +++ b/lib/libhac/libhac.vcxproj.filters @@ -18,169 +18,169 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files diff --git a/lib/libnx/nx.vcxproj.user b/lib/libhac/libhac.vcxproj.user similarity index 100% rename from lib/libnx/nx.vcxproj.user rename to lib/libhac/libhac.vcxproj.user diff --git a/lib/libnx/makefile b/lib/libhac/makefile similarity index 100% rename from lib/libnx/makefile rename to lib/libhac/makefile diff --git a/lib/libnx/source/AccessControlInfoBinary.cpp b/lib/libhac/source/AccessControlInfoBinary.cpp similarity index 100% rename from lib/libnx/source/AccessControlInfoBinary.cpp rename to lib/libhac/source/AccessControlInfoBinary.cpp diff --git a/lib/libnx/source/AccessControlInfoDescBinary.cpp b/lib/libhac/source/AccessControlInfoDescBinary.cpp similarity index 100% rename from lib/libnx/source/AccessControlInfoDescBinary.cpp rename to lib/libhac/source/AccessControlInfoDescBinary.cpp diff --git a/lib/libnx/source/AesKeygen.cpp b/lib/libhac/source/AesKeygen.cpp similarity index 100% rename from lib/libnx/source/AesKeygen.cpp rename to lib/libhac/source/AesKeygen.cpp diff --git a/lib/libnx/source/ApplicationControlPropertyBinary.cpp b/lib/libhac/source/ApplicationControlPropertyBinary.cpp similarity index 100% rename from lib/libnx/source/ApplicationControlPropertyBinary.cpp rename to lib/libhac/source/ApplicationControlPropertyBinary.cpp diff --git a/lib/libnx/source/ApplicationControlPropertyUtils.cpp b/lib/libhac/source/ApplicationControlPropertyUtils.cpp similarity index 100% rename from lib/libnx/source/ApplicationControlPropertyUtils.cpp rename to lib/libhac/source/ApplicationControlPropertyUtils.cpp diff --git a/lib/libnx/source/ContentMetaBinary.cpp b/lib/libhac/source/ContentMetaBinary.cpp similarity index 100% rename from lib/libnx/source/ContentMetaBinary.cpp rename to lib/libhac/source/ContentMetaBinary.cpp diff --git a/lib/libnx/source/FileSystemAccessControlBinary.cpp b/lib/libhac/source/FileSystemAccessControlBinary.cpp similarity index 100% rename from lib/libnx/source/FileSystemAccessControlBinary.cpp rename to lib/libhac/source/FileSystemAccessControlBinary.cpp diff --git a/lib/libnx/source/HandleTableSizeEntry.cpp b/lib/libhac/source/HandleTableSizeEntry.cpp similarity index 100% rename from lib/libnx/source/HandleTableSizeEntry.cpp rename to lib/libhac/source/HandleTableSizeEntry.cpp diff --git a/lib/libnx/source/HandleTableSizeHandler.cpp b/lib/libhac/source/HandleTableSizeHandler.cpp similarity index 100% rename from lib/libnx/source/HandleTableSizeHandler.cpp rename to lib/libhac/source/HandleTableSizeHandler.cpp diff --git a/lib/libnx/source/HierarchicalIntegrityHeader.cpp b/lib/libhac/source/HierarchicalIntegrityHeader.cpp similarity index 100% rename from lib/libnx/source/HierarchicalIntegrityHeader.cpp rename to lib/libhac/source/HierarchicalIntegrityHeader.cpp diff --git a/lib/libnx/source/HierarchicalSha256Header.cpp b/lib/libhac/source/HierarchicalSha256Header.cpp similarity index 100% rename from lib/libnx/source/HierarchicalSha256Header.cpp rename to lib/libhac/source/HierarchicalSha256Header.cpp diff --git a/lib/libnx/source/InteruptEntry.cpp b/lib/libhac/source/InteruptEntry.cpp similarity index 100% rename from lib/libnx/source/InteruptEntry.cpp rename to lib/libhac/source/InteruptEntry.cpp diff --git a/lib/libnx/source/InteruptHandler.cpp b/lib/libhac/source/InteruptHandler.cpp similarity index 100% rename from lib/libnx/source/InteruptHandler.cpp rename to lib/libhac/source/InteruptHandler.cpp diff --git a/lib/libnx/source/KernelCapabilityBinary.cpp b/lib/libhac/source/KernelCapabilityBinary.cpp similarity index 100% rename from lib/libnx/source/KernelCapabilityBinary.cpp rename to lib/libhac/source/KernelCapabilityBinary.cpp diff --git a/lib/libnx/source/KernelCapabilityEntry.cpp b/lib/libhac/source/KernelCapabilityEntry.cpp similarity index 100% rename from lib/libnx/source/KernelCapabilityEntry.cpp rename to lib/libhac/source/KernelCapabilityEntry.cpp diff --git a/lib/libnx/source/KernelVersionEntry.cpp b/lib/libhac/source/KernelVersionEntry.cpp similarity index 100% rename from lib/libnx/source/KernelVersionEntry.cpp rename to lib/libhac/source/KernelVersionEntry.cpp diff --git a/lib/libnx/source/KernelVersionHandler.cpp b/lib/libhac/source/KernelVersionHandler.cpp similarity index 100% rename from lib/libnx/source/KernelVersionHandler.cpp rename to lib/libhac/source/KernelVersionHandler.cpp diff --git a/lib/libnx/source/MemoryMappingHandler.cpp b/lib/libhac/source/MemoryMappingHandler.cpp similarity index 100% rename from lib/libnx/source/MemoryMappingHandler.cpp rename to lib/libhac/source/MemoryMappingHandler.cpp diff --git a/lib/libnx/source/MemoryPageEntry.cpp b/lib/libhac/source/MemoryPageEntry.cpp similarity index 100% rename from lib/libnx/source/MemoryPageEntry.cpp rename to lib/libhac/source/MemoryPageEntry.cpp diff --git a/lib/libnx/source/MiscFlagsEntry.cpp b/lib/libhac/source/MiscFlagsEntry.cpp similarity index 100% rename from lib/libnx/source/MiscFlagsEntry.cpp rename to lib/libhac/source/MiscFlagsEntry.cpp diff --git a/lib/libnx/source/MiscFlagsHandler.cpp b/lib/libhac/source/MiscFlagsHandler.cpp similarity index 100% rename from lib/libnx/source/MiscFlagsHandler.cpp rename to lib/libhac/source/MiscFlagsHandler.cpp diff --git a/lib/libnx/source/MiscParamsEntry.cpp b/lib/libhac/source/MiscParamsEntry.cpp similarity index 100% rename from lib/libnx/source/MiscParamsEntry.cpp rename to lib/libhac/source/MiscParamsEntry.cpp diff --git a/lib/libnx/source/MiscParamsHandler.cpp b/lib/libhac/source/MiscParamsHandler.cpp similarity index 100% rename from lib/libnx/source/MiscParamsHandler.cpp rename to lib/libhac/source/MiscParamsHandler.cpp diff --git a/lib/libnx/source/NcaHeader.cpp b/lib/libhac/source/NcaHeader.cpp similarity index 100% rename from lib/libnx/source/NcaHeader.cpp rename to lib/libhac/source/NcaHeader.cpp diff --git a/lib/libnx/source/NcaUtils.cpp b/lib/libhac/source/NcaUtils.cpp similarity index 100% rename from lib/libnx/source/NcaUtils.cpp rename to lib/libhac/source/NcaUtils.cpp diff --git a/lib/libnx/source/NpdmBinary.cpp b/lib/libhac/source/NpdmBinary.cpp similarity index 100% rename from lib/libnx/source/NpdmBinary.cpp rename to lib/libhac/source/NpdmBinary.cpp diff --git a/lib/libnx/source/NroHeader.cpp b/lib/libhac/source/NroHeader.cpp similarity index 100% rename from lib/libnx/source/NroHeader.cpp rename to lib/libhac/source/NroHeader.cpp diff --git a/lib/libnx/source/NsoHeader.cpp b/lib/libhac/source/NsoHeader.cpp similarity index 100% rename from lib/libnx/source/NsoHeader.cpp rename to lib/libhac/source/NsoHeader.cpp diff --git a/lib/libnx/source/PfsHeader.cpp b/lib/libhac/source/PfsHeader.cpp similarity index 100% rename from lib/libnx/source/PfsHeader.cpp rename to lib/libhac/source/PfsHeader.cpp diff --git a/lib/libnx/source/ServiceAccessControlBinary.cpp b/lib/libhac/source/ServiceAccessControlBinary.cpp similarity index 100% rename from lib/libnx/source/ServiceAccessControlBinary.cpp rename to lib/libhac/source/ServiceAccessControlBinary.cpp diff --git a/lib/libnx/source/ServiceAccessControlEntry.cpp b/lib/libhac/source/ServiceAccessControlEntry.cpp similarity index 100% rename from lib/libnx/source/ServiceAccessControlEntry.cpp rename to lib/libhac/source/ServiceAccessControlEntry.cpp diff --git a/lib/libnx/source/SystemCallEntry.cpp b/lib/libhac/source/SystemCallEntry.cpp similarity index 100% rename from lib/libnx/source/SystemCallEntry.cpp rename to lib/libhac/source/SystemCallEntry.cpp diff --git a/lib/libnx/source/SystemCallHandler.cpp b/lib/libhac/source/SystemCallHandler.cpp similarity index 100% rename from lib/libnx/source/SystemCallHandler.cpp rename to lib/libhac/source/SystemCallHandler.cpp diff --git a/lib/libnx/source/ThreadInfoEntry.cpp b/lib/libhac/source/ThreadInfoEntry.cpp similarity index 100% rename from lib/libnx/source/ThreadInfoEntry.cpp rename to lib/libhac/source/ThreadInfoEntry.cpp diff --git a/lib/libnx/source/ThreadInfoHandler.cpp b/lib/libhac/source/ThreadInfoHandler.cpp similarity index 100% rename from lib/libnx/source/ThreadInfoHandler.cpp rename to lib/libhac/source/ThreadInfoHandler.cpp diff --git a/lib/libnx/source/XciHeader.cpp b/lib/libhac/source/XciHeader.cpp similarity index 100% rename from lib/libnx/source/XciHeader.cpp rename to lib/libhac/source/XciHeader.cpp diff --git a/lib/libnx/source/XciUtils.cpp b/lib/libhac/source/XciUtils.cpp similarity index 100% rename from lib/libnx/source/XciUtils.cpp rename to lib/libhac/source/XciUtils.cpp diff --git a/lib/libcompress/source/lz4/lz4.h b/lib/liblz4/include/lz4.h similarity index 100% rename from lib/libcompress/source/lz4/lz4.h rename to lib/liblz4/include/lz4.h diff --git a/lib/liblz4/liblz4.vcxproj b/lib/liblz4/liblz4.vcxproj new file mode 100644 index 0000000..fc5c241 --- /dev/null +++ b/lib/liblz4/liblz4.vcxproj @@ -0,0 +1,132 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {AB0C3362-63AB-480A-ADBC-2EF7D859778B} + 10.0.16299.0 + + + + StaticLibrary + true + v141 + MultiByte + + + StaticLibrary + false + v141 + true + MultiByte + + + StaticLibrary + true + v141 + MultiByte + + + StaticLibrary + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + ..\liblz4\include; + + + + + Level3 + Disabled + true + true + ..\liblz4\include; + + + + + Level3 + MaxSpeed + true + true + true + true + ..\liblz4\include; + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + ..\liblz4\include; + + + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/liblz4/liblz4.vcxproj.filters b/lib/liblz4/liblz4.vcxproj.filters new file mode 100644 index 0000000..054e80b --- /dev/null +++ b/lib/liblz4/liblz4.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/lib/liblz4/liblz4.vcxproj.user b/lib/liblz4/liblz4.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/lib/liblz4/liblz4.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lib/liblz4/makefile b/lib/liblz4/makefile new file mode 100644 index 0000000..6fac1e6 --- /dev/null +++ b/lib/liblz4/makefile @@ -0,0 +1,43 @@ +# Sources +SRC_DIR = source +OBJS = $(foreach dir,$(SRC_DIR), $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) + +# External dependencies +INCS = -I"include" + + +# Compiler Settings +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value +ARFLAGS = cr -o +ifeq ($(OS),Windows_NT) + # Windows Only Flags/Libs + CC = x86_64-w64-mingw32-gcc + CXX = x86_64-w64-mingw32-g++ + CFLAGS += -Wno-unused-but-set-variable + CXXFLAGS += -Wno-unused-but-set-variable +else + UNAME = $(shell uname -s) + ifeq ($(UNAME), Darwin) + # MacOS Only Flags/Libs + CFLAGS += -arch x86_64 -Wno-unused-private-field + CXXFLAGS += -arch x86_64 -Wno-unused-private-field + ARFLAGS = rc + else + # *nix Only Flags/Libs + CFLAGS += -Wno-unused-but-set-variable + CXXFLAGS += -Wno-unused-but-set-variable + endif +endif + +# Output +OUTPUT = $(shell basename $(CURDIR)).a + +main: build + +rebuild: clean build + +build: $(OBJS) + ar cr -o $(OUTPUT) $(OBJS) + +clean: + rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libcompress/source/lz4/lz4.c b/lib/liblz4/source/lz4.c similarity index 100% rename from lib/libcompress/source/lz4/lz4.c rename to lib/liblz4/source/lz4.c diff --git a/lib/libpki/include/pki/CertificateBody.h b/lib/libpki/include/nn/pki/CertificateBody.h similarity index 100% rename from lib/libpki/include/pki/CertificateBody.h rename to lib/libpki/include/nn/pki/CertificateBody.h diff --git a/lib/libpki/include/pki/SignUtils.h b/lib/libpki/include/nn/pki/SignUtils.h similarity index 100% rename from lib/libpki/include/pki/SignUtils.h rename to lib/libpki/include/nn/pki/SignUtils.h diff --git a/lib/libpki/include/pki/SignatureBlock.h b/lib/libpki/include/nn/pki/SignatureBlock.h similarity index 100% rename from lib/libpki/include/pki/SignatureBlock.h rename to lib/libpki/include/nn/pki/SignatureBlock.h diff --git a/lib/libpki/include/pki/SignedData.h b/lib/libpki/include/nn/pki/SignedData.h similarity index 100% rename from lib/libpki/include/pki/SignedData.h rename to lib/libpki/include/nn/pki/SignedData.h diff --git a/lib/libpki/include/pki/cert.h b/lib/libpki/include/nn/pki/cert.h similarity index 100% rename from lib/libpki/include/pki/cert.h rename to lib/libpki/include/nn/pki/cert.h diff --git a/lib/libpki/include/pki/sign.h b/lib/libpki/include/nn/pki/sign.h similarity index 100% rename from lib/libpki/include/pki/sign.h rename to lib/libpki/include/nn/pki/sign.h diff --git a/lib/libpki/libpki.vcxproj b/lib/libpki/libpki.vcxproj index 7347aca..ef497f5 100644 --- a/lib/libpki/libpki.vcxproj +++ b/lib/libpki/libpki.vcxproj @@ -21,7 +21,6 @@ 15.0 {B9113734-6E84-44FF-8CF7-58199AA815C5} - libpki 10.0.16299.0 @@ -123,12 +122,12 @@ - - - - - - + + + + + + diff --git a/lib/libpki/libpki.vcxproj.filters b/lib/libpki/libpki.vcxproj.filters index ab6f249..2396670 100644 --- a/lib/libpki/libpki.vcxproj.filters +++ b/lib/libpki/libpki.vcxproj.filters @@ -15,22 +15,22 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/aes.h b/lib/libpolarssl/include/polarssl/aes.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/aes.h rename to lib/libpolarssl/include/polarssl/aes.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/base64.h b/lib/libpolarssl/include/polarssl/base64.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/base64.h rename to lib/libpolarssl/include/polarssl/base64.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/bignum.h b/lib/libpolarssl/include/polarssl/bignum.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/bignum.h rename to lib/libpolarssl/include/polarssl/bignum.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/bn_mul.h b/lib/libpolarssl/include/polarssl/bn_mul.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/bn_mul.h rename to lib/libpolarssl/include/polarssl/bn_mul.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/config.h b/lib/libpolarssl/include/polarssl/config.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/config.h rename to lib/libpolarssl/include/polarssl/config.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/md.h b/lib/libpolarssl/include/polarssl/md.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/md.h rename to lib/libpolarssl/include/polarssl/md.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/md_wrap.h b/lib/libpolarssl/include/polarssl/md_wrap.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/md_wrap.h rename to lib/libpolarssl/include/polarssl/md_wrap.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/rsa.h b/lib/libpolarssl/include/polarssl/rsa.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/rsa.h rename to lib/libpolarssl/include/polarssl/rsa.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/sha1.h b/lib/libpolarssl/include/polarssl/sha1.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/sha1.h rename to lib/libpolarssl/include/polarssl/sha1.h diff --git a/lib/libcrypto/source/libpolarssl/include/polarssl/sha2.h b/lib/libpolarssl/include/polarssl/sha2.h similarity index 100% rename from lib/libcrypto/source/libpolarssl/include/polarssl/sha2.h rename to lib/libpolarssl/include/polarssl/sha2.h diff --git a/lib/libpolarssl/libpolarssl.vcxproj b/lib/libpolarssl/libpolarssl.vcxproj new file mode 100644 index 0000000..18336ba --- /dev/null +++ b/lib/libpolarssl/libpolarssl.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} + 10.0.15063.0 + + + + StaticLibrary + true + v141 + MultiByte + + + StaticLibrary + false + v141 + true + MultiByte + + + StaticLibrary + true + v141 + MultiByte + + + StaticLibrary + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + ..\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + Level3 + Disabled + true + ..\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + Level3 + MaxSpeed + true + true + true + ..\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + ..\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/libpolarssl/libpolarssl.vcxproj.filters b/lib/libpolarssl/libpolarssl.vcxproj.filters new file mode 100644 index 0000000..1b4bf96 --- /dev/null +++ b/lib/libpolarssl/libpolarssl.vcxproj.filters @@ -0,0 +1,78 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/lib/libpolarssl/libpolarssl.vcxproj.user b/lib/libpolarssl/libpolarssl.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/lib/libpolarssl/libpolarssl.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lib/libpolarssl/makefile b/lib/libpolarssl/makefile new file mode 100644 index 0000000..6fac1e6 --- /dev/null +++ b/lib/libpolarssl/makefile @@ -0,0 +1,43 @@ +# Sources +SRC_DIR = source +OBJS = $(foreach dir,$(SRC_DIR), $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) + +# External dependencies +INCS = -I"include" + + +# Compiler Settings +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value +ARFLAGS = cr -o +ifeq ($(OS),Windows_NT) + # Windows Only Flags/Libs + CC = x86_64-w64-mingw32-gcc + CXX = x86_64-w64-mingw32-g++ + CFLAGS += -Wno-unused-but-set-variable + CXXFLAGS += -Wno-unused-but-set-variable +else + UNAME = $(shell uname -s) + ifeq ($(UNAME), Darwin) + # MacOS Only Flags/Libs + CFLAGS += -arch x86_64 -Wno-unused-private-field + CXXFLAGS += -arch x86_64 -Wno-unused-private-field + ARFLAGS = rc + else + # *nix Only Flags/Libs + CFLAGS += -Wno-unused-but-set-variable + CXXFLAGS += -Wno-unused-but-set-variable + endif +endif + +# Output +OUTPUT = $(shell basename $(CURDIR)).a + +main: build + +rebuild: clean build + +build: $(OBJS) + ar cr -o $(OUTPUT) $(OBJS) + +clean: + rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libcrypto/source/libpolarssl/source/aes.c b/lib/libpolarssl/source/aes.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/aes.c rename to lib/libpolarssl/source/aes.c diff --git a/lib/libcrypto/source/libpolarssl/source/base64.c b/lib/libpolarssl/source/base64.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/base64.c rename to lib/libpolarssl/source/base64.c diff --git a/lib/libcrypto/source/libpolarssl/source/bignum.c b/lib/libpolarssl/source/bignum.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/bignum.c rename to lib/libpolarssl/source/bignum.c diff --git a/lib/libcrypto/source/libpolarssl/source/md.c b/lib/libpolarssl/source/md.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/md.c rename to lib/libpolarssl/source/md.c diff --git a/lib/libcrypto/source/libpolarssl/source/md_wrap.c b/lib/libpolarssl/source/md_wrap.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/md_wrap.c rename to lib/libpolarssl/source/md_wrap.c diff --git a/lib/libcrypto/source/libpolarssl/source/rsa.c b/lib/libpolarssl/source/rsa.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/rsa.c rename to lib/libpolarssl/source/rsa.c diff --git a/lib/libcrypto/source/libpolarssl/source/sha1.c b/lib/libpolarssl/source/sha1.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/sha1.c rename to lib/libpolarssl/source/sha1.c diff --git a/lib/libcrypto/source/libpolarssl/source/sha2.c b/lib/libpolarssl/source/sha2.c similarity index 100% rename from lib/libcrypto/source/libpolarssl/source/sha2.c rename to lib/libpolarssl/source/sha2.c diff --git a/programs/nstool/nstool.vcxproj b/programs/nstool/nstool.vcxproj index 848e899..d9e7aed 100644 --- a/programs/nstool/nstool.vcxproj +++ b/programs/nstool/nstool.vcxproj @@ -151,22 +151,28 @@ + + {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} + + + {AB0C3362-63AB-480A-ADBC-2EF7D859778B} + {cf01b5b7-730a-447f-9bb2-5eda9b082177} - + {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} - + {7be99936-0d40-410d-944b-4513c2eff8dc} - + {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b} - + {738cb4fc-cd9e-4b81-a04b-deadbfa71c63} - + {91ba9e79-8242-4f7d-b997-0dfec95ea22b} From 909f18a219a4aa574359ae65214ec495dab69f5e Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 13:28:37 +0800 Subject: [PATCH 03/16] Rename .sln to NNTools --- NXTools.sln => NNTools.sln | 0 NXTools.vcxproj => NNTools.vcxproj | 0 NXTools.vcxproj.filters => NNTools.vcxproj.filters | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename NXTools.sln => NNTools.sln (100%) rename NXTools.vcxproj => NNTools.vcxproj (100%) rename NXTools.vcxproj.filters => NNTools.vcxproj.filters (100%) diff --git a/NXTools.sln b/NNTools.sln similarity index 100% rename from NXTools.sln rename to NNTools.sln diff --git a/NXTools.vcxproj b/NNTools.vcxproj similarity index 100% rename from NXTools.vcxproj rename to NNTools.vcxproj diff --git a/NXTools.vcxproj.filters b/NNTools.vcxproj.filters similarity index 100% rename from NXTools.vcxproj.filters rename to NNTools.vcxproj.filters From 02d9a998c3fb0a3b57e090bc0d91741c55c4d56a Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 13:30:52 +0800 Subject: [PATCH 04/16] Update makefiles --- lib/makefile | 2 +- programs/nstool/makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/makefile b/lib/makefile index 7928e45..c39f843 100644 --- a/lib/makefile +++ b/lib/makefile @@ -1,4 +1,4 @@ -LIBS = libfnd libcrypto libcompress libes libpki libnx libnx-hb +LIBS = libfnd libpolarssl liblz4 libcrypto libcompress libes libpki libhac libhac-hb main: build rebuild: clean build diff --git a/programs/nstool/makefile b/programs/nstool/makefile index ddbdcd3..3b5bc7d 100644 --- a/programs/nstool/makefile +++ b/programs/nstool/makefile @@ -3,7 +3,7 @@ SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = nx-hb nx es pki crypto compress fnd +DEPENDS = hac-hb hac es pki crypto compress polarssl lz4 fnd LIB_DIR = ../../lib LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep)) INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") From 2645a174442e7f93f839770580cb33a4ec134e02 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 13:39:55 +0800 Subject: [PATCH 05/16] Update readme --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7d6abae..a24c53d 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,18 @@ Tools & Libraries for Nintendo devices. [![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE) # Tools -* [__nstool__](/programs/nstool/README.md) - General purpose reading/extraction tool for Nintendo Switch file formats. +* [__nstool__](/programs/nstool/README.md) - General purpose read/extract tool for Nintendo Switch file formats. # Libraries -* __libfnd__ - Foundation library. -* __libcrypto__ - Cryptographic functions (AES,SHA,RSA). Wrapper for [mbedTLS](https://github.com/ARMmbed/mbedtls) -* __libcompress__ - Compression algorithms (LZ4). Wrapper for [lz4](https://github.com/lz4/lz4) +* __libfnd__ - Foundation library. Provides file IO, crypto, CLI utils, string conversion, etc. * __libpki__ - Processes Nintendo's proprietary PKI. -* __libes__ - Processes Nintendo's eShop file types. -* __libhac__ - Processes Nintendo Switch file types. -* __libhac-hb__ - Processes Nintendo Switch file types (homebrew extensions). +* __libes__ - Processes Nintendo's eShop file formats. +* __libhac__ - Processes Nintendo Switch file formats. +* __libhac-hb__ - Processes Nintendo Switch file formats (homebrew extensions). + +# Dependencies +* __libpolarssl__ - Cryptographic functions (AES,SHA,RSA). Clone of [polarssl](https://github.com/ARMmbed/mbedtls) (now mbedTLS). +* __liblz4__ - Compression algorithms (LZ4). Clone of [lz4](https://github.com/lz4/lz4). # Building On MacOS/Linux/WSL run `make`. From 2c3753e2bd48379cc2f30d3233b797e687376296 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 13:43:58 +0800 Subject: [PATCH 06/16] Include a note about dependency libraries. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a24c53d..48824a1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Tools & Libraries for Nintendo devices. * __libpolarssl__ - Cryptographic functions (AES,SHA,RSA). Clone of [polarssl](https://github.com/ARMmbed/mbedtls) (now mbedTLS). * __liblz4__ - Compression algorithms (LZ4). Clone of [lz4](https://github.com/lz4/lz4). +(Copies of these are included locally and are statically linked libraries) + # Building On MacOS/Linux/WSL run `make`. From 5b26c370da5c4244955010af2eed5a4faa43e8ac Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 14:00:09 +0800 Subject: [PATCH 07/16] Updated top level makefile to include prog and lib level makefile logic. --- lib/makefile | 10 ---------- makefile | 19 +++++++++++++++---- programs/makefile | 14 -------------- 3 files changed, 15 insertions(+), 28 deletions(-) delete mode 100644 lib/makefile delete mode 100644 programs/makefile diff --git a/lib/makefile b/lib/makefile deleted file mode 100644 index c39f843..0000000 --- a/lib/makefile +++ /dev/null @@ -1,10 +0,0 @@ -LIBS = libfnd libpolarssl liblz4 libcrypto libcompress libes libpki libhac libhac-hb -main: build - -rebuild: clean build - -build: - @$(foreach lib,$(LIBS), cd $(lib) && $(MAKE) && cd ..;) - -clean: - @$(foreach lib,$(LIBS), cd $(lib) && $(MAKE) clean && cd ..;) \ No newline at end of file diff --git a/makefile b/makefile index 2e12b4c..e6acda4 100644 --- a/makefile +++ b/makefile @@ -1,11 +1,22 @@ +PROJECT_DIR = $(CURDIR) +LIB_DIR = $(PROJECT_DIR)/lib +PROGRAM_DIR = $(PROJECT_DIR)/programs +BIN_DIR = $(PROJECT_DIR)/bin + +LIBS = libfnd libpolarssl liblz4 libcrypto libcompress libes libpki libhac libhac-hb +PROGS = nstool + main: build rebuild: clean build build: - cd lib && $(MAKE) && cd .. - cd programs && $(MAKE) && cd .. + mkdir -p $(BIN_DIR) + @$(foreach lib,$(LIBS), cd $(LIB_DIR)/$(lib) && $(MAKE) && cd $(PROJECT_DIR);) + @$(foreach prog,$(PROGS), cd $(PROGRAM_DIR)/$(prog) && $(MAKE) && cd $(PROJECT_DIR) && cp -r $(PROGRAM_DIR)/$(prog)/bin/* $(BIN_DIR);) + clean: - cd lib && $(MAKE) clean && cd .. - cd programs && $(MAKE) clean && cd .. \ No newline at end of file + rm -rf $(BIN_DIR) + @$(foreach lib,$(LIBS), cd $(LIB_DIR)/$(lib) && $(MAKE) clean && cd $(PROJECT_DIR);) + @$(foreach prog,$(PROGS), cd $(PROGRAM_DIR)/$(prog) && $(MAKE) clean && cd $(PROJECT_DIR);) \ No newline at end of file diff --git a/programs/makefile b/programs/makefile deleted file mode 100644 index 533c7af..0000000 --- a/programs/makefile +++ /dev/null @@ -1,14 +0,0 @@ -PROGS = nstool -BIN_DIR = "../bin" - -main: build - -rebuild: clean build - -build: - mkdir -p $(BIN_DIR) - @$(foreach prog,$(PROGS), cd $(prog) && $(MAKE) && cd .. && cp -r $(prog)/bin/* $(BIN_DIR);) - -clean: - @$(foreach prog,$(PROGS), cd $(prog) && $(MAKE) clean && cd ..;) - rm -rf $(BIN_DIR) \ No newline at end of file From 3a4a5b9fb2717e65d4a5a34b821fcc5fc348ed8b Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 14:33:39 +0800 Subject: [PATCH 08/16] Update makefiles --- lib/libcompress/makefile | 1 - lib/libcrypto/makefile | 4 ++-- lib/libes/makefile | 1 - lib/libfnd/makefile | 1 - lib/libhac-hb/makefile | 1 - lib/libhac/makefile | 1 - lib/liblz4/makefile | 8 +++++--- lib/libpki/makefile | 1 - lib/libpolarssl/makefile | 8 +++++--- makefile | 2 +- programs/nstool/makefile | 7 ++++--- 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/libcompress/makefile b/lib/libcompress/makefile index 931617a..3f009cb 100644 --- a/lib/libcompress/makefile +++ b/lib/libcompress/makefile @@ -7,7 +7,6 @@ DEPENDS = lz4 LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/libcrypto/makefile b/lib/libcrypto/makefile index d1bf049..f41f545 100644 --- a/lib/libcrypto/makefile +++ b/lib/libcrypto/makefile @@ -1,15 +1,15 @@ # Sources SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) +OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies DEPENDS = fnd polarssl LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value ARFLAGS = cr -o ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs diff --git a/lib/libes/makefile b/lib/libes/makefile index ba0b6e8..a6d2bf8 100644 --- a/lib/libes/makefile +++ b/lib/libes/makefile @@ -7,7 +7,6 @@ DEPENDS = fnd crypto LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/libfnd/makefile b/lib/libfnd/makefile index a5a2c72..d453126 100644 --- a/lib/libfnd/makefile +++ b/lib/libfnd/makefile @@ -7,7 +7,6 @@ DEPENDS = LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/libhac-hb/makefile b/lib/libhac-hb/makefile index f069c2b..fd763c5 100644 --- a/lib/libhac-hb/makefile +++ b/lib/libhac-hb/makefile @@ -7,7 +7,6 @@ DEPENDS = fnd crypto nx LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/libhac/makefile b/lib/libhac/makefile index ba0b6e8..a6d2bf8 100644 --- a/lib/libhac/makefile +++ b/lib/libhac/makefile @@ -7,7 +7,6 @@ DEPENDS = fnd crypto LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/liblz4/makefile b/lib/liblz4/makefile index 6fac1e6..a29d7be 100644 --- a/lib/liblz4/makefile +++ b/lib/liblz4/makefile @@ -1,12 +1,14 @@ # Sources SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR), $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) +OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -INCS = -I"include" - +DEPENDS = +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") # Compiler Settings +CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value ARFLAGS = cr -o ifeq ($(OS),Windows_NT) diff --git a/lib/libpki/makefile b/lib/libpki/makefile index ba0b6e8..a6d2bf8 100644 --- a/lib/libpki/makefile +++ b/lib/libpki/makefile @@ -7,7 +7,6 @@ DEPENDS = fnd crypto LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value diff --git a/lib/libpolarssl/makefile b/lib/libpolarssl/makefile index 6fac1e6..1507e0e 100644 --- a/lib/libpolarssl/makefile +++ b/lib/libpolarssl/makefile @@ -1,12 +1,14 @@ # Sources SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR), $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) +OBJS = $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -INCS = -I"include" - +DEPENDS = +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") # Compiler Settings +CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value ARFLAGS = cr -o ifeq ($(OS),Windows_NT) diff --git a/makefile b/makefile index e6acda4..3435159 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ LIB_DIR = $(PROJECT_DIR)/lib PROGRAM_DIR = $(PROJECT_DIR)/programs BIN_DIR = $(PROJECT_DIR)/bin -LIBS = libfnd libpolarssl liblz4 libcrypto libcompress libes libpki libhac libhac-hb +LIBS = libpolarssl liblz4 libfnd libcrypto libcompress libes libpki libhac libhac-hb PROGS = nstool main: build diff --git a/programs/nstool/makefile b/programs/nstool/makefile index 3b5bc7d..4359763 100644 --- a/programs/nstool/makefile +++ b/programs/nstool/makefile @@ -8,11 +8,9 @@ LIB_DIR = ../../lib LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep)) INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") -BIN_DIR = bin -OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) - # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs CC = x86_64-w64-mingw32-gcc @@ -35,6 +33,9 @@ else endif endif +BIN_DIR = bin +OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) + all: build rebuild: clean build From 8954dc405f8517b4068bd1584762a403c781441a Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 15:17:51 +0800 Subject: [PATCH 09/16] Fixed links. --- lib/libcompress/source/lz4_wrapper.cpp | 2 +- lib/libes/include/nn/es/SectionHeader_V2.h | 6 +- lib/libes/include/nn/es/TicketBody_V2.h | 7 +- lib/libes/include/nn/es/ticket.h | 3 + lib/libes/source/SectionHeader_V2.cpp | 42 ++-- lib/libes/source/TicketBody_V2.cpp | 86 ++++---- lib/libhac-hb/include/nn/hac/AssetHeader.h | 8 +- lib/libhac-hb/include/nn/hac/aset.h | 9 +- lib/libhac-hb/include/nn/hac/nro-hb.h | 9 +- lib/libhac-hb/makefile | 2 +- lib/libhac-hb/source/AssetHeader.cpp | 36 ++-- .../include/nn/hac/AccessControlInfoBinary.h | 25 +-- .../nn/hac/AccessControlInfoDescBinary.h | 25 +-- lib/libhac/include/nn/hac/AesKeygen.h | 5 +- .../nn/hac/ApplicationControlPropertyBinary.h | 9 +- .../nn/hac/ApplicationControlPropertyUtils.h | 7 +- lib/libhac/include/nn/hac/ContentMetaBinary.h | 26 +-- .../nn/hac/FileSystemAccessControlBinary.h | 10 +- .../include/nn/hac/HandleTableSizeEntry.h | 7 +- .../include/nn/hac/HandleTableSizeHandler.h | 10 +- .../nn/hac/HierarchicalIntegrityHeader.h | 8 +- .../include/nn/hac/HierarchicalSha256Header.h | 8 +- .../include/nn/hac/IKernelCapabilityHandler.h | 8 +- lib/libhac/include/nn/hac/InteruptEntry.h | 8 +- lib/libhac/include/nn/hac/InteruptHandler.h | 10 +- .../include/nn/hac/KernelCapabilityBinary.h | 22 ++- .../include/nn/hac/KernelCapabilityEntry.h | 8 +- .../include/nn/hac/KernelVersionEntry.h | 8 +- .../include/nn/hac/KernelVersionHandler.h | 10 +- .../include/nn/hac/MemoryMappingHandler.h | 8 +- lib/libhac/include/nn/hac/MemoryPageEntry.h | 8 +- lib/libhac/include/nn/hac/MiscFlagsEntry.h | 8 +- lib/libhac/include/nn/hac/MiscFlagsHandler.h | 10 +- lib/libhac/include/nn/hac/MiscParamsEntry.h | 9 +- lib/libhac/include/nn/hac/MiscParamsHandler.h | 10 +- lib/libhac/include/nn/hac/NcaHeader.h | 8 +- lib/libhac/include/nn/hac/NcaUtils.h | 11 +- lib/libhac/include/nn/hac/NpdmBinary.h | 13 +- lib/libhac/include/nn/hac/NroHeader.h | 8 +- lib/libhac/include/nn/hac/NsoHeader.h | 8 +- lib/libhac/include/nn/hac/PfsHeader.h | 9 +- .../nn/hac/ServiceAccessControlBinary.h | 8 +- .../nn/hac/ServiceAccessControlEntry.h | 5 +- lib/libhac/include/nn/hac/SystemCallEntry.h | 8 +- lib/libhac/include/nn/hac/SystemCallHandler.h | 8 +- lib/libhac/include/nn/hac/ThreadInfoEntry.h | 7 +- lib/libhac/include/nn/hac/ThreadInfoHandler.h | 10 +- lib/libhac/include/nn/hac/XciHeader.h | 8 +- lib/libhac/include/nn/hac/XciUtils.h | 9 +- lib/libhac/include/nn/hac/aci.h | 7 +- lib/libhac/include/nn/hac/cnmt.h | 5 +- lib/libhac/include/nn/hac/elf.h | 5 +- lib/libhac/include/nn/hac/fac.h | 5 +- .../include/nn/hac/hierarchicalintegrity.h | 7 +- .../include/nn/hac/hierarchicalsha256.h | 5 +- lib/libhac/include/nn/hac/kc.h | 7 +- lib/libhac/include/nn/hac/nacp.h | 5 +- lib/libhac/include/nn/hac/nca.h | 9 +- lib/libhac/include/nn/hac/npdm.h | 7 +- lib/libhac/include/nn/hac/nro.h | 7 +- lib/libhac/include/nn/hac/nrr.h | 7 +- lib/libhac/include/nn/hac/nso.h | 7 +- lib/libhac/include/nn/hac/pfs.h | 7 +- lib/libhac/include/nn/hac/romfs.h | 5 +- lib/libhac/include/nn/hac/xci.h | 7 +- lib/libhac/source/AccessControlInfoBinary.cpp | 36 ++-- .../source/AccessControlInfoDescBinary.cpp | 48 ++--- lib/libhac/source/AesKeygen.cpp | 8 +- .../ApplicationControlPropertyBinary.cpp | 182 ++++++++--------- .../ApplicationControlPropertyUtils.cpp | 6 +- lib/libhac/source/ContentMetaBinary.cpp | 78 ++++---- .../source/FileSystemAccessControlBinary.cpp | 36 ++-- lib/libhac/source/HandleTableSizeEntry.cpp | 22 +-- lib/libhac/source/HandleTableSizeHandler.cpp | 22 +-- .../source/HierarchicalIntegrityHeader.cpp | 40 ++-- .../source/HierarchicalSha256Header.cpp | 40 ++-- lib/libhac/source/InteruptEntry.cpp | 24 +-- lib/libhac/source/InteruptHandler.cpp | 22 +-- lib/libhac/source/KernelCapabilityBinary.cpp | 52 ++--- lib/libhac/source/KernelCapabilityEntry.cpp | 26 +-- lib/libhac/source/KernelVersionEntry.cpp | 26 +-- lib/libhac/source/KernelVersionHandler.cpp | 26 +-- lib/libhac/source/MemoryMappingHandler.cpp | 24 +-- lib/libhac/source/MemoryPageEntry.cpp | 32 +-- lib/libhac/source/MiscFlagsEntry.cpp | 22 +-- lib/libhac/source/MiscFlagsHandler.cpp | 22 +-- lib/libhac/source/MiscParamsEntry.cpp | 22 +-- lib/libhac/source/MiscParamsHandler.cpp | 22 +-- lib/libhac/source/NcaHeader.cpp | 74 +++---- lib/libhac/source/NcaUtils.cpp | 18 +- lib/libhac/source/NpdmBinary.cpp | 60 +++--- lib/libhac/source/NroHeader.cpp | 64 +++--- lib/libhac/source/NsoHeader.cpp | 60 +++--- lib/libhac/source/PfsHeader.cpp | 34 ++-- .../source/ServiceAccessControlBinary.cpp | 24 +-- .../source/ServiceAccessControlEntry.cpp | 30 +-- lib/libhac/source/SystemCallEntry.cpp | 26 +-- lib/libhac/source/SystemCallHandler.cpp | 24 +-- lib/libhac/source/ThreadInfoEntry.cpp | 34 ++-- lib/libhac/source/ThreadInfoHandler.cpp | 34 ++-- lib/libhac/source/XciHeader.cpp | 138 ++++++------- lib/libhac/source/XciUtils.cpp | 12 +- lib/liblz4/makefile | 2 +- lib/libpki/include/nn/pki/CertificateBody.h | 5 +- lib/libpki/include/nn/pki/SignUtils.h | 9 +- lib/libpki/include/nn/pki/SignatureBlock.h | 5 +- lib/libpki/include/nn/pki/SignedData.h | 4 +- lib/libpki/include/nn/pki/cert.h | 3 + lib/libpki/include/nn/pki/sign.h | 3 + lib/libpki/makefile | 5 +- lib/libpki/source/CertificateBody.cpp | 48 ++--- lib/libpki/source/SignUtils.cpp | 30 +-- lib/libpki/source/SignatureBlock.cpp | 32 +-- lib/libpolarssl/makefile | 2 +- programs/nstool/source/AssetProcess.cpp | 4 +- programs/nstool/source/AssetProcess.h | 4 +- programs/nstool/source/CnmtProcess.cpp | 26 +-- programs/nstool/source/CnmtProcess.h | 6 +- programs/nstool/source/ElfSymbolParser.cpp | 18 +- programs/nstool/source/ElfSymbolParser.h | 8 +- programs/nstool/source/EsTikProcess.cpp | 2 +- programs/nstool/source/EsTikProcess.h | 6 +- programs/nstool/source/HashTreeMeta.cpp | 8 +- programs/nstool/source/HashTreeMeta.h | 8 +- programs/nstool/source/NacpProcess.cpp | 170 ++++++++-------- programs/nstool/source/NacpProcess.h | 6 +- programs/nstool/source/NcaProcess.cpp | 186 +++++++++--------- programs/nstool/source/NcaProcess.h | 16 +- programs/nstool/source/NpdmProcess.cpp | 30 +-- programs/nstool/source/NpdmProcess.h | 22 +-- programs/nstool/source/NroProcess.cpp | 16 +- programs/nstool/source/NroProcess.h | 8 +- programs/nstool/source/NsoProcess.cpp | 8 +- programs/nstool/source/NsoProcess.h | 10 +- programs/nstool/source/PfsProcess.cpp | 26 +-- programs/nstool/source/PfsProcess.h | 10 +- programs/nstool/source/PkiCertProcess.cpp | 2 +- programs/nstool/source/PkiCertProcess.h | 4 +- programs/nstool/source/PkiValidator.cpp | 2 +- programs/nstool/source/PkiValidator.h | 4 +- programs/nstool/source/RoMetadataProcess.cpp | 58 +++--- programs/nstool/source/RoMetadataProcess.h | 12 +- programs/nstool/source/RomfsProcess.cpp | 30 +-- programs/nstool/source/RomfsProcess.h | 10 +- programs/nstool/source/UserSettings.cpp | 114 +++++------ programs/nstool/source/UserSettings.h | 12 +- programs/nstool/source/XciProcess.cpp | 42 ++-- programs/nstool/source/XciProcess.h | 6 +- programs/nstool/source/main.cpp | 8 +- programs/nstool/source/nstool.h | 4 +- 150 files changed, 1690 insertions(+), 1533 deletions(-) diff --git a/lib/libcompress/source/lz4_wrapper.cpp b/lib/libcompress/source/lz4_wrapper.cpp index aa340d2..68b773c 100644 --- a/lib/libcompress/source/lz4_wrapper.cpp +++ b/lib/libcompress/source/lz4_wrapper.cpp @@ -1,5 +1,5 @@ #include -#include "lz4/lz4.h" +#include void compress::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size) { diff --git a/lib/libes/include/nn/es/SectionHeader_V2.h b/lib/libes/include/nn/es/SectionHeader_V2.h index 35b1083..eb7558b 100644 --- a/lib/libes/include/nn/es/SectionHeader_V2.h +++ b/lib/libes/include/nn/es/SectionHeader_V2.h @@ -1,8 +1,10 @@ #pragma once #include #include -#include +#include +namespace nn +{ namespace es { class SectionHeader_V2 : @@ -52,5 +54,5 @@ namespace es uint16_t mRecordNum; ticket::SectionType mSectionType; }; - } +} \ No newline at end of file diff --git a/lib/libes/include/nn/es/TicketBody_V2.h b/lib/libes/include/nn/es/TicketBody_V2.h index 4741cac..6c7150a 100644 --- a/lib/libes/include/nn/es/TicketBody_V2.h +++ b/lib/libes/include/nn/es/TicketBody_V2.h @@ -2,8 +2,10 @@ #include #include #include -#include +#include +namespace nn +{ namespace es { class TicketBody_V2 : @@ -98,5 +100,4 @@ namespace es uint16_t mSectEntrySize; }; } - - +} \ No newline at end of file diff --git a/lib/libes/include/nn/es/ticket.h b/lib/libes/include/nn/es/ticket.h index 689ecce..ffb483b 100644 --- a/lib/libes/include/nn/es/ticket.h +++ b/lib/libes/include/nn/es/ticket.h @@ -3,6 +3,8 @@ #include #include +namespace nn +{ namespace es { namespace ticket @@ -105,4 +107,5 @@ namespace es inline uint16_t get_group(uint16_t index) const { return index & kGroupMask; } }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libes/source/SectionHeader_V2.cpp b/lib/libes/source/SectionHeader_V2.cpp index 2fd18ac..ae5ad04 100644 --- a/lib/libes/source/SectionHeader_V2.cpp +++ b/lib/libes/source/SectionHeader_V2.cpp @@ -1,16 +1,14 @@ -#include +#include - - -es::SectionHeader_V2::SectionHeader_V2() +nn::es::SectionHeader_V2::SectionHeader_V2() {} -es::SectionHeader_V2::SectionHeader_V2(const SectionHeader_V2 & other) +nn::es::SectionHeader_V2::SectionHeader_V2(const SectionHeader_V2 & other) { *this = other; } -void es::SectionHeader_V2::operator=(const SectionHeader_V2 & other) +void nn::es::SectionHeader_V2::operator=(const SectionHeader_V2 & other) { if (other.getBytes().size()) { @@ -27,7 +25,7 @@ void es::SectionHeader_V2::operator=(const SectionHeader_V2 & other) } } -bool es::SectionHeader_V2::operator==(const SectionHeader_V2 & other) const +bool nn::es::SectionHeader_V2::operator==(const SectionHeader_V2 & other) const { return (mSectionOffset == other.mSectionOffset) \ && (mRecordSize == other.mRecordSize) \ @@ -36,12 +34,12 @@ bool es::SectionHeader_V2::operator==(const SectionHeader_V2 & other) const && (mSectionType == other.mSectionType); } -bool es::SectionHeader_V2::operator!=(const SectionHeader_V2 & other) const +bool nn::es::SectionHeader_V2::operator!=(const SectionHeader_V2 & other) const { return !(*this ==other); } -void es::SectionHeader_V2::toBytes() +void nn::es::SectionHeader_V2::toBytes() { mRawBinary.alloc(sizeof(sSectionHeader_v2)); sSectionHeader_v2* hdr = (sSectionHeader_v2*)mRawBinary.data(); @@ -53,7 +51,7 @@ void es::SectionHeader_V2::toBytes() hdr->section_type = (mSectionType); } -void es::SectionHeader_V2::fromBytes(const byte_t * bytes, size_t len) +void nn::es::SectionHeader_V2::fromBytes(const byte_t * bytes, size_t len) { if (len < sizeof(sSectionHeader_v2)) { @@ -73,12 +71,12 @@ void es::SectionHeader_V2::fromBytes(const byte_t * bytes, size_t len) mSectionType = (ticket::SectionType)hdr->section_type.get(); } -const fnd::Vec& es::SectionHeader_V2::getBytes() const +const fnd::Vec& nn::es::SectionHeader_V2::getBytes() const { return mRawBinary; } -void es::SectionHeader_V2::clear() +void nn::es::SectionHeader_V2::clear() { mRawBinary.clear(); mSectionOffset = 0; @@ -88,52 +86,52 @@ void es::SectionHeader_V2::clear() mSectionType = ticket::SECTION_PERMANENT; } -uint32_t es::SectionHeader_V2::getSectionOffset() const +uint32_t nn::es::SectionHeader_V2::getSectionOffset() const { return mSectionOffset; } -void es::SectionHeader_V2::setSectionOffset(uint32_t offset) +void nn::es::SectionHeader_V2::setSectionOffset(uint32_t offset) { mSectionOffset = offset; } -uint32_t es::SectionHeader_V2::getRecordSize() const +uint32_t nn::es::SectionHeader_V2::getRecordSize() const { return mRecordSize; } -void es::SectionHeader_V2::setRecordSize(uint32_t size) +void nn::es::SectionHeader_V2::setRecordSize(uint32_t size) { mRecordSize = size; } -uint32_t es::SectionHeader_V2::getSectionSize() const +uint32_t nn::es::SectionHeader_V2::getSectionSize() const { return mSectionSize; } -void es::SectionHeader_V2::getSectionSize(uint32_t size) +void nn::es::SectionHeader_V2::getSectionSize(uint32_t size) { mSectionSize = size; } -uint16_t es::SectionHeader_V2::getRecordNum() const +uint16_t nn::es::SectionHeader_V2::getRecordNum() const { return mRecordNum; } -void es::SectionHeader_V2::setRecordNum(uint16_t record_num) +void nn::es::SectionHeader_V2::setRecordNum(uint16_t record_num) { mRecordNum = record_num; } -es::ticket::SectionType es::SectionHeader_V2::getSectionType() const +nn::es::ticket::SectionType nn::es::SectionHeader_V2::getSectionType() const { return mSectionType; } -void es::SectionHeader_V2::setSectionType(ticket::SectionType type) +void nn::es::SectionHeader_V2::setSectionType(ticket::SectionType type) { mSectionType = type; } diff --git a/lib/libes/source/TicketBody_V2.cpp b/lib/libes/source/TicketBody_V2.cpp index 93816c7..1a5302d 100644 --- a/lib/libes/source/TicketBody_V2.cpp +++ b/lib/libes/source/TicketBody_V2.cpp @@ -1,18 +1,16 @@ -#include +#include - - -es::TicketBody_V2::TicketBody_V2() +nn::es::TicketBody_V2::TicketBody_V2() { clear(); } -es::TicketBody_V2::TicketBody_V2(const TicketBody_V2 & other) +nn::es::TicketBody_V2::TicketBody_V2(const TicketBody_V2 & other) { *this = other; } -void es::TicketBody_V2::operator=(const TicketBody_V2 & other) +void nn::es::TicketBody_V2::operator=(const TicketBody_V2 & other) { if (other.getBytes().size()) { @@ -40,7 +38,7 @@ void es::TicketBody_V2::operator=(const TicketBody_V2 & other) } } -bool es::TicketBody_V2::operator==(const TicketBody_V2 & other) const +bool nn::es::TicketBody_V2::operator==(const TicketBody_V2 & other) const { return (mIssuer == other.mIssuer) \ && (memcmp(mEncTitleKey, other.mEncTitleKey, ticket::kEncTitleKeySize) == 0) \ @@ -59,12 +57,12 @@ bool es::TicketBody_V2::operator==(const TicketBody_V2 & other) const && (mSectEntrySize == other.mSectEntrySize); } -bool es::TicketBody_V2::operator!=(const TicketBody_V2 & other) const +bool nn::es::TicketBody_V2::operator!=(const TicketBody_V2 & other) const { return !(*this == other); } -void es::TicketBody_V2::toBytes() +void nn::es::TicketBody_V2::toBytes() { mRawBinary.alloc(sizeof(sTicketBody_v2)); sTicketBody_v2* body = (sTicketBody_v2*)mRawBinary.data(); @@ -94,7 +92,7 @@ void es::TicketBody_V2::toBytes() body->sect_entry_size = (mSectEntrySize); } -void es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len) +void nn::es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len) { if (len < sizeof(sTicketBody_v2)) { @@ -134,12 +132,12 @@ void es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len) mSectEntrySize = body->sect_entry_size.get(); } -const fnd::Vec& es::TicketBody_V2::getBytes() const +const fnd::Vec& nn::es::TicketBody_V2::getBytes() const { return mRawBinary; } -void es::TicketBody_V2::clear() +void nn::es::TicketBody_V2::clear() { mRawBinary.clear(); mIssuer.clear(); @@ -160,12 +158,12 @@ void es::TicketBody_V2::clear() mSectEntrySize = 0; } -const std::string & es::TicketBody_V2::getIssuer() const +const std::string & nn::es::TicketBody_V2::getIssuer() const { return mIssuer; } -void es::TicketBody_V2::setIssuer(const std::string & issuer) +void nn::es::TicketBody_V2::setIssuer(const std::string & issuer) { if (issuer.length() > ticket::kIssuerSize) { @@ -175,154 +173,154 @@ void es::TicketBody_V2::setIssuer(const std::string & issuer) mIssuer = issuer; } -const byte_t * es::TicketBody_V2::getEncTitleKey() const +const byte_t * nn::es::TicketBody_V2::getEncTitleKey() const { return mEncTitleKey; } -void es::TicketBody_V2::setEncTitleKey(const byte_t * data, size_t len) +void nn::es::TicketBody_V2::setEncTitleKey(const byte_t * data, size_t len) { memset(mEncTitleKey, 0, ticket::kEncTitleKeySize); memcpy(mEncTitleKey, data, _MIN(len, ticket::kEncTitleKeySize)); } -es::ticket::TitleKeyEncType es::TicketBody_V2::getTitleKeyEncType() const +nn::es::ticket::TitleKeyEncType nn::es::TicketBody_V2::getTitleKeyEncType() const { return mEncType; } -void es::TicketBody_V2::setTitleKeyEncType(ticket::TitleKeyEncType type) +void nn::es::TicketBody_V2::setTitleKeyEncType(ticket::TitleKeyEncType type) { mEncType = type; } -uint16_t es::TicketBody_V2::getTicketVersion() const +uint16_t nn::es::TicketBody_V2::getTicketVersion() const { return mTicketVersion; } -void es::TicketBody_V2::setTicketVersion(uint16_t version) +void nn::es::TicketBody_V2::setTicketVersion(uint16_t version) { mTicketVersion = version; } -es::ticket::LicenseType es::TicketBody_V2::getLicenseType() const +nn::es::ticket::LicenseType nn::es::TicketBody_V2::getLicenseType() const { return mLicenseType; } -void es::TicketBody_V2::setLicenseType(ticket::LicenseType type) +void nn::es::TicketBody_V2::setLicenseType(ticket::LicenseType type) { mLicenseType = type; } -byte_t es::TicketBody_V2::getCommonKeyId() const +byte_t nn::es::TicketBody_V2::getCommonKeyId() const { return mCommonKeyId; } -void es::TicketBody_V2::setCommonKeyId(byte_t id) +void nn::es::TicketBody_V2::setCommonKeyId(byte_t id) { mCommonKeyId = id; } -const fnd::List& es::TicketBody_V2::getPropertyFlags() const +const fnd::List& nn::es::TicketBody_V2::getPropertyFlags() const { return mPropertyFlags; } -void es::TicketBody_V2::setPropertyFlags(const fnd::List& flags) +void nn::es::TicketBody_V2::setPropertyFlags(const fnd::List& flags) { mPropertyFlags = flags; } -const byte_t * es::TicketBody_V2::getReservedRegion() const +const byte_t * nn::es::TicketBody_V2::getReservedRegion() const { return mReservedRegion; } -void es::TicketBody_V2::setReservedRegion(const byte_t * data, size_t len) +void nn::es::TicketBody_V2::setReservedRegion(const byte_t * data, size_t len) { memset(mReservedRegion, 0, ticket::kReservedRegionSize); memcpy(mReservedRegion, data, _MIN(len, ticket::kReservedRegionSize)); } -uint64_t es::TicketBody_V2::getTicketId() const +uint64_t nn::es::TicketBody_V2::getTicketId() const { return mTicketId; } -void es::TicketBody_V2::setTicketId(uint64_t id) +void nn::es::TicketBody_V2::setTicketId(uint64_t id) { mTicketId = id; } -uint64_t es::TicketBody_V2::getDeviceId() const +uint64_t nn::es::TicketBody_V2::getDeviceId() const { return mDeviceId; } -void es::TicketBody_V2::setDeviceId(uint64_t id) +void nn::es::TicketBody_V2::setDeviceId(uint64_t id) { mDeviceId = id; } -const byte_t * es::TicketBody_V2::getRightsId() const +const byte_t * nn::es::TicketBody_V2::getRightsId() const { return mRightsId; } -void es::TicketBody_V2::setRightsId(const byte_t * id) +void nn::es::TicketBody_V2::setRightsId(const byte_t * id) { memcpy(mRightsId, id, ticket::kRightsIdSize); } -uint32_t es::TicketBody_V2::getAccountId() const +uint32_t nn::es::TicketBody_V2::getAccountId() const { return mAccountId; } -void es::TicketBody_V2::setAccountId(uint32_t id) +void nn::es::TicketBody_V2::setAccountId(uint32_t id) { mAccountId = id; } -uint32_t es::TicketBody_V2::getSectionTotalSize() const +uint32_t nn::es::TicketBody_V2::getSectionTotalSize() const { return mSectTotalSize; } -void es::TicketBody_V2::setSectionTotalSize(uint32_t size) +void nn::es::TicketBody_V2::setSectionTotalSize(uint32_t size) { mSectTotalSize = size; } -uint32_t es::TicketBody_V2::getSectionHeaderOffset() const +uint32_t nn::es::TicketBody_V2::getSectionHeaderOffset() const { return mSectHeaderOffset; } -void es::TicketBody_V2::setSectionHeaderOffset(uint32_t offset) +void nn::es::TicketBody_V2::setSectionHeaderOffset(uint32_t offset) { mSectHeaderOffset = offset; } -uint16_t es::TicketBody_V2::getSectionNum() const +uint16_t nn::es::TicketBody_V2::getSectionNum() const { return mSectNum; } -void es::TicketBody_V2::setSectionNum(uint16_t num) +void nn::es::TicketBody_V2::setSectionNum(uint16_t num) { mSectNum = num; } -uint16_t es::TicketBody_V2::getSectionEntrySize() const +uint16_t nn::es::TicketBody_V2::getSectionEntrySize() const { return mSectEntrySize; } -void es::TicketBody_V2::setSectionEntrySize(uint16_t size) +void nn::es::TicketBody_V2::setSectionEntrySize(uint16_t size) { mSectEntrySize = size; } \ No newline at end of file diff --git a/lib/libhac-hb/include/nn/hac/AssetHeader.h b/lib/libhac-hb/include/nn/hac/AssetHeader.h index 61deecb..bbef068 100644 --- a/lib/libhac-hb/include/nn/hac/AssetHeader.h +++ b/lib/libhac-hb/include/nn/hac/AssetHeader.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class AssetHeader : public fnd::ISerialisable @@ -66,5 +68,5 @@ namespace nx sSection mNacpInfo; sSection mRomfsInfo; }; - +} } \ No newline at end of file diff --git a/lib/libhac-hb/include/nn/hac/aset.h b/lib/libhac-hb/include/nn/hac/aset.h index 9e821cb..f7c1bfd 100644 --- a/lib/libhac-hb/include/nn/hac/aset.h +++ b/lib/libhac-hb/include/nn/hac/aset.h @@ -1,8 +1,10 @@ #pragma once - #include -#include -namespace nx +#include + +namespace nn +{ +namespace hac { namespace aset { @@ -27,4 +29,5 @@ namespace nx sAssetSection romfs; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac-hb/include/nn/hac/nro-hb.h b/lib/libhac-hb/include/nn/hac/nro-hb.h index 5e5bd05..a1dcc67 100644 --- a/lib/libhac-hb/include/nn/hac/nro-hb.h +++ b/lib/libhac-hb/include/nn/hac/nro-hb.h @@ -1,11 +1,14 @@ #pragma once +#include +#include -#include -#include -namespace nx +namespace nn +{ +namespace hac { namespace nro { static const uint64_t kNroHomebrewStructMagic = _MAKE_STRUCT_MAGIC_U64("HOMEBREW"); } +} } \ No newline at end of file diff --git a/lib/libhac-hb/makefile b/lib/libhac-hb/makefile index fd763c5..c91b3df 100644 --- a/lib/libhac-hb/makefile +++ b/lib/libhac-hb/makefile @@ -3,7 +3,7 @@ SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = fnd crypto nx +DEPENDS = fnd crypto hac LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") diff --git a/lib/libhac-hb/source/AssetHeader.cpp b/lib/libhac-hb/source/AssetHeader.cpp index 0f8eebb..aab6fe4 100644 --- a/lib/libhac-hb/source/AssetHeader.cpp +++ b/lib/libhac-hb/source/AssetHeader.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::AssetHeader::AssetHeader() +nn::hac::AssetHeader::AssetHeader() { clear(); } -nx::AssetHeader::AssetHeader(const AssetHeader& other) +nn::hac::AssetHeader::AssetHeader(const AssetHeader& other) { *this = other; } -void nx::AssetHeader::operator=(const AssetHeader& other) +void nn::hac::AssetHeader::operator=(const AssetHeader& other) { mRawBinary = other.mRawBinary; mIconInfo = other.mIconInfo; @@ -18,22 +18,22 @@ void nx::AssetHeader::operator=(const AssetHeader& other) mRomfsInfo = other.mRomfsInfo; } -bool nx::AssetHeader::operator==(const AssetHeader& other) const +bool nn::hac::AssetHeader::operator==(const AssetHeader& other) const { return (mIconInfo == other.mIconInfo) \ && (mNacpInfo == other.mNacpInfo) \ && (mRomfsInfo == other.mRomfsInfo); } -bool nx::AssetHeader::operator!=(const AssetHeader& other) const +bool nn::hac::AssetHeader::operator!=(const AssetHeader& other) const { return !(*this == other); } -void nx::AssetHeader::toBytes() +void nn::hac::AssetHeader::toBytes() { mRawBinary.alloc(sizeof(sAssetHeader)); - nx::sAssetHeader* hdr = (nx::sAssetHeader*)mRawBinary.data(); + nn::hac::sAssetHeader* hdr = (nn::hac::sAssetHeader*)mRawBinary.data(); // set header identifers hdr->st_magic = aset::kAssetStructMagic; @@ -52,7 +52,7 @@ void nx::AssetHeader::toBytes() hdr->romfs.size = mRomfsInfo.size; } -void nx::AssetHeader::fromBytes(const byte_t* bytes, size_t len) +void nn::hac::AssetHeader::fromBytes(const byte_t* bytes, size_t len) { // check input data size if (len < sizeof(sAssetHeader)) @@ -68,7 +68,7 @@ void nx::AssetHeader::fromBytes(const byte_t* bytes, size_t len) memcpy(mRawBinary.data(), bytes, mRawBinary.size()); // get sAssetHeader ptr - const nx::sAssetHeader* hdr = (const nx::sAssetHeader*)mRawBinary.data(); + const nn::hac::sAssetHeader* hdr = (const nn::hac::sAssetHeader*)mRawBinary.data(); // check NRO signature if (hdr->st_magic.get() != aset::kAssetStructMagic) @@ -90,12 +90,12 @@ void nx::AssetHeader::fromBytes(const byte_t* bytes, size_t len) mRomfsInfo.size = hdr->romfs.size.get(); } -const fnd::Vec& nx::AssetHeader::getBytes() const +const fnd::Vec& nn::hac::AssetHeader::getBytes() const { return mRawBinary; } -void nx::AssetHeader::clear() +void nn::hac::AssetHeader::clear() { mRawBinary.clear(); memset(&mIconInfo, 0, sizeof(mIconInfo)); @@ -103,32 +103,32 @@ void nx::AssetHeader::clear() memset(&mRomfsInfo, 0, sizeof(mRomfsInfo)); } -const nx::AssetHeader::sSection& nx::AssetHeader::getIconInfo() const +const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getIconInfo() const { return mIconInfo; } -void nx::AssetHeader::setIconInfo(const nx::AssetHeader::sSection& info) +void nn::hac::AssetHeader::setIconInfo(const nn::hac::AssetHeader::sSection& info) { mIconInfo = info; } -const nx::AssetHeader::sSection& nx::AssetHeader::getNacpInfo() const +const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getNacpInfo() const { return mNacpInfo; } -void nx::AssetHeader::setNacpInfo(const sSection& info) +void nn::hac::AssetHeader::setNacpInfo(const sSection& info) { mNacpInfo = info; } -const nx::AssetHeader::sSection& nx::AssetHeader::getRomfsInfo() const +const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getRomfsInfo() const { return mRomfsInfo; } -void nx::AssetHeader::setRomfsInfo(const sSection& info) +void nn::hac::AssetHeader::setRomfsInfo(const sSection& info) { mRomfsInfo = info; } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/AccessControlInfoBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoBinary.h index f16cc20..3fa1763 100644 --- a/lib/libhac/include/nn/hac/AccessControlInfoBinary.h +++ b/lib/libhac/include/nn/hac/AccessControlInfoBinary.h @@ -2,12 +2,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class AccessControlInfoBinary : public fnd::ISerialisable { @@ -30,13 +32,13 @@ namespace nx uint64_t getProgramId() const; void setProgramId(uint64_t program_id); - const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const; + const nn::hac::FileSystemAccessControlBinary& getFileSystemAccessControl() const; void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac); - const nx::ServiceAccessControlBinary& getServiceAccessControl() const; + const nn::hac::ServiceAccessControlBinary& getServiceAccessControl() const; void setServiceAccessControl(const ServiceAccessControlBinary& sac); - const nx::KernelCapabilityBinary& getKernelCapabilities() const; + const nn::hac::KernelCapabilityBinary& getKernelCapabilities() const; void setKernelCapabilities(const KernelCapabilityBinary& kc); private: const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY"; @@ -46,8 +48,9 @@ namespace nx // variables uint64_t mProgramId; - nx::FileSystemAccessControlBinary mFileSystemAccessControl; - nx::ServiceAccessControlBinary mServiceAccessControl; - nx::KernelCapabilityBinary mKernelCapabilities; + nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl; + nn::hac::ServiceAccessControlBinary mServiceAccessControl; + nn::hac::KernelCapabilityBinary mKernelCapabilities; }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h index 53519a8..f42b195 100644 --- a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h +++ b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h @@ -3,12 +3,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class AccessControlInfoDescBinary : public fnd::ISerialisable { @@ -63,13 +65,13 @@ namespace nx const sProgramIdRestrict& getProgramIdRestrict() const; void setProgramIdRestrict(const sProgramIdRestrict& pid_restrict); - const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const; + const nn::hac::FileSystemAccessControlBinary& getFileSystemAccessControl() const; void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac); - const nx::ServiceAccessControlBinary& getServiceAccessControl() const; + const nn::hac::ServiceAccessControlBinary& getServiceAccessControl() const; void setServiceAccessControl(const ServiceAccessControlBinary& sac); - const nx::KernelCapabilityBinary& getKernelCapabilities() const; + const nn::hac::KernelCapabilityBinary& getKernelCapabilities() const; void setKernelCapabilities(const KernelCapabilityBinary& kc); private: const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY"; @@ -81,8 +83,9 @@ namespace nx crypto::rsa::sRsa2048Key mNcaHeaderSignature2Key; fnd::List mFlags; sProgramIdRestrict mProgramIdRestrict; - nx::FileSystemAccessControlBinary mFileSystemAccessControl; - nx::ServiceAccessControlBinary mServiceAccessControl; - nx::KernelCapabilityBinary mKernelCapabilities; + nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl; + nn::hac::ServiceAccessControlBinary mServiceAccessControl; + nn::hac::KernelCapabilityBinary mKernelCapabilities; }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/AesKeygen.h b/lib/libhac/include/nn/hac/AesKeygen.h index 64333a0..8d30eba 100644 --- a/lib/libhac/include/nn/hac/AesKeygen.h +++ b/lib/libhac/include/nn/hac/AesKeygen.h @@ -3,7 +3,9 @@ #include #include -namespace nx +namespace nn +{ +namespace hac { class AesKeygen { @@ -16,4 +18,5 @@ namespace nx // 3 stage key generation dst = ((src1_key.decrypt(src1)).decrypt(src2)).decrypt(src3) static void generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key); }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h b/lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h index ae28816..af69e42 100644 --- a/lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h +++ b/lib/libhac/include/nn/hac/ApplicationControlPropertyBinary.h @@ -3,9 +3,11 @@ #include #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class ApplicationControlPropertyBinary : public fnd::ISerialisable @@ -229,7 +231,7 @@ namespace nx nacp::TouchScreenUsageMode mTouchScreenUsageMode; nacp::AocRegistrationType mAocRegistrationType; nacp::AttributeFlag mAttributeFlag; - fnd::List mSupportedLanguages; + fnd::List mSupportedLanguages; nacp::ParentalControlFlag mParentalControlFlag; nacp::ScreenshotMode mScreenshotMode; nacp::VideoCaptureMode mVideoCaptureMode; @@ -263,4 +265,5 @@ namespace nx nacp::RepairFlag mRepairFlag; byte_t mProgramIndex; }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h b/lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h index e6be804..9955de3 100644 --- a/lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h +++ b/lib/libhac/include/nn/hac/ApplicationControlPropertyUtils.h @@ -1,7 +1,9 @@ #pragma once -#include +#include -namespace nx +namespace nn +{ +namespace hac { class ApplicationControlPropertyUtils { @@ -9,4 +11,5 @@ namespace nx static bool validateSaveDataSizeMax(int64_t size, int64_t alignment); static bool validateSaveDataSize(int64_t size); }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/ContentMetaBinary.h b/lib/libhac/include/nn/hac/ContentMetaBinary.h index 59eee5d..2b44913 100644 --- a/lib/libhac/include/nn/hac/ContentMetaBinary.h +++ b/lib/libhac/include/nn/hac/ContentMetaBinary.h @@ -2,10 +2,11 @@ #include #include #include -#include +#include - -namespace nx +namespace nn +{ +namespace hac { class ContentMetaBinary : public fnd::ISerialisable @@ -200,17 +201,17 @@ namespace nx const DeltaMetaExtendedHeader& getDeltaMetaExtendedHeader() const; void setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr); - const fnd::List& getContentInfo() const; - void setContentInfo(const fnd::List& info); + const fnd::List& getContentInfo() const; + void setContentInfo(const fnd::List& info); - const fnd::List& getContentMetaInfo() const; - void setContentMetaInfo(const fnd::List& info); + const fnd::List& getContentMetaInfo() const; + void setContentMetaInfo(const fnd::List& info); const fnd::Vec& getExtendedData() const; void setExtendedData(const fnd::Vec& data); - const nx::sDigest& getDigest() const; - void setDigest(const nx::sDigest& digest); + const nn::hac::sDigest& getDigest() const; + void setDigest(const nn::hac::sDigest& digest); private: @@ -232,10 +233,10 @@ namespace nx AddOnContentMetaExtendedHeader mAddOnContentMetaExtendedHeader; DeltaMetaExtendedHeader mDeltaMetaExtendedHeader; - fnd::List mContentInfo; - fnd::List mContentMetaInfo; + fnd::List mContentInfo; + fnd::List mContentMetaInfo; fnd::Vec mExtendedData; - nx::sDigest mDigest; + nn::hac::sDigest mDigest; inline size_t getExtendedHeaderOffset() const { return sizeof(sContentMetaHeader); } inline size_t getContentInfoOffset(size_t exhdrSize) const { return getExtendedHeaderOffset() + exhdrSize; } @@ -248,4 +249,5 @@ namespace nx size_t getExtendedDataSize(cnmt::ContentMetaType type, const byte_t* data) const; void validateBinary(const byte_t* bytes, size_t len) const; }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h b/lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h index 90d6663..dbf898a 100644 --- a/lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h +++ b/lib/libhac/include/nn/hac/FileSystemAccessControlBinary.h @@ -3,17 +3,18 @@ #include #include #include -#include +#include - -namespace nx +namespace nn +{ +namespace hac { class FileSystemAccessControlBinary : public fnd::ISerialisable { public: struct sSaveDataOwnerId { - nx::fac::SaveDataOwnerIdAccessType access_type; + nn::hac::fac::SaveDataOwnerIdAccessType access_type; uint64_t id; void operator=(const sSaveDataOwnerId& other) @@ -72,4 +73,5 @@ namespace nx fnd::List mContentOwnerIdList; fnd::List mSaveDataOwnerIdList; }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/HandleTableSizeEntry.h b/lib/libhac/include/nn/hac/HandleTableSizeEntry.h index 18c92e8..5ef89df 100644 --- a/lib/libhac/include/nn/hac/HandleTableSizeEntry.h +++ b/lib/libhac/include/nn/hac/HandleTableSizeEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class HandleTableSizeEntry { @@ -44,4 +46,5 @@ namespace nx mHandleTableSize = field & kMaxHandleTableSize; } }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/HandleTableSizeHandler.h b/lib/libhac/include/nn/hac/HandleTableSizeHandler.h index 3094df8..200036d 100644 --- a/lib/libhac/include/nn/hac/HandleTableSizeHandler.h +++ b/lib/libhac/include/nn/hac/HandleTableSizeHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class HandleTableSizeHandler : public IKernelCapabilityHandler @@ -32,4 +34,4 @@ namespace nx HandleTableSizeEntry mEntry; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h index b0d0945..e8c9a3a 100644 --- a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h +++ b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h @@ -1,10 +1,12 @@ #pragma once -#include +#include #include #include #include -namespace nx +namespace nn +{ +namespace hac { class HierarchicalIntegrityHeader : public fnd::ISerialisable @@ -64,5 +66,5 @@ namespace nx fnd::List mLayerInfo; fnd::List mMasterHashList; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h index 4082916..eea54be 100644 --- a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h +++ b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class HierarchicalSha256Header : public fnd::ISerialisable @@ -65,5 +67,5 @@ namespace nx size_t mHashBlockSize; fnd::List mLayerInfo; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/IKernelCapabilityHandler.h b/lib/libhac/include/nn/hac/IKernelCapabilityHandler.h index ad117c4..7437465 100644 --- a/lib/libhac/include/nn/hac/IKernelCapabilityHandler.h +++ b/lib/libhac/include/nn/hac/IKernelCapabilityHandler.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class IKernelCapabilityHandler { @@ -14,4 +16,4 @@ namespace nx virtual bool isSet() const = 0; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/InteruptEntry.h b/lib/libhac/include/nn/hac/InteruptEntry.h index 7633281..9998fb6 100644 --- a/lib/libhac/include/nn/hac/InteruptEntry.h +++ b/lib/libhac/include/nn/hac/InteruptEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class InteruptEntry { @@ -52,5 +54,5 @@ namespace nx mInterupt[1] = (field >> kInteruptBits) & kInteruptMax; } }; - +} } diff --git a/lib/libhac/include/nn/hac/InteruptHandler.h b/lib/libhac/include/nn/hac/InteruptHandler.h index 529886f..156b992 100644 --- a/lib/libhac/include/nn/hac/InteruptHandler.h +++ b/lib/libhac/include/nn/hac/InteruptHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class InteruptHandler : public IKernelCapabilityHandler @@ -31,4 +33,4 @@ namespace nx fnd::List mInterupts; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/KernelCapabilityBinary.h b/lib/libhac/include/nn/hac/KernelCapabilityBinary.h index d5369a3..72869c3 100644 --- a/lib/libhac/include/nn/hac/KernelCapabilityBinary.h +++ b/lib/libhac/include/nn/hac/KernelCapabilityBinary.h @@ -3,16 +3,18 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class KernelCapabilityBinary : public fnd::ISerialisable @@ -73,4 +75,4 @@ namespace nx MiscFlagsHandler mMiscFlags; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/KernelCapabilityEntry.h b/lib/libhac/include/nn/hac/KernelCapabilityEntry.h index 9be2761..e8711e3 100644 --- a/lib/libhac/include/nn/hac/KernelCapabilityEntry.h +++ b/lib/libhac/include/nn/hac/KernelCapabilityEntry.h @@ -1,8 +1,10 @@ #pragma once #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class KernelCapabilityEntry { @@ -47,4 +49,4 @@ namespace nx } }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/KernelVersionEntry.h b/lib/libhac/include/nn/hac/KernelVersionEntry.h index d0b339b..ed52714 100644 --- a/lib/libhac/include/nn/hac/KernelVersionEntry.h +++ b/lib/libhac/include/nn/hac/KernelVersionEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class KernelVersionEntry { @@ -53,4 +55,4 @@ namespace nx } }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/KernelVersionHandler.h b/lib/libhac/include/nn/hac/KernelVersionHandler.h index be9cc2e..fe43226 100644 --- a/lib/libhac/include/nn/hac/KernelVersionHandler.h +++ b/lib/libhac/include/nn/hac/KernelVersionHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class KernelVersionHandler : public IKernelCapabilityHandler @@ -34,4 +36,4 @@ namespace nx KernelVersionEntry mEntry; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MemoryMappingHandler.h b/lib/libhac/include/nn/hac/MemoryMappingHandler.h index 9b5e0d4..d4d73d7 100644 --- a/lib/libhac/include/nn/hac/MemoryMappingHandler.h +++ b/lib/libhac/include/nn/hac/MemoryMappingHandler.h @@ -1,7 +1,9 @@ #pragma once -#include +#include -namespace nx +namespace nn +{ +namespace hac { class MemoryMappingHandler : public IKernelCapabilityHandler @@ -75,4 +77,4 @@ namespace nx fnd::List mMemPage; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MemoryPageEntry.h b/lib/libhac/include/nn/hac/MemoryPageEntry.h index 9fc4536..368b233 100644 --- a/lib/libhac/include/nn/hac/MemoryPageEntry.h +++ b/lib/libhac/include/nn/hac/MemoryPageEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class MemoryPageEntry { @@ -56,5 +58,5 @@ namespace nx mUseFlag = mCap.getType() == kc::KC_MEMORY_MAP; } }; - } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MiscFlagsEntry.h b/lib/libhac/include/nn/hac/MiscFlagsEntry.h index 34167e0..359589c 100644 --- a/lib/libhac/include/nn/hac/MiscFlagsEntry.h +++ b/lib/libhac/include/nn/hac/MiscFlagsEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class MiscFlagsEntry { @@ -44,5 +46,5 @@ namespace nx mFlags = field & kMaxVal; } }; - } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MiscFlagsHandler.h b/lib/libhac/include/nn/hac/MiscFlagsHandler.h index 41d3bf9..8351120 100644 --- a/lib/libhac/include/nn/hac/MiscFlagsHandler.h +++ b/lib/libhac/include/nn/hac/MiscFlagsHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class MiscFlagsHandler : public IKernelCapabilityHandler @@ -51,5 +53,5 @@ namespace nx bool mIsSet; fnd::List mFlags; }; - } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MiscParamsEntry.h b/lib/libhac/include/nn/hac/MiscParamsEntry.h index 04b5cc0..0925d16 100644 --- a/lib/libhac/include/nn/hac/MiscParamsEntry.h +++ b/lib/libhac/include/nn/hac/MiscParamsEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class MiscParamsEntry { @@ -44,6 +46,5 @@ namespace nx mProgramType = field & kMaxProgramType; } }; - - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/MiscParamsHandler.h b/lib/libhac/include/nn/hac/MiscParamsHandler.h index b88b522..063a22c 100644 --- a/lib/libhac/include/nn/hac/MiscParamsHandler.h +++ b/lib/libhac/include/nn/hac/MiscParamsHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class MiscParamsHandler : public IKernelCapabilityHandler @@ -32,4 +34,4 @@ namespace nx MiscParamsEntry mEntry; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/NcaHeader.h b/lib/libhac/include/nn/hac/NcaHeader.h index 6a2f1fe..f08ed53 100644 --- a/lib/libhac/include/nn/hac/NcaHeader.h +++ b/lib/libhac/include/nn/hac/NcaHeader.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class NcaHeader : public fnd::ISerialisable @@ -112,5 +114,5 @@ namespace nx uint64_t blockNumToSize(uint32_t block_num) const; uint32_t sizeToBlockNum(uint64_t real_size) const; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/NcaUtils.h b/lib/libhac/include/nn/hac/NcaUtils.h index 50365b4..b3b14a6 100644 --- a/lib/libhac/include/nn/hac/NcaUtils.h +++ b/lib/libhac/include/nn/hac/NcaUtils.h @@ -1,14 +1,17 @@ #pragma once -#include +#include -namespace nx +namespace nn +{ +namespace hac { class NcaUtils { public: - static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nx::nca::kSectorSize; } + static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; } static void decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key); static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation); - static void getNcaPartitionAesCtr(const nx::sNcaFsHeader* hdr, byte_t* ctr); + static void getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr); }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/NpdmBinary.h b/lib/libhac/include/nn/hac/NpdmBinary.h index c64f2d8..24d16e0 100644 --- a/lib/libhac/include/nn/hac/NpdmBinary.h +++ b/lib/libhac/include/nn/hac/NpdmBinary.h @@ -2,12 +2,13 @@ #include #include #include -#include -#include -#include +#include +#include +#include - -namespace nx +namespace nn +{ +namespace hac { class NpdmBinary : public fnd::ISerialisable @@ -75,5 +76,5 @@ namespace nx AccessControlInfoBinary mAci; AccessControlInfoDescBinary mAcid; }; - } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/NroHeader.h b/lib/libhac/include/nn/hac/NroHeader.h index cb1dc95..840563a 100644 --- a/lib/libhac/include/nn/hac/NroHeader.h +++ b/lib/libhac/include/nn/hac/NroHeader.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class NroHeader : public fnd::ISerialisable @@ -134,5 +136,5 @@ namespace nx sSection mRoDynStrInfo; sSection mRoDynSymInfo; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/NsoHeader.h b/lib/libhac/include/nn/hac/NsoHeader.h index cd65fde..1593c7e 100644 --- a/lib/libhac/include/nn/hac/NsoHeader.h +++ b/lib/libhac/include/nn/hac/NsoHeader.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class NsoHeader : public fnd::ISerialisable @@ -142,5 +144,5 @@ namespace nx sLayout mRoDynStrInfo; sLayout mRoDynSymInfo; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/PfsHeader.h b/lib/libhac/include/nn/hac/PfsHeader.h index 2c5ed37..4eab512 100644 --- a/lib/libhac/include/nn/hac/PfsHeader.h +++ b/lib/libhac/include/nn/hac/PfsHeader.h @@ -3,10 +3,11 @@ #include #include #include -#include +#include - -namespace nx +namespace nn +{ +namespace hac { class PfsHeader : public fnd::ISerialisable @@ -99,4 +100,4 @@ namespace nx void calculateOffsets(size_t data_offset); }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/ServiceAccessControlBinary.h b/lib/libhac/include/nn/hac/ServiceAccessControlBinary.h index 3066e5f..8c63d9c 100644 --- a/lib/libhac/include/nn/hac/ServiceAccessControlBinary.h +++ b/lib/libhac/include/nn/hac/ServiceAccessControlBinary.h @@ -3,9 +3,11 @@ #include #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class ServiceAccessControlBinary : public fnd::ISerialisable @@ -36,5 +38,5 @@ namespace nx // variables fnd::List mServices; }; - +} } diff --git a/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h b/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h index 71a6587..cfd999b 100644 --- a/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h +++ b/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h @@ -3,7 +3,9 @@ #include #include -namespace nx +namespace nn +{ +namespace hac { class ServiceAccessControlEntry : public fnd::ISerialisable @@ -48,4 +50,5 @@ namespace nx bool isEqual(const ServiceAccessControlEntry& other) const; void copyFrom(const ServiceAccessControlEntry& other); }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/SystemCallEntry.h b/lib/libhac/include/nn/hac/SystemCallEntry.h index 1a1ca64..3eb0b0a 100644 --- a/lib/libhac/include/nn/hac/SystemCallEntry.h +++ b/lib/libhac/include/nn/hac/SystemCallEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class SystemCallEntry { @@ -54,4 +56,4 @@ namespace nx } }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/SystemCallHandler.h b/lib/libhac/include/nn/hac/SystemCallHandler.h index 35ac45a..d726d7c 100644 --- a/lib/libhac/include/nn/hac/SystemCallHandler.h +++ b/lib/libhac/include/nn/hac/SystemCallHandler.h @@ -1,7 +1,9 @@ #pragma once -#include +#include -namespace nx +namespace nn +{ +namespace hac { class SystemCallHandler : public IKernelCapabilityHandler @@ -32,5 +34,5 @@ namespace nx bool mIsSet; fnd::List mSystemCalls; }; - +} } diff --git a/lib/libhac/include/nn/hac/ThreadInfoEntry.h b/lib/libhac/include/nn/hac/ThreadInfoEntry.h index ff0e062..07a3e93 100644 --- a/lib/libhac/include/nn/hac/ThreadInfoEntry.h +++ b/lib/libhac/include/nn/hac/ThreadInfoEntry.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { class ThreadInfoEntry { @@ -64,3 +66,4 @@ namespace nx } }; } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/ThreadInfoHandler.h b/lib/libhac/include/nn/hac/ThreadInfoHandler.h index d2fd01c..f7301f6 100644 --- a/lib/libhac/include/nn/hac/ThreadInfoHandler.h +++ b/lib/libhac/include/nn/hac/ThreadInfoHandler.h @@ -1,8 +1,10 @@ #pragma once -#include -#include +#include +#include -namespace nx +namespace nn +{ +namespace hac { class ThreadInfoHandler : public IKernelCapabilityHandler @@ -38,4 +40,4 @@ namespace nx ThreadInfoEntry mEntry; }; } - +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/XciHeader.h b/lib/libhac/include/nn/hac/XciHeader.h index bbbf2cd..89ff730 100644 --- a/lib/libhac/include/nn/hac/XciHeader.h +++ b/lib/libhac/include/nn/hac/XciHeader.h @@ -1,9 +1,11 @@ #pragma once -#include +#include #include #include -namespace nx +namespace nn +{ +namespace hac { class XciHeader : public fnd::ISerialisable @@ -121,5 +123,5 @@ namespace nx byte_t mUppHash[8]; uint64_t mUppId; }; - +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/XciUtils.h b/lib/libhac/include/nn/hac/XciUtils.h index 0482bb1..7ba7eaa 100644 --- a/lib/libhac/include/nn/hac/XciUtils.h +++ b/lib/libhac/include/nn/hac/XciUtils.h @@ -1,13 +1,16 @@ #pragma once -#include +#include -namespace nx +namespace nn +{ +namespace hac { class XciUtils { public: static inline uint64_t blockToAddr(uint32_t block) { return ((uint64_t)block) << 9; } - static void getXciHeaderAesIv(const nx::sXciHeader* hdr, byte_t* iv); + static void getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t* iv); static void decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key); }; +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/aci.h b/lib/libhac/include/nn/hac/aci.h index b2755e5..e426469 100644 --- a/lib/libhac/include/nn/hac/aci.h +++ b/lib/libhac/include/nn/hac/aci.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace aci { @@ -50,4 +52,5 @@ namespace nx sAciSection kc; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/cnmt.h b/lib/libhac/include/nn/hac/cnmt.h index 10d972c..ededd0b 100644 --- a/lib/libhac/include/nn/hac/cnmt.h +++ b/lib/libhac/include/nn/hac/cnmt.h @@ -2,7 +2,9 @@ #include #include -namespace nx +namespace nn +{ +namespace hac { namespace cnmt { @@ -132,4 +134,5 @@ namespace nx byte_t data[cnmt::kDigestLen]; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/elf.h b/lib/libhac/include/nn/hac/elf.h index 00356d6..2083238 100644 --- a/lib/libhac/include/nn/hac/elf.h +++ b/lib/libhac/include/nn/hac/elf.h @@ -1,7 +1,9 @@ #pragma once #include -namespace nx +namespace nn +{ +namespace hac { namespace elf { @@ -64,4 +66,5 @@ namespace nx le_uint64_t size; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/fac.h b/lib/libhac/include/nn/hac/fac.h index 7707353..1b1714e 100644 --- a/lib/libhac/include/nn/hac/fac.h +++ b/lib/libhac/include/nn/hac/fac.h @@ -1,7 +1,9 @@ #pragma once #include -namespace nx +namespace nn +{ +namespace hac { namespace fac { @@ -54,4 +56,5 @@ namespace nx } content_owner_ids, save_data_owner_ids; // the data for these follow later in binary. start/end relative to base of FacData instance }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/hierarchicalintegrity.h b/lib/libhac/include/nn/hac/hierarchicalintegrity.h index 4c16d0d..e662ee2 100644 --- a/lib/libhac/include/nn/hac/hierarchicalintegrity.h +++ b/lib/libhac/include/nn/hac/hierarchicalintegrity.h @@ -1,8 +1,10 @@ #pragma once #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace hierarchicalintegrity { @@ -30,3 +32,4 @@ namespace nx }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/hierarchicalsha256.h b/lib/libhac/include/nn/hac/hierarchicalsha256.h index 5b78c66..e392c8c 100644 --- a/lib/libhac/include/nn/hac/hierarchicalsha256.h +++ b/lib/libhac/include/nn/hac/hierarchicalsha256.h @@ -2,7 +2,9 @@ #include #include -namespace nx +namespace nn +{ +namespace hac { namespace hierarchicalsha256 { @@ -24,3 +26,4 @@ namespace nx }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/kc.h b/lib/libhac/include/nn/hac/kc.h index 192c6de..e4f5949 100644 --- a/lib/libhac/include/nn/hac/kc.h +++ b/lib/libhac/include/nn/hac/kc.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace kc { @@ -21,4 +23,5 @@ namespace nx KC_MISC_FLAGS = 16 }; } +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/nacp.h b/lib/libhac/include/nn/hac/nacp.h index bbb7019..61de162 100644 --- a/lib/libhac/include/nn/hac/nacp.h +++ b/lib/libhac/include/nn/hac/nacp.h @@ -1,7 +1,9 @@ #pragma once #include -namespace nx +namespace nn +{ +namespace hac { namespace nacp { @@ -217,4 +219,5 @@ namespace nx byte_t reserved_04[0xDED]; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/nca.h b/lib/libhac/include/nn/hac/nca.h index e49e4a4..3a3207c 100644 --- a/lib/libhac/include/nn/hac/nca.h +++ b/lib/libhac/include/nn/hac/nca.h @@ -3,9 +3,11 @@ #include #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace nca { @@ -127,8 +129,9 @@ namespace nx byte_t signature_main[crypto::rsa::kRsa2048Size]; byte_t signature_acid[crypto::rsa::kRsa2048Size]; sNcaHeader header; - sNcaFsHeader fs_header[nx::nca::kPartitionNum]; + sNcaFsHeader fs_header[nn::hac::nca::kPartitionNum]; }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/npdm.h b/lib/libhac/include/nn/hac/npdm.h index b508ba8..dbcda23 100644 --- a/lib/libhac/include/nn/hac/npdm.h +++ b/lib/libhac/include/nn/hac/npdm.h @@ -1,8 +1,10 @@ #pragma once #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace npdm { @@ -51,4 +53,5 @@ namespace nx }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/nro.h b/lib/libhac/include/nn/hac/nro.h index c145e64..e46b316 100644 --- a/lib/libhac/include/nn/hac/nro.h +++ b/lib/libhac/include/nn/hac/nro.h @@ -1,8 +1,10 @@ #pragma once #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace nro { @@ -40,3 +42,4 @@ namespace nx }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/nrr.h b/lib/libhac/include/nn/hac/nrr.h index 3931ad1..eae5180 100644 --- a/lib/libhac/include/nn/hac/nrr.h +++ b/lib/libhac/include/nn/hac/nrr.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace nrr { @@ -34,3 +36,4 @@ namespace nx }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/nso.h b/lib/libhac/include/nn/hac/nso.h index d40c925..4223b37 100644 --- a/lib/libhac/include/nn/hac/nso.h +++ b/lib/libhac/include/nn/hac/nso.h @@ -1,9 +1,11 @@ #pragma once #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace nso { @@ -63,3 +65,4 @@ namespace nx #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/pfs.h b/lib/libhac/include/nn/hac/pfs.h index 9b1fde1..18f4e5c 100644 --- a/lib/libhac/include/nn/hac/pfs.h +++ b/lib/libhac/include/nn/hac/pfs.h @@ -1,8 +1,10 @@ #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace pfs { @@ -39,3 +41,4 @@ namespace nx }; // sizeof(0x40) #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/romfs.h b/lib/libhac/include/nn/hac/romfs.h index 1756425..73d376d 100644 --- a/lib/libhac/include/nn/hac/romfs.h +++ b/lib/libhac/include/nn/hac/romfs.h @@ -1,7 +1,9 @@ #pragma once #include -namespace nx +namespace nn +{ +namespace hac { namespace romfs { @@ -55,3 +57,4 @@ namespace nx }; #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/xci.h b/lib/libhac/include/nn/hac/xci.h index b7b0797..79be4d9 100644 --- a/lib/libhac/include/nn/hac/xci.h +++ b/lib/libhac/include/nn/hac/xci.h @@ -4,9 +4,11 @@ #include #include #include -#include +#include -namespace nx +namespace nn +{ +namespace hac { namespace xci { @@ -128,3 +130,4 @@ namespace nx #pragma pack(pop) } +} \ No newline at end of file diff --git a/lib/libhac/source/AccessControlInfoBinary.cpp b/lib/libhac/source/AccessControlInfoBinary.cpp index 6c31f74..cdf5a50 100644 --- a/lib/libhac/source/AccessControlInfoBinary.cpp +++ b/lib/libhac/source/AccessControlInfoBinary.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::AccessControlInfoBinary::AccessControlInfoBinary() +nn::hac::AccessControlInfoBinary::AccessControlInfoBinary() { clear(); } -nx::AccessControlInfoBinary::AccessControlInfoBinary(const AccessControlInfoBinary & other) +nn::hac::AccessControlInfoBinary::AccessControlInfoBinary(const AccessControlInfoBinary & other) { *this = other; } -void nx::AccessControlInfoBinary::operator=(const AccessControlInfoBinary & other) +void nn::hac::AccessControlInfoBinary::operator=(const AccessControlInfoBinary & other) { mRawBinary = other.mRawBinary; mProgramId = other.mProgramId; @@ -19,7 +19,7 @@ void nx::AccessControlInfoBinary::operator=(const AccessControlInfoBinary & othe mKernelCapabilities = other.mKernelCapabilities; } -bool nx::AccessControlInfoBinary::operator==(const AccessControlInfoBinary & other) const +bool nn::hac::AccessControlInfoBinary::operator==(const AccessControlInfoBinary & other) const { return (mProgramId == other.mProgramId) \ && (mFileSystemAccessControl == other.mFileSystemAccessControl) \ @@ -27,12 +27,12 @@ bool nx::AccessControlInfoBinary::operator==(const AccessControlInfoBinary & oth && (mKernelCapabilities == other.mKernelCapabilities); } -bool nx::AccessControlInfoBinary::operator!=(const AccessControlInfoBinary & other) const +bool nn::hac::AccessControlInfoBinary::operator!=(const AccessControlInfoBinary & other) const { return !(*this == other); } -void nx::AccessControlInfoBinary::toBytes() +void nn::hac::AccessControlInfoBinary::toBytes() { if (mFileSystemAccessControl.getBytes().size() == 0) mFileSystemAccessControl.toBytes(); @@ -76,7 +76,7 @@ void nx::AccessControlInfoBinary::toBytes() hdr->kc.size = kc.size; } -void nx::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len) { // check size if (len < sizeof(sAciHeader)) @@ -117,12 +117,12 @@ void nx::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len) mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get()); } -const fnd::Vec& nx::AccessControlInfoBinary::getBytes() const +const fnd::Vec& nn::hac::AccessControlInfoBinary::getBytes() const { return mRawBinary; } -void nx::AccessControlInfoBinary::clear() +void nn::hac::AccessControlInfoBinary::clear() { mRawBinary.clear(); mProgramId = 0; @@ -131,42 +131,42 @@ void nx::AccessControlInfoBinary::clear() mKernelCapabilities.clear(); } -uint64_t nx::AccessControlInfoBinary::getProgramId() const +uint64_t nn::hac::AccessControlInfoBinary::getProgramId() const { return mProgramId; } -void nx::AccessControlInfoBinary::setProgramId(uint64_t program_id) +void nn::hac::AccessControlInfoBinary::setProgramId(uint64_t program_id) { mProgramId = program_id; } -const nx::FileSystemAccessControlBinary& nx::AccessControlInfoBinary::getFileSystemAccessControl() const +const nn::hac::FileSystemAccessControlBinary& nn::hac::AccessControlInfoBinary::getFileSystemAccessControl() const { return mFileSystemAccessControl; } -void nx::AccessControlInfoBinary::setFileSystemAccessControl(const nx::FileSystemAccessControlBinary& fac) +void nn::hac::AccessControlInfoBinary::setFileSystemAccessControl(const nn::hac::FileSystemAccessControlBinary& fac) { mFileSystemAccessControl = fac; } -const nx::ServiceAccessControlBinary& nx::AccessControlInfoBinary::getServiceAccessControl() const +const nn::hac::ServiceAccessControlBinary& nn::hac::AccessControlInfoBinary::getServiceAccessControl() const { return mServiceAccessControl; } -void nx::AccessControlInfoBinary::setServiceAccessControl(const nx::ServiceAccessControlBinary& sac) +void nn::hac::AccessControlInfoBinary::setServiceAccessControl(const nn::hac::ServiceAccessControlBinary& sac) { mServiceAccessControl = sac; } -const nx::KernelCapabilityBinary& nx::AccessControlInfoBinary::getKernelCapabilities() const +const nn::hac::KernelCapabilityBinary& nn::hac::AccessControlInfoBinary::getKernelCapabilities() const { return mKernelCapabilities; } -void nx::AccessControlInfoBinary::setKernelCapabilities(const nx::KernelCapabilityBinary& kc) +void nn::hac::AccessControlInfoBinary::setKernelCapabilities(const nn::hac::KernelCapabilityBinary& kc) { mKernelCapabilities = kc; } \ No newline at end of file diff --git a/lib/libhac/source/AccessControlInfoDescBinary.cpp b/lib/libhac/source/AccessControlInfoDescBinary.cpp index a351f0b..d7c24d4 100644 --- a/lib/libhac/source/AccessControlInfoDescBinary.cpp +++ b/lib/libhac/source/AccessControlInfoDescBinary.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::AccessControlInfoDescBinary::AccessControlInfoDescBinary() +nn::hac::AccessControlInfoDescBinary::AccessControlInfoDescBinary() { clear(); } -nx::AccessControlInfoDescBinary::AccessControlInfoDescBinary(const AccessControlInfoDescBinary & other) +nn::hac::AccessControlInfoDescBinary::AccessControlInfoDescBinary(const AccessControlInfoDescBinary & other) { *this = other; } -void nx::AccessControlInfoDescBinary::operator=(const AccessControlInfoDescBinary & other) +void nn::hac::AccessControlInfoDescBinary::operator=(const AccessControlInfoDescBinary & other) { mRawBinary = other.mRawBinary; mNcaHeaderSignature2Key = other.mNcaHeaderSignature2Key; @@ -21,7 +21,7 @@ void nx::AccessControlInfoDescBinary::operator=(const AccessControlInfoDescBinar mKernelCapabilities = other.mKernelCapabilities; } -bool nx::AccessControlInfoDescBinary::operator==(const AccessControlInfoDescBinary & other) const +bool nn::hac::AccessControlInfoDescBinary::operator==(const AccessControlInfoDescBinary & other) const { return (mNcaHeaderSignature2Key == other.mNcaHeaderSignature2Key) \ && (mFlags == other.mFlags) \ @@ -31,12 +31,12 @@ bool nx::AccessControlInfoDescBinary::operator==(const AccessControlInfoDescBina && (mKernelCapabilities == other.mKernelCapabilities); } -bool nx::AccessControlInfoDescBinary::operator!=(const AccessControlInfoDescBinary & other) const +bool nn::hac::AccessControlInfoDescBinary::operator!=(const AccessControlInfoDescBinary & other) const { return !(*this == other); } -void nx::AccessControlInfoDescBinary::toBytes() +void nn::hac::AccessControlInfoDescBinary::toBytes() { if (mFileSystemAccessControl.getBytes().size() == 0) mFileSystemAccessControl.toBytes(); @@ -93,7 +93,7 @@ void nx::AccessControlInfoDescBinary::toBytes() hdr->kc.size = kc.size; } -void nx::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len) { // check size if (len < sizeof(sAciDescHeader)) @@ -144,12 +144,12 @@ void nx::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len) mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get()); } -const fnd::Vec& nx::AccessControlInfoDescBinary::getBytes() const +const fnd::Vec& nn::hac::AccessControlInfoDescBinary::getBytes() const { return mRawBinary; } -void nx::AccessControlInfoDescBinary::generateSignature(const crypto::rsa::sRsa2048Key& key) +void nn::hac::AccessControlInfoDescBinary::generateSignature(const crypto::rsa::sRsa2048Key& key) { if (mRawBinary.size() == 0) toBytes(); @@ -163,7 +163,7 @@ void nx::AccessControlInfoDescBinary::generateSignature(const crypto::rsa::sRsa2 } } -void nx::AccessControlInfoDescBinary::validateSignature(const crypto::rsa::sRsa2048Key& key) const +void nn::hac::AccessControlInfoDescBinary::validateSignature(const crypto::rsa::sRsa2048Key& key) const { if (mRawBinary.size() == 0) throw fnd::Exception(kModuleName, "No Access Control Info Desc binary exists to verify"); @@ -177,7 +177,7 @@ void nx::AccessControlInfoDescBinary::validateSignature(const crypto::rsa::sRsa2 } } -void nx::AccessControlInfoDescBinary::clear() +void nn::hac::AccessControlInfoDescBinary::clear() { mRawBinary.clear(); memset((void*)&mNcaHeaderSignature2Key, 0, sizeof(mNcaHeaderSignature2Key)); @@ -189,62 +189,62 @@ void nx::AccessControlInfoDescBinary::clear() mKernelCapabilities.clear(); } -const crypto::rsa::sRsa2048Key& nx::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const +const crypto::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const { return mNcaHeaderSignature2Key; } -void nx::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key) +void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key) { mNcaHeaderSignature2Key = key; } -const fnd::List& nx::AccessControlInfoDescBinary::getFlagList() const +const fnd::List& nn::hac::AccessControlInfoDescBinary::getFlagList() const { return mFlags; } -void nx::AccessControlInfoDescBinary::setFlagList(const fnd::List& flags) +void nn::hac::AccessControlInfoDescBinary::setFlagList(const fnd::List& flags) { mFlags = flags; } -const nx::AccessControlInfoDescBinary::sProgramIdRestrict& nx::AccessControlInfoDescBinary::getProgramIdRestrict() const +const nn::hac::AccessControlInfoDescBinary::sProgramIdRestrict& nn::hac::AccessControlInfoDescBinary::getProgramIdRestrict() const { return mProgramIdRestrict; } -void nx::AccessControlInfoDescBinary::setProgramIdRestrict(const sProgramIdRestrict& pid_restrict) +void nn::hac::AccessControlInfoDescBinary::setProgramIdRestrict(const sProgramIdRestrict& pid_restrict) { mProgramIdRestrict = pid_restrict; } -const nx::FileSystemAccessControlBinary& nx::AccessControlInfoDescBinary::getFileSystemAccessControl() const +const nn::hac::FileSystemAccessControlBinary& nn::hac::AccessControlInfoDescBinary::getFileSystemAccessControl() const { return mFileSystemAccessControl; } -void nx::AccessControlInfoDescBinary::setFileSystemAccessControl(const nx::FileSystemAccessControlBinary& fac) +void nn::hac::AccessControlInfoDescBinary::setFileSystemAccessControl(const nn::hac::FileSystemAccessControlBinary& fac) { mFileSystemAccessControl = fac; } -const nx::ServiceAccessControlBinary& nx::AccessControlInfoDescBinary::getServiceAccessControl() const +const nn::hac::ServiceAccessControlBinary& nn::hac::AccessControlInfoDescBinary::getServiceAccessControl() const { return mServiceAccessControl; } -void nx::AccessControlInfoDescBinary::setServiceAccessControl(const nx::ServiceAccessControlBinary& sac) +void nn::hac::AccessControlInfoDescBinary::setServiceAccessControl(const nn::hac::ServiceAccessControlBinary& sac) { mServiceAccessControl = sac; } -const nx::KernelCapabilityBinary& nx::AccessControlInfoDescBinary::getKernelCapabilities() const +const nn::hac::KernelCapabilityBinary& nn::hac::AccessControlInfoDescBinary::getKernelCapabilities() const { return mKernelCapabilities; } -void nx::AccessControlInfoDescBinary::setKernelCapabilities(const nx::KernelCapabilityBinary& kc) +void nn::hac::AccessControlInfoDescBinary::setKernelCapabilities(const nn::hac::KernelCapabilityBinary& kc) { mKernelCapabilities = kc; } \ No newline at end of file diff --git a/lib/libhac/source/AesKeygen.cpp b/lib/libhac/source/AesKeygen.cpp index 804c3c6..7233394 100644 --- a/lib/libhac/source/AesKeygen.cpp +++ b/lib/libhac/source/AesKeygen.cpp @@ -1,17 +1,17 @@ -#include +#include -void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key) +void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key) { crypto::aes::AesEcbDecrypt(src, sizeof(crypto::aes::sAes128Key), src_key, dst); } -void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key) +void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key) { crypto::aes::sAes128Key src2_key; generateKey(src2_key.key, src1, src1_key); generateKey(dst, src2, src2_key.key); } -void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key) +void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key) { crypto::aes::sAes128Key src3_key; generateKey(src3_key.key, src1, src2, src1_key); diff --git a/lib/libhac/source/ApplicationControlPropertyBinary.cpp b/lib/libhac/source/ApplicationControlPropertyBinary.cpp index a6ca675..14f9125 100644 --- a/lib/libhac/source/ApplicationControlPropertyBinary.cpp +++ b/lib/libhac/source/ApplicationControlPropertyBinary.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::ApplicationControlPropertyBinary::ApplicationControlPropertyBinary() +nn::hac::ApplicationControlPropertyBinary::ApplicationControlPropertyBinary() { clear(); } -nx::ApplicationControlPropertyBinary::ApplicationControlPropertyBinary(const ApplicationControlPropertyBinary& other) +nn::hac::ApplicationControlPropertyBinary::ApplicationControlPropertyBinary(const ApplicationControlPropertyBinary& other) { *this = other; } -void nx::ApplicationControlPropertyBinary::operator=(const ApplicationControlPropertyBinary& other) +void nn::hac::ApplicationControlPropertyBinary::operator=(const ApplicationControlPropertyBinary& other) { clear(); mTitle = other.mTitle; @@ -54,7 +54,7 @@ void nx::ApplicationControlPropertyBinary::operator=(const ApplicationControlPro mProgramIndex = other.mProgramIndex; } -bool nx::ApplicationControlPropertyBinary::operator==(const ApplicationControlPropertyBinary& other) const +bool nn::hac::ApplicationControlPropertyBinary::operator==(const ApplicationControlPropertyBinary& other) const { return (mTitle == other.mTitle) \ && (mIsbn == other.mIsbn) \ @@ -97,14 +97,14 @@ bool nx::ApplicationControlPropertyBinary::operator==(const ApplicationControlPr && (mProgramIndex == other.mProgramIndex); } -bool nx::ApplicationControlPropertyBinary::operator!=(const ApplicationControlPropertyBinary& other) const +bool nn::hac::ApplicationControlPropertyBinary::operator!=(const ApplicationControlPropertyBinary& other) const { return !(*this == other); } -void nx::ApplicationControlPropertyBinary::toBytes() +void nn::hac::ApplicationControlPropertyBinary::toBytes() { - mRawBinary.alloc(sizeof(nx::sApplicationControlProperty)); + mRawBinary.alloc(sizeof(nn::hac::sApplicationControlProperty)); sApplicationControlProperty* data = (sApplicationControlProperty*)mRawBinary.data(); @@ -182,16 +182,16 @@ void nx::ApplicationControlPropertyBinary::toBytes() data->cache_storage_data_and_journal_size_max = mCacheStorageDataAndJournalSizeMax; } -void nx::ApplicationControlPropertyBinary::fromBytes(const byte_t* bytes, size_t len) +void nn::hac::ApplicationControlPropertyBinary::fromBytes(const byte_t* bytes, size_t len) { - if (len < sizeof(nx::sApplicationControlProperty)) + if (len < sizeof(nn::hac::sApplicationControlProperty)) { throw fnd::Exception(kModuleName, "NACP too small"); } clear(); - mRawBinary.alloc(sizeof(nx::sApplicationControlProperty)); + mRawBinary.alloc(sizeof(nn::hac::sApplicationControlProperty)); memcpy(mRawBinary.data(), bytes, mRawBinary.size()); const sApplicationControlProperty* data = (const sApplicationControlProperty*)mRawBinary.data(); @@ -275,12 +275,12 @@ void nx::ApplicationControlPropertyBinary::fromBytes(const byte_t* bytes, size_t mCacheStorageDataAndJournalSizeMax = (int64_t)data->cache_storage_data_and_journal_size_max.get(); } -const fnd::Vec& nx::ApplicationControlPropertyBinary::getBytes() const +const fnd::Vec& nn::hac::ApplicationControlPropertyBinary::getBytes() const { return mRawBinary; } -void nx::ApplicationControlPropertyBinary::clear() +void nn::hac::ApplicationControlPropertyBinary::clear() { mRawBinary.clear(); mTitle.clear(); @@ -324,392 +324,392 @@ void nx::ApplicationControlPropertyBinary::clear() mProgramIndex = 0; } -const fnd::List& nx::ApplicationControlPropertyBinary::getTitle() const +const fnd::List& nn::hac::ApplicationControlPropertyBinary::getTitle() const { return mTitle; } -void nx::ApplicationControlPropertyBinary::setTitle(const fnd::List& title) +void nn::hac::ApplicationControlPropertyBinary::setTitle(const fnd::List& title) { mTitle = title; } -const std::string& nx::ApplicationControlPropertyBinary::getIsbn() const +const std::string& nn::hac::ApplicationControlPropertyBinary::getIsbn() const { return mIsbn; } -void nx::ApplicationControlPropertyBinary::setIsbn(const std::string& isbn) +void nn::hac::ApplicationControlPropertyBinary::setIsbn(const std::string& isbn) { mIsbn = isbn; } -nx::nacp::StartupUserAccount nx::ApplicationControlPropertyBinary::getStartupUserAccount() const +nn::hac::nacp::StartupUserAccount nn::hac::ApplicationControlPropertyBinary::getStartupUserAccount() const { return mStartupUserAccount; } -void nx::ApplicationControlPropertyBinary::setStartupUserAccount(nacp::StartupUserAccount var) +void nn::hac::ApplicationControlPropertyBinary::setStartupUserAccount(nacp::StartupUserAccount var) { mStartupUserAccount = var; } -nx::nacp::TouchScreenUsageMode nx::ApplicationControlPropertyBinary::getTouchScreenUsageMode() const +nn::hac::nacp::TouchScreenUsageMode nn::hac::ApplicationControlPropertyBinary::getTouchScreenUsageMode() const { return mTouchScreenUsageMode; } -void nx::ApplicationControlPropertyBinary::setTouchScreenUsageMode(nacp::TouchScreenUsageMode var) +void nn::hac::ApplicationControlPropertyBinary::setTouchScreenUsageMode(nacp::TouchScreenUsageMode var) { mTouchScreenUsageMode = var; } -nx::nacp::AocRegistrationType nx::ApplicationControlPropertyBinary::getAocRegistrationType() const +nn::hac::nacp::AocRegistrationType nn::hac::ApplicationControlPropertyBinary::getAocRegistrationType() const { return mAocRegistrationType; } -void nx::ApplicationControlPropertyBinary::setAocRegistrationType(nacp::AocRegistrationType var) +void nn::hac::ApplicationControlPropertyBinary::setAocRegistrationType(nacp::AocRegistrationType var) { mAocRegistrationType = var; } -nx::nacp::AttributeFlag nx::ApplicationControlPropertyBinary::getAttributeFlag() const +nn::hac::nacp::AttributeFlag nn::hac::ApplicationControlPropertyBinary::getAttributeFlag() const { return mAttributeFlag; } -void nx::ApplicationControlPropertyBinary::setAttributeFlag(nacp::AttributeFlag var) +void nn::hac::ApplicationControlPropertyBinary::setAttributeFlag(nacp::AttributeFlag var) { mAttributeFlag = var; } -const fnd::List& nx::ApplicationControlPropertyBinary::getSupportedLanguages() const +const fnd::List& nn::hac::ApplicationControlPropertyBinary::getSupportedLanguages() const { return mSupportedLanguages; } -void nx::ApplicationControlPropertyBinary::setSupportedLanguages(const fnd::List& var) +void nn::hac::ApplicationControlPropertyBinary::setSupportedLanguages(const fnd::List& var) { mSupportedLanguages = var; } -nx::nacp::ParentalControlFlag nx::ApplicationControlPropertyBinary::getParentalControlFlag() const +nn::hac::nacp::ParentalControlFlag nn::hac::ApplicationControlPropertyBinary::getParentalControlFlag() const { return mParentalControlFlag; } -void nx::ApplicationControlPropertyBinary::setParentalControlFlag(nacp::ParentalControlFlag var) +void nn::hac::ApplicationControlPropertyBinary::setParentalControlFlag(nacp::ParentalControlFlag var) { mParentalControlFlag = var; } -nx::nacp::ScreenshotMode nx::ApplicationControlPropertyBinary::getScreenshotMode() const +nn::hac::nacp::ScreenshotMode nn::hac::ApplicationControlPropertyBinary::getScreenshotMode() const { return mScreenshotMode; } -void nx::ApplicationControlPropertyBinary::setScreenshotMode(nacp::ScreenshotMode var) +void nn::hac::ApplicationControlPropertyBinary::setScreenshotMode(nacp::ScreenshotMode var) { mScreenshotMode = var; } -nx::nacp::VideoCaptureMode nx::ApplicationControlPropertyBinary::getVideoCaptureMode() const +nn::hac::nacp::VideoCaptureMode nn::hac::ApplicationControlPropertyBinary::getVideoCaptureMode() const { return mVideoCaptureMode; } -void nx::ApplicationControlPropertyBinary::setVideoCaptureMode(nacp::VideoCaptureMode var) +void nn::hac::ApplicationControlPropertyBinary::setVideoCaptureMode(nacp::VideoCaptureMode var) { mVideoCaptureMode = var; } -nx::nacp::DataLossConfirmation nx::ApplicationControlPropertyBinary::getDataLossConfirmation() const +nn::hac::nacp::DataLossConfirmation nn::hac::ApplicationControlPropertyBinary::getDataLossConfirmation() const { return mDataLossConfirmation; } -void nx::ApplicationControlPropertyBinary::setDataLossConfirmation(nacp::DataLossConfirmation var) +void nn::hac::ApplicationControlPropertyBinary::setDataLossConfirmation(nacp::DataLossConfirmation var) { mDataLossConfirmation = var; } -nx::nacp::PlayLogPolicy nx::ApplicationControlPropertyBinary::getPlayLogPolicy() const +nn::hac::nacp::PlayLogPolicy nn::hac::ApplicationControlPropertyBinary::getPlayLogPolicy() const { return mPlayLogPolicy; } -void nx::ApplicationControlPropertyBinary::setPlayLogPolicy(nacp::PlayLogPolicy var) +void nn::hac::ApplicationControlPropertyBinary::setPlayLogPolicy(nacp::PlayLogPolicy var) { mPlayLogPolicy = var; } -uint64_t nx::ApplicationControlPropertyBinary::getPresenceGroupId() const +uint64_t nn::hac::ApplicationControlPropertyBinary::getPresenceGroupId() const { return mPresenceGroupId; } -void nx::ApplicationControlPropertyBinary::setPresenceGroupId(uint64_t var) +void nn::hac::ApplicationControlPropertyBinary::setPresenceGroupId(uint64_t var) { mPresenceGroupId = var; } -const fnd::List& nx::ApplicationControlPropertyBinary::getRatingAge() const +const fnd::List& nn::hac::ApplicationControlPropertyBinary::getRatingAge() const { return mRatingAge; } -void nx::ApplicationControlPropertyBinary::setRatingAge(const fnd::List& var) +void nn::hac::ApplicationControlPropertyBinary::setRatingAge(const fnd::List& var) { mRatingAge = var; } -const std::string& nx::ApplicationControlPropertyBinary::getDisplayVersion() const +const std::string& nn::hac::ApplicationControlPropertyBinary::getDisplayVersion() const { return mDisplayVersion; } -void nx::ApplicationControlPropertyBinary::setDisplayVersion(const std::string& var) +void nn::hac::ApplicationControlPropertyBinary::setDisplayVersion(const std::string& var) { mDisplayVersion = var; } -uint64_t nx::ApplicationControlPropertyBinary::getAocBaseId() const +uint64_t nn::hac::ApplicationControlPropertyBinary::getAocBaseId() const { return mAocBaseId; } -void nx::ApplicationControlPropertyBinary::setAocBaseId(uint64_t var) +void nn::hac::ApplicationControlPropertyBinary::setAocBaseId(uint64_t var) { mAocBaseId = var; } -uint64_t nx::ApplicationControlPropertyBinary::getSaveDatawOwnerId() const +uint64_t nn::hac::ApplicationControlPropertyBinary::getSaveDatawOwnerId() const { return mSaveDatawOwnerId; } -void nx::ApplicationControlPropertyBinary::setSaveDatawOwnerId(uint64_t var) +void nn::hac::ApplicationControlPropertyBinary::setSaveDatawOwnerId(uint64_t var) { mSaveDatawOwnerId = var; } -const nx::ApplicationControlPropertyBinary::sStorageSize& nx::ApplicationControlPropertyBinary::getUserAccountSaveDataSize() const +const nn::hac::ApplicationControlPropertyBinary::sStorageSize& nn::hac::ApplicationControlPropertyBinary::getUserAccountSaveDataSize() const { return mUserAccountSaveDataSize; } -void nx::ApplicationControlPropertyBinary::setUserAccountSaveDataSize(const sStorageSize& var) +void nn::hac::ApplicationControlPropertyBinary::setUserAccountSaveDataSize(const sStorageSize& var) { mUserAccountSaveDataSize = var; } -const nx::ApplicationControlPropertyBinary::sStorageSize& nx::ApplicationControlPropertyBinary::getDeviceSaveDataSize() const +const nn::hac::ApplicationControlPropertyBinary::sStorageSize& nn::hac::ApplicationControlPropertyBinary::getDeviceSaveDataSize() const { return mDeviceSaveDataSize; } -void nx::ApplicationControlPropertyBinary::setDeviceSaveDataSize(const sStorageSize& var) +void nn::hac::ApplicationControlPropertyBinary::setDeviceSaveDataSize(const sStorageSize& var) { mDeviceSaveDataSize = var; } -int64_t nx::ApplicationControlPropertyBinary::getBcatDeliveryCacheStorageSize() const +int64_t nn::hac::ApplicationControlPropertyBinary::getBcatDeliveryCacheStorageSize() const { return mBcatDeliveryCacheStorageSize; } -void nx::ApplicationControlPropertyBinary::setBcatDeliveryCacheStorageSize(int64_t var) +void nn::hac::ApplicationControlPropertyBinary::setBcatDeliveryCacheStorageSize(int64_t var) { mBcatDeliveryCacheStorageSize = var; } -const std::string& nx::ApplicationControlPropertyBinary::getApplicationErrorCodeCategory() const +const std::string& nn::hac::ApplicationControlPropertyBinary::getApplicationErrorCodeCategory() const { return mApplicationErrorCodeCategory; } -void nx::ApplicationControlPropertyBinary::setApplicationErrorCodeCategory(const std::string& var) +void nn::hac::ApplicationControlPropertyBinary::setApplicationErrorCodeCategory(const std::string& var) { mApplicationErrorCodeCategory = var; } -const fnd::List& nx::ApplicationControlPropertyBinary::getLocalCommunicationId() const +const fnd::List& nn::hac::ApplicationControlPropertyBinary::getLocalCommunicationId() const { return mLocalCommunicationId; } -void nx::ApplicationControlPropertyBinary::setLocalCommunicationId(const fnd::List& var) +void nn::hac::ApplicationControlPropertyBinary::setLocalCommunicationId(const fnd::List& var) { mLocalCommunicationId = var; } -nx::nacp::LogoType nx::ApplicationControlPropertyBinary::getLogoType() const +nn::hac::nacp::LogoType nn::hac::ApplicationControlPropertyBinary::getLogoType() const { return mLogoType; } -void nx::ApplicationControlPropertyBinary::setLogoType(nacp::LogoType var) +void nn::hac::ApplicationControlPropertyBinary::setLogoType(nacp::LogoType var) { mLogoType = var; } -nx::nacp::LogoHandling nx::ApplicationControlPropertyBinary::getLogoHandling() const +nn::hac::nacp::LogoHandling nn::hac::ApplicationControlPropertyBinary::getLogoHandling() const { return mLogoHandling; } -void nx::ApplicationControlPropertyBinary::setLogoHandling(nacp::LogoHandling var) +void nn::hac::ApplicationControlPropertyBinary::setLogoHandling(nacp::LogoHandling var) { mLogoHandling = var; } -nx::nacp::RuntimeAocInstallMode nx::ApplicationControlPropertyBinary::getRuntimeAocInstallMode() const +nn::hac::nacp::RuntimeAocInstallMode nn::hac::ApplicationControlPropertyBinary::getRuntimeAocInstallMode() const { return mRuntimeAocInstallMode; } -void nx::ApplicationControlPropertyBinary::setRuntimeAocInstallMode(nacp::RuntimeAocInstallMode var) +void nn::hac::ApplicationControlPropertyBinary::setRuntimeAocInstallMode(nacp::RuntimeAocInstallMode var) { mRuntimeAocInstallMode = var; } -nx::nacp::CrashReportMode nx::ApplicationControlPropertyBinary::getCrashReportMode() const +nn::hac::nacp::CrashReportMode nn::hac::ApplicationControlPropertyBinary::getCrashReportMode() const { return mCrashReportMode; } -void nx::ApplicationControlPropertyBinary::setCrashReportMode(nacp::CrashReportMode var) +void nn::hac::ApplicationControlPropertyBinary::setCrashReportMode(nacp::CrashReportMode var) { mCrashReportMode = var; } -nx::nacp::Hdcp nx::ApplicationControlPropertyBinary::getHdcp() const +nn::hac::nacp::Hdcp nn::hac::ApplicationControlPropertyBinary::getHdcp() const { return mHdcp; } -void nx::ApplicationControlPropertyBinary::setHdcp(nacp::Hdcp var) +void nn::hac::ApplicationControlPropertyBinary::setHdcp(nacp::Hdcp var) { mHdcp = var; } -uint64_t nx::ApplicationControlPropertyBinary::getSeedForPsuedoDeviceId() const +uint64_t nn::hac::ApplicationControlPropertyBinary::getSeedForPsuedoDeviceId() const { return mSeedForPsuedoDeviceId; } -void nx::ApplicationControlPropertyBinary::setSeedForPsuedoDeviceId(uint64_t var) +void nn::hac::ApplicationControlPropertyBinary::setSeedForPsuedoDeviceId(uint64_t var) { mSeedForPsuedoDeviceId = var; } -const std::string& nx::ApplicationControlPropertyBinary::getBcatPassphase() const +const std::string& nn::hac::ApplicationControlPropertyBinary::getBcatPassphase() const { return mBcatPassphase; } -void nx::ApplicationControlPropertyBinary::setBcatPassphase(const std::string& var) +void nn::hac::ApplicationControlPropertyBinary::setBcatPassphase(const std::string& var) { mBcatPassphase = var; } -const nx::ApplicationControlPropertyBinary::sStorageSize& nx::ApplicationControlPropertyBinary::getUserAccountSaveDataMax() const +const nn::hac::ApplicationControlPropertyBinary::sStorageSize& nn::hac::ApplicationControlPropertyBinary::getUserAccountSaveDataMax() const { return mUserAccountSaveDataMax; } -void nx::ApplicationControlPropertyBinary::setUserAccountSaveDataMax(const sStorageSize& var) +void nn::hac::ApplicationControlPropertyBinary::setUserAccountSaveDataMax(const sStorageSize& var) { mUserAccountSaveDataMax = var; } -const nx::ApplicationControlPropertyBinary::sStorageSize& nx::ApplicationControlPropertyBinary::getDeviceSaveDataMax() const +const nn::hac::ApplicationControlPropertyBinary::sStorageSize& nn::hac::ApplicationControlPropertyBinary::getDeviceSaveDataMax() const { return mDeviceSaveDataMax; } -void nx::ApplicationControlPropertyBinary::setDeviceSaveDataMax(const sStorageSize& var) +void nn::hac::ApplicationControlPropertyBinary::setDeviceSaveDataMax(const sStorageSize& var) { mDeviceSaveDataMax = var; } -int64_t nx::ApplicationControlPropertyBinary::getTemporaryStorageSize() const +int64_t nn::hac::ApplicationControlPropertyBinary::getTemporaryStorageSize() const { return mTemporaryStorageSize; } -void nx::ApplicationControlPropertyBinary::setTemporaryStorageSize(int64_t var) +void nn::hac::ApplicationControlPropertyBinary::setTemporaryStorageSize(int64_t var) { mTemporaryStorageSize = var; } -const nx::ApplicationControlPropertyBinary::sStorageSize& nx::ApplicationControlPropertyBinary::getCacheStorageSize() const +const nn::hac::ApplicationControlPropertyBinary::sStorageSize& nn::hac::ApplicationControlPropertyBinary::getCacheStorageSize() const { return mCacheStorageSize; } -void nx::ApplicationControlPropertyBinary::setCacheStorageSize(const sStorageSize& var) +void nn::hac::ApplicationControlPropertyBinary::setCacheStorageSize(const sStorageSize& var) { mCacheStorageSize = var; } -int64_t nx::ApplicationControlPropertyBinary::getCacheStorageDataAndJournalSizeMax() const +int64_t nn::hac::ApplicationControlPropertyBinary::getCacheStorageDataAndJournalSizeMax() const { return mCacheStorageDataAndJournalSizeMax; } -void nx::ApplicationControlPropertyBinary::setCacheStorageDataAndJournalSizeMax(int64_t var) +void nn::hac::ApplicationControlPropertyBinary::setCacheStorageDataAndJournalSizeMax(int64_t var) { mCacheStorageDataAndJournalSizeMax = var; } -uint16_t nx::ApplicationControlPropertyBinary::getCacheStorageIndexMax() const +uint16_t nn::hac::ApplicationControlPropertyBinary::getCacheStorageIndexMax() const { return mCacheStorageIndexMax; } -void nx::ApplicationControlPropertyBinary::setCacheStorageIndexMax(uint16_t var) +void nn::hac::ApplicationControlPropertyBinary::setCacheStorageIndexMax(uint16_t var) { mCacheStorageIndexMax = var; } -const fnd::List& nx::ApplicationControlPropertyBinary::getPlayLogQueryableApplicationId() const +const fnd::List& nn::hac::ApplicationControlPropertyBinary::getPlayLogQueryableApplicationId() const { return mPlayLogQueryableApplicationId; } -void nx::ApplicationControlPropertyBinary::setPlayLogQueryableApplicationId(const fnd::List& var) +void nn::hac::ApplicationControlPropertyBinary::setPlayLogQueryableApplicationId(const fnd::List& var) { mPlayLogQueryableApplicationId = var; } -nx::nacp::PlayLogQueryCapability nx::ApplicationControlPropertyBinary::getPlayLogQueryCapability() const +nn::hac::nacp::PlayLogQueryCapability nn::hac::ApplicationControlPropertyBinary::getPlayLogQueryCapability() const { return mPlayLogQueryCapability; } -void nx::ApplicationControlPropertyBinary::setPlayLogQueryCapability(nacp::PlayLogQueryCapability var) +void nn::hac::ApplicationControlPropertyBinary::setPlayLogQueryCapability(nacp::PlayLogQueryCapability var) { mPlayLogQueryCapability = var; } -nx::nacp::RepairFlag nx::ApplicationControlPropertyBinary::getRepairFlag() const +nn::hac::nacp::RepairFlag nn::hac::ApplicationControlPropertyBinary::getRepairFlag() const { return mRepairFlag; } -void nx::ApplicationControlPropertyBinary::setRepairFlag(nacp::RepairFlag var) +void nn::hac::ApplicationControlPropertyBinary::setRepairFlag(nacp::RepairFlag var) { mRepairFlag = var; } -byte_t nx::ApplicationControlPropertyBinary::getProgramIndex() const +byte_t nn::hac::ApplicationControlPropertyBinary::getProgramIndex() const { return mProgramIndex; } -void nx::ApplicationControlPropertyBinary::setProgramIndex(byte_t var) +void nn::hac::ApplicationControlPropertyBinary::setProgramIndex(byte_t var) { mProgramIndex = var; } \ No newline at end of file diff --git a/lib/libhac/source/ApplicationControlPropertyUtils.cpp b/lib/libhac/source/ApplicationControlPropertyUtils.cpp index 5e1076c..b0c3e7b 100644 --- a/lib/libhac/source/ApplicationControlPropertyUtils.cpp +++ b/lib/libhac/source/ApplicationControlPropertyUtils.cpp @@ -1,11 +1,11 @@ -#include +#include -bool nx::ApplicationControlPropertyUtils::validateSaveDataSizeMax(int64_t size, int64_t alignment) +bool nn::hac::ApplicationControlPropertyUtils::validateSaveDataSizeMax(int64_t size, int64_t alignment) { return (alignment != 0 && (size & (alignment - 1)) != 0) == false; } -bool nx::ApplicationControlPropertyUtils::validateSaveDataSize(int64_t size) +bool nn::hac::ApplicationControlPropertyUtils::validateSaveDataSize(int64_t size) { return (size & 0x3fff) == 0; } diff --git a/lib/libhac/source/ContentMetaBinary.cpp b/lib/libhac/source/ContentMetaBinary.cpp index b90de17..22c5ab7 100644 --- a/lib/libhac/source/ContentMetaBinary.cpp +++ b/lib/libhac/source/ContentMetaBinary.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::ContentMetaBinary::ContentMetaBinary() +nn::hac::ContentMetaBinary::ContentMetaBinary() { clear(); } -nx::ContentMetaBinary::ContentMetaBinary(const ContentMetaBinary & other) +nn::hac::ContentMetaBinary::ContentMetaBinary(const ContentMetaBinary & other) { *this = other; } -void nx::ContentMetaBinary::operator=(const ContentMetaBinary& other) +void nn::hac::ContentMetaBinary::operator=(const ContentMetaBinary& other) { if (other.getBytes().size() > 0) { @@ -36,7 +36,7 @@ void nx::ContentMetaBinary::operator=(const ContentMetaBinary& other) } } -bool nx::ContentMetaBinary::operator==(const ContentMetaBinary& other) const +bool nn::hac::ContentMetaBinary::operator==(const ContentMetaBinary& other) const { return (mTitleId == other.mTitleId) \ && (mTitleVersion == other.mTitleVersion) \ @@ -54,17 +54,17 @@ bool nx::ContentMetaBinary::operator==(const ContentMetaBinary& other) const && (memcmp(mDigest.data, other.mDigest.data, cnmt::kDigestLen) == 0); } -bool nx::ContentMetaBinary::operator!=(const ContentMetaBinary& other) const +bool nn::hac::ContentMetaBinary::operator!=(const ContentMetaBinary& other) const { return !(*this == other); } -void nx::ContentMetaBinary::toBytes() +void nn::hac::ContentMetaBinary::toBytes() { throw fnd::Exception(kModuleName, "exportBinary() not implemented"); } -void nx::ContentMetaBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::ContentMetaBinary::fromBytes(const byte_t* data, size_t len) { // clear member variables clear(); @@ -153,12 +153,12 @@ void nx::ContentMetaBinary::fromBytes(const byte_t* data, size_t len) memcpy(mDigest.data, data + getDigestOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), exdata_size), cnmt::kDigestLen); } -const fnd::Vec& nx::ContentMetaBinary::getBytes() const +const fnd::Vec& nn::hac::ContentMetaBinary::getBytes() const { return mRawBinary; } -void nx::ContentMetaBinary::clear() +void nn::hac::ContentMetaBinary::clear() { mRawBinary.clear(); mTitleId = 0; @@ -177,138 +177,138 @@ void nx::ContentMetaBinary::clear() memset(mDigest.data, 0, cnmt::kDigestLen); } -uint64_t nx::ContentMetaBinary::getTitleId() const +uint64_t nn::hac::ContentMetaBinary::getTitleId() const { return mTitleId; } -void nx::ContentMetaBinary::setTitleId(uint64_t title_id) +void nn::hac::ContentMetaBinary::setTitleId(uint64_t title_id) { mTitleId = title_id; } -uint32_t nx::ContentMetaBinary::getTitleVersion() const +uint32_t nn::hac::ContentMetaBinary::getTitleVersion() const { return mTitleVersion; } -void nx::ContentMetaBinary::setTitleVersion(uint32_t version) +void nn::hac::ContentMetaBinary::setTitleVersion(uint32_t version) { mTitleVersion = version; } -nx::cnmt::ContentMetaType nx::ContentMetaBinary::getType() const +nn::hac::cnmt::ContentMetaType nn::hac::ContentMetaBinary::getType() const { return mType; } -void nx::ContentMetaBinary::setType(cnmt::ContentMetaType type) +void nn::hac::ContentMetaBinary::setType(cnmt::ContentMetaType type) { mType = type; } -byte_t nx::ContentMetaBinary::getAttributes() const +byte_t nn::hac::ContentMetaBinary::getAttributes() const { return mAttributes; } -void nx::ContentMetaBinary::setAttributes(byte_t attributes) +void nn::hac::ContentMetaBinary::setAttributes(byte_t attributes) { mAttributes = attributes; } -uint32_t nx::ContentMetaBinary::getRequiredDownloadSystemVersion() const +uint32_t nn::hac::ContentMetaBinary::getRequiredDownloadSystemVersion() const { return mRequiredDownloadSystemVersion; } -void nx::ContentMetaBinary::setRequiredDownloadSystemVersion(uint32_t version) +void nn::hac::ContentMetaBinary::setRequiredDownloadSystemVersion(uint32_t version) { mRequiredDownloadSystemVersion = version; } -const nx::ContentMetaBinary::ApplicationMetaExtendedHeader& nx::ContentMetaBinary::getApplicationMetaExtendedHeader() const +const nn::hac::ContentMetaBinary::ApplicationMetaExtendedHeader& nn::hac::ContentMetaBinary::getApplicationMetaExtendedHeader() const { return mApplicationMetaExtendedHeader; } -void nx::ContentMetaBinary::setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr) +void nn::hac::ContentMetaBinary::setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr) { mApplicationMetaExtendedHeader = exhdr; } -const nx::ContentMetaBinary::PatchMetaExtendedHeader& nx::ContentMetaBinary::getPatchMetaExtendedHeader() const +const nn::hac::ContentMetaBinary::PatchMetaExtendedHeader& nn::hac::ContentMetaBinary::getPatchMetaExtendedHeader() const { return mPatchMetaExtendedHeader; } -void nx::ContentMetaBinary::setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr) +void nn::hac::ContentMetaBinary::setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr) { mPatchMetaExtendedHeader = exhdr; } -const nx::ContentMetaBinary::AddOnContentMetaExtendedHeader& nx::ContentMetaBinary::getAddOnContentMetaExtendedHeader() const +const nn::hac::ContentMetaBinary::AddOnContentMetaExtendedHeader& nn::hac::ContentMetaBinary::getAddOnContentMetaExtendedHeader() const { return mAddOnContentMetaExtendedHeader; } -void nx::ContentMetaBinary::setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr) +void nn::hac::ContentMetaBinary::setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr) { mAddOnContentMetaExtendedHeader = exhdr; } -const nx::ContentMetaBinary::DeltaMetaExtendedHeader& nx::ContentMetaBinary::getDeltaMetaExtendedHeader() const +const nn::hac::ContentMetaBinary::DeltaMetaExtendedHeader& nn::hac::ContentMetaBinary::getDeltaMetaExtendedHeader() const { return mDeltaMetaExtendedHeader; } -void nx::ContentMetaBinary::setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr) +void nn::hac::ContentMetaBinary::setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr) { mDeltaMetaExtendedHeader = exhdr; } -const fnd::List& nx::ContentMetaBinary::getContentInfo() const +const fnd::List& nn::hac::ContentMetaBinary::getContentInfo() const { return mContentInfo; } -void nx::ContentMetaBinary::setContentInfo(const fnd::List& info) +void nn::hac::ContentMetaBinary::setContentInfo(const fnd::List& info) { mContentInfo = info; } -const fnd::List& nx::ContentMetaBinary::getContentMetaInfo() const +const fnd::List& nn::hac::ContentMetaBinary::getContentMetaInfo() const { return mContentMetaInfo; } -void nx::ContentMetaBinary::setContentMetaInfo(const fnd::List& info) +void nn::hac::ContentMetaBinary::setContentMetaInfo(const fnd::List& info) { mContentMetaInfo = info; } -const fnd::Vec & nx::ContentMetaBinary::getExtendedData() const +const fnd::Vec & nn::hac::ContentMetaBinary::getExtendedData() const { return mExtendedData; } -void nx::ContentMetaBinary::setExtendedData(const fnd::Vec & data) +void nn::hac::ContentMetaBinary::setExtendedData(const fnd::Vec & data) { mExtendedData = data; } -const nx::sDigest & nx::ContentMetaBinary::getDigest() const +const nn::hac::sDigest & nn::hac::ContentMetaBinary::getDigest() const { return mDigest; } -void nx::ContentMetaBinary::setDigest(const nx::sDigest & digest) +void nn::hac::ContentMetaBinary::setDigest(const nn::hac::sDigest & digest) { memcpy(mDigest.data, digest.data, cnmt::kDigestLen); } -bool nx::ContentMetaBinary::validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const +bool nn::hac::ContentMetaBinary::validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const { bool validSize = false; @@ -333,7 +333,7 @@ bool nx::ContentMetaBinary::validateExtendedHeaderSize(cnmt::ContentMetaType typ return validSize; } -size_t nx::ContentMetaBinary::getExtendedDataSize(cnmt::ContentMetaType type, const byte_t * data) const +size_t nn::hac::ContentMetaBinary::getExtendedDataSize(cnmt::ContentMetaType type, const byte_t * data) const { size_t exdata_len = 0; if (type == cnmt::METATYPE_PATCH) @@ -349,7 +349,7 @@ size_t nx::ContentMetaBinary::getExtendedDataSize(cnmt::ContentMetaType type, co return exdata_len; } -void nx::ContentMetaBinary::validateBinary(const byte_t * data, size_t len) const +void nn::hac::ContentMetaBinary::validateBinary(const byte_t * data, size_t len) const { // check if it is large enough to read the header if (len < sizeof(sContentMetaHeader)) diff --git a/lib/libhac/source/FileSystemAccessControlBinary.cpp b/lib/libhac/source/FileSystemAccessControlBinary.cpp index c2c4c94..81e007f 100644 --- a/lib/libhac/source/FileSystemAccessControlBinary.cpp +++ b/lib/libhac/source/FileSystemAccessControlBinary.cpp @@ -1,18 +1,18 @@ -#include +#include #include -nx::FileSystemAccessControlBinary::FileSystemAccessControlBinary() +nn::hac::FileSystemAccessControlBinary::FileSystemAccessControlBinary() { clear(); } -nx::FileSystemAccessControlBinary::FileSystemAccessControlBinary(const FileSystemAccessControlBinary & other) +nn::hac::FileSystemAccessControlBinary::FileSystemAccessControlBinary(const FileSystemAccessControlBinary & other) { *this = other; } -void nx::FileSystemAccessControlBinary::operator=(const FileSystemAccessControlBinary & other) +void nn::hac::FileSystemAccessControlBinary::operator=(const FileSystemAccessControlBinary & other) { mRawBinary = other.mRawBinary; mVersion = other.mVersion; @@ -21,7 +21,7 @@ void nx::FileSystemAccessControlBinary::operator=(const FileSystemAccessControlB mSaveDataOwnerIdList = other.mSaveDataOwnerIdList; } -bool nx::FileSystemAccessControlBinary::operator==(const FileSystemAccessControlBinary & other) const +bool nn::hac::FileSystemAccessControlBinary::operator==(const FileSystemAccessControlBinary & other) const { return (mVersion == other.mVersion) \ && (mFsaRights == other.mFsaRights) \ @@ -29,12 +29,12 @@ bool nx::FileSystemAccessControlBinary::operator==(const FileSystemAccessControl && (mSaveDataOwnerIdList == other.mSaveDataOwnerIdList); } -bool nx::FileSystemAccessControlBinary::operator!=(const FileSystemAccessControlBinary & other) const +bool nn::hac::FileSystemAccessControlBinary::operator!=(const FileSystemAccessControlBinary & other) const { return !(*this == other); } -void nx::FileSystemAccessControlBinary::toBytes() +void nn::hac::FileSystemAccessControlBinary::toBytes() { // determine section layout struct sLayout { @@ -91,7 +91,7 @@ void nx::FileSystemAccessControlBinary::toBytes() } } -void nx::FileSystemAccessControlBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::FileSystemAccessControlBinary::fromBytes(const byte_t* data, size_t len) { // check size if (len < sizeof(sFacHeader)) @@ -157,12 +157,12 @@ void nx::FileSystemAccessControlBinary::fromBytes(const byte_t* data, size_t len } } -const fnd::Vec& nx::FileSystemAccessControlBinary::getBytes() const +const fnd::Vec& nn::hac::FileSystemAccessControlBinary::getBytes() const { return mRawBinary; } -void nx::FileSystemAccessControlBinary::clear() +void nn::hac::FileSystemAccessControlBinary::clear() { mRawBinary.clear(); mVersion = 0; @@ -171,42 +171,42 @@ void nx::FileSystemAccessControlBinary::clear() mSaveDataOwnerIdList.clear(); } -uint32_t nx::FileSystemAccessControlBinary::getFormatVersion() const +uint32_t nn::hac::FileSystemAccessControlBinary::getFormatVersion() const { return mVersion; } -void nx::FileSystemAccessControlBinary::setFormatVersion(uint32_t format_version) +void nn::hac::FileSystemAccessControlBinary::setFormatVersion(uint32_t format_version) { mVersion = format_version; } -const fnd::List& nx::FileSystemAccessControlBinary::getFsaRightsList() const +const fnd::List& nn::hac::FileSystemAccessControlBinary::getFsaRightsList() const { return mFsaRights; } -void nx::FileSystemAccessControlBinary::setFsaRightsList(const fnd::List& list) +void nn::hac::FileSystemAccessControlBinary::setFsaRightsList(const fnd::List& list) { mFsaRights = list; } -const fnd::List& nx::FileSystemAccessControlBinary::getContentOwnerIdList() const +const fnd::List& nn::hac::FileSystemAccessControlBinary::getContentOwnerIdList() const { return mContentOwnerIdList; } -void nx::FileSystemAccessControlBinary::setContentOwnerIdList(const fnd::List& list) +void nn::hac::FileSystemAccessControlBinary::setContentOwnerIdList(const fnd::List& list) { mContentOwnerIdList = list; } -const fnd::List& nx::FileSystemAccessControlBinary::getSaveDataOwnerIdList() const +const fnd::List& nn::hac::FileSystemAccessControlBinary::getSaveDataOwnerIdList() const { return mSaveDataOwnerIdList; } -void nx::FileSystemAccessControlBinary::setSaveDataOwnerIdList(const fnd::List& list) +void nn::hac::FileSystemAccessControlBinary::setSaveDataOwnerIdList(const fnd::List& list) { mSaveDataOwnerIdList = list; } \ No newline at end of file diff --git a/lib/libhac/source/HandleTableSizeEntry.cpp b/lib/libhac/source/HandleTableSizeEntry.cpp index c01471c..23c6257 100644 --- a/lib/libhac/source/HandleTableSizeEntry.cpp +++ b/lib/libhac/source/HandleTableSizeEntry.cpp @@ -1,47 +1,47 @@ -#include +#include -nx::HandleTableSizeEntry::HandleTableSizeEntry() : +nn::hac::HandleTableSizeEntry::HandleTableSizeEntry() : mCap(kCapId), mHandleTableSize(0) {} -nx::HandleTableSizeEntry::HandleTableSizeEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::HandleTableSizeEntry::HandleTableSizeEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mHandleTableSize(0) { setKernelCapability(kernel_cap); } -nx::HandleTableSizeEntry::HandleTableSizeEntry(uint16_t size) : +nn::hac::HandleTableSizeEntry::HandleTableSizeEntry(uint16_t size) : mCap(kCapId), mHandleTableSize(0) { setHandleTableSize(size); } -void nx::HandleTableSizeEntry::operator=(const HandleTableSizeEntry& other) +void nn::hac::HandleTableSizeEntry::operator=(const HandleTableSizeEntry& other) { mHandleTableSize = other.mHandleTableSize; updateCapField(); } -bool nx::HandleTableSizeEntry::operator==(const HandleTableSizeEntry& other) const +bool nn::hac::HandleTableSizeEntry::operator==(const HandleTableSizeEntry& other) const { return (mHandleTableSize == other.mHandleTableSize); } -bool nx::HandleTableSizeEntry::operator!=(const HandleTableSizeEntry& other) const +bool nn::hac::HandleTableSizeEntry::operator!=(const HandleTableSizeEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::HandleTableSizeEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::HandleTableSizeEntry::getKernelCapability() const { return mCap; } -void nx::HandleTableSizeEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::HandleTableSizeEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -52,12 +52,12 @@ void nx::HandleTableSizeEntry::setKernelCapability(const KernelCapabilityEntry & processCapField(); } -uint16_t nx::HandleTableSizeEntry::getHandleTableSize() const +uint16_t nn::hac::HandleTableSizeEntry::getHandleTableSize() const { return mHandleTableSize; } -void nx::HandleTableSizeEntry::setHandleTableSize(uint16_t size) +void nn::hac::HandleTableSizeEntry::setHandleTableSize(uint16_t size) { if (size > kMaxHandleTableSize) { diff --git a/lib/libhac/source/HandleTableSizeHandler.cpp b/lib/libhac/source/HandleTableSizeHandler.cpp index da1bda1..3b429cf 100644 --- a/lib/libhac/source/HandleTableSizeHandler.cpp +++ b/lib/libhac/source/HandleTableSizeHandler.cpp @@ -1,28 +1,28 @@ -#include +#include -nx::HandleTableSizeHandler::HandleTableSizeHandler() : +nn::hac::HandleTableSizeHandler::HandleTableSizeHandler() : mIsSet(false), mEntry(0) {} -void nx::HandleTableSizeHandler::operator=(const HandleTableSizeHandler & other) +void nn::hac::HandleTableSizeHandler::operator=(const HandleTableSizeHandler & other) { mIsSet = other.mIsSet; mEntry.setKernelCapability(other.mEntry.getKernelCapability()); } -bool nx::HandleTableSizeHandler::operator==(const HandleTableSizeHandler & other) const +bool nn::hac::HandleTableSizeHandler::operator==(const HandleTableSizeHandler & other) const { return (mIsSet == other.mIsSet) \ && (mEntry.getKernelCapability() == other.mEntry.getKernelCapability()); } -bool nx::HandleTableSizeHandler::operator!=(const HandleTableSizeHandler & other) const +bool nn::hac::HandleTableSizeHandler::operator!=(const HandleTableSizeHandler & other) const { return !(*this == other); } -void nx::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() > kMaxKernelCapNum) { @@ -36,7 +36,7 @@ void nx::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::HandleTableSizeHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -44,23 +44,23 @@ void nx::HandleTableSizeHandler::exportKernelCapabilityList(fnd::List -#include +#include -nx::HierarchicalIntegrityHeader::HierarchicalIntegrityHeader() +nn::hac::HierarchicalIntegrityHeader::HierarchicalIntegrityHeader() { clear(); } -nx::HierarchicalIntegrityHeader::HierarchicalIntegrityHeader(const HierarchicalIntegrityHeader & other) +nn::hac::HierarchicalIntegrityHeader::HierarchicalIntegrityHeader(const HierarchicalIntegrityHeader & other) { *this = other; } -void nx::HierarchicalIntegrityHeader::operator=(const HierarchicalIntegrityHeader & other) +void nn::hac::HierarchicalIntegrityHeader::operator=(const HierarchicalIntegrityHeader & other) { if (other.getBytes().size() != 0) { @@ -25,33 +25,33 @@ void nx::HierarchicalIntegrityHeader::operator=(const HierarchicalIntegrityHeade } } -bool nx::HierarchicalIntegrityHeader::operator==(const HierarchicalIntegrityHeader & other) const +bool nn::hac::HierarchicalIntegrityHeader::operator==(const HierarchicalIntegrityHeader & other) const { return (mLayerInfo == other.mLayerInfo) \ && (mMasterHashList == other.mMasterHashList); } -bool nx::HierarchicalIntegrityHeader::operator!=(const HierarchicalIntegrityHeader & other) const +bool nn::hac::HierarchicalIntegrityHeader::operator!=(const HierarchicalIntegrityHeader & other) const { return !(*this == other); } -void nx::HierarchicalIntegrityHeader::toBytes() +void nn::hac::HierarchicalIntegrityHeader::toBytes() { throw fnd::Exception(kModuleName, "exportBinary() not implemented"); } -void nx::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) { std::stringstream error_str; // validate size for at least header - if (len < sizeof(nx::sHierarchicalIntegrityHeader)) + if (len < sizeof(nn::hac::sHierarchicalIntegrityHeader)) { throw fnd::Exception(kModuleName, "Header too small"); } - const nx::sHierarchicalIntegrityHeader* hdr = (const nx::sHierarchicalIntegrityHeader*)data; + const nn::hac::sHierarchicalIntegrityHeader* hdr = (const nn::hac::sHierarchicalIntegrityHeader*)data; // Validate Header Sig "IVFC" if (hdr->st_magic.get() != hierarchicalintegrity::kStructMagic) @@ -60,7 +60,7 @@ void nx::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) } // Validate TypeId - if (hdr->type_id.get() != nx::hierarchicalintegrity::kRomfsTypeId) + if (hdr->type_id.get() != nn::hac::hierarchicalintegrity::kRomfsTypeId) { error_str.clear(); error_str << "Unsupported type id (" << std::hex << hdr->type_id.get() << ")"; @@ -72,12 +72,12 @@ void nx::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) { error_str.clear(); error_str << "Invalid layer count. "; - error_str << "(actual=" << std::dec << hdr->layer_num.get() << ", expected=" << nx::hierarchicalintegrity::kDefaultLayerNum+1 << ")"; + error_str << "(actual=" << std::dec << hdr->layer_num.get() << ", expected=" << nn::hac::hierarchicalintegrity::kDefaultLayerNum+1 << ")"; throw fnd::Exception(kModuleName, error_str.str()); } // Get Sizes/Offsets - size_t master_hash_offset = align((sizeof(nx::sHierarchicalIntegrityHeader) + sizeof(nx::sHierarchicalIntegrityLayerInfo) * hdr->layer_num.get()), nx::hierarchicalintegrity::kHeaderAlignLen); + size_t master_hash_offset = align((sizeof(nn::hac::sHierarchicalIntegrityHeader) + sizeof(nn::hac::sHierarchicalIntegrityLayerInfo) * hdr->layer_num.get()), nn::hac::hierarchicalintegrity::kHeaderAlignLen); size_t total_size = master_hash_offset + hdr->master_hash_size.get(); // Validate total size @@ -91,7 +91,7 @@ void nx::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) memcpy(mRawBinary.data(), data, mRawBinary.size()); // save layer info - const nx::sHierarchicalIntegrityLayerInfo* layer_info = (const nx::sHierarchicalIntegrityLayerInfo*)(mRawBinary.data() + sizeof(nx::sHierarchicalIntegrityHeader)); + const nn::hac::sHierarchicalIntegrityLayerInfo* layer_info = (const nn::hac::sHierarchicalIntegrityLayerInfo*)(mRawBinary.data() + sizeof(nn::hac::sHierarchicalIntegrityHeader)); for (size_t i = 0; i < hierarchicalintegrity::kDefaultLayerNum; i++) { mLayerInfo.addElement({layer_info[i].offset.get(), layer_info[i].size.get(), layer_info[i].block_size.get()}); @@ -105,33 +105,33 @@ void nx::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t len) } } -const fnd::Vec& nx::HierarchicalIntegrityHeader::getBytes() const +const fnd::Vec& nn::hac::HierarchicalIntegrityHeader::getBytes() const { return mRawBinary; } -void nx::HierarchicalIntegrityHeader::clear() +void nn::hac::HierarchicalIntegrityHeader::clear() { mLayerInfo.clear(); mMasterHashList.clear(); } -const fnd::List& nx::HierarchicalIntegrityHeader::getLayerInfo() const +const fnd::List& nn::hac::HierarchicalIntegrityHeader::getLayerInfo() const { return mLayerInfo; } -void nx::HierarchicalIntegrityHeader::setLayerInfo(const fnd::List& layer_info) +void nn::hac::HierarchicalIntegrityHeader::setLayerInfo(const fnd::List& layer_info) { mLayerInfo = layer_info; } -const fnd::List& nx::HierarchicalIntegrityHeader::getMasterHashList() const +const fnd::List& nn::hac::HierarchicalIntegrityHeader::getMasterHashList() const { return mMasterHashList; } -void nx::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list) +void nn::hac::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list) { mMasterHashList = master_hash_list; } \ No newline at end of file diff --git a/lib/libhac/source/HierarchicalSha256Header.cpp b/lib/libhac/source/HierarchicalSha256Header.cpp index e199075..6b3f42c 100644 --- a/lib/libhac/source/HierarchicalSha256Header.cpp +++ b/lib/libhac/source/HierarchicalSha256Header.cpp @@ -1,17 +1,17 @@ #include -#include +#include -nx::HierarchicalSha256Header::HierarchicalSha256Header() +nn::hac::HierarchicalSha256Header::HierarchicalSha256Header() { clear(); } -nx::HierarchicalSha256Header::HierarchicalSha256Header(const HierarchicalSha256Header & other) +nn::hac::HierarchicalSha256Header::HierarchicalSha256Header(const HierarchicalSha256Header & other) { *this = other; } -void nx::HierarchicalSha256Header::operator=(const HierarchicalSha256Header & other) +void nn::hac::HierarchicalSha256Header::operator=(const HierarchicalSha256Header & other) { if (other.getBytes().size() != 0) { @@ -25,39 +25,39 @@ void nx::HierarchicalSha256Header::operator=(const HierarchicalSha256Header & ot } } -bool nx::HierarchicalSha256Header::operator==(const HierarchicalSha256Header & other) const +bool nn::hac::HierarchicalSha256Header::operator==(const HierarchicalSha256Header & other) const { return (mMasterHash == other.mMasterHash) \ && (mHashBlockSize == other.mHashBlockSize) \ && (mLayerInfo == other.mLayerInfo); } -bool nx::HierarchicalSha256Header::operator!=(const HierarchicalSha256Header & other) const +bool nn::hac::HierarchicalSha256Header::operator!=(const HierarchicalSha256Header & other) const { return !(*this == other); } -void nx::HierarchicalSha256Header::toBytes() +void nn::hac::HierarchicalSha256Header::toBytes() { throw fnd::Exception(kModuleName, "exportBinary() not implemented"); } -void nx::HierarchicalSha256Header::fromBytes(const byte_t* data, size_t len) +void nn::hac::HierarchicalSha256Header::fromBytes(const byte_t* data, size_t len) { std::stringstream error_str; - if (len < sizeof(nx::sHierarchicalSha256Header)) + if (len < sizeof(nn::hac::sHierarchicalSha256Header)) { throw fnd::Exception(kModuleName, "Header too small"); } - const nx::sHierarchicalSha256Header* hdr = (const nx::sHierarchicalSha256Header*)data; + const nn::hac::sHierarchicalSha256Header* hdr = (const nn::hac::sHierarchicalSha256Header*)data; - if (hdr->layer_num.get() != nx::hierarchicalsha256::kDefaultLayerNum) + if (hdr->layer_num.get() != nn::hac::hierarchicalsha256::kDefaultLayerNum) { error_str.clear(); error_str << "Invalid layer count. "; - error_str << "(actual=" << std::dec << hdr->layer_num.get() << ", expected=" << nx::hierarchicalsha256::kDefaultLayerNum << ")"; + error_str << "(actual=" << std::dec << hdr->layer_num.get() << ", expected=" << nn::hac::hierarchicalsha256::kDefaultLayerNum << ")"; throw fnd::Exception(kModuleName, error_str.str()); } @@ -69,44 +69,44 @@ void nx::HierarchicalSha256Header::fromBytes(const byte_t* data, size_t len) } } -const fnd::Vec& nx::HierarchicalSha256Header::getBytes() const +const fnd::Vec& nn::hac::HierarchicalSha256Header::getBytes() const { return mRawBinary; } -void nx::HierarchicalSha256Header::clear() +void nn::hac::HierarchicalSha256Header::clear() { memset(mMasterHash.bytes, 0, sizeof(crypto::sha::sSha256Hash)); mHashBlockSize = 0; mLayerInfo.clear(); } -const crypto::sha::sSha256Hash & nx::HierarchicalSha256Header::getMasterHash() const +const crypto::sha::sSha256Hash & nn::hac::HierarchicalSha256Header::getMasterHash() const { return mMasterHash; } -void nx::HierarchicalSha256Header::setMasterHash(const crypto::sha::sSha256Hash & master_hash) +void nn::hac::HierarchicalSha256Header::setMasterHash(const crypto::sha::sSha256Hash & master_hash) { mMasterHash = master_hash; } -size_t nx::HierarchicalSha256Header::getHashBlockSize() const +size_t nn::hac::HierarchicalSha256Header::getHashBlockSize() const { return mHashBlockSize; } -void nx::HierarchicalSha256Header::setHashBlockSize(size_t hash_block_size) +void nn::hac::HierarchicalSha256Header::setHashBlockSize(size_t hash_block_size) { mHashBlockSize = hash_block_size; } -const fnd::List& nx::HierarchicalSha256Header::getLayerInfo() const +const fnd::List& nn::hac::HierarchicalSha256Header::getLayerInfo() const { return mLayerInfo; } -void nx::HierarchicalSha256Header::setLayerInfo(const fnd::List& layer_info) +void nn::hac::HierarchicalSha256Header::setLayerInfo(const fnd::List& layer_info) { mLayerInfo = layer_info; } \ No newline at end of file diff --git a/lib/libhac/source/InteruptEntry.cpp b/lib/libhac/source/InteruptEntry.cpp index ef07c4f..188de53 100644 --- a/lib/libhac/source/InteruptEntry.cpp +++ b/lib/libhac/source/InteruptEntry.cpp @@ -1,20 +1,20 @@ -#include +#include -nx::InteruptEntry::InteruptEntry() : +nn::hac::InteruptEntry::InteruptEntry() : mCap(kCapId), mInterupt{0,0} { } -nx::InteruptEntry::InteruptEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::InteruptEntry::InteruptEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mInterupt{ 0,0 } { setKernelCapability(kernel_cap); } -nx::InteruptEntry::InteruptEntry(uint32_t interupt0, uint32_t interupt1) : +nn::hac::InteruptEntry::InteruptEntry(uint32_t interupt0, uint32_t interupt1) : mCap(kCapId), mInterupt{ 0,0 } { @@ -22,30 +22,30 @@ nx::InteruptEntry::InteruptEntry(uint32_t interupt0, uint32_t interupt1) : setInterupt(1, interupt1); } -void nx::InteruptEntry::operator=(const InteruptEntry& other) +void nn::hac::InteruptEntry::operator=(const InteruptEntry& other) { mInterupt[0] = other.mInterupt[0]; mInterupt[1] = other.mInterupt[1]; updateCapField(); } -bool nx::InteruptEntry::operator==(const InteruptEntry& other) const +bool nn::hac::InteruptEntry::operator==(const InteruptEntry& other) const { return (mInterupt[0] == other.mInterupt[0]) \ && (mInterupt[1] == other.mInterupt[1]); } -bool nx::InteruptEntry::operator!=(const InteruptEntry& other) const +bool nn::hac::InteruptEntry::operator!=(const InteruptEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::InteruptEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::InteruptEntry::getKernelCapability() const { return mCap; } -void nx::InteruptEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::InteruptEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -56,17 +56,17 @@ void nx::InteruptEntry::setKernelCapability(const KernelCapabilityEntry & kernel processCapField(); } -uint32_t nx::InteruptEntry::operator[](size_t index) const +uint32_t nn::hac::InteruptEntry::operator[](size_t index) const { return getInterupt(index); } -uint32_t nx::InteruptEntry::getInterupt(size_t index) const +uint32_t nn::hac::InteruptEntry::getInterupt(size_t index) const { return mInterupt[index % kInteruptNum]; } -void nx::InteruptEntry::setInterupt(size_t index, uint32_t interupt) +void nn::hac::InteruptEntry::setInterupt(size_t index, uint32_t interupt) { if (interupt > kInteruptMax) { diff --git a/lib/libhac/source/InteruptHandler.cpp b/lib/libhac/source/InteruptHandler.cpp index b2e95f1..421ee19 100644 --- a/lib/libhac/source/InteruptHandler.cpp +++ b/lib/libhac/source/InteruptHandler.cpp @@ -1,28 +1,28 @@ -#include +#include -nx::InteruptHandler::InteruptHandler() : +nn::hac::InteruptHandler::InteruptHandler() : mIsSet(false), mInterupts() {} -void nx::InteruptHandler::operator=(const InteruptHandler & other) +void nn::hac::InteruptHandler::operator=(const InteruptHandler & other) { mIsSet = other.mIsSet; mInterupts = other.mInterupts; } -bool nx::InteruptHandler::operator==(const InteruptHandler & other) const +bool nn::hac::InteruptHandler::operator==(const InteruptHandler & other) const { return (mIsSet == other.mIsSet) \ && (mInterupts == other.mInterupts); } -bool nx::InteruptHandler::operator!=(const InteruptHandler & other) const +bool nn::hac::InteruptHandler::operator!=(const InteruptHandler & other) const { return !(*this == other); } -void nx::InteruptHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::InteruptHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() == 0) return; @@ -58,7 +58,7 @@ void nx::InteruptHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::InteruptHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -84,23 +84,23 @@ void nx::InteruptHandler::exportKernelCapabilityList(fnd::List& nx::InteruptHandler::getInteruptList() const +const fnd::List& nn::hac::InteruptHandler::getInteruptList() const { return mInterupts; } -void nx::InteruptHandler::setInteruptList(const fnd::List& interupts) +void nn::hac::InteruptHandler::setInteruptList(const fnd::List& interupts) { mInterupts.clear(); for (size_t i = 0; i < interupts.size(); i++) diff --git a/lib/libhac/source/KernelCapabilityBinary.cpp b/lib/libhac/source/KernelCapabilityBinary.cpp index 39f7425..71d5eed 100644 --- a/lib/libhac/source/KernelCapabilityBinary.cpp +++ b/lib/libhac/source/KernelCapabilityBinary.cpp @@ -1,14 +1,14 @@ -#include +#include -nx::KernelCapabilityBinary::KernelCapabilityBinary() +nn::hac::KernelCapabilityBinary::KernelCapabilityBinary() {} -nx::KernelCapabilityBinary::KernelCapabilityBinary(const KernelCapabilityBinary & other) +nn::hac::KernelCapabilityBinary::KernelCapabilityBinary(const KernelCapabilityBinary & other) { *this = other; } -void nx::KernelCapabilityBinary::operator=(const KernelCapabilityBinary & other) +void nn::hac::KernelCapabilityBinary::operator=(const KernelCapabilityBinary & other) { clear(); mThreadInfo = other.mThreadInfo; @@ -21,7 +21,7 @@ void nx::KernelCapabilityBinary::operator=(const KernelCapabilityBinary & other) mMiscFlags = other.mMiscFlags; } -bool nx::KernelCapabilityBinary::operator==(const KernelCapabilityBinary & other) const +bool nn::hac::KernelCapabilityBinary::operator==(const KernelCapabilityBinary & other) const { return (mThreadInfo == other.mThreadInfo) \ && (mSystemCalls == other.mSystemCalls) \ @@ -33,12 +33,12 @@ bool nx::KernelCapabilityBinary::operator==(const KernelCapabilityBinary & other && (mMiscFlags == other.mMiscFlags); } -bool nx::KernelCapabilityBinary::operator!=(const KernelCapabilityBinary & other) const +bool nn::hac::KernelCapabilityBinary::operator!=(const KernelCapabilityBinary & other) const { return !(*this == other); } -void nx::KernelCapabilityBinary::toBytes() +void nn::hac::KernelCapabilityBinary::toBytes() { fnd::List caps; @@ -63,7 +63,7 @@ void nx::KernelCapabilityBinary::toBytes() } } -void nx::KernelCapabilityBinary::fromBytes(const byte_t * data, size_t len) +void nn::hac::KernelCapabilityBinary::fromBytes(const byte_t * data, size_t len) { if ((len % sizeof(uint32_t)) != 0) { @@ -131,12 +131,12 @@ void nx::KernelCapabilityBinary::fromBytes(const byte_t * data, size_t len) mMiscFlags.importKernelCapabilityList(miscFlagsCaps); } -const fnd::Vec& nx::KernelCapabilityBinary::getBytes() const +const fnd::Vec& nn::hac::KernelCapabilityBinary::getBytes() const { return mRawBinary; } -void nx::KernelCapabilityBinary::clear() +void nn::hac::KernelCapabilityBinary::clear() { mRawBinary.clear(); mThreadInfo.clear(); @@ -149,82 +149,82 @@ void nx::KernelCapabilityBinary::clear() mMiscFlags.clear(); } -const nx::ThreadInfoHandler & nx::KernelCapabilityBinary::getThreadInfo() const +const nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityBinary::getThreadInfo() const { return mThreadInfo; } -nx::ThreadInfoHandler & nx::KernelCapabilityBinary::getThreadInfo() +nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityBinary::getThreadInfo() { return mThreadInfo; } -const nx::SystemCallHandler & nx::KernelCapabilityBinary::getSystemCalls() const +const nn::hac::SystemCallHandler & nn::hac::KernelCapabilityBinary::getSystemCalls() const { return mSystemCalls; } -nx::SystemCallHandler & nx::KernelCapabilityBinary::getSystemCalls() +nn::hac::SystemCallHandler & nn::hac::KernelCapabilityBinary::getSystemCalls() { return mSystemCalls; } -const nx::MemoryMappingHandler & nx::KernelCapabilityBinary::getMemoryMaps() const +const nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityBinary::getMemoryMaps() const { return mMemoryMap; } -nx::MemoryMappingHandler & nx::KernelCapabilityBinary::getMemoryMaps() +nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityBinary::getMemoryMaps() { return mMemoryMap; } -const nx::InteruptHandler & nx::KernelCapabilityBinary::getInterupts() const +const nn::hac::InteruptHandler & nn::hac::KernelCapabilityBinary::getInterupts() const { return mInterupts; } -nx::InteruptHandler & nx::KernelCapabilityBinary::getInterupts() +nn::hac::InteruptHandler & nn::hac::KernelCapabilityBinary::getInterupts() { return mInterupts; } -const nx::MiscParamsHandler & nx::KernelCapabilityBinary::getMiscParams() const +const nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityBinary::getMiscParams() const { return mMiscParams; } -nx::MiscParamsHandler & nx::KernelCapabilityBinary::getMiscParams() +nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityBinary::getMiscParams() { return mMiscParams; } -const nx::KernelVersionHandler & nx::KernelCapabilityBinary::getKernelVersion() const +const nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityBinary::getKernelVersion() const { return mKernelVersion; } -nx::KernelVersionHandler & nx::KernelCapabilityBinary::getKernelVersion() +nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityBinary::getKernelVersion() { return mKernelVersion; } -const nx::HandleTableSizeHandler & nx::KernelCapabilityBinary::getHandleTableSize() const +const nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityBinary::getHandleTableSize() const { return mHandleTableSize; } -nx::HandleTableSizeHandler & nx::KernelCapabilityBinary::getHandleTableSize() +nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityBinary::getHandleTableSize() { return mHandleTableSize; } -const nx::MiscFlagsHandler & nx::KernelCapabilityBinary::getMiscFlags() const +const nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityBinary::getMiscFlags() const { return mMiscFlags; } -nx::MiscFlagsHandler & nx::KernelCapabilityBinary::getMiscFlags() +nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityBinary::getMiscFlags() { return mMiscFlags; } \ No newline at end of file diff --git a/lib/libhac/source/KernelCapabilityEntry.cpp b/lib/libhac/source/KernelCapabilityEntry.cpp index cbca030..7da3bf1 100644 --- a/lib/libhac/source/KernelCapabilityEntry.cpp +++ b/lib/libhac/source/KernelCapabilityEntry.cpp @@ -1,63 +1,63 @@ -#include +#include -nx::KernelCapabilityEntry::KernelCapabilityEntry() : +nn::hac::KernelCapabilityEntry::KernelCapabilityEntry() : mType(kc::KC_INVALID) {} -nx::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type) : +nn::hac::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type) : mType(type), mField(0) {} -nx::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type, uint32_t field) : +nn::hac::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type, uint32_t field) : mType(type), mField(field) {} -void nx::KernelCapabilityEntry::operator=(const KernelCapabilityEntry & other) +void nn::hac::KernelCapabilityEntry::operator=(const KernelCapabilityEntry & other) { mType = other.mType; mField = other.mField; } -bool nx::KernelCapabilityEntry::operator==(const KernelCapabilityEntry & other) const +bool nn::hac::KernelCapabilityEntry::operator==(const KernelCapabilityEntry & other) const { return (mType == other.mType) \ && (mField == other.mField); } -bool nx::KernelCapabilityEntry::operator!=(const KernelCapabilityEntry & other) const +bool nn::hac::KernelCapabilityEntry::operator!=(const KernelCapabilityEntry & other) const { return !operator==(other); } -uint32_t nx::KernelCapabilityEntry::getCap() const +uint32_t nn::hac::KernelCapabilityEntry::getCap() const { return (mField & getFieldMask()) << getFieldShift() | getCapMask(); } -void nx::KernelCapabilityEntry::setCap(uint32_t cap) +void nn::hac::KernelCapabilityEntry::setCap(uint32_t cap) { mType = getCapId(cap); mField = (cap >> getFieldShift()) & getFieldMask(); } -nx::kc::KernelCapId nx::KernelCapabilityEntry::getType() const +nn::hac::kc::KernelCapId nn::hac::KernelCapabilityEntry::getType() const { return mType; } -void nx::KernelCapabilityEntry::setType(kc::KernelCapId type) +void nn::hac::KernelCapabilityEntry::setType(kc::KernelCapId type) { mType = type; } -uint32_t nx::KernelCapabilityEntry::getField() const +uint32_t nn::hac::KernelCapabilityEntry::getField() const { return mField & getFieldMask(); } -void nx::KernelCapabilityEntry::setField(uint32_t field) +void nn::hac::KernelCapabilityEntry::setField(uint32_t field) { mField = field; } diff --git a/lib/libhac/source/KernelVersionEntry.cpp b/lib/libhac/source/KernelVersionEntry.cpp index efd07ab..98343d5 100644 --- a/lib/libhac/source/KernelVersionEntry.cpp +++ b/lib/libhac/source/KernelVersionEntry.cpp @@ -1,12 +1,12 @@ -#include +#include -nx::KernelVersionEntry::KernelVersionEntry() : +nn::hac::KernelVersionEntry::KernelVersionEntry() : mCap(kCapId), mVerMajor(0), mVerMinor(0) {} -nx::KernelVersionEntry::KernelVersionEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::KernelVersionEntry::KernelVersionEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mVerMajor(0), mVerMinor(0) @@ -14,7 +14,7 @@ nx::KernelVersionEntry::KernelVersionEntry(const KernelCapabilityEntry & kernel_ setKernelCapability(kernel_cap); } -nx::KernelVersionEntry::KernelVersionEntry(uint16_t major, uint8_t minor) : +nn::hac::KernelVersionEntry::KernelVersionEntry(uint16_t major, uint8_t minor) : mCap(kCapId), mVerMajor(0), mVerMinor(0) @@ -23,30 +23,30 @@ nx::KernelVersionEntry::KernelVersionEntry(uint16_t major, uint8_t minor) : setVerMinor(minor); } -void nx::KernelVersionEntry::operator=(const KernelVersionEntry& other) +void nn::hac::KernelVersionEntry::operator=(const KernelVersionEntry& other) { mVerMajor = other.mVerMajor; mVerMinor = other.mVerMinor; updateCapField(); } -bool nx::KernelVersionEntry::operator==(const KernelVersionEntry& other) const +bool nn::hac::KernelVersionEntry::operator==(const KernelVersionEntry& other) const { return (mVerMajor == other.mVerMajor) \ && (mVerMinor == other.mVerMinor); } -bool nx::KernelVersionEntry::operator!=(const KernelVersionEntry& other) const +bool nn::hac::KernelVersionEntry::operator!=(const KernelVersionEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::KernelVersionEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::KernelVersionEntry::getKernelCapability() const { return mCap; } -void nx::KernelVersionEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::KernelVersionEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -57,12 +57,12 @@ void nx::KernelVersionEntry::setKernelCapability(const KernelCapabilityEntry & k processCapField(); } -uint16_t nx::KernelVersionEntry::getVerMajor() const +uint16_t nn::hac::KernelVersionEntry::getVerMajor() const { return mVerMajor; } -void nx::KernelVersionEntry::setVerMajor(uint16_t major) +void nn::hac::KernelVersionEntry::setVerMajor(uint16_t major) { if (major > kVerMajorMax) { @@ -73,12 +73,12 @@ void nx::KernelVersionEntry::setVerMajor(uint16_t major) updateCapField(); } -uint8_t nx::KernelVersionEntry::getVerMinor() const +uint8_t nn::hac::KernelVersionEntry::getVerMinor() const { return mVerMinor; } -void nx::KernelVersionEntry::setVerMinor(uint8_t minor) +void nn::hac::KernelVersionEntry::setVerMinor(uint8_t minor) { if (minor > kVerMinorMax) { diff --git a/lib/libhac/source/KernelVersionHandler.cpp b/lib/libhac/source/KernelVersionHandler.cpp index ee3e960..580fa6f 100644 --- a/lib/libhac/source/KernelVersionHandler.cpp +++ b/lib/libhac/source/KernelVersionHandler.cpp @@ -1,28 +1,28 @@ -#include +#include -nx::KernelVersionHandler::KernelVersionHandler() : +nn::hac::KernelVersionHandler::KernelVersionHandler() : mIsSet(false), mEntry(0,0) {} -void nx::KernelVersionHandler::operator=(const KernelVersionHandler & other) +void nn::hac::KernelVersionHandler::operator=(const KernelVersionHandler & other) { mIsSet = other.mIsSet; mEntry.setKernelCapability(other.mEntry.getKernelCapability()); } -bool nx::KernelVersionHandler::operator==(const KernelVersionHandler & other) const +bool nn::hac::KernelVersionHandler::operator==(const KernelVersionHandler & other) const { return (mIsSet == other.mIsSet) \ && (mEntry.getKernelCapability() == other.mEntry.getKernelCapability()); } -bool nx::KernelVersionHandler::operator!=(const KernelVersionHandler & other) const +bool nn::hac::KernelVersionHandler::operator!=(const KernelVersionHandler & other) const { return !(*this == other); } -void nx::KernelVersionHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::KernelVersionHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() > kMaxKernelCapNum) { @@ -37,7 +37,7 @@ void nx::KernelVersionHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::KernelVersionHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -45,35 +45,35 @@ void nx::KernelVersionHandler::exportKernelCapabilityList(fnd::List -#include +#include +#include -nx::MemoryMappingHandler::MemoryMappingHandler() : +nn::hac::MemoryMappingHandler::MemoryMappingHandler() : mIsSet(false) {} -void nx::MemoryMappingHandler::operator=(const MemoryMappingHandler & other) +void nn::hac::MemoryMappingHandler::operator=(const MemoryMappingHandler & other) { mIsSet = other.mIsSet; mMemRange = other.mMemRange; mMemPage = other.mMemPage; } -bool nx::MemoryMappingHandler::operator==(const MemoryMappingHandler & other) const +bool nn::hac::MemoryMappingHandler::operator==(const MemoryMappingHandler & other) const { return (mIsSet == other.mIsSet) \ && (mMemRange == other.mMemRange) \ && (mMemPage == other.mMemPage); } -bool nx::MemoryMappingHandler::operator!=(const MemoryMappingHandler & other) const +bool nn::hac::MemoryMappingHandler::operator!=(const MemoryMappingHandler & other) const { return !(*this == other); } -void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::MemoryMappingHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() == 0) return; @@ -87,7 +87,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::MemoryMappingHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -116,24 +116,24 @@ void nx::MemoryMappingHandler::exportKernelCapabilityList(fnd::List& nx::MemoryMappingHandler::getMemoryMaps() const +const fnd::List& nn::hac::MemoryMappingHandler::getMemoryMaps() const { return mMemRange; } -const fnd::List& nx::MemoryMappingHandler::getIoMemoryMaps() const +const fnd::List& nn::hac::MemoryMappingHandler::getIoMemoryMaps() const { return mMemPage; } \ No newline at end of file diff --git a/lib/libhac/source/MemoryPageEntry.cpp b/lib/libhac/source/MemoryPageEntry.cpp index 3b068e6..2277c09 100644 --- a/lib/libhac/source/MemoryPageEntry.cpp +++ b/lib/libhac/source/MemoryPageEntry.cpp @@ -1,13 +1,13 @@ -#include +#include -nx::MemoryPageEntry::MemoryPageEntry() : +nn::hac::MemoryPageEntry::MemoryPageEntry() : mCap(kc::KC_INVALID), mPage(0), mFlag(false), mUseFlag(false) {} -nx::MemoryPageEntry::MemoryPageEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::MemoryPageEntry::MemoryPageEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kc::KC_INVALID), mPage(0), mFlag(false), @@ -16,7 +16,7 @@ nx::MemoryPageEntry::MemoryPageEntry(const KernelCapabilityEntry & kernel_cap) : setKernelCapability(kernel_cap); } -nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) : +nn::hac::MemoryPageEntry::MemoryPageEntry(uint32_t page) : mCap(kc::KC_INVALID), mPage(0), mFlag(false), @@ -25,7 +25,7 @@ nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) : setPage(page); } -nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) : +nn::hac::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) : mCap(kc::KC_INVALID), mPage(0), mFlag(false), @@ -35,7 +35,7 @@ nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) : setFlag(flag); } -void nx::MemoryPageEntry::operator=(const MemoryPageEntry& other) +void nn::hac::MemoryPageEntry::operator=(const MemoryPageEntry& other) { mPage = other.mPage; mFlag = other.mFlag; @@ -43,24 +43,24 @@ void nx::MemoryPageEntry::operator=(const MemoryPageEntry& other) updateCapField(); } -bool nx::MemoryPageEntry::operator==(const MemoryPageEntry& other) const +bool nn::hac::MemoryPageEntry::operator==(const MemoryPageEntry& other) const { return (mPage == other.mPage) \ && (mFlag == other.mFlag) \ && (mUseFlag == other.mUseFlag); } -bool nx::MemoryPageEntry::operator!=(const MemoryPageEntry& other) const +bool nn::hac::MemoryPageEntry::operator!=(const MemoryPageEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::MemoryPageEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::MemoryPageEntry::getKernelCapability() const { return mCap; } -void nx::MemoryPageEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::MemoryPageEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kc::KC_MEMORY_MAP && kernel_cap.getType() != kc::KC_IO_MEMORY_MAP) { @@ -71,12 +71,12 @@ void nx::MemoryPageEntry::setKernelCapability(const KernelCapabilityEntry & kern processCapField(); } -uint32_t nx::MemoryPageEntry::getPage() const +uint32_t nn::hac::MemoryPageEntry::getPage() const { return mPage; } -void nx::MemoryPageEntry::setPage(uint32_t page) +void nn::hac::MemoryPageEntry::setPage(uint32_t page) { if (page > kMaxPage) { @@ -87,23 +87,23 @@ void nx::MemoryPageEntry::setPage(uint32_t page) updateCapField(); } -bool nx::MemoryPageEntry::getFlag() const +bool nn::hac::MemoryPageEntry::getFlag() const { return mFlag; } -void nx::MemoryPageEntry::setFlag(bool flag) +void nn::hac::MemoryPageEntry::setFlag(bool flag) { mFlag = flag; updateCapField(); } -bool nx::MemoryPageEntry::isMultiplePages() const +bool nn::hac::MemoryPageEntry::isMultiplePages() const { return mUseFlag; } -void nx::MemoryPageEntry::setMapMultiplePages(bool useFlag) +void nn::hac::MemoryPageEntry::setMapMultiplePages(bool useFlag) { mUseFlag = useFlag; } diff --git a/lib/libhac/source/MiscFlagsEntry.cpp b/lib/libhac/source/MiscFlagsEntry.cpp index f0ac787..fe100ef 100644 --- a/lib/libhac/source/MiscFlagsEntry.cpp +++ b/lib/libhac/source/MiscFlagsEntry.cpp @@ -1,46 +1,46 @@ -#include +#include -nx::MiscFlagsEntry::MiscFlagsEntry() : +nn::hac::MiscFlagsEntry::MiscFlagsEntry() : mCap(kCapId), mFlags(0) {} -nx::MiscFlagsEntry::MiscFlagsEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::MiscFlagsEntry::MiscFlagsEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mFlags(0) { setKernelCapability(kernel_cap); } -nx::MiscFlagsEntry::MiscFlagsEntry(uint32_t flags) : +nn::hac::MiscFlagsEntry::MiscFlagsEntry(uint32_t flags) : mCap(kCapId), mFlags(0) { setFlags(flags); } -void nx::MiscFlagsEntry::operator=(const MiscFlagsEntry& other) +void nn::hac::MiscFlagsEntry::operator=(const MiscFlagsEntry& other) { mFlags = other.mFlags; updateCapField(); } -bool nx::MiscFlagsEntry::operator==(const MiscFlagsEntry& other) const +bool nn::hac::MiscFlagsEntry::operator==(const MiscFlagsEntry& other) const { return (mFlags == other.mFlags); } -bool nx::MiscFlagsEntry::operator!=(const MiscFlagsEntry& other) const +bool nn::hac::MiscFlagsEntry::operator!=(const MiscFlagsEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::MiscFlagsEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::MiscFlagsEntry::getKernelCapability() const { return mCap; } -void nx::MiscFlagsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::MiscFlagsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -51,12 +51,12 @@ void nx::MiscFlagsEntry::setKernelCapability(const KernelCapabilityEntry & kerne processCapField(); } -uint32_t nx::MiscFlagsEntry::getFlags() const +uint32_t nn::hac::MiscFlagsEntry::getFlags() const { return mFlags; } -void nx::MiscFlagsEntry::setFlags(uint32_t flags) +void nn::hac::MiscFlagsEntry::setFlags(uint32_t flags) { if ((flags & ~kMaxVal) != 0) { diff --git a/lib/libhac/source/MiscFlagsHandler.cpp b/lib/libhac/source/MiscFlagsHandler.cpp index d608b4b..bb9a961 100644 --- a/lib/libhac/source/MiscFlagsHandler.cpp +++ b/lib/libhac/source/MiscFlagsHandler.cpp @@ -1,27 +1,27 @@ -#include +#include -nx::MiscFlagsHandler::MiscFlagsHandler() : +nn::hac::MiscFlagsHandler::MiscFlagsHandler() : mIsSet(false) {} -void nx::MiscFlagsHandler::operator=(const MiscFlagsHandler & other) +void nn::hac::MiscFlagsHandler::operator=(const MiscFlagsHandler & other) { mIsSet = other.mIsSet; mFlags = other.mFlags; } -bool nx::MiscFlagsHandler::operator==(const MiscFlagsHandler & other) const +bool nn::hac::MiscFlagsHandler::operator==(const MiscFlagsHandler & other) const { return (mIsSet == other.mIsSet) \ && (mFlags == other.mFlags); } -bool nx::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const +bool nn::hac::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const { return !(*this == other); } -void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::MiscFlagsHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() > kMaxKernelCapNum) { @@ -46,7 +46,7 @@ void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::MiscFlagsHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -66,23 +66,23 @@ void nx::MiscFlagsHandler::exportKernelCapabilityList(fnd::List& nx::MiscFlagsHandler::getFlagList() const +const fnd::List& nn::hac::MiscFlagsHandler::getFlagList() const { return mFlags; } -void nx::MiscFlagsHandler::setFlagList(fnd::List flags) +void nn::hac::MiscFlagsHandler::setFlagList(fnd::List flags) { mFlags = flags; mIsSet = true; diff --git a/lib/libhac/source/MiscParamsEntry.cpp b/lib/libhac/source/MiscParamsEntry.cpp index 28af0df..f9a14cb 100644 --- a/lib/libhac/source/MiscParamsEntry.cpp +++ b/lib/libhac/source/MiscParamsEntry.cpp @@ -1,46 +1,46 @@ -#include +#include -nx::MiscParamsEntry::MiscParamsEntry() : +nn::hac::MiscParamsEntry::MiscParamsEntry() : mCap(kCapId), mProgramType(0) {} -nx::MiscParamsEntry::MiscParamsEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::MiscParamsEntry::MiscParamsEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mProgramType(0) { setKernelCapability(kernel_cap); } -nx::MiscParamsEntry::MiscParamsEntry(uint8_t program_type) : +nn::hac::MiscParamsEntry::MiscParamsEntry(uint8_t program_type) : mCap(kCapId), mProgramType(0) { setProgramType(program_type); } -void nx::MiscParamsEntry::operator=(const MiscParamsEntry& other) +void nn::hac::MiscParamsEntry::operator=(const MiscParamsEntry& other) { mProgramType = other.mProgramType; updateCapField(); } -bool nx::MiscParamsEntry::operator==(const MiscParamsEntry& other) const +bool nn::hac::MiscParamsEntry::operator==(const MiscParamsEntry& other) const { return (mProgramType == other.mProgramType); } -bool nx::MiscParamsEntry::operator!=(const MiscParamsEntry& other) const +bool nn::hac::MiscParamsEntry::operator!=(const MiscParamsEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::MiscParamsEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::MiscParamsEntry::getKernelCapability() const { return mCap; } -void nx::MiscParamsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::MiscParamsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -51,12 +51,12 @@ void nx::MiscParamsEntry::setKernelCapability(const KernelCapabilityEntry & kern processCapField(); } -uint8_t nx::MiscParamsEntry::getProgramType() const +uint8_t nn::hac::MiscParamsEntry::getProgramType() const { return mProgramType; } -void nx::MiscParamsEntry::setProgramType(uint8_t type) +void nn::hac::MiscParamsEntry::setProgramType(uint8_t type) { if (type > kMaxProgramType) { diff --git a/lib/libhac/source/MiscParamsHandler.cpp b/lib/libhac/source/MiscParamsHandler.cpp index 3d59650..d7bc863 100644 --- a/lib/libhac/source/MiscParamsHandler.cpp +++ b/lib/libhac/source/MiscParamsHandler.cpp @@ -1,28 +1,28 @@ -#include +#include -nx::MiscParamsHandler::MiscParamsHandler() : +nn::hac::MiscParamsHandler::MiscParamsHandler() : mIsSet(false), mEntry(0) {} -void nx::MiscParamsHandler::operator=(const MiscParamsHandler & other) +void nn::hac::MiscParamsHandler::operator=(const MiscParamsHandler & other) { mIsSet = other.mIsSet; mEntry.setKernelCapability(other.mEntry.getKernelCapability()); } -bool nx::MiscParamsHandler::operator==(const MiscParamsHandler & other) const +bool nn::hac::MiscParamsHandler::operator==(const MiscParamsHandler & other) const { return (mIsSet == other.mIsSet) \ && (mEntry.getKernelCapability() == other.mEntry.getKernelCapability()); } -bool nx::MiscParamsHandler::operator!=(const MiscParamsHandler & other) const +bool nn::hac::MiscParamsHandler::operator!=(const MiscParamsHandler & other) const { return !(*this == other); } -void nx::MiscParamsHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::MiscParamsHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() > kMaxKernelCapNum) { @@ -37,7 +37,7 @@ void nx::MiscParamsHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::MiscParamsHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -45,23 +45,23 @@ void nx::MiscParamsHandler::exportKernelCapabilityList(fnd::List +#include -nx::NcaHeader::NcaHeader() +nn::hac::NcaHeader::NcaHeader() { clear(); } -nx::NcaHeader::NcaHeader(const NcaHeader & other) +nn::hac::NcaHeader::NcaHeader(const NcaHeader & other) { *this = other; } -bool nx::NcaHeader::operator==(const NcaHeader & other) const +bool nn::hac::NcaHeader::operator==(const NcaHeader & other) const { return (mDistributionType == other.mDistributionType) \ && (mContentType == other.mContentType) \ @@ -24,12 +24,12 @@ bool nx::NcaHeader::operator==(const NcaHeader & other) const && (mEncAesKeys == other.mEncAesKeys); } -bool nx::NcaHeader::operator!=(const NcaHeader & other) const +bool nn::hac::NcaHeader::operator!=(const NcaHeader & other) const { return !(*this == other); } -void nx::NcaHeader::operator=(const NcaHeader & other) +void nn::hac::NcaHeader::operator=(const NcaHeader & other) { if (other.getBytes().size()) { @@ -51,7 +51,7 @@ void nx::NcaHeader::operator=(const NcaHeader & other) } } -void nx::NcaHeader::toBytes() +void nn::hac::NcaHeader::toBytes() { mRawBinary.alloc(sizeof(sNcaHeader)); sNcaHeader* hdr = (sNcaHeader*)mRawBinary.data(); @@ -108,7 +108,7 @@ void nx::NcaHeader::toBytes() } } -void nx::NcaHeader::fromBytes(const byte_t * data, size_t len) +void nn::hac::NcaHeader::fromBytes(const byte_t * data, size_t len) { if (len < sizeof(sNcaHeader)) { @@ -158,12 +158,12 @@ void nx::NcaHeader::fromBytes(const byte_t * data, size_t len) } } -const fnd::Vec& nx::NcaHeader::getBytes() const +const fnd::Vec& nn::hac::NcaHeader::getBytes() const { return mRawBinary; } -void nx::NcaHeader::clear() +void nn::hac::NcaHeader::clear() { mFormatVersion = NCA3_FORMAT; mDistributionType = nca::DIST_DOWNLOAD; @@ -179,97 +179,97 @@ void nx::NcaHeader::clear() mEncAesKeys.clear(); } -nx::NcaHeader::FormatVersion nx::NcaHeader::getFormatVersion() const +nn::hac::NcaHeader::FormatVersion nn::hac::NcaHeader::getFormatVersion() const { return mFormatVersion; } -void nx::NcaHeader::setFormatVersion(FormatVersion version) +void nn::hac::NcaHeader::setFormatVersion(FormatVersion version) { mFormatVersion = version; } -nx::nca::DistributionType nx::NcaHeader::getDistributionType() const +nn::hac::nca::DistributionType nn::hac::NcaHeader::getDistributionType() const { return mDistributionType; } -void nx::NcaHeader::setDistributionType(nca::DistributionType type) +void nn::hac::NcaHeader::setDistributionType(nca::DistributionType type) { mDistributionType = type; } -nx::nca::ContentType nx::NcaHeader::getContentType() const +nn::hac::nca::ContentType nn::hac::NcaHeader::getContentType() const { return mContentType; } -void nx::NcaHeader::setContentType(nca::ContentType type) +void nn::hac::NcaHeader::setContentType(nca::ContentType type) { mContentType = type; } -byte_t nx::NcaHeader::getKeyGeneration() const +byte_t nn::hac::NcaHeader::getKeyGeneration() const { return mKeyGeneration; } -void nx::NcaHeader::setKeyGeneration(byte_t gen) +void nn::hac::NcaHeader::setKeyGeneration(byte_t gen) { mKeyGeneration = gen; } -byte_t nx::NcaHeader::getKaekIndex() const +byte_t nn::hac::NcaHeader::getKaekIndex() const { return mKaekIndex; } -void nx::NcaHeader::setKaekIndex(byte_t index) +void nn::hac::NcaHeader::setKaekIndex(byte_t index) { mKaekIndex = index; } -uint64_t nx::NcaHeader::getContentSize() const +uint64_t nn::hac::NcaHeader::getContentSize() const { return mContentSize; } -void nx::NcaHeader::setContentSize(uint64_t size) +void nn::hac::NcaHeader::setContentSize(uint64_t size) { mContentSize = size; } -uint64_t nx::NcaHeader::getProgramId() const +uint64_t nn::hac::NcaHeader::getProgramId() const { return mProgramId; } -void nx::NcaHeader::setProgramId(uint64_t program_id) +void nn::hac::NcaHeader::setProgramId(uint64_t program_id) { mProgramId = program_id; } -uint32_t nx::NcaHeader::getContentIndex() const +uint32_t nn::hac::NcaHeader::getContentIndex() const { return mContentIndex; } -void nx::NcaHeader::setContentIndex(uint32_t index) +void nn::hac::NcaHeader::setContentIndex(uint32_t index) { mContentIndex = index; } -uint32_t nx::NcaHeader::getSdkAddonVersion() const +uint32_t nn::hac::NcaHeader::getSdkAddonVersion() const { return mSdkAddonVersion; } -void nx::NcaHeader::setSdkAddonVersion(uint32_t version) +void nn::hac::NcaHeader::setSdkAddonVersion(uint32_t version) { mSdkAddonVersion = version; } -bool nx::NcaHeader::hasRightsId() const +bool nn::hac::NcaHeader::hasRightsId() const { bool rightsIdIsSet = false; @@ -282,22 +282,22 @@ bool nx::NcaHeader::hasRightsId() const return rightsIdIsSet; } -const byte_t* nx::NcaHeader::getRightsId() const +const byte_t* nn::hac::NcaHeader::getRightsId() const { return mRightsId; } -void nx::NcaHeader::setRightsId(const byte_t* rights_id) +void nn::hac::NcaHeader::setRightsId(const byte_t* rights_id) { memcpy(mRightsId, rights_id, nca::kRightsIdLen); } -const fnd::List& nx::NcaHeader::getPartitions() const +const fnd::List& nn::hac::NcaHeader::getPartitions() const { return mPartitions; } -void nx::NcaHeader::setPartitions(const fnd::List& partitions) +void nn::hac::NcaHeader::setPartitions(const fnd::List& partitions) { mPartitions = partitions; if (mPartitions.size() >= nca::kPartitionNum) @@ -306,22 +306,22 @@ void nx::NcaHeader::setPartitions(const fnd::List& pa } } -const fnd::List& nx::NcaHeader::getEncAesKeys() const +const fnd::List& nn::hac::NcaHeader::getEncAesKeys() const { return mEncAesKeys; } -void nx::NcaHeader::setEncAesKeys(const fnd::List& keys) +void nn::hac::NcaHeader::setEncAesKeys(const fnd::List& keys) { mEncAesKeys = keys; } -uint64_t nx::NcaHeader::blockNumToSize(uint32_t block_num) const +uint64_t nn::hac::NcaHeader::blockNumToSize(uint32_t block_num) const { return block_num*nca::kSectorSize; } -uint32_t nx::NcaHeader::sizeToBlockNum(uint64_t real_size) const +uint32_t nn::hac::NcaHeader::sizeToBlockNum(uint64_t real_size) const { return (uint32_t)(align(real_size, nca::kSectorSize) / nca::kSectorSize); } \ No newline at end of file diff --git a/lib/libhac/source/NcaUtils.cpp b/lib/libhac/source/NcaUtils.cpp index 5ec75c2..12f78c1 100644 --- a/lib/libhac/source/NcaUtils.cpp +++ b/lib/libhac/source/NcaUtils.cpp @@ -1,25 +1,25 @@ -#include +#include -void nx::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key) +void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key) { byte_t tweak[crypto::aes::kAesBlockSize]; // decrypt main header - byte_t raw_hdr[nx::nca::kSectorSize]; + byte_t raw_hdr[nn::hac::nca::kSectorSize]; crypto::aes::AesXtsMakeTweak(tweak, 1); - crypto::aes::AesXtsDecryptSector(src + sectorToOffset(1), nx::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr); + crypto::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr); - bool useNca2SectorIndex = ((nx::sNcaHeader*)(raw_hdr))->st_magic.get() == nx::nca::kNca2StructMagic; + bool useNca2SectorIndex = ((nn::hac::sNcaHeader*)(raw_hdr))->st_magic.get() == nn::hac::nca::kNca2StructMagic; // decrypt whole header - for (size_t i = 0; i < nx::nca::kHeaderSectorNum; i++) + for (size_t i = 0; i < nn::hac::nca::kHeaderSectorNum; i++) { crypto::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i); - crypto::aes::AesXtsDecryptSector(src + sectorToOffset(i), nx::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i)); + crypto::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i)); } } -byte_t nx::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation) +byte_t nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation) { byte_t masterkey_rev; @@ -48,7 +48,7 @@ byte_t nx::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation return masterkey_rev; } -void nx::NcaUtils::getNcaPartitionAesCtr(const nx::sNcaFsHeader* hdr, byte_t* ctr) +void nn::hac::NcaUtils::getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr) { for (size_t i = 0; i < 8; i++) { diff --git a/lib/libhac/source/NpdmBinary.cpp b/lib/libhac/source/NpdmBinary.cpp index 0d88e53..716cc08 100644 --- a/lib/libhac/source/NpdmBinary.cpp +++ b/lib/libhac/source/NpdmBinary.cpp @@ -1,19 +1,19 @@ -#include +#include #include -nx::NpdmBinary::NpdmBinary() +nn::hac::NpdmBinary::NpdmBinary() { clear(); } -nx::NpdmBinary::NpdmBinary(const NpdmBinary & other) : +nn::hac::NpdmBinary::NpdmBinary(const NpdmBinary & other) : NpdmBinary() { *this = other; } -void nx::NpdmBinary::operator=(const NpdmBinary & other) +void nn::hac::NpdmBinary::operator=(const NpdmBinary & other) { mRawBinary = other.mRawBinary; mInstructionType = other.mInstructionType; @@ -28,7 +28,7 @@ void nx::NpdmBinary::operator=(const NpdmBinary & other) mAcid = other.mAcid; } -bool nx::NpdmBinary::operator==(const NpdmBinary & other) const +bool nn::hac::NpdmBinary::operator==(const NpdmBinary & other) const { return (mInstructionType == other.mInstructionType) \ && (mProcAddressSpaceType == other.mProcAddressSpaceType) \ @@ -42,12 +42,12 @@ bool nx::NpdmBinary::operator==(const NpdmBinary & other) const && (mAcid == other.mAcid); } -bool nx::NpdmBinary::operator!=(const NpdmBinary & other) const +bool nn::hac::NpdmBinary::operator!=(const NpdmBinary & other) const { return !(*this == other); } -void nx::NpdmBinary::toBytes() +void nn::hac::NpdmBinary::toBytes() { if (mAcid.getBytes().size() == 0) mAcid.toBytes(); @@ -103,7 +103,7 @@ void nx::NpdmBinary::toBytes() } } -void nx::NpdmBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::NpdmBinary::fromBytes(const byte_t* data, size_t len) { // check size if (len < sizeof(sNpdmHeader)) @@ -167,12 +167,12 @@ void nx::NpdmBinary::fromBytes(const byte_t* data, size_t len) } } -const fnd::Vec& nx::NpdmBinary::getBytes() const +const fnd::Vec& nn::hac::NpdmBinary::getBytes() const { return mRawBinary; } -void nx::NpdmBinary::clear() +void nn::hac::NpdmBinary::clear() { mRawBinary.clear(); mInstructionType = npdm::INSTR_64BIT; @@ -187,32 +187,32 @@ void nx::NpdmBinary::clear() mAcid.clear(); } -nx::npdm::InstructionType nx::NpdmBinary::getInstructionType() const +nn::hac::npdm::InstructionType nn::hac::NpdmBinary::getInstructionType() const { return mInstructionType; } -void nx::NpdmBinary::setInstructionType(npdm::InstructionType type) +void nn::hac::NpdmBinary::setInstructionType(npdm::InstructionType type) { mInstructionType = type; } -nx::npdm::ProcAddrSpaceType nx::NpdmBinary::getProcAddressSpaceType() const +nn::hac::npdm::ProcAddrSpaceType nn::hac::NpdmBinary::getProcAddressSpaceType() const { return mProcAddressSpaceType; } -void nx::NpdmBinary::setProcAddressSpaceType(npdm::ProcAddrSpaceType type) +void nn::hac::NpdmBinary::setProcAddressSpaceType(npdm::ProcAddrSpaceType type) { mProcAddressSpaceType = type; } -byte_t nx::NpdmBinary::getMainThreadPriority() const +byte_t nn::hac::NpdmBinary::getMainThreadPriority() const { return mMainThreadPriority; } -void nx::NpdmBinary::setMainThreadPriority(byte_t priority) +void nn::hac::NpdmBinary::setMainThreadPriority(byte_t priority) { if (priority > npdm::kMaxPriority) { @@ -222,42 +222,42 @@ void nx::NpdmBinary::setMainThreadPriority(byte_t priority) mMainThreadPriority = priority; } -byte_t nx::NpdmBinary::getMainThreadCpuId() const +byte_t nn::hac::NpdmBinary::getMainThreadCpuId() const { return mMainThreadCpuId; } -void nx::NpdmBinary::setMainThreadCpuId(byte_t core_num) +void nn::hac::NpdmBinary::setMainThreadCpuId(byte_t core_num) { mMainThreadCpuId = core_num; } -uint32_t nx::NpdmBinary::getVersion() const +uint32_t nn::hac::NpdmBinary::getVersion() const { return mVersion; } -void nx::NpdmBinary::setVersion(uint32_t version) +void nn::hac::NpdmBinary::setVersion(uint32_t version) { mVersion = version; } -uint32_t nx::NpdmBinary::getMainThreadStackSize() const +uint32_t nn::hac::NpdmBinary::getMainThreadStackSize() const { return mMainThreadStackSize; } -void nx::NpdmBinary::setMainThreadStackSize(uint32_t size) +void nn::hac::NpdmBinary::setMainThreadStackSize(uint32_t size) { mMainThreadStackSize = size; } -const std::string & nx::NpdmBinary::getName() const +const std::string & nn::hac::NpdmBinary::getName() const { return mName; } -void nx::NpdmBinary::setName(const std::string & name) +void nn::hac::NpdmBinary::setName(const std::string & name) { if (name.length() > npdm::kNameMaxLen) { @@ -267,12 +267,12 @@ void nx::NpdmBinary::setName(const std::string & name) mName = name; } -const std::string & nx::NpdmBinary::getProductCode() const +const std::string & nn::hac::NpdmBinary::getProductCode() const { return mProductCode; } -void nx::NpdmBinary::setProductCode(const std::string & product_code) +void nn::hac::NpdmBinary::setProductCode(const std::string & product_code) { if (product_code.length() > npdm::kProductCodeMaxLen) { @@ -282,22 +282,22 @@ void nx::NpdmBinary::setProductCode(const std::string & product_code) mProductCode = product_code; } -const nx::AccessControlInfoBinary & nx::NpdmBinary::getAci() const +const nn::hac::AccessControlInfoBinary & nn::hac::NpdmBinary::getAci() const { return mAci; } -void nx::NpdmBinary::setAci(const AccessControlInfoBinary & aci) +void nn::hac::NpdmBinary::setAci(const AccessControlInfoBinary & aci) { mAci = aci; } -const nx::AccessControlInfoDescBinary & nx::NpdmBinary::getAcid() const +const nn::hac::AccessControlInfoDescBinary & nn::hac::NpdmBinary::getAcid() const { return mAcid; } -void nx::NpdmBinary::setAcid(const AccessControlInfoDescBinary & acid) +void nn::hac::NpdmBinary::setAcid(const AccessControlInfoDescBinary & acid) { mAcid = acid; } \ No newline at end of file diff --git a/lib/libhac/source/NroHeader.cpp b/lib/libhac/source/NroHeader.cpp index dfd2ba3..40f8d21 100644 --- a/lib/libhac/source/NroHeader.cpp +++ b/lib/libhac/source/NroHeader.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::NroHeader::NroHeader() +nn::hac::NroHeader::NroHeader() { clear(); } -nx::NroHeader::NroHeader(const NroHeader& other) +nn::hac::NroHeader::NroHeader(const NroHeader& other) { *this = other; } -void nx::NroHeader::operator=(const NroHeader& other) +void nn::hac::NroHeader::operator=(const NroHeader& other) { clear(); mRoCrt = other.mRoCrt; @@ -26,7 +26,7 @@ void nx::NroHeader::operator=(const NroHeader& other) mRoDynSymInfo = other.mRoDynSymInfo; } -bool nx::NroHeader::operator==(const NroHeader& other) const +bool nn::hac::NroHeader::operator==(const NroHeader& other) const { return (mRoCrt == other.mRoCrt) \ && (mNroSize == other.mNroSize) \ @@ -41,15 +41,15 @@ bool nx::NroHeader::operator==(const NroHeader& other) const && (mRoDynSymInfo == other.mRoDynSymInfo); } -bool nx::NroHeader::operator!=(const NroHeader& other) const +bool nn::hac::NroHeader::operator!=(const NroHeader& other) const { return !(*this == other); } -void nx::NroHeader::toBytes() +void nn::hac::NroHeader::toBytes() { mRawBinary.alloc(sizeof(sNroHeader)); - nx::sNroHeader* hdr = (nx::sNroHeader*)mRawBinary.data(); + nn::hac::sNroHeader* hdr = (nn::hac::sNroHeader*)mRawBinary.data(); // set header identifers hdr->st_magic = nro::kNroStructMagic; @@ -93,7 +93,7 @@ void nx::NroHeader::toBytes() hdr->dyn_sym.size = mRoDynSymInfo.size; } -void nx::NroHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::NroHeader::fromBytes(const byte_t* data, size_t len) { // check input data size if (len < sizeof(sNroHeader)) @@ -109,7 +109,7 @@ void nx::NroHeader::fromBytes(const byte_t* data, size_t len) memcpy(mRawBinary.data(), data, mRawBinary.size()); // get sNroHeader ptr - const nx::sNroHeader* hdr = (const nx::sNroHeader*)mRawBinary.data(); + const nn::hac::sNroHeader* hdr = (const nn::hac::sNroHeader*)mRawBinary.data(); // check NRO signature if (hdr->st_magic.get() != nro::kNroStructMagic) @@ -150,12 +150,12 @@ void nx::NroHeader::fromBytes(const byte_t* data, size_t len) mRoDynSymInfo.size = hdr->dyn_sym.size.get(); } -const fnd::Vec& nx::NroHeader::getBytes() const +const fnd::Vec& nn::hac::NroHeader::getBytes() const { return mRawBinary; } -void nx::NroHeader::clear() +void nn::hac::NroHeader::clear() { mRawBinary.clear(); memset(&mRoCrt, 0, sizeof(mRoCrt)); @@ -169,102 +169,102 @@ void nx::NroHeader::clear() memset(&mRoDynSymInfo, 0, sizeof(mRoDynSymInfo)); } -const nx::NroHeader::sRoCrt& nx::NroHeader::getRoCrt() const +const nn::hac::NroHeader::sRoCrt& nn::hac::NroHeader::getRoCrt() const { return mRoCrt; } -void nx::NroHeader::setRoCrt(const sRoCrt& ro_crt) +void nn::hac::NroHeader::setRoCrt(const sRoCrt& ro_crt) { mRoCrt = ro_crt; } -uint32_t nx::NroHeader::getNroSize() const +uint32_t nn::hac::NroHeader::getNroSize() const { return mNroSize; } -void nx::NroHeader::setNroSize(uint32_t size) +void nn::hac::NroHeader::setNroSize(uint32_t size) { mNroSize = size; } -const nx::NroHeader::sSection& nx::NroHeader::getTextInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getTextInfo() const { return mTextInfo; } -void nx::NroHeader::setTextInfo(const sSection& info) +void nn::hac::NroHeader::setTextInfo(const sSection& info) { mTextInfo = info; } -const nx::NroHeader::sSection& nx::NroHeader::getRoInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getRoInfo() const { return mRoInfo; } -void nx::NroHeader::setRoInfo(const sSection& info) +void nn::hac::NroHeader::setRoInfo(const sSection& info) { mRoInfo = info; } -const nx::NroHeader::sSection& nx::NroHeader::getDataInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getDataInfo() const { return mDataInfo; } -void nx::NroHeader::setDataInfo(const sSection& info) +void nn::hac::NroHeader::setDataInfo(const sSection& info) { mDataInfo = info; } -uint32_t nx::NroHeader::getBssSize() const +uint32_t nn::hac::NroHeader::getBssSize() const { return mBssSize; } -void nx::NroHeader::setBssSize(uint32_t size) +void nn::hac::NroHeader::setBssSize(uint32_t size) { mBssSize = size; } -const nx::NroHeader::sModuleId& nx::NroHeader::getModuleId() const +const nn::hac::NroHeader::sModuleId& nn::hac::NroHeader::getModuleId() const { return mModuleId; } -void nx::NroHeader::setModuleId(const sModuleId& id) +void nn::hac::NroHeader::setModuleId(const sModuleId& id) { mModuleId = id; } -const nx::NroHeader::sSection& nx::NroHeader::getRoEmbeddedInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getRoEmbeddedInfo() const { return mRoEmbeddedInfo; } -void nx::NroHeader::setRoEmbeddedInfo(const sSection& info) +void nn::hac::NroHeader::setRoEmbeddedInfo(const sSection& info) { mRoEmbeddedInfo = info; } -const nx::NroHeader::sSection& nx::NroHeader::getRoDynStrInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getRoDynStrInfo() const { return mRoDynStrInfo; } -void nx::NroHeader::setRoDynStrInfo(const sSection& info) +void nn::hac::NroHeader::setRoDynStrInfo(const sSection& info) { mRoDynStrInfo = info; } -const nx::NroHeader::sSection& nx::NroHeader::getRoDynSymInfo() const +const nn::hac::NroHeader::sSection& nn::hac::NroHeader::getRoDynSymInfo() const { return mRoDynSymInfo; } -void nx::NroHeader::setRoDynSymInfo(const sSection& info) +void nn::hac::NroHeader::setRoDynSymInfo(const sSection& info) { mRoDynSymInfo = info; } \ No newline at end of file diff --git a/lib/libhac/source/NsoHeader.cpp b/lib/libhac/source/NsoHeader.cpp index 4612786..85468fd 100644 --- a/lib/libhac/source/NsoHeader.cpp +++ b/lib/libhac/source/NsoHeader.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::NsoHeader::NsoHeader() +nn::hac::NsoHeader::NsoHeader() { clear(); } -nx::NsoHeader::NsoHeader(const NsoHeader& other) +nn::hac::NsoHeader::NsoHeader(const NsoHeader& other) { *this = other; } -void nx::NsoHeader::operator=(const NsoHeader& other) +void nn::hac::NsoHeader::operator=(const NsoHeader& other) { clear(); mModuleId = other.mModuleId; @@ -25,7 +25,7 @@ void nx::NsoHeader::operator=(const NsoHeader& other) } -bool nx::NsoHeader::operator==(const NsoHeader& other) const +bool nn::hac::NsoHeader::operator==(const NsoHeader& other) const { return (mModuleId == other.mModuleId) \ && (mBssSize == other.mBssSize) \ @@ -38,15 +38,15 @@ bool nx::NsoHeader::operator==(const NsoHeader& other) const && (mRoDynSymInfo == other.mRoDynSymInfo); } -bool nx::NsoHeader::operator!=(const NsoHeader& other) const +bool nn::hac::NsoHeader::operator!=(const NsoHeader& other) const { return !(*this == other); } -void nx::NsoHeader::toBytes() +void nn::hac::NsoHeader::toBytes() { mRawBinary.alloc(sizeof(sNsoHeader)); - nx::sNsoHeader* hdr = (nx::sNsoHeader*)mRawBinary.data(); + nn::hac::sNsoHeader* hdr = (nn::hac::sNsoHeader*)mRawBinary.data(); // set header identifers hdr->st_magic = nso::kNsoStructMagic; @@ -125,7 +125,7 @@ void nx::NsoHeader::toBytes() hdr->flags = flags; } -void nx::NsoHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::NsoHeader::fromBytes(const byte_t* data, size_t len) { // check input data size if (len < sizeof(sNsoHeader)) @@ -141,7 +141,7 @@ void nx::NsoHeader::fromBytes(const byte_t* data, size_t len) memcpy(mRawBinary.data(), data, mRawBinary.size()); // get sNsoHeader ptr - const nx::sNsoHeader* hdr = (const nx::sNsoHeader*)mRawBinary.data(); + const nn::hac::sNsoHeader* hdr = (const nn::hac::sNsoHeader*)mRawBinary.data(); // check NSO signature if (hdr->st_magic.get() != nso::kNsoStructMagic) @@ -196,12 +196,12 @@ void nx::NsoHeader::fromBytes(const byte_t* data, size_t len) mRoDynSymInfo.size = hdr->dyn_sym.size.get(); } -const fnd::Vec& nx::NsoHeader::getBytes() const +const fnd::Vec& nn::hac::NsoHeader::getBytes() const { return mRawBinary; } -void nx::NsoHeader::clear() +void nn::hac::NsoHeader::clear() { mRawBinary.clear(); memset(&mModuleId, 0, sizeof(mModuleId)); @@ -215,92 +215,92 @@ void nx::NsoHeader::clear() memset(&mRoDynSymInfo, 0, sizeof(mRoDynSymInfo)); } -const nx::NsoHeader::sModuleId& nx::NsoHeader::getModuleId() const +const nn::hac::NsoHeader::sModuleId& nn::hac::NsoHeader::getModuleId() const { return mModuleId; } -void nx::NsoHeader::setModuleId(const sModuleId& id) +void nn::hac::NsoHeader::setModuleId(const sModuleId& id) { mModuleId = id; } -uint32_t nx::NsoHeader::getBssSize() const +uint32_t nn::hac::NsoHeader::getBssSize() const { return mBssSize; } -void nx::NsoHeader::setBssSize(uint32_t size) +void nn::hac::NsoHeader::setBssSize(uint32_t size) { mBssSize = size; } -const nx::NsoHeader::sCodeSegment& nx::NsoHeader::getTextSegmentInfo() const +const nn::hac::NsoHeader::sCodeSegment& nn::hac::NsoHeader::getTextSegmentInfo() const { return mTextSegmentInfo; } -void nx::NsoHeader::setTextSegmentInfo(const sCodeSegment& info) +void nn::hac::NsoHeader::setTextSegmentInfo(const sCodeSegment& info) { mTextSegmentInfo = info; } -const nx::NsoHeader::sCodeSegment& nx::NsoHeader::getRoSegmentInfo() const +const nn::hac::NsoHeader::sCodeSegment& nn::hac::NsoHeader::getRoSegmentInfo() const { return mRoSegmentInfo; } -void nx::NsoHeader::setRoSegmentInfo(const sCodeSegment& info) +void nn::hac::NsoHeader::setRoSegmentInfo(const sCodeSegment& info) { mRoSegmentInfo = info; } -const nx::NsoHeader::sCodeSegment& nx::NsoHeader::getDataSegmentInfo() const +const nn::hac::NsoHeader::sCodeSegment& nn::hac::NsoHeader::getDataSegmentInfo() const { return mDataSegmentInfo; } -void nx::NsoHeader::setDataSegmentInfo(const sCodeSegment& info) +void nn::hac::NsoHeader::setDataSegmentInfo(const sCodeSegment& info) { mDataSegmentInfo = info; } -const nx::NsoHeader::sLayout& nx::NsoHeader::getModuleNameInfo() const +const nn::hac::NsoHeader::sLayout& nn::hac::NsoHeader::getModuleNameInfo() const { return mModuleNameInfo; } -void nx::NsoHeader::setModuleNameInfo(const sLayout& info) +void nn::hac::NsoHeader::setModuleNameInfo(const sLayout& info) { mModuleNameInfo = info; } -const nx::NsoHeader::sLayout& nx::NsoHeader::getRoEmbeddedInfo() const +const nn::hac::NsoHeader::sLayout& nn::hac::NsoHeader::getRoEmbeddedInfo() const { return mRoEmbeddedInfo; } -void nx::NsoHeader::setRoEmbeddedInfo(const sLayout& info) +void nn::hac::NsoHeader::setRoEmbeddedInfo(const sLayout& info) { mRoEmbeddedInfo = info; } -const nx::NsoHeader::sLayout& nx::NsoHeader::getRoDynStrInfo() const +const nn::hac::NsoHeader::sLayout& nn::hac::NsoHeader::getRoDynStrInfo() const { return mRoDynStrInfo; } -void nx::NsoHeader::setRoDynStrInfo(const sLayout& info) +void nn::hac::NsoHeader::setRoDynStrInfo(const sLayout& info) { mRoDynStrInfo = info; } -const nx::NsoHeader::sLayout& nx::NsoHeader::getRoDynSymInfo() const +const nn::hac::NsoHeader::sLayout& nn::hac::NsoHeader::getRoDynSymInfo() const { return mRoDynSymInfo; } -void nx::NsoHeader::setRoDynSymInfo(const sLayout& info) +void nn::hac::NsoHeader::setRoDynSymInfo(const sLayout& info) { mRoDynSymInfo = info; } \ No newline at end of file diff --git a/lib/libhac/source/PfsHeader.cpp b/lib/libhac/source/PfsHeader.cpp index 7fdae51..7923992 100644 --- a/lib/libhac/source/PfsHeader.cpp +++ b/lib/libhac/source/PfsHeader.cpp @@ -1,16 +1,16 @@ -#include +#include -nx::PfsHeader::PfsHeader() +nn::hac::PfsHeader::PfsHeader() { clear(); } -nx::PfsHeader::PfsHeader(const PfsHeader & other) +nn::hac::PfsHeader::PfsHeader(const PfsHeader & other) { *this = other; } -void nx::PfsHeader::operator=(const PfsHeader & other) +void nn::hac::PfsHeader::operator=(const PfsHeader & other) { if (other.getBytes().size()) { @@ -24,24 +24,24 @@ void nx::PfsHeader::operator=(const PfsHeader & other) } } -bool nx::PfsHeader::operator==(const PfsHeader & other) const +bool nn::hac::PfsHeader::operator==(const PfsHeader & other) const { return (mFsType == other.mFsType) \ && (mFileList == other.mFileList); } -bool nx::PfsHeader::operator!=(const PfsHeader & other) const +bool nn::hac::PfsHeader::operator!=(const PfsHeader & other) const { return !(*this == other); } -const fnd::Vec& nx::PfsHeader::getBytes() const +const fnd::Vec& nn::hac::PfsHeader::getBytes() const { return mRawBinary; } -void nx::PfsHeader::toBytes() +void nn::hac::PfsHeader::toBytes() { // calculate name table size size_t name_table_size = 0; @@ -113,7 +113,7 @@ void nx::PfsHeader::toBytes() } -void nx::PfsHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::PfsHeader::fromBytes(const byte_t* data, size_t len) { // check input length meets minimum size if (len < sizeof(sPfsHeader)) @@ -195,39 +195,39 @@ void nx::PfsHeader::fromBytes(const byte_t* data, size_t len) } -void nx::PfsHeader::clear() +void nn::hac::PfsHeader::clear() { mRawBinary.clear(); mFsType = TYPE_PFS0; mFileList.clear(); } -nx::PfsHeader::FsType nx::PfsHeader::getFsType() const +nn::hac::PfsHeader::FsType nn::hac::PfsHeader::getFsType() const { return mFsType; } -void nx::PfsHeader::setFsType(FsType type) +void nn::hac::PfsHeader::setFsType(FsType type) { mFsType = type; } -const fnd::List& nx::PfsHeader::getFileList() const +const fnd::List& nn::hac::PfsHeader::getFileList() const { return mFileList; } -void nx::PfsHeader::addFile(const std::string & name, size_t size) +void nn::hac::PfsHeader::addFile(const std::string & name, size_t size) { mFileList.addElement({ name, 0, size, 0 }); } -void nx::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash) +void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash) { mFileList.addElement({ name, 0, size, hash_protected_size, hash }); } -size_t nx::PfsHeader::getFileEntrySize(FsType fs_type) +size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type) { size_t size = 0; switch(fs_type) @@ -244,7 +244,7 @@ size_t nx::PfsHeader::getFileEntrySize(FsType fs_type) return size; } -void nx::PfsHeader::calculateOffsets(size_t data_offset) +void nn::hac::PfsHeader::calculateOffsets(size_t data_offset) { for (size_t i = 0; i < mFileList.size(); i++) { diff --git a/lib/libhac/source/ServiceAccessControlBinary.cpp b/lib/libhac/source/ServiceAccessControlBinary.cpp index b46f4f9..3aac03d 100644 --- a/lib/libhac/source/ServiceAccessControlBinary.cpp +++ b/lib/libhac/source/ServiceAccessControlBinary.cpp @@ -1,32 +1,32 @@ -#include +#include -nx::ServiceAccessControlBinary::ServiceAccessControlBinary() +nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary() { clear(); } -nx::ServiceAccessControlBinary::ServiceAccessControlBinary(const ServiceAccessControlBinary & other) +nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary(const ServiceAccessControlBinary & other) { *this = other; } -void nx::ServiceAccessControlBinary::operator=(const ServiceAccessControlBinary & other) +void nn::hac::ServiceAccessControlBinary::operator=(const ServiceAccessControlBinary & other) { mRawBinary = other.mRawBinary; mServices = other.mServices; } -bool nx::ServiceAccessControlBinary::operator==(const ServiceAccessControlBinary & other) const +bool nn::hac::ServiceAccessControlBinary::operator==(const ServiceAccessControlBinary & other) const { return (mServices == other.mServices); } -bool nx::ServiceAccessControlBinary::operator!=(const ServiceAccessControlBinary & other) const +bool nn::hac::ServiceAccessControlBinary::operator!=(const ServiceAccessControlBinary & other) const { return !(*this == other); } -void nx::ServiceAccessControlBinary::toBytes() +void nn::hac::ServiceAccessControlBinary::toBytes() { size_t totalSize = 0; for (size_t i = 0; i < mServices.size(); i++) @@ -42,7 +42,7 @@ void nx::ServiceAccessControlBinary::toBytes() } } -void nx::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len) +void nn::hac::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len) { clear(); mRawBinary.alloc(len); @@ -56,23 +56,23 @@ void nx::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len) } } -const fnd::Vec& nx::ServiceAccessControlBinary::getBytes() const +const fnd::Vec& nn::hac::ServiceAccessControlBinary::getBytes() const { return mRawBinary; } -void nx::ServiceAccessControlBinary::clear() +void nn::hac::ServiceAccessControlBinary::clear() { mRawBinary.clear(); mServices.clear(); } -const fnd::List& nx::ServiceAccessControlBinary::getServiceList() const +const fnd::List& nn::hac::ServiceAccessControlBinary::getServiceList() const { return mServices; } -void nx::ServiceAccessControlBinary::addService(const ServiceAccessControlEntry& service) +void nn::hac::ServiceAccessControlBinary::addService(const ServiceAccessControlEntry& service) { mServices.addElement(service); } \ No newline at end of file diff --git a/lib/libhac/source/ServiceAccessControlEntry.cpp b/lib/libhac/source/ServiceAccessControlEntry.cpp index 00d3b9c..1e6e7ef 100644 --- a/lib/libhac/source/ServiceAccessControlEntry.cpp +++ b/lib/libhac/source/ServiceAccessControlEntry.cpp @@ -1,23 +1,23 @@ -#include +#include -nx::ServiceAccessControlEntry::ServiceAccessControlEntry() +nn::hac::ServiceAccessControlEntry::ServiceAccessControlEntry() { clear(); } -nx::ServiceAccessControlEntry::ServiceAccessControlEntry(const std::string & name, bool isServer) : +nn::hac::ServiceAccessControlEntry::ServiceAccessControlEntry(const std::string & name, bool isServer) : mIsServer(isServer), mName(name) { toBytes(); } -nx::ServiceAccessControlEntry::ServiceAccessControlEntry(const ServiceAccessControlEntry & other) +nn::hac::ServiceAccessControlEntry::ServiceAccessControlEntry(const ServiceAccessControlEntry & other) { *this = other; } -void nx::ServiceAccessControlEntry::operator=(const ServiceAccessControlEntry & other) +void nn::hac::ServiceAccessControlEntry::operator=(const ServiceAccessControlEntry & other) { if (other.getBytes().size()) { @@ -31,19 +31,19 @@ void nx::ServiceAccessControlEntry::operator=(const ServiceAccessControlEntry & } } -bool nx::ServiceAccessControlEntry::operator==(const ServiceAccessControlEntry & other) const +bool nn::hac::ServiceAccessControlEntry::operator==(const ServiceAccessControlEntry & other) const { return (mIsServer == other.mIsServer) \ && (mName == other.mName); } -bool nx::ServiceAccessControlEntry::operator!=(const ServiceAccessControlEntry & other) const +bool nn::hac::ServiceAccessControlEntry::operator!=(const ServiceAccessControlEntry & other) const { return !(*this == other); } -void nx::ServiceAccessControlEntry::toBytes() +void nn::hac::ServiceAccessControlEntry::toBytes() { try { mRawBinary.alloc(mName.size() + 1); @@ -68,7 +68,7 @@ void nx::ServiceAccessControlEntry::toBytes() memcpy(mRawBinary.data() + 1, mName.c_str(), mName.length()); } -void nx::ServiceAccessControlEntry::fromBytes(const byte_t* data, size_t len) +void nn::hac::ServiceAccessControlEntry::fromBytes(const byte_t* data, size_t len) { bool isServer = (data[0] & SAC_IS_SERVER) == SAC_IS_SERVER; size_t nameLen = (data[0] & SAC_NAME_LEN_MASK) + 1; // bug? @@ -94,33 +94,33 @@ void nx::ServiceAccessControlEntry::fromBytes(const byte_t* data, size_t len) mName = std::string((const char*)(mRawBinary.data() + 1), nameLen); } -const fnd::Vec& nx::ServiceAccessControlEntry::getBytes() const +const fnd::Vec& nn::hac::ServiceAccessControlEntry::getBytes() const { return mRawBinary; } -void nx::ServiceAccessControlEntry::clear() +void nn::hac::ServiceAccessControlEntry::clear() { mIsServer = false; mName.clear(); } -bool nx::ServiceAccessControlEntry::isServer() const +bool nn::hac::ServiceAccessControlEntry::isServer() const { return mIsServer; } -void nx::ServiceAccessControlEntry::setIsServer(bool isServer) +void nn::hac::ServiceAccessControlEntry::setIsServer(bool isServer) { mIsServer = isServer; } -const std::string & nx::ServiceAccessControlEntry::getName() const +const std::string & nn::hac::ServiceAccessControlEntry::getName() const { return mName; } -void nx::ServiceAccessControlEntry::setName(const std::string & name) +void nn::hac::ServiceAccessControlEntry::setName(const std::string & name) { if (name.length() > kMaxServiceNameLen) { diff --git a/lib/libhac/source/SystemCallEntry.cpp b/lib/libhac/source/SystemCallEntry.cpp index bf4a764..6af1677 100644 --- a/lib/libhac/source/SystemCallEntry.cpp +++ b/lib/libhac/source/SystemCallEntry.cpp @@ -1,6 +1,6 @@ -#include +#include -nx::SystemCallEntry::SystemCallEntry() : +nn::hac::SystemCallEntry::SystemCallEntry() : mCap(kCapId), mSystemCallUpper(0), mSystemCallLower(0) @@ -8,7 +8,7 @@ nx::SystemCallEntry::SystemCallEntry() : } -nx::SystemCallEntry::SystemCallEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::SystemCallEntry::SystemCallEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mSystemCallUpper(0), mSystemCallLower(0) @@ -16,7 +16,7 @@ nx::SystemCallEntry::SystemCallEntry(const KernelCapabilityEntry & kernel_cap) : setKernelCapability(kernel_cap); } -nx::SystemCallEntry::SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits) : +nn::hac::SystemCallEntry::SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits) : mCap(kCapId), mSystemCallUpper(0), mSystemCallLower(0) @@ -25,30 +25,30 @@ nx::SystemCallEntry::SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits) : setSystemCallLowerBits(lower_bits); } -void nx::SystemCallEntry::operator=(const SystemCallEntry& other) +void nn::hac::SystemCallEntry::operator=(const SystemCallEntry& other) { mSystemCallUpper = other.mSystemCallUpper; mSystemCallLower = other.mSystemCallLower; updateCapField(); } -bool nx::SystemCallEntry::operator==(const SystemCallEntry& other) const +bool nn::hac::SystemCallEntry::operator==(const SystemCallEntry& other) const { return (mSystemCallUpper == other.mSystemCallUpper) \ && (mSystemCallLower == other.mSystemCallLower); } -bool nx::SystemCallEntry::operator!=(const SystemCallEntry& other) const +bool nn::hac::SystemCallEntry::operator!=(const SystemCallEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::SystemCallEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::SystemCallEntry::getKernelCapability() const { return mCap; } -void nx::SystemCallEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::SystemCallEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -59,12 +59,12 @@ void nx::SystemCallEntry::setKernelCapability(const KernelCapabilityEntry & kern processCapField(); } -uint32_t nx::SystemCallEntry::getSystemCallUpperBits() const +uint32_t nn::hac::SystemCallEntry::getSystemCallUpperBits() const { return mSystemCallUpper; } -void nx::SystemCallEntry::setSystemCallUpperBits(uint32_t upper_bits) +void nn::hac::SystemCallEntry::setSystemCallUpperBits(uint32_t upper_bits) { if (upper_bits > kSysCallUpperMax) { @@ -75,12 +75,12 @@ void nx::SystemCallEntry::setSystemCallUpperBits(uint32_t upper_bits) updateCapField(); } -uint32_t nx::SystemCallEntry::getSystemCallLowerBits() const +uint32_t nn::hac::SystemCallEntry::getSystemCallLowerBits() const { return mSystemCallLower; } -void nx::SystemCallEntry::setSystemCallLowerBits(uint32_t lower_bits) +void nn::hac::SystemCallEntry::setSystemCallLowerBits(uint32_t lower_bits) { if (lower_bits > kSysCallLowerMax) { diff --git a/lib/libhac/source/SystemCallHandler.cpp b/lib/libhac/source/SystemCallHandler.cpp index da6d677..c2e58b5 100644 --- a/lib/libhac/source/SystemCallHandler.cpp +++ b/lib/libhac/source/SystemCallHandler.cpp @@ -1,29 +1,29 @@ -#include -#include +#include +#include -nx::SystemCallHandler::SystemCallHandler() : +nn::hac::SystemCallHandler::SystemCallHandler() : mIsSet(false), mSystemCalls() {} -void nx::SystemCallHandler::operator=(const SystemCallHandler & other) +void nn::hac::SystemCallHandler::operator=(const SystemCallHandler & other) { mIsSet = other.mIsSet; mSystemCalls = other.mSystemCalls; } -bool nx::SystemCallHandler::operator==(const SystemCallHandler & other) const +bool nn::hac::SystemCallHandler::operator==(const SystemCallHandler & other) const { return (mIsSet == other.mIsSet) \ && (mSystemCalls == other.mSystemCalls); } -bool nx::SystemCallHandler::operator!=(const SystemCallHandler & other) const +bool nn::hac::SystemCallHandler::operator!=(const SystemCallHandler & other) const { return !(*this == other); } -void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::SystemCallHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() == 0) return; @@ -49,7 +49,7 @@ void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::SystemCallHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -80,23 +80,23 @@ void nx::SystemCallHandler::exportKernelCapabilityList(fnd::List& nx::SystemCallHandler::getSystemCalls() const +const fnd::List& nn::hac::SystemCallHandler::getSystemCalls() const { return mSystemCalls; } -void nx::SystemCallHandler::setSystemCallList(const fnd::List& calls) +void nn::hac::SystemCallHandler::setSystemCallList(const fnd::List& calls) { mSystemCalls.clear(); for (size_t i = 0; i < calls.size(); i++) diff --git a/lib/libhac/source/ThreadInfoEntry.cpp b/lib/libhac/source/ThreadInfoEntry.cpp index 00cd7c8..a1c957c 100644 --- a/lib/libhac/source/ThreadInfoEntry.cpp +++ b/lib/libhac/source/ThreadInfoEntry.cpp @@ -1,6 +1,6 @@ -#include +#include -nx::ThreadInfoEntry::ThreadInfoEntry() : +nn::hac::ThreadInfoEntry::ThreadInfoEntry() : mCap(kCapId), mMinPriority(kDefaultPriority), mMaxPriority(kDefaultPriority), @@ -8,7 +8,7 @@ nx::ThreadInfoEntry::ThreadInfoEntry() : mMaxCpuId(kDefaultCpuId) {} -nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) : +nn::hac::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) : mCap(kCapId), mMinPriority(kDefaultPriority), mMaxPriority(kDefaultPriority), @@ -18,7 +18,7 @@ nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) : setKernelCapability(kernel_cap); } -nx::ThreadInfoEntry::ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_core_number, uint8_t max_core_number) : +nn::hac::ThreadInfoEntry::ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_core_number, uint8_t max_core_number) : mCap(kCapId), mMinPriority(kDefaultPriority), mMaxPriority(kDefaultPriority), @@ -31,7 +31,7 @@ nx::ThreadInfoEntry::ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, setMaxCpuId(max_core_number); } -void nx::ThreadInfoEntry::operator=(const ThreadInfoEntry& other) +void nn::hac::ThreadInfoEntry::operator=(const ThreadInfoEntry& other) { mMinPriority = other.mMinPriority; mMaxPriority = other.mMaxPriority; @@ -40,7 +40,7 @@ void nx::ThreadInfoEntry::operator=(const ThreadInfoEntry& other) updateCapField(); } -bool nx::ThreadInfoEntry::operator==(const ThreadInfoEntry& other) const +bool nn::hac::ThreadInfoEntry::operator==(const ThreadInfoEntry& other) const { return (mMinPriority == other.mMinPriority) \ && (mMaxPriority == other.mMaxPriority) \ @@ -48,17 +48,17 @@ bool nx::ThreadInfoEntry::operator==(const ThreadInfoEntry& other) const && (mMaxCpuId == other.mMaxCpuId); } -bool nx::ThreadInfoEntry::operator!=(const ThreadInfoEntry& other) const +bool nn::hac::ThreadInfoEntry::operator!=(const ThreadInfoEntry& other) const { return !(*this == other); } -const nx::KernelCapabilityEntry & nx::ThreadInfoEntry::getKernelCapability() const +const nn::hac::KernelCapabilityEntry & nn::hac::ThreadInfoEntry::getKernelCapability() const { return mCap; } -void nx::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) +void nn::hac::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap) { if (kernel_cap.getType() != kCapId) { @@ -69,12 +69,12 @@ void nx::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kern processCapField(); } -uint8_t nx::ThreadInfoEntry::getMinPriority() const +uint8_t nn::hac::ThreadInfoEntry::getMinPriority() const { return mMinPriority; } -void nx::ThreadInfoEntry::setMinPriority(uint8_t priority) +void nn::hac::ThreadInfoEntry::setMinPriority(uint8_t priority) { if (priority > kMaxVal) { @@ -85,12 +85,12 @@ void nx::ThreadInfoEntry::setMinPriority(uint8_t priority) updateCapField(); } -uint8_t nx::ThreadInfoEntry::getMaxPriority() const +uint8_t nn::hac::ThreadInfoEntry::getMaxPriority() const { return mMaxPriority; } -void nx::ThreadInfoEntry::setMaxPriority(uint8_t priority) +void nn::hac::ThreadInfoEntry::setMaxPriority(uint8_t priority) { if (priority > kMaxVal) { @@ -101,12 +101,12 @@ void nx::ThreadInfoEntry::setMaxPriority(uint8_t priority) updateCapField(); } -uint8_t nx::ThreadInfoEntry::getMinCpuId() const +uint8_t nn::hac::ThreadInfoEntry::getMinCpuId() const { return mMinCpuId; } -void nx::ThreadInfoEntry::setMinCpuId(uint8_t core_num) +void nn::hac::ThreadInfoEntry::setMinCpuId(uint8_t core_num) { if (core_num > kMaxVal) { @@ -117,12 +117,12 @@ void nx::ThreadInfoEntry::setMinCpuId(uint8_t core_num) updateCapField(); } -uint8_t nx::ThreadInfoEntry::getMaxCpuId() const +uint8_t nn::hac::ThreadInfoEntry::getMaxCpuId() const { return mMaxCpuId; } -void nx::ThreadInfoEntry::setMaxCpuId(uint8_t core_num) +void nn::hac::ThreadInfoEntry::setMaxCpuId(uint8_t core_num) { if (core_num > kMaxVal) { diff --git a/lib/libhac/source/ThreadInfoHandler.cpp b/lib/libhac/source/ThreadInfoHandler.cpp index da906db..c0d8532 100644 --- a/lib/libhac/source/ThreadInfoHandler.cpp +++ b/lib/libhac/source/ThreadInfoHandler.cpp @@ -1,28 +1,28 @@ -#include +#include -nx::ThreadInfoHandler::ThreadInfoHandler() : +nn::hac::ThreadInfoHandler::ThreadInfoHandler() : mIsSet(false), mEntry(0,0,0,0) {} -void nx::ThreadInfoHandler::operator=(const ThreadInfoHandler & other) +void nn::hac::ThreadInfoHandler::operator=(const ThreadInfoHandler & other) { mIsSet = other.mIsSet; mEntry.setKernelCapability(other.mEntry.getKernelCapability()); } -bool nx::ThreadInfoHandler::operator==(const ThreadInfoHandler & other) const +bool nn::hac::ThreadInfoHandler::operator==(const ThreadInfoHandler & other) const { return (mIsSet == other.mIsSet) \ && (mEntry.getKernelCapability() == other.mEntry.getKernelCapability()); } -bool nx::ThreadInfoHandler::operator!=(const ThreadInfoHandler & other) const +bool nn::hac::ThreadInfoHandler::operator!=(const ThreadInfoHandler & other) const { return !(*this == other); } -void nx::ThreadInfoHandler::importKernelCapabilityList(const fnd::List& caps) +void nn::hac::ThreadInfoHandler::importKernelCapabilityList(const fnd::List& caps) { if (caps.size() > kMaxKernelCapNum) { @@ -36,7 +36,7 @@ void nx::ThreadInfoHandler::importKernelCapabilityList(const fnd::List& caps) const +void nn::hac::ThreadInfoHandler::exportKernelCapabilityList(fnd::List& caps) const { if (isSet() == false) return; @@ -44,7 +44,7 @@ void nx::ThreadInfoHandler::exportKernelCapabilityList(fnd::List +#include -nx::XciHeader::XciHeader() +nn::hac::XciHeader::XciHeader() { clear(); } -nx::XciHeader::XciHeader(const XciHeader& other) +nn::hac::XciHeader::XciHeader(const XciHeader& other) { *this = other; } -void nx::XciHeader::operator=(const XciHeader& other) +void nn::hac::XciHeader::operator=(const XciHeader& other) { mRomAreaStartPage = other.mRomAreaStartPage; mBackupAreaStartPage = other.mBackupAreaStartPage; @@ -43,7 +43,7 @@ void nx::XciHeader::operator=(const XciHeader& other) mUppId = other.mUppId; } -bool nx::XciHeader::operator==(const XciHeader& other) const +bool nn::hac::XciHeader::operator==(const XciHeader& other) const { return (mRomAreaStartPage == other.mRomAreaStartPage) && (mBackupAreaStartPage == other.mBackupAreaStartPage) @@ -76,17 +76,17 @@ bool nx::XciHeader::operator==(const XciHeader& other) const && (mUppId == other.mUppId); } -bool nx::XciHeader::operator!=(const XciHeader& other) const +bool nn::hac::XciHeader::operator!=(const XciHeader& other) const { return !(*this == other); } -void nx::XciHeader::toBytes() +void nn::hac::XciHeader::toBytes() { fnd::Exception(kModuleName, "exportBinary() not implemented"); } -void nx::XciHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len) { // check input data size if (len < sizeof(sXciHeader)) @@ -102,7 +102,7 @@ void nx::XciHeader::fromBytes(const byte_t* data, size_t len) memcpy(mRawBinary.data(), data, mRawBinary.size()); // get sXciHeader ptr - const nx::sXciHeader* hdr = (const nx::sXciHeader*)mRawBinary.data(); + const nn::hac::sXciHeader* hdr = (const nn::hac::sXciHeader*)mRawBinary.data(); // check XCI signature if (hdr->st_magic.get() != xci::kXciStructMagic) @@ -148,13 +148,13 @@ void nx::XciHeader::fromBytes(const byte_t* data, size_t len) } -const fnd::Vec& nx::XciHeader::getBytes() const +const fnd::Vec& nn::hac::XciHeader::getBytes() const { return mRawBinary; } // variables -void nx::XciHeader::clear() +void nn::hac::XciHeader::clear() { mRomAreaStartPage = 0; mBackupAreaStartPage = 0; @@ -187,293 +187,293 @@ void nx::XciHeader::clear() mUppId = 0; } -uint32_t nx::XciHeader::getRomAreaStartPage() const +uint32_t nn::hac::XciHeader::getRomAreaStartPage() const { return mRomAreaStartPage; } -void nx::XciHeader::setRomAreaStartPage(uint32_t startPage) +void nn::hac::XciHeader::setRomAreaStartPage(uint32_t startPage) { mRomAreaStartPage = startPage; } -uint32_t nx::XciHeader::getBackupAreaStartPage() const +uint32_t nn::hac::XciHeader::getBackupAreaStartPage() const { return mBackupAreaStartPage; } -void nx::XciHeader::setBackupAreaStartPage(uint32_t startPage) +void nn::hac::XciHeader::setBackupAreaStartPage(uint32_t startPage) { mBackupAreaStartPage = startPage; } -byte_t nx::XciHeader::getKekIndex() const +byte_t nn::hac::XciHeader::getKekIndex() const { return mKekIndex; } -void nx::XciHeader::setKekIndex(byte_t kekIndex) +void nn::hac::XciHeader::setKekIndex(byte_t kekIndex) { mKekIndex = kekIndex; } -byte_t nx::XciHeader::getTitleKeyDecIndex() const +byte_t nn::hac::XciHeader::getTitleKeyDecIndex() const { return mTitleKeyDecIndex; } -void nx::XciHeader::setTitleKeyDecIndex(byte_t index) +void nn::hac::XciHeader::setTitleKeyDecIndex(byte_t index) { mTitleKeyDecIndex = index; } -byte_t nx::XciHeader::getRomSizeType() const +byte_t nn::hac::XciHeader::getRomSizeType() const { return mRomSize; } -void nx::XciHeader::setRomSizeType(byte_t romSizeType) +void nn::hac::XciHeader::setRomSizeType(byte_t romSizeType) { mRomSize = romSizeType; } -byte_t nx::XciHeader::getCardHeaderVersion() const +byte_t nn::hac::XciHeader::getCardHeaderVersion() const { return mCardHeaderVersion; } -void nx::XciHeader::setCardHeaderVersion(byte_t version) +void nn::hac::XciHeader::setCardHeaderVersion(byte_t version) { mCardHeaderVersion = version; } -byte_t nx::XciHeader::getFlags() const +byte_t nn::hac::XciHeader::getFlags() const { return mFlags; } -void nx::XciHeader::setFlags(byte_t flags) +void nn::hac::XciHeader::setFlags(byte_t flags) { mFlags = flags; } -uint64_t nx::XciHeader::getPackageId() const +uint64_t nn::hac::XciHeader::getPackageId() const { return mPackageId; } -void nx::XciHeader::setPackageId(uint64_t id) +void nn::hac::XciHeader::setPackageId(uint64_t id) { mPackageId = id; } -uint32_t nx::XciHeader::getValidDataEndPage() const +uint32_t nn::hac::XciHeader::getValidDataEndPage() const { return mValidDataEndPage; } -void nx::XciHeader::setValidDataEndPage(uint32_t page) +void nn::hac::XciHeader::setValidDataEndPage(uint32_t page) { mValidDataEndPage = page; } -const crypto::aes::sAesIvCtr& nx::XciHeader::getAesCbcIv() const +const crypto::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const { return mAesCbcIv; } -void nx::XciHeader::setAesCbcIv(const crypto::aes::sAesIvCtr& iv) +void nn::hac::XciHeader::setAesCbcIv(const crypto::aes::sAesIvCtr& iv) { mAesCbcIv = iv; } -uint64_t nx::XciHeader::getPartitionFsAddress() const +uint64_t nn::hac::XciHeader::getPartitionFsAddress() const { return mPartitionFsHeaderAddress; } -void nx::XciHeader::setPartitionFsAddress(uint64_t address) +void nn::hac::XciHeader::setPartitionFsAddress(uint64_t address) { mPartitionFsHeaderAddress = address; } -uint64_t nx::XciHeader::getPartitionFsSize() const +uint64_t nn::hac::XciHeader::getPartitionFsSize() const { return mPartitionFsHeaderSize; } -void nx::XciHeader::setPartitionFsSize(uint64_t size) +void nn::hac::XciHeader::setPartitionFsSize(uint64_t size) { mPartitionFsHeaderSize = size; } -const crypto::sha::sSha256Hash& nx::XciHeader::getPartitionFsHash() const +const crypto::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const { return mPartitionFsHeaderHash; } -void nx::XciHeader::setPartitionFsHash(const crypto::sha::sSha256Hash& hash) +void nn::hac::XciHeader::setPartitionFsHash(const crypto::sha::sSha256Hash& hash) { mPartitionFsHeaderHash = hash; } -const crypto::sha::sSha256Hash& nx::XciHeader::getInitialDataHash() const +const crypto::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const { return mInitialDataHash; } -void nx::XciHeader::setInitialDataHash(const crypto::sha::sSha256Hash& hash) +void nn::hac::XciHeader::setInitialDataHash(const crypto::sha::sSha256Hash& hash) { mInitialDataHash = hash; } -uint32_t nx::XciHeader::getSelSec() const +uint32_t nn::hac::XciHeader::getSelSec() const { return mSelSec; } -void nx::XciHeader::setSelSec(uint32_t sel_sec) +void nn::hac::XciHeader::setSelSec(uint32_t sel_sec) { mSelSec = sel_sec; } -uint32_t nx::XciHeader::getSelT1Key() const +uint32_t nn::hac::XciHeader::getSelT1Key() const { return mSelT1Key; } -void nx::XciHeader::setSelT1Key(uint32_t sel_t1_key) +void nn::hac::XciHeader::setSelT1Key(uint32_t sel_t1_key) { mSelT1Key = sel_t1_key; } -uint32_t nx::XciHeader::getSelKey() const +uint32_t nn::hac::XciHeader::getSelKey() const { return mSelKey; } -void nx::XciHeader::setSelKey(uint32_t sel_key) +void nn::hac::XciHeader::setSelKey(uint32_t sel_key) { mSelKey = sel_key; } -uint32_t nx::XciHeader::getLimAreaPage() const +uint32_t nn::hac::XciHeader::getLimAreaPage() const { return mLimAreaPage; } -void nx::XciHeader::setLimAreaPage(uint32_t page) +void nn::hac::XciHeader::setLimAreaPage(uint32_t page) { mLimAreaPage = page; } -uint32_t nx::XciHeader::getFwVerMajor() const +uint32_t nn::hac::XciHeader::getFwVerMajor() const { return mFwVersion[xci::FWVER_MAJOR]; } -void nx::XciHeader::setFwVerMajor(uint32_t ver) +void nn::hac::XciHeader::setFwVerMajor(uint32_t ver) { mFwVersion[xci::FWVER_MAJOR] = ver; } -uint32_t nx::XciHeader::getFwVerMinor() const +uint32_t nn::hac::XciHeader::getFwVerMinor() const { return mFwVersion[xci::FWVER_MINOR]; } -void nx::XciHeader::setFwVerMinor(uint32_t ver) +void nn::hac::XciHeader::setFwVerMinor(uint32_t ver) { mFwVersion[xci::FWVER_MINOR] = ver; } -uint32_t nx::XciHeader::getAccCtrl1() const +uint32_t nn::hac::XciHeader::getAccCtrl1() const { return mAccCtrl1; } -void nx::XciHeader::setAccCtrl1(uint32_t acc_ctrl_1) +void nn::hac::XciHeader::setAccCtrl1(uint32_t acc_ctrl_1) { mAccCtrl1 = acc_ctrl_1; } -uint32_t nx::XciHeader::getWait1TimeRead() const +uint32_t nn::hac::XciHeader::getWait1TimeRead() const { return mWait1TimeRead; } -void nx::XciHeader::setWait1TimeRead(uint32_t seconds) +void nn::hac::XciHeader::setWait1TimeRead(uint32_t seconds) { mWait1TimeRead = seconds; } -uint32_t nx::XciHeader::getWait2TimeRead() const +uint32_t nn::hac::XciHeader::getWait2TimeRead() const { return mWait2TimeRead; } -void nx::XciHeader::setWait2TimeRead(uint32_t seconds) +void nn::hac::XciHeader::setWait2TimeRead(uint32_t seconds) { mWait2TimeRead = seconds; } -uint32_t nx::XciHeader::getWait1TimeWrite() const +uint32_t nn::hac::XciHeader::getWait1TimeWrite() const { return mWait1TimeWrite; } -void nx::XciHeader::setWait1TimeWrite(uint32_t seconds) +void nn::hac::XciHeader::setWait1TimeWrite(uint32_t seconds) { mWait1TimeWrite = seconds; } -uint32_t nx::XciHeader::getWait2TimeWrite() const +uint32_t nn::hac::XciHeader::getWait2TimeWrite() const { return mWait2TimeWrite; } -void nx::XciHeader::setWait2TimeWrite(uint32_t seconds) +void nn::hac::XciHeader::setWait2TimeWrite(uint32_t seconds) { mWait2TimeWrite = seconds; } -uint32_t nx::XciHeader::getFwMode() const +uint32_t nn::hac::XciHeader::getFwMode() const { return mFwMode; } -void nx::XciHeader::setFwMode(uint32_t fw_mode) +void nn::hac::XciHeader::setFwMode(uint32_t fw_mode) { mFwMode = fw_mode; } -uint32_t nx::XciHeader::getUppVersion() const +uint32_t nn::hac::XciHeader::getUppVersion() const { return mUppVersion; } -void nx::XciHeader::setUppVersion(uint32_t version) +void nn::hac::XciHeader::setUppVersion(uint32_t version) { mUppVersion = version; } -const byte_t* nx::XciHeader::getUppHash() const +const byte_t* nn::hac::XciHeader::getUppHash() const { return mUppHash; } -void nx::XciHeader::setUppHash(const byte_t* hash) +void nn::hac::XciHeader::setUppHash(const byte_t* hash) { memcpy(mUppHash, hash, xci::kUppHashLen); } -uint64_t nx::XciHeader::getUppId() const +uint64_t nn::hac::XciHeader::getUppId() const { return mUppId; } -void nx::XciHeader::setUppId(uint64_t id) +void nn::hac::XciHeader::setUppId(uint64_t id) { mUppId = id; } diff --git a/lib/libhac/source/XciUtils.cpp b/lib/libhac/source/XciUtils.cpp index 756725b..40aa00a 100644 --- a/lib/libhac/source/XciUtils.cpp +++ b/lib/libhac/source/XciUtils.cpp @@ -1,6 +1,6 @@ -#include +#include -void nx::XciUtils::getXciHeaderAesIv(const nx::sXciHeader* hdr, byte_t* iv) +void nn::hac::XciUtils::getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t* iv) { for (size_t i = 0; i < 16; i++) { @@ -8,15 +8,15 @@ void nx::XciUtils::getXciHeaderAesIv(const nx::sXciHeader* hdr, byte_t* iv) } } -void nx::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key) +void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key) { byte_t iv[crypto::aes::kAesBlockSize]; - getXciHeaderAesIv((const nx::sXciHeader*)src, iv); + getXciHeaderAesIv((const nn::hac::sXciHeader*)src, iv); // copy plain - memcpy(dst, src, nx::xci::kHeaderEncOffset); + memcpy(dst, src, nn::hac::xci::kHeaderEncOffset); // decrypt encrypted data - crypto::aes::AesCbcDecrypt(src + nx::xci::kHeaderEncOffset, nx::xci::kHeaderEncSize, key, iv, dst + nx::xci::kHeaderEncOffset); + crypto::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset); } \ No newline at end of file diff --git a/lib/liblz4/makefile b/lib/liblz4/makefile index a29d7be..b6fc4ef 100644 --- a/lib/liblz4/makefile +++ b/lib/liblz4/makefile @@ -39,7 +39,7 @@ main: build rebuild: clean build build: $(OBJS) - ar cr -o $(OUTPUT) $(OBJS) + ar $(ARFLAGS) $(OUTPUT) $(OBJS) clean: rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/CertificateBody.h b/lib/libpki/include/nn/pki/CertificateBody.h index c02494c..497cca1 100644 --- a/lib/libpki/include/nn/pki/CertificateBody.h +++ b/lib/libpki/include/nn/pki/CertificateBody.h @@ -1,8 +1,10 @@ #pragma once #include #include -#include +#include +namespace nn +{ namespace pki { class CertificateBody @@ -61,4 +63,5 @@ namespace pki crypto::rsa::sRsa2048Key mRsa2048PublicKey; crypto::ecdsa::sEcdsa240Point mEcdsa240PublicKey; }; +} } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/SignUtils.h b/lib/libpki/include/nn/pki/SignUtils.h index dc71e2a..873ff41 100644 --- a/lib/libpki/include/nn/pki/SignUtils.h +++ b/lib/libpki/include/nn/pki/SignUtils.h @@ -1,14 +1,17 @@ #pragma once -#include +#include #include +namespace nn +{ namespace pki { namespace sign { - pki::sign::SignatureAlgo getSignatureAlgo(pki::sign::SignatureId sign_id); - pki::sign::HashAlgo getHashAlgo(pki::sign::SignatureId sign_id); + nn::pki::sign::SignatureAlgo getSignatureAlgo(pki::sign::SignatureId sign_id); + nn::pki::sign::HashAlgo getHashAlgo(pki::sign::SignatureId sign_id); } +} } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/SignatureBlock.h b/lib/libpki/include/nn/pki/SignatureBlock.h index 1fcad69..0b2ed71 100644 --- a/lib/libpki/include/nn/pki/SignatureBlock.h +++ b/lib/libpki/include/nn/pki/SignatureBlock.h @@ -1,8 +1,10 @@ #pragma once #include #include -#include +#include +namespace nn +{ namespace pki { class SignatureBlock @@ -45,4 +47,5 @@ namespace pki bool mIsLittleEndian; fnd::Vec mSignature; }; +} } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/SignedData.h b/lib/libpki/include/nn/pki/SignedData.h index abe38d6..112e9f9 100644 --- a/lib/libpki/include/nn/pki/SignedData.h +++ b/lib/libpki/include/nn/pki/SignedData.h @@ -1,8 +1,10 @@ #pragma once #include #include -#include +#include +namespace nn +{ namespace pki { template diff --git a/lib/libpki/include/nn/pki/cert.h b/lib/libpki/include/nn/pki/cert.h index c7e3b52..1fd7a1b 100644 --- a/lib/libpki/include/nn/pki/cert.h +++ b/lib/libpki/include/nn/pki/cert.h @@ -5,6 +5,8 @@ #include #include +namespace nn +{ namespace pki { namespace cert @@ -48,4 +50,5 @@ namespace pki byte_t padding[0x3C]; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/sign.h b/lib/libpki/include/nn/pki/sign.h index 27442cc..7d31f35 100644 --- a/lib/libpki/include/nn/pki/sign.h +++ b/lib/libpki/include/nn/pki/sign.h @@ -5,6 +5,8 @@ #include #include +namespace nn +{ namespace pki { namespace sign @@ -59,4 +61,5 @@ namespace pki byte_t padding[0x40]; }; #pragma pack(pop) +} } \ No newline at end of file diff --git a/lib/libpki/makefile b/lib/libpki/makefile index a6d2bf8..da68d0b 100644 --- a/lib/libpki/makefile +++ b/lib/libpki/makefile @@ -21,15 +21,14 @@ else UNAME = $(shell uname -s) ifeq ($(UNAME), Darwin) # MacOS Only Flags/Libs - CFLAGS += -Wno-unused-private-field - CXXFLAGS += -Wno-unused-private-field + CFLAGS += -arch x86_64 -Wno-unused-private-field + CXXFLAGS += -arch x86_64 -Wno-unused-private-field ARFLAGS = rc else # *nix Only Flags/Libs CFLAGS += -Wno-unused-but-set-variable CXXFLAGS += -Wno-unused-but-set-variable endif - endif # Output diff --git a/lib/libpki/source/CertificateBody.cpp b/lib/libpki/source/CertificateBody.cpp index d844101..bcf3d03 100644 --- a/lib/libpki/source/CertificateBody.cpp +++ b/lib/libpki/source/CertificateBody.cpp @@ -1,16 +1,16 @@ -#include +#include -pki::CertificateBody::CertificateBody() +nn::pki::CertificateBody::CertificateBody() { clear(); } -pki::CertificateBody::CertificateBody(const CertificateBody& other) +nn::pki::CertificateBody::CertificateBody(const CertificateBody& other) { *this = other; } -void pki::CertificateBody::operator=(const CertificateBody& other) +void nn::pki::CertificateBody::operator=(const CertificateBody& other) { mRawBinary = other.mRawBinary; mIssuer = other.mIssuer; @@ -22,7 +22,7 @@ void pki::CertificateBody::operator=(const CertificateBody& other) mEcdsa240PublicKey = other.mEcdsa240PublicKey; } -bool pki::CertificateBody::operator==(const CertificateBody& other) const +bool nn::pki::CertificateBody::operator==(const CertificateBody& other) const { return (mIssuer == other.mIssuer) \ && (mSubject == other.mSubject) \ @@ -33,12 +33,12 @@ bool pki::CertificateBody::operator==(const CertificateBody& other) const && (mEcdsa240PublicKey == other.mEcdsa240PublicKey); } -bool pki::CertificateBody::operator!=(const CertificateBody& other) const +bool nn::pki::CertificateBody::operator!=(const CertificateBody& other) const { return !(*this == other); } -void pki::CertificateBody::toBytes() +void nn::pki::CertificateBody::toBytes() { // get public key size size_t pubkeySize = 0; @@ -86,7 +86,7 @@ void pki::CertificateBody::toBytes() } } -void pki::CertificateBody::fromBytes(const byte_t* src, size_t size) +void nn::pki::CertificateBody::fromBytes(const byte_t* src, size_t size) { clear(); @@ -155,13 +155,13 @@ void pki::CertificateBody::fromBytes(const byte_t* src, size_t size) } } -const fnd::Vec& pki::CertificateBody::getBytes() const +const fnd::Vec& nn::pki::CertificateBody::getBytes() const { return mRawBinary; } -void pki::CertificateBody::clear() +void nn::pki::CertificateBody::clear() { mIssuer.clear(); mSubject.clear(); @@ -173,12 +173,12 @@ void pki::CertificateBody::clear() memset(&mEcdsa240PublicKey, 0, sizeof(crypto::ecdsa::sEcdsa240Point)); } -const std::string& pki::CertificateBody::getIssuer() const +const std::string& nn::pki::CertificateBody::getIssuer() const { return mIssuer; } -void pki::CertificateBody::setIssuer(const std::string& issuer) +void nn::pki::CertificateBody::setIssuer(const std::string& issuer) { if (issuer.size() > cert::kIssuerSize) { @@ -188,22 +188,22 @@ void pki::CertificateBody::setIssuer(const std::string& issuer) mIssuer = issuer; } -pki::cert::PublicKeyType pki::CertificateBody::getPublicKeyType() const +nn::pki::cert::PublicKeyType nn::pki::CertificateBody::getPublicKeyType() const { return mPublicKeyType; } -void pki::CertificateBody::setPublicKeyType(cert::PublicKeyType type) +void nn::pki::CertificateBody::setPublicKeyType(cert::PublicKeyType type) { mPublicKeyType = type; } -const std::string& pki::CertificateBody::getSubject() const +const std::string& nn::pki::CertificateBody::getSubject() const { return mSubject; } -void pki::CertificateBody::setSubject(const std::string& subject) +void nn::pki::CertificateBody::setSubject(const std::string& subject) { if (subject.size() > cert::kSubjectSize) { @@ -213,42 +213,42 @@ void pki::CertificateBody::setSubject(const std::string& subject) mSubject = subject; } -uint32_t pki::CertificateBody::getCertId() const +uint32_t nn::pki::CertificateBody::getCertId() const { return mCertId; } -void pki::CertificateBody::setCertId(uint32_t id) +void nn::pki::CertificateBody::setCertId(uint32_t id) { mCertId = id; } -const crypto::rsa::sRsa4096Key& pki::CertificateBody::getRsa4098PublicKey() const +const crypto::rsa::sRsa4096Key& nn::pki::CertificateBody::getRsa4098PublicKey() const { return mRsa4096PublicKey; } -void pki::CertificateBody::setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key) +void nn::pki::CertificateBody::setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key) { mRsa4096PublicKey = key; } -const crypto::rsa::sRsa2048Key& pki::CertificateBody::getRsa2048PublicKey() const +const crypto::rsa::sRsa2048Key& nn::pki::CertificateBody::getRsa2048PublicKey() const { return mRsa2048PublicKey; } -void pki::CertificateBody::setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key) +void nn::pki::CertificateBody::setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key) { mRsa2048PublicKey = key; } -const crypto::ecdsa::sEcdsa240Point& pki::CertificateBody::getEcdsa240PublicKey() const +const crypto::ecdsa::sEcdsa240Point& nn::pki::CertificateBody::getEcdsa240PublicKey() const { return mEcdsa240PublicKey; } -void pki::CertificateBody::setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key) +void nn::pki::CertificateBody::setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key) { mEcdsa240PublicKey = key; } \ No newline at end of file diff --git a/lib/libpki/source/SignUtils.cpp b/lib/libpki/source/SignUtils.cpp index 43cfb1e..56ff86d 100644 --- a/lib/libpki/source/SignUtils.cpp +++ b/lib/libpki/source/SignUtils.cpp @@ -1,21 +1,21 @@ -#include +#include -pki::sign::SignatureAlgo pki::sign::getSignatureAlgo(pki::sign::SignatureId sign_id) +nn::pki::sign::SignatureAlgo nn::pki::sign::getSignatureAlgo(nn::pki::sign::SignatureId sign_id) { SignatureAlgo sign_algo = SIGN_ALGO_RSA4096; switch (sign_id) { - case (pki::sign::SIGN_ID_RSA4096_SHA1): - case (pki::sign::SIGN_ID_RSA4096_SHA256): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA1): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA256): sign_algo = SIGN_ALGO_RSA4096; break; - case (pki::sign::SIGN_ID_RSA2048_SHA1): - case (pki::sign::SIGN_ID_RSA2048_SHA256): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA1): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA256): sign_algo = SIGN_ALGO_RSA2048; break; - case (pki::sign::SIGN_ID_ECDSA240_SHA1): - case (pki::sign::SIGN_ID_ECDSA240_SHA256): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256): sign_algo = SIGN_ALGO_ECDSA240; break; }; @@ -23,20 +23,20 @@ pki::sign::SignatureAlgo pki::sign::getSignatureAlgo(pki::sign::SignatureId sign return sign_algo; } -pki::sign::HashAlgo pki::sign::getHashAlgo(pki::sign::SignatureId sign_id) +nn::pki::sign::HashAlgo nn::pki::sign::getHashAlgo(nn::pki::sign::SignatureId sign_id) { HashAlgo hash_algo = HASH_ALGO_SHA1; switch (sign_id) { - case (pki::sign::SIGN_ID_RSA4096_SHA1): - case (pki::sign::SIGN_ID_RSA2048_SHA1): - case (pki::sign::SIGN_ID_ECDSA240_SHA1): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA1): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA1): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1): hash_algo = HASH_ALGO_SHA1; break; - case (pki::sign::SIGN_ID_RSA4096_SHA256): - case (pki::sign::SIGN_ID_RSA2048_SHA256): - case (pki::sign::SIGN_ID_ECDSA240_SHA256): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA256): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA256): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256): hash_algo = HASH_ALGO_SHA256; break; }; diff --git a/lib/libpki/source/SignatureBlock.cpp b/lib/libpki/source/SignatureBlock.cpp index bf19b20..b25944a 100644 --- a/lib/libpki/source/SignatureBlock.cpp +++ b/lib/libpki/source/SignatureBlock.cpp @@ -1,16 +1,16 @@ -#include +#include -pki::SignatureBlock::SignatureBlock() +nn::pki::SignatureBlock::SignatureBlock() { clear(); } -pki::SignatureBlock::SignatureBlock(const SignatureBlock& other) +nn::pki::SignatureBlock::SignatureBlock(const SignatureBlock& other) { *this = other; } -void pki::SignatureBlock::operator=(const SignatureBlock& other) +void nn::pki::SignatureBlock::operator=(const SignatureBlock& other) { mRawBinary = other.mRawBinary; mSignType = other.mSignType; @@ -18,19 +18,19 @@ void pki::SignatureBlock::operator=(const SignatureBlock& other) mSignature = other.mSignature; } -bool pki::SignatureBlock::operator==(const SignatureBlock& other) const +bool nn::pki::SignatureBlock::operator==(const SignatureBlock& other) const { return (mSignType == other.mSignType) \ && (mIsLittleEndian == other.mIsLittleEndian) \ && (mSignature == other.mSignature); } -bool pki::SignatureBlock::operator!=(const SignatureBlock& other) const +bool nn::pki::SignatureBlock::operator!=(const SignatureBlock& other) const { return !(*this == other); } -void pki::SignatureBlock::toBytes() +void nn::pki::SignatureBlock::toBytes() { size_t totalSize = 0; size_t sigSize = 0; @@ -68,7 +68,7 @@ void pki::SignatureBlock::toBytes() memcpy(mRawBinary.data() + 4, mSignature.data(), sigSize); } -void pki::SignatureBlock::fromBytes(const byte_t* src, size_t size) +void nn::pki::SignatureBlock::fromBytes(const byte_t* src, size_t size) { clear(); @@ -138,12 +138,12 @@ void pki::SignatureBlock::fromBytes(const byte_t* src, size_t size) memcpy(mSignature.data(), mRawBinary.data() + 4, sigSize); } -const fnd::Vec& pki::SignatureBlock::getBytes() const +const fnd::Vec& nn::pki::SignatureBlock::getBytes() const { return mRawBinary; } -void pki::SignatureBlock::clear() +void nn::pki::SignatureBlock::clear() { mRawBinary.clear(); mSignType = sign::SIGN_ID_RSA4096_SHA1; @@ -151,32 +151,32 @@ void pki::SignatureBlock::clear() mSignature.clear(); } -pki::sign::SignatureId pki::SignatureBlock::getSignType() const +nn::pki::sign::SignatureId nn::pki::SignatureBlock::getSignType() const { return mSignType; } -void pki::SignatureBlock::setSignType(pki::sign::SignatureId type) +void nn::pki::SignatureBlock::setSignType(nn::pki::sign::SignatureId type) { mSignType = type; } -bool pki::SignatureBlock::isLittleEndian() const +bool nn::pki::SignatureBlock::isLittleEndian() const { return mIsLittleEndian; } -void pki::SignatureBlock::setLittleEndian(bool isLE) +void nn::pki::SignatureBlock::setLittleEndian(bool isLE) { mIsLittleEndian = isLE; } -const fnd::Vec& pki::SignatureBlock::getSignature() const +const fnd::Vec& nn::pki::SignatureBlock::getSignature() const { return mSignature; } -void pki::SignatureBlock::setSignature(const fnd::Vec& signature) +void nn::pki::SignatureBlock::setSignature(const fnd::Vec& signature) { mSignature = signature; } diff --git a/lib/libpolarssl/makefile b/lib/libpolarssl/makefile index 1507e0e..2c2becf 100644 --- a/lib/libpolarssl/makefile +++ b/lib/libpolarssl/makefile @@ -39,7 +39,7 @@ main: build rebuild: clean build build: $(OBJS) - ar cr -o $(OUTPUT) $(OBJS) + ar $(ARFLAGS) $(OUTPUT) $(OBJS) clean: rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/programs/nstool/source/AssetProcess.cpp b/programs/nstool/source/AssetProcess.cpp index 65d759c..ef48adf 100644 --- a/programs/nstool/source/AssetProcess.cpp +++ b/programs/nstool/source/AssetProcess.cpp @@ -74,12 +74,12 @@ void AssetProcess::setRomfsExtractPath(const std::string& path) void AssetProcess::importHeader() { fnd::Vec scratch; - if (mFile->size() < sizeof(nx::sAssetHeader)) + if (mFile->size() < sizeof(nn::hac::sAssetHeader)) { throw fnd::Exception(kModuleName, "Corrupt ASET: file too small"); } - scratch.alloc(sizeof(nx::sAssetHeader)); + scratch.alloc(sizeof(nn::hac::sAssetHeader)); mFile->read(scratch.data(), 0, scratch.size()); mHdr.fromBytes(scratch.data(), scratch.size()); diff --git a/programs/nstool/source/AssetProcess.h b/programs/nstool/source/AssetProcess.h index 4e1b707..aae5177 100644 --- a/programs/nstool/source/AssetProcess.h +++ b/programs/nstool/source/AssetProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "NacpProcess.h" #include "RomfsProcess.h" @@ -38,7 +38,7 @@ private: sOptional mIconExtractPath; sOptional mNacpExtractPath; - nx::AssetHeader mHdr; + nn::hac::AssetHeader mHdr; NacpProcess mNacp; RomfsProcess mRomfs; diff --git a/programs/nstool/source/CnmtProcess.cpp b/programs/nstool/source/CnmtProcess.cpp index 8f2e95d..1606a9d 100644 --- a/programs/nstool/source/CnmtProcess.cpp +++ b/programs/nstool/source/CnmtProcess.cpp @@ -73,27 +73,27 @@ void CnmtProcess::displayCmnt() printf(" Version: v%" PRId32 " (%d.%d.%d.%d)\n", (uint32_t)mCnmt.getTitleVersion(), _SPLIT_VER(mCnmt.getTitleVersion())); printf(" Type: %s (%d)\n", getContentMetaTypeStr(mCnmt.getType()), mCnmt.getType()); printf(" Attributes: %x\n", mCnmt.getAttributes()); - printf(" IncludesExFatDriver: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nx::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER))); - printf(" Rebootless: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nx::cnmt::ATTRIBUTE_REBOOTLESS))); + printf(" IncludesExFatDriver: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER))); + printf(" Rebootless: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_REBOOTLESS))); printf(" RequiredDownloadSystemVersion: v%" PRId32 " (%d.%d.%d.%d)\n", (uint32_t)mCnmt.getRequiredDownloadSystemVersion(), _SPLIT_VER(mCnmt.getRequiredDownloadSystemVersion())); switch(mCnmt.getType()) { - case (nx::cnmt::METATYPE_APPLICATION): + case (nn::hac::cnmt::METATYPE_APPLICATION): printf(" ApplicationExtendedHeader:\n"); printf(" RequiredSystemVersion: v%" PRId32 " (%d.%d.%d.%d)\n", (uint32_t)mCnmt.getApplicationMetaExtendedHeader().required_system_version, _SPLIT_VER(mCnmt.getApplicationMetaExtendedHeader().required_system_version)); printf(" PatchId: 0x%016" PRIx64 "\n", (uint64_t)mCnmt.getApplicationMetaExtendedHeader().patch_id); break; - case (nx::cnmt::METATYPE_PATCH): + case (nn::hac::cnmt::METATYPE_PATCH): printf(" PatchMetaExtendedHeader:\n"); printf(" RequiredSystemVersion: v%" PRId32 " (%d.%d.%d.%d))\n", (uint32_t)mCnmt.getPatchMetaExtendedHeader().required_system_version, _SPLIT_VER(mCnmt.getPatchMetaExtendedHeader().required_system_version)); printf(" ApplicationId: 0x%016" PRIx64 "\n", (uint64_t)mCnmt.getPatchMetaExtendedHeader().application_id); break; - case (nx::cnmt::METATYPE_ADD_ON_CONTENT): + case (nn::hac::cnmt::METATYPE_ADD_ON_CONTENT): printf(" AddOnContentMetaExtendedHeader:\n"); printf(" RequiredSystemVersion: v%" PRId32 " (%d.%d.%d.%d)\n", (uint32_t)mCnmt.getAddOnContentMetaExtendedHeader().required_system_version, _SPLIT_VER(mCnmt.getAddOnContentMetaExtendedHeader().required_system_version)); printf(" ApplicationId: 0x%016" PRIx64 "\n", (uint64_t)mCnmt.getAddOnContentMetaExtendedHeader().application_id); break; - case (nx::cnmt::METATYPE_DELTA): + case (nn::hac::cnmt::METATYPE_DELTA): printf(" DeltaMetaExtendedHeader:\n"); printf(" ApplicationId: 0x%016" PRIx64 "\n", (uint64_t)mCnmt.getDeltaMetaExtendedHeader().application_id); break; @@ -105,11 +105,11 @@ void CnmtProcess::displayCmnt() printf(" ContentInfo:\n"); for (size_t i = 0; i < mCnmt.getContentInfo().size(); i++) { - const nx::ContentMetaBinary::ContentInfo& info = mCnmt.getContentInfo()[i]; + const nn::hac::ContentMetaBinary::ContentInfo& info = mCnmt.getContentInfo()[i]; printf(" %d\n", (int)i); printf(" Type: %s (%d)\n", getContentTypeStr(info.type), info.type); printf(" Id: "); - _HEXDUMP_L(info.nca_id, nx::cnmt::kContentIdLen); + _HEXDUMP_L(info.nca_id, nn::hac::cnmt::kContentIdLen); printf("\n"); printf(" Size: 0x%" PRIx64 "\n", (uint64_t)info.size); printf(" Hash: "); @@ -122,18 +122,18 @@ void CnmtProcess::displayCmnt() printf(" ContentMetaInfo:\n"); for (size_t i = 0; i < mCnmt.getContentMetaInfo().size(); i++) { - const nx::ContentMetaBinary::ContentMetaInfo& info = mCnmt.getContentMetaInfo()[i]; + const nn::hac::ContentMetaBinary::ContentMetaInfo& info = mCnmt.getContentMetaInfo()[i]; printf(" %d\n", (int)i); printf(" Id: 0x%016" PRIx64 "\n", (uint64_t)info.id); printf(" Version: v%" PRId32 " (%d.%d.%d.%d)\n", (uint32_t)info.version, _SPLIT_VER(info.version)); printf(" Type: %s (%d)\n", getContentMetaTypeStr(info.type), info.type); printf(" Attributes: %x\n", mCnmt.getAttributes()); - printf(" IncludesExFatDriver: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nx::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER))); - printf(" Rebootless: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nx::cnmt::ATTRIBUTE_REBOOTLESS))); + printf(" IncludesExFatDriver: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER))); + printf(" Rebootless: %s\n", getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_REBOOTLESS))); } } printf(" Digest: "); - _HEXDUMP_L(mCnmt.getDigest().data, nx::cnmt::kDigestLen); + _HEXDUMP_L(mCnmt.getDigest().data, nn::hac::cnmt::kDigestLen); printf("\n"); #undef _HEXDUMP_L @@ -191,7 +191,7 @@ void CnmtProcess::setVerifyMode(bool verify) mVerify = verify; } -const nx::ContentMetaBinary& CnmtProcess::getContentMetaBinary() const +const nn::hac::ContentMetaBinary& CnmtProcess::getContentMetaBinary() const { return mCnmt; } diff --git a/programs/nstool/source/CnmtProcess.h b/programs/nstool/source/CnmtProcess.h index 7fbd65a..1f4ca52 100644 --- a/programs/nstool/source/CnmtProcess.h +++ b/programs/nstool/source/CnmtProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -18,7 +18,7 @@ public: void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); - const nx::ContentMetaBinary& getContentMetaBinary() const; + const nn::hac::ContentMetaBinary& getContentMetaBinary() const; private: const std::string kModuleName = "CnmtProcess"; @@ -28,7 +28,7 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - nx::ContentMetaBinary mCnmt; + nn::hac::ContentMetaBinary mCnmt; void displayCmnt(); }; \ No newline at end of file diff --git a/programs/nstool/source/ElfSymbolParser.cpp b/programs/nstool/source/ElfSymbolParser.cpp index 9808a19..acac3d0 100644 --- a/programs/nstool/source/ElfSymbolParser.cpp +++ b/programs/nstool/source/ElfSymbolParser.cpp @@ -23,7 +23,7 @@ bool ElfSymbolParser::operator!=(const ElfSymbolParser& other) const void ElfSymbolParser::parseData(const byte_t *dyn_sym, size_t dyn_sym_size, const byte_t *dyn_str, size_t dyn_str_size, bool is64Bit) { //printf("ElfSymbolParser::parseData()"); - size_t dynSymSize = is64Bit ? sizeof(nx::sElfSymbol64Bit) : sizeof(nx::sElfSymbol32Bit); + size_t dynSymSize = is64Bit ? sizeof(nn::hac::sElfSymbol64Bit) : sizeof(nn::hac::sElfSymbol32Bit); sElfSymbol symbol; for (size_t i = 0; i < dyn_sym_size; i += dynSymSize) @@ -34,17 +34,17 @@ void ElfSymbolParser::parseData(const byte_t *dyn_sym, size_t dyn_sym_size, cons if (is64Bit) { - name_pos = ((nx::sElfSymbol64Bit*)(dyn_sym + i))->name.get(); - symbol.shn_index = (nx::elf::SpecialSectionIndex)((nx::sElfSymbol64Bit*)(dyn_sym + i))->special_section_index.get(); - symbol.symbol_type = (nx::elf::SymbolType)((((nx::sElfSymbol64Bit*)(dyn_sym + i))->info) & nx::elf::STT_HIPROC); - symbol.symbol_binding = (nx::elf::SymbolBinding)(((((nx::sElfSymbol64Bit*)(dyn_sym + i))->info) >> 4) & nx::elf::STB_HIPROC); + name_pos = ((nn::hac::sElfSymbol64Bit*)(dyn_sym + i))->name.get(); + symbol.shn_index = (nn::hac::elf::SpecialSectionIndex)((nn::hac::sElfSymbol64Bit*)(dyn_sym + i))->special_section_index.get(); + symbol.symbol_type = (nn::hac::elf::SymbolType)((((nn::hac::sElfSymbol64Bit*)(dyn_sym + i))->info) & nn::hac::elf::STT_HIPROC); + symbol.symbol_binding = (nn::hac::elf::SymbolBinding)(((((nn::hac::sElfSymbol64Bit*)(dyn_sym + i))->info) >> 4) & nn::hac::elf::STB_HIPROC); } else { - name_pos = ((nx::sElfSymbol64Bit*)(dyn_sym + i))->name.get(); - symbol.shn_index = (nx::elf::SpecialSectionIndex)((nx::sElfSymbol32Bit*)(dyn_sym + i))->special_section_index.get(); - symbol.symbol_type = (nx::elf::SymbolType)((((nx::sElfSymbol32Bit*)(dyn_sym + i))->info.get()) & nx::elf::STT_HIPROC); - symbol.symbol_binding = (nx::elf::SymbolBinding)(((((nx::sElfSymbol32Bit*)(dyn_sym + i))->info.get()) >> 4) & nx::elf::STB_HIPROC); + name_pos = ((nn::hac::sElfSymbol64Bit*)(dyn_sym + i))->name.get(); + symbol.shn_index = (nn::hac::elf::SpecialSectionIndex)((nn::hac::sElfSymbol32Bit*)(dyn_sym + i))->special_section_index.get(); + symbol.symbol_type = (nn::hac::elf::SymbolType)((((nn::hac::sElfSymbol32Bit*)(dyn_sym + i))->info.get()) & nn::hac::elf::STT_HIPROC); + symbol.symbol_binding = (nn::hac::elf::SymbolBinding)(((((nn::hac::sElfSymbol32Bit*)(dyn_sym + i))->info.get()) >> 4) & nn::hac::elf::STB_HIPROC); } for (; dyn_str[name_pos] == 0x00 && name_pos < dyn_str_size; name_pos++); diff --git a/programs/nstool/source/ElfSymbolParser.h b/programs/nstool/source/ElfSymbolParser.h index 751b535..a4e4b5c 100644 --- a/programs/nstool/source/ElfSymbolParser.h +++ b/programs/nstool/source/ElfSymbolParser.h @@ -1,16 +1,16 @@ #pragma once #include #include -#include +#include class ElfSymbolParser { public: struct sElfSymbol { - nx::elf::SpecialSectionIndex shn_index; - nx::elf::SymbolType symbol_type; - nx::elf::SymbolBinding symbol_binding; + nn::hac::elf::SpecialSectionIndex shn_index; + nn::hac::elf::SymbolType symbol_type; + nn::hac::elf::SymbolBinding symbol_binding; std::string name; void operator=(const sElfSymbol& other) diff --git a/programs/nstool/source/EsTikProcess.cpp b/programs/nstool/source/EsTikProcess.cpp index 22402a8..fb897de 100644 --- a/programs/nstool/source/EsTikProcess.cpp +++ b/programs/nstool/source/EsTikProcess.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "OffsetAdjustedIFile.h" #include "EsTikProcess.h" #include "PkiValidator.h" diff --git a/programs/nstool/source/EsTikProcess.h b/programs/nstool/source/EsTikProcess.h index 2ada90c..2424156 100644 --- a/programs/nstool/source/EsTikProcess.h +++ b/programs/nstool/source/EsTikProcess.h @@ -3,9 +3,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include "nstool.h" class EsTikProcess diff --git a/programs/nstool/source/HashTreeMeta.cpp b/programs/nstool/source/HashTreeMeta.cpp index a8d4d41..4822164 100644 --- a/programs/nstool/source/HashTreeMeta.cpp +++ b/programs/nstool/source/HashTreeMeta.cpp @@ -40,13 +40,13 @@ void HashTreeMeta::importData(const byte_t* data, size_t len, HashTreeType type) { if (type == HASH_TYPE_INTEGRITY) { - nx::HierarchicalIntegrityHeader hdr; + nn::hac::HierarchicalIntegrityHeader hdr; hdr.fromBytes(data, len); importHierarchicalIntergityHeader(hdr); } else if (type == HASH_TYPE_SHA256) { - nx::HierarchicalSha256Header hdr; + nn::hac::HierarchicalSha256Header hdr; hdr.fromBytes(data, len); importHierarchicalSha256Header(hdr); } @@ -92,7 +92,7 @@ void HashTreeMeta::setAlignHashToBlock(bool doAlign) mDoAlignHashToBlock = doAlign; } -void HashTreeMeta::importHierarchicalIntergityHeader(const nx::HierarchicalIntegrityHeader& hdr) +void HashTreeMeta::importHierarchicalIntergityHeader(const nn::hac::HierarchicalIntegrityHeader& hdr) { mDoAlignHashToBlock = true; for (size_t i = 0; i < hdr.getLayerInfo().size(); i++) @@ -113,7 +113,7 @@ void HashTreeMeta::importHierarchicalIntergityHeader(const nx::HierarchicalInteg mMasterHashList = hdr.getMasterHashList(); } -void HashTreeMeta::importHierarchicalSha256Header(const nx::HierarchicalSha256Header& hdr) +void HashTreeMeta::importHierarchicalSha256Header(const nn::hac::HierarchicalSha256Header& hdr) { mDoAlignHashToBlock = false; for (size_t i = 0; i < hdr.getLayerInfo().size(); i++) diff --git a/programs/nstool/source/HashTreeMeta.h b/programs/nstool/source/HashTreeMeta.h index f8225a2..ecdbdda 100644 --- a/programs/nstool/source/HashTreeMeta.h +++ b/programs/nstool/source/HashTreeMeta.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include class HashTreeMeta { @@ -63,6 +63,6 @@ private: fnd::List mMasterHashList; bool mDoAlignHashToBlock; - void importHierarchicalIntergityHeader(const nx::HierarchicalIntegrityHeader& hdr); - void importHierarchicalSha256Header(const nx::HierarchicalSha256Header& hdr); + void importHierarchicalIntergityHeader(const nn::hac::HierarchicalIntegrityHeader& hdr); + void importHierarchicalSha256Header(const nn::hac::HierarchicalSha256Header& hdr); }; \ No newline at end of file diff --git a/programs/nstool/source/NacpProcess.cpp b/programs/nstool/source/NacpProcess.cpp index dfbe51a..52cb2f8 100644 --- a/programs/nstool/source/NacpProcess.cpp +++ b/programs/nstool/source/NacpProcess.cpp @@ -3,54 +3,54 @@ #include "OffsetAdjustedIFile.h" #include "NacpProcess.h" -const char* getLanguageStr(nx::nacp::Language var) +const char* getLanguageStr(nn::hac::nacp::Language var) { const char* str = nullptr; switch(var) { - case (nx::nacp::LANG_AmericanEnglish): + case (nn::hac::nacp::LANG_AmericanEnglish): str = "AmericanEnglish"; break; - case (nx::nacp::LANG_BritishEnglish): + case (nn::hac::nacp::LANG_BritishEnglish): str = "BritishEnglish"; break; - case (nx::nacp::LANG_Japanese): + case (nn::hac::nacp::LANG_Japanese): str = "Japanese"; break; - case (nx::nacp::LANG_French): + case (nn::hac::nacp::LANG_French): str = "French"; break; - case (nx::nacp::LANG_German): + case (nn::hac::nacp::LANG_German): str = "German"; break; - case (nx::nacp::LANG_LatinAmericanSpanish): + case (nn::hac::nacp::LANG_LatinAmericanSpanish): str = "LatinAmericanSpanish"; break; - case (nx::nacp::LANG_Spanish): + case (nn::hac::nacp::LANG_Spanish): str = "Spanish"; break; - case (nx::nacp::LANG_Italian): + case (nn::hac::nacp::LANG_Italian): str = "Italian"; break; - case (nx::nacp::LANG_Dutch): + case (nn::hac::nacp::LANG_Dutch): str = "Dutch"; break; - case (nx::nacp::LANG_CanadianFrench): + case (nn::hac::nacp::LANG_CanadianFrench): str = "CanadianFrench"; break; - case (nx::nacp::LANG_Portuguese): + case (nn::hac::nacp::LANG_Portuguese): str = "Portuguese"; break; - case (nx::nacp::LANG_Russian): + case (nn::hac::nacp::LANG_Russian): str = "Russian"; break; - case (nx::nacp::LANG_Korean): + case (nn::hac::nacp::LANG_Korean): str = "Korean"; break; - case (nx::nacp::LANG_TraditionalChinese): + case (nn::hac::nacp::LANG_TraditionalChinese): str = "TraditionalChinese"; break; - case (nx::nacp::LANG_SimplifiedChinese): + case (nn::hac::nacp::LANG_SimplifiedChinese): str = "SimplifiedChinese"; break; default: @@ -59,18 +59,18 @@ const char* getLanguageStr(nx::nacp::Language var) return str; } -const char* getStartupUserAccountStr(nx::nacp::StartupUserAccount var) +const char* getStartupUserAccountStr(nn::hac::nacp::StartupUserAccount var) { const char* str = nullptr; switch(var) { - case (nx::nacp::USER_None): + case (nn::hac::nacp::USER_None): str = "None"; break; - case (nx::nacp::USER_Required): + case (nn::hac::nacp::USER_Required): str = "Required"; break; - case (nx::nacp::USER_RequiredWithNetworkServiceAccountAvailable): + case (nn::hac::nacp::USER_RequiredWithNetworkServiceAccountAvailable): str = "RequiredWithNetworkServiceAccountAvailable"; break; default: @@ -79,18 +79,18 @@ const char* getStartupUserAccountStr(nx::nacp::StartupUserAccount var) return str; } -const char* getTouchScreenUsageModeStr(nx::nacp::TouchScreenUsageMode var) +const char* getTouchScreenUsageModeStr(nn::hac::nacp::TouchScreenUsageMode var) { const char* str = nullptr; switch(var) { - case (nx::nacp::TOUCH_None): + case (nn::hac::nacp::TOUCH_None): str = "None"; break; - case (nx::nacp::TOUCH_Supported): + case (nn::hac::nacp::TOUCH_Supported): str = "Supported"; break; - case (nx::nacp::TOUCH_Required): + case (nn::hac::nacp::TOUCH_Required): str = "Required"; break; default: @@ -99,15 +99,15 @@ const char* getTouchScreenUsageModeStr(nx::nacp::TouchScreenUsageMode var) return str; } -const char* getAocRegistrationTypeStr(nx::nacp::AocRegistrationType var) +const char* getAocRegistrationTypeStr(nn::hac::nacp::AocRegistrationType var) { const char* str = nullptr; switch(var) { - case (nx::nacp::AOC_AllOnLaunch): + case (nn::hac::nacp::AOC_AllOnLaunch): str = "AllOnLaunch"; break; - case (nx::nacp::AOC_OnDemand): + case (nn::hac::nacp::AOC_OnDemand): str = "OnDemand"; break; default: @@ -116,18 +116,18 @@ const char* getAocRegistrationTypeStr(nx::nacp::AocRegistrationType var) return str; } -const char* getAttributeFlagStr(nx::nacp::AttributeFlag var) +const char* getAttributeFlagStr(nn::hac::nacp::AttributeFlag var) { const char* str = nullptr; switch(var) { - case (nx::nacp::ATTR_None): + case (nn::hac::nacp::ATTR_None): str = "None"; break; - case (nx::nacp::ATTR_Demo): + case (nn::hac::nacp::ATTR_Demo): str = "Demo"; break; - case (nx::nacp::ATTR_RetailInteractiveDisplay): + case (nn::hac::nacp::ATTR_RetailInteractiveDisplay): str = "RetailInteractiveDisplay"; break; default: @@ -136,15 +136,15 @@ const char* getAttributeFlagStr(nx::nacp::AttributeFlag var) return str; } -const char* getParentalControlFlagStr(nx::nacp::ParentalControlFlag var) +const char* getParentalControlFlagStr(nn::hac::nacp::ParentalControlFlag var) { const char* str = nullptr; switch(var) { - case (nx::nacp::PC_None): + case (nn::hac::nacp::PC_None): str = "None"; break; - case (nx::nacp::PC_FreeCommunication): + case (nn::hac::nacp::PC_FreeCommunication): str = "FreeCommunication"; break; default: @@ -153,15 +153,15 @@ const char* getParentalControlFlagStr(nx::nacp::ParentalControlFlag var) return str; } -const char* getScreenshotModeStr(nx::nacp::ScreenshotMode var) +const char* getScreenshotModeStr(nn::hac::nacp::ScreenshotMode var) { const char* str = nullptr; switch(var) { - case (nx::nacp::SCRN_Allow): + case (nn::hac::nacp::SCRN_Allow): str = "Allow"; break; - case (nx::nacp::SCRN_Deny): + case (nn::hac::nacp::SCRN_Deny): str = "Deny"; break; default: @@ -170,18 +170,18 @@ const char* getScreenshotModeStr(nx::nacp::ScreenshotMode var) return str; } -const char* getVideoCaptureModeStr(nx::nacp::VideoCaptureMode var) +const char* getVideoCaptureModeStr(nn::hac::nacp::VideoCaptureMode var) { const char* str = nullptr; switch(var) { - case (nx::nacp::VCAP_Disable): + case (nn::hac::nacp::VCAP_Disable): str = "Disable"; break; - case (nx::nacp::VCAP_Manual): + case (nn::hac::nacp::VCAP_Manual): str = "Manual"; break; - case (nx::nacp::VCAP_Enable): + case (nn::hac::nacp::VCAP_Enable): str = "Enable"; break; default: @@ -190,15 +190,15 @@ const char* getVideoCaptureModeStr(nx::nacp::VideoCaptureMode var) return str; } -const char* getDataLossConfirmationStr(nx::nacp::DataLossConfirmation var) +const char* getDataLossConfirmationStr(nn::hac::nacp::DataLossConfirmation var) { const char* str = nullptr; switch(var) { - case (nx::nacp::DLOSS_None): + case (nn::hac::nacp::DLOSS_None): str = "None"; break; - case (nx::nacp::DLOSS_Required): + case (nn::hac::nacp::DLOSS_Required): str = "Required"; break; default: @@ -207,18 +207,18 @@ const char* getDataLossConfirmationStr(nx::nacp::DataLossConfirmation var) return str; } -const char* getPlayLogPolicyStr(nx::nacp::PlayLogPolicy var) +const char* getPlayLogPolicyStr(nn::hac::nacp::PlayLogPolicy var) { const char* str = nullptr; switch(var) { - case (nx::nacp::PLP_All): + case (nn::hac::nacp::PLP_All): str = "All"; break; - case (nx::nacp::PLP_LogOnly): + case (nn::hac::nacp::PLP_LogOnly): str = "LogOnly"; break; - case (nx::nacp::PLP_None): + case (nn::hac::nacp::PLP_None): str = "None"; break; default: @@ -227,45 +227,45 @@ const char* getPlayLogPolicyStr(nx::nacp::PlayLogPolicy var) return str; } -const char* getOrganisationStr(nx::nacp::Organisation var) +const char* getOrganisationStr(nn::hac::nacp::Organisation var) { const char* str = nullptr; switch(var) { - case (nx::nacp::ORGN_CERO): + case (nn::hac::nacp::ORGN_CERO): str = "CERO"; break; - case (nx::nacp::ORGN_GRACGCRB): + case (nn::hac::nacp::ORGN_GRACGCRB): str = "GRACGCRB"; break; - case (nx::nacp::ORGN_GSRMR): + case (nn::hac::nacp::ORGN_GSRMR): str = "GSRMR"; break; - case (nx::nacp::ORGN_ESRB): + case (nn::hac::nacp::ORGN_ESRB): str = "ESRB"; break; - case (nx::nacp::ORGN_ClassInd): + case (nn::hac::nacp::ORGN_ClassInd): str = "ClassInd"; break; - case (nx::nacp::ORGN_USK): + case (nn::hac::nacp::ORGN_USK): str = "USK"; break; - case (nx::nacp::ORGN_PEGI): + case (nn::hac::nacp::ORGN_PEGI): str = "PEGI"; break; - case (nx::nacp::ORGN_PEGIPortugal): + case (nn::hac::nacp::ORGN_PEGIPortugal): str = "PEGIPortugal"; break; - case (nx::nacp::ORGN_PEGIBBFC): + case (nn::hac::nacp::ORGN_PEGIBBFC): str = "PEGIBBFC"; break; - case (nx::nacp::ORGN_Russian): + case (nn::hac::nacp::ORGN_Russian): str = "Russian"; break; - case (nx::nacp::ORGN_ACB): + case (nn::hac::nacp::ORGN_ACB): str = "ACB"; break; - case (nx::nacp::ORGN_OFLC): + case (nn::hac::nacp::ORGN_OFLC): str = "OFLC"; break; default: @@ -274,18 +274,18 @@ const char* getOrganisationStr(nx::nacp::Organisation var) return str; } -const char* getLogoTypeStr(nx::nacp::LogoType var) +const char* getLogoTypeStr(nn::hac::nacp::LogoType var) { const char* str = nullptr; switch(var) { - case (nx::nacp::LOGO_LicensedByNintendo): + case (nn::hac::nacp::LOGO_LicensedByNintendo): str = "LicensedByNintendo"; break; - case (nx::nacp::LOGO_DistributedByNintendo): + case (nn::hac::nacp::LOGO_DistributedByNintendo): str = "DistributedByNintendo"; break; - case (nx::nacp::LOGO_Nintendo): + case (nn::hac::nacp::LOGO_Nintendo): str = "Nintendo"; break; default: @@ -294,15 +294,15 @@ const char* getLogoTypeStr(nx::nacp::LogoType var) return str; } -const char* getLogoHandlingStr(nx::nacp::LogoHandling var) +const char* getLogoHandlingStr(nn::hac::nacp::LogoHandling var) { const char* str = nullptr; switch(var) { - case (nx::nacp::LHND_Auto): + case (nn::hac::nacp::LHND_Auto): str = "Auto"; break; - case (nx::nacp::LHND_None): + case (nn::hac::nacp::LHND_None): str = "None"; break; default: @@ -311,15 +311,15 @@ const char* getLogoHandlingStr(nx::nacp::LogoHandling var) return str; } -const char* getRuntimeAocInstallModeStr(nx::nacp::RuntimeAocInstallMode var) +const char* getRuntimeAocInstallModeStr(nn::hac::nacp::RuntimeAocInstallMode var) { const char* str = nullptr; switch(var) { - case (nx::nacp::RTAOC_Deny): + case (nn::hac::nacp::RTAOC_Deny): str = "Deny"; break; - case (nx::nacp::RTAOC_AllowAppend): + case (nn::hac::nacp::RTAOC_AllowAppend): str = "AllowAppend"; break; default: @@ -328,15 +328,15 @@ const char* getRuntimeAocInstallModeStr(nx::nacp::RuntimeAocInstallMode var) return str; } -const char* getCrashReportModeStr(nx::nacp::CrashReportMode var) +const char* getCrashReportModeStr(nn::hac::nacp::CrashReportMode var) { const char* str = nullptr; switch(var) { - case (nx::nacp::CREP_Deny): + case (nn::hac::nacp::CREP_Deny): str = "Deny"; break; - case (nx::nacp::CREP_Allow): + case (nn::hac::nacp::CREP_Allow): str = "Allow"; break; default: @@ -345,15 +345,15 @@ const char* getCrashReportModeStr(nx::nacp::CrashReportMode var) return str; } -const char* getHdcpStr(nx::nacp::Hdcp var) +const char* getHdcpStr(nn::hac::nacp::Hdcp var) { const char* str = nullptr; switch(var) { - case (nx::nacp::HDCP_None): + case (nn::hac::nacp::HDCP_None): str = "None"; break; - case (nx::nacp::HDCP_Required): + case (nn::hac::nacp::HDCP_Required): str = "Required"; break; default: @@ -362,18 +362,18 @@ const char* getHdcpStr(nx::nacp::Hdcp var) return str; } -const char* getPlayLogQueryCapabilityStr(nx::nacp::PlayLogQueryCapability var) +const char* getPlayLogQueryCapabilityStr(nn::hac::nacp::PlayLogQueryCapability var) { const char* str = nullptr; switch(var) { - case (nx::nacp::PLQC_None): + case (nn::hac::nacp::PLQC_None): str = "None"; break; - case (nx::nacp::PLQC_Whitelist): + case (nn::hac::nacp::PLQC_Whitelist): str = "Whitelist"; break; - case (nx::nacp::PLQC_All): + case (nn::hac::nacp::PLQC_All): str = "All"; break; default: @@ -382,15 +382,15 @@ const char* getPlayLogQueryCapabilityStr(nx::nacp::PlayLogQueryCapability var) return str; } -const char* getRepairFlagStr(nx::nacp::RepairFlag var) +const char* getRepairFlagStr(nn::hac::nacp::RepairFlag var) { const char* str = nullptr; switch(var) { - case (nx::nacp::REPF_None): + case (nn::hac::nacp::REPF_None): str = "None"; break; - case (nx::nacp::REPF_SuppressGameCardAccess): + case (nn::hac::nacp::REPF_SuppressGameCardAccess): str = "SuppressGameCardAccess"; break; default: @@ -473,7 +473,7 @@ void NacpProcess::setVerifyMode(bool verify) mVerify = verify; } -const nx::ApplicationControlPropertyBinary& NacpProcess::getApplicationControlPropertyBinary() const +const nn::hac::ApplicationControlPropertyBinary& NacpProcess::getApplicationControlPropertyBinary() const { return mNacp; } diff --git a/programs/nstool/source/NacpProcess.h b/programs/nstool/source/NacpProcess.h index bd7dc82..7511d79 100644 --- a/programs/nstool/source/NacpProcess.h +++ b/programs/nstool/source/NacpProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -18,7 +18,7 @@ public: void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); - const nx::ApplicationControlPropertyBinary& getApplicationControlPropertyBinary() const; + const nn::hac::ApplicationControlPropertyBinary& getApplicationControlPropertyBinary() const; private: const std::string kModuleName = "NacpProcess"; @@ -28,7 +28,7 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - nx::ApplicationControlPropertyBinary mNacp; + nn::hac::ApplicationControlPropertyBinary mNacp; void displayNacp(); }; \ No newline at end of file diff --git a/programs/nstool/source/NcaProcess.cpp b/programs/nstool/source/NcaProcess.cpp index 5080f06..bf7838b 100644 --- a/programs/nstool/source/NcaProcess.cpp +++ b/programs/nstool/source/NcaProcess.cpp @@ -1,8 +1,8 @@ #include #include #include -#include -#include +#include +#include #include "NcaProcess.h" #include "PfsProcess.h" #include "RomfsProcess.h" @@ -11,15 +11,15 @@ #include "AesCtrWrappedIFile.h" #include "HashTreeWrappedIFile.h" -const char* getFormatVersionStr(nx::NcaHeader::FormatVersion format_ver) +const char* getFormatVersionStr(nn::hac::NcaHeader::FormatVersion format_ver) { const char* str; switch (format_ver) { - case (nx::NcaHeader::NCA2_FORMAT): + case (nn::hac::NcaHeader::NCA2_FORMAT): str = "NCA2"; break; - case (nx::NcaHeader::NCA3_FORMAT): + case (nn::hac::NcaHeader::NCA3_FORMAT): str = "NCA3"; break; default: @@ -29,15 +29,15 @@ const char* getFormatVersionStr(nx::NcaHeader::FormatVersion format_ver) return str; } -const char* getDistributionTypeStr(nx::nca::DistributionType dist_type) +const char* getDistributionTypeStr(nn::hac::nca::DistributionType dist_type) { const char* str; switch (dist_type) { - case (nx::nca::DIST_DOWNLOAD): + case (nn::hac::nca::DIST_DOWNLOAD): str = "Download"; break; - case (nx::nca::DIST_GAME_CARD): + case (nn::hac::nca::DIST_GAME_CARD): str = "Game Card"; break; default: @@ -48,27 +48,27 @@ const char* getDistributionTypeStr(nx::nca::DistributionType dist_type) } - const char* getContentTypeStr(nx::nca::ContentType cont_type) + const char* getContentTypeStr(nn::hac::nca::ContentType cont_type) { const char* str; switch (cont_type) { - case (nx::nca::TYPE_PROGRAM): + case (nn::hac::nca::TYPE_PROGRAM): str = "Program"; break; - case (nx::nca::TYPE_META): + case (nn::hac::nca::TYPE_META): str = "Meta"; break; - case (nx::nca::TYPE_CONTROL): + case (nn::hac::nca::TYPE_CONTROL): str = "Control"; break; - case (nx::nca::TYPE_MANUAL): + case (nn::hac::nca::TYPE_MANUAL): str = "Manual"; break; - case (nx::nca::TYPE_DATA): + case (nn::hac::nca::TYPE_DATA): str = "Data"; break; - case (nx::nca::TYPE_PUBLIC_DATA): + case (nn::hac::nca::TYPE_PUBLIC_DATA): str = "PublicData"; break; default: @@ -78,24 +78,24 @@ const char* getDistributionTypeStr(nx::nca::DistributionType dist_type) return str; } -const char* getEncryptionTypeStr(nx::nca::EncryptionType enc_type) +const char* getEncryptionTypeStr(nn::hac::nca::EncryptionType enc_type) { const char* str; switch (enc_type) { - case (nx::nca::CRYPT_AUTO): + case (nn::hac::nca::CRYPT_AUTO): str = "Auto"; break; - case (nx::nca::CRYPT_NONE): + case (nn::hac::nca::CRYPT_NONE): str = "None"; break; - case (nx::nca::CRYPT_AESXTS): + case (nn::hac::nca::CRYPT_AESXTS): str = "AesXts"; break; - case (nx::nca::CRYPT_AESCTR): + case (nn::hac::nca::CRYPT_AESCTR): str = "AesCtr"; break; - case (nx::nca::CRYPT_AESCTREX): + case (nn::hac::nca::CRYPT_AESCTREX): str = "AesCtrEx"; break; default: @@ -105,21 +105,21 @@ const char* getEncryptionTypeStr(nx::nca::EncryptionType enc_type) return str; } -inline const char* getHashTypeStr(nx::nca::HashType hash_type) +inline const char* getHashTypeStr(nn::hac::nca::HashType hash_type) { const char* str; switch (hash_type) { - case (nx::nca::HASH_AUTO): + case (nn::hac::nca::HASH_AUTO): str = "Auto"; break; - case (nx::nca::HASH_NONE): + case (nn::hac::nca::HASH_NONE): str = "None"; break; - case (nx::nca::HASH_HIERARCHICAL_SHA256): + case (nn::hac::nca::HASH_HIERARCHICAL_SHA256): str = "HierarchicalSha256"; break; - case (nx::nca::HASH_HIERARCHICAL_INTERGRITY): + case (nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY): str = "HierarchicalIntegrity"; break; default: @@ -129,15 +129,15 @@ inline const char* getHashTypeStr(nx::nca::HashType hash_type) return str; } -inline const char* getFormatTypeStr(nx::nca::FormatType format_type) +inline const char* getFormatTypeStr(nn::hac::nca::FormatType format_type) { const char* str; switch (format_type) { - case (nx::nca::FORMAT_ROMFS): + case (nn::hac::nca::FORMAT_ROMFS): str = "RomFs"; break; - case (nx::nca::FORMAT_PFS0): + case (nn::hac::nca::FORMAT_PFS0): str = "PartitionFs"; break; default: @@ -147,18 +147,18 @@ inline const char* getFormatTypeStr(nx::nca::FormatType format_type) return str; } -inline const char* getKaekIndexStr(nx::nca::KeyAreaEncryptionKeyIndex keak_index) +inline const char* getKaekIndexStr(nn::hac::nca::KeyAreaEncryptionKeyIndex keak_index) { const char* str; switch (keak_index) { - case (nx::nca::KAEK_IDX_APPLICATION): + case (nn::hac::nca::KAEK_IDX_APPLICATION): str = "Application"; break; - case (nx::nca::KAEK_IDX_OCEAN): + case (nn::hac::nca::KAEK_IDX_OCEAN): str = "Ocean"; break; - case (nx::nca::KAEK_IDX_SYSTEM): + case (nn::hac::nca::KAEK_IDX_SYSTEM): str = "System"; break; default: @@ -168,27 +168,27 @@ inline const char* getKaekIndexStr(nx::nca::KeyAreaEncryptionKeyIndex keak_index return str; } -inline const char* getContentTypeForMountStr(nx::nca::ContentType cont_type) +inline const char* getContentTypeForMountStr(nn::hac::nca::ContentType cont_type) { const char* str; switch (cont_type) { - case (nx::nca::TYPE_PROGRAM): + case (nn::hac::nca::TYPE_PROGRAM): str = "program"; break; - case (nx::nca::TYPE_META): + case (nn::hac::nca::TYPE_META): str = "meta"; break; - case (nx::nca::TYPE_CONTROL): + case (nn::hac::nca::TYPE_CONTROL): str = "control"; break; - case (nx::nca::TYPE_MANUAL): + case (nn::hac::nca::TYPE_MANUAL): str = "manual"; break; - case (nx::nca::TYPE_DATA): + case (nn::hac::nca::TYPE_DATA): str = "data"; break; - case (nx::nca::TYPE_PUBLIC_DATA): + case (nn::hac::nca::TYPE_PUBLIC_DATA): str = "publicData"; break; default: @@ -203,13 +203,13 @@ const char* getProgramPartitionNameStr(size_t i) const char* str; switch (i) { - case (nx::nca::PARTITION_CODE): + case (nn::hac::nca::PARTITION_CODE): str = "code"; break; - case (nx::nca::PARTITION_DATA): + case (nn::hac::nca::PARTITION_DATA): str = "data"; break; - case (nx::nca::PARTITION_LOGO): + case (nn::hac::nca::PARTITION_LOGO): str = "logo"; break; default: @@ -228,7 +228,7 @@ NcaProcess::NcaProcess() : mVerify(false), mListFs(false) { - for (size_t i = 0; i < nx::nca::kPartitionNum; i++) + for (size_t i = 0; i < nn::hac::nca::kPartitionNum; i++) { mPartitionPath[i].doExtract = false; mPartitions[i].reader = nullptr; @@ -242,7 +242,7 @@ NcaProcess::~NcaProcess() delete mFile; } - for (size_t i = 0; i < nx::nca::kPartitionNum; i++) + for (size_t i = 0; i < nn::hac::nca::kPartitionNum; i++) { if (mPartitions[i].reader != nullptr) { @@ -259,16 +259,16 @@ void NcaProcess::process() } // read header block - mFile->read((byte_t*)&mHdrBlock, 0, sizeof(nx::sNcaHeaderBlock)); + mFile->read((byte_t*)&mHdrBlock, 0, sizeof(nn::hac::sNcaHeaderBlock)); // decrypt header block - nx::NcaUtils::decryptNcaHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, mKeyset->nca.header_key); + nn::hac::NcaUtils::decryptNcaHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, mKeyset->nca.header_key); // generate header hash - crypto::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nx::sNcaHeader), mHdrHash.bytes); + crypto::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader), mHdrHash.bytes); // proccess main header - mHdr.fromBytes((byte_t*)&mHdrBlock.header, sizeof(nx::sNcaHeader)); + mHdr.fromBytes((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader)); // determine keys generateNcaBodyEncryptionKeys(); @@ -347,12 +347,12 @@ void NcaProcess::generateNcaBodyEncryptionKeys() memset(zero_aesxts_key.key, 0, sizeof(zero_aesxts_key)); // get key data from header - byte_t masterkey_rev = nx::NcaUtils::getMasterKeyRevisionFromKeyGeneration(mHdr.getKeyGeneration()); + byte_t masterkey_rev = nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(mHdr.getKeyGeneration()); byte_t keak_index = mHdr.getKaekIndex(); // process key area sKeys::sKeyAreaKey keak; - for (size_t i = 0; i < nx::nca::kAesKeyNum; i++) + for (size_t i = 0; i < nn::hac::nca::kAesKeyNum; i++) { if (mHdr.getEncAesKeys()[i] != zero_aesctr_key) { @@ -361,7 +361,7 @@ void NcaProcess::generateNcaBodyEncryptionKeys() if (i < 4 && mKeyset->nca.key_area_key[keak_index][masterkey_rev] != zero_aesctr_key) { keak.decrypted = true; - nx::AesKeygen::generateKey(keak.dec.key, keak.enc.key, mKeyset->nca.key_area_key[keak_index][masterkey_rev].key); + nn::hac::AesKeygen::generateKey(keak.dec.key, keak.enc.key, mKeyset->nca.key_area_key[keak_index][masterkey_rev].key); } else { @@ -384,13 +384,13 @@ void NcaProcess::generateNcaBodyEncryptionKeys() // the title key is provided (sourced from ticket) if (mKeyset->nca.manual_title_key_aesctr != zero_aesctr_key) { - nx::AesKeygen::generateKey(mBodyKeys.aes_ctr.var.key, mKeyset->nca.manual_title_key_aesctr.key, mKeyset->ticket.titlekey_kek[masterkey_rev].key); + nn::hac::AesKeygen::generateKey(mBodyKeys.aes_ctr.var.key, mKeyset->nca.manual_title_key_aesctr.key, mKeyset->ticket.titlekey_kek[masterkey_rev].key); mBodyKeys.aes_ctr.isSet = true; } if (mKeyset->nca.manual_title_key_aesxts != zero_aesxts_key) { - nx::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[0], mKeyset->nca.manual_title_key_aesxts.key[0], mKeyset->ticket.titlekey_kek[masterkey_rev].key); - nx::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[1], mKeyset->nca.manual_title_key_aesxts.key[1], mKeyset->ticket.titlekey_kek[masterkey_rev].key); + nn::hac::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[0], mKeyset->nca.manual_title_key_aesxts.key[0], mKeyset->ticket.titlekey_kek[masterkey_rev].key); + nn::hac::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[1], mKeyset->nca.manual_title_key_aesxts.key[1], mKeyset->ticket.titlekey_kek[masterkey_rev].key); mBodyKeys.aes_xts.isSet = true; } } @@ -402,15 +402,15 @@ void NcaProcess::generateNcaBodyEncryptionKeys() crypto::aes::sAesXts128Key keak_aesxts_key = zero_aesxts_key; for (size_t i = 0; i < mBodyKeys.keak_list.size(); i++) { - if (mBodyKeys.keak_list[i].index == nx::nca::KEY_AESCTR && mBodyKeys.keak_list[i].decrypted) + if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESCTR && mBodyKeys.keak_list[i].decrypted) { keak_aesctr_key = mBodyKeys.keak_list[i].dec; } - else if (mBodyKeys.keak_list[i].index == nx::nca::KEY_AESXTS_0 && mBodyKeys.keak_list[i].decrypted) + else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_0 && mBodyKeys.keak_list[i].decrypted) { memcpy(keak_aesxts_key.key[0], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key)); } - else if (mBodyKeys.keak_list[i].index == nx::nca::KEY_AESXTS_1 && mBodyKeys.keak_list[i].decrypted) + else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_1 && mBodyKeys.keak_list[i].decrypted) { memcpy(keak_aesxts_key.key[1], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key)); } @@ -465,15 +465,15 @@ void NcaProcess::generatePartitionConfiguration() for (size_t i = 0; i < mHdr.getPartitions().size(); i++) { // get reference to relevant structures - const nx::NcaHeader::sPartition& partition = mHdr.getPartitions()[i]; - nx::sNcaFsHeader& fs_header = mHdrBlock.fs_header[partition.index]; + const nn::hac::NcaHeader::sPartition& partition = mHdr.getPartitions()[i]; + nn::hac::sNcaFsHeader& fs_header = mHdrBlock.fs_header[partition.index]; // output structure sPartitionInfo& info = mPartitions[partition.index]; // validate header hash crypto::sha::sSha256Hash calc_hash; - crypto::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nx::sNcaFsHeader), calc_hash.bytes); + crypto::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nn::hac::sNcaFsHeader), calc_hash.bytes); if (calc_hash.compare(partition.hash) == false) { error.clear(); @@ -482,7 +482,7 @@ void NcaProcess::generatePartitionConfiguration() } - if (fs_header.version.get() != nx::nca::kDefaultFsHeaderVersion) + if (fs_header.version.get() != nn::hac::nca::kDefaultFsHeaderVersion) { error.clear(); error << "NCA FS Header [" << partition.index << "] Version(" << fs_header.version.get() << "): UNSUPPORTED"; @@ -490,19 +490,19 @@ void NcaProcess::generatePartitionConfiguration() } // setup AES-CTR - nx::NcaUtils::getNcaPartitionAesCtr(&fs_header, info.aes_ctr.iv); + nn::hac::NcaUtils::getNcaPartitionAesCtr(&fs_header, info.aes_ctr.iv); // save partition config info.reader = nullptr; info.offset = partition.offset; info.size = partition.size; - info.format_type = (nx::nca::FormatType)fs_header.format_type; - info.hash_type = (nx::nca::HashType)fs_header.hash_type; - info.enc_type = (nx::nca::EncryptionType)fs_header.encryption_type; - if (info.hash_type == nx::nca::HASH_HIERARCHICAL_SHA256) - info.hash_tree_meta.importData(fs_header.hash_superblock, nx::nca::kFsHeaderHashSuperblockLen, HashTreeMeta::HASH_TYPE_SHA256); - else if (info.hash_type == nx::nca::HASH_HIERARCHICAL_INTERGRITY) - info.hash_tree_meta.importData(fs_header.hash_superblock, nx::nca::kFsHeaderHashSuperblockLen, HashTreeMeta::HASH_TYPE_INTEGRITY); + info.format_type = (nn::hac::nca::FormatType)fs_header.format_type; + info.hash_type = (nn::hac::nca::HashType)fs_header.hash_type; + info.enc_type = (nn::hac::nca::EncryptionType)fs_header.encryption_type; + if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256) + info.hash_tree_meta.importData(fs_header.hash_superblock, nn::hac::nca::kFsHeaderHashSuperblockLen, HashTreeMeta::HASH_TYPE_SHA256); + else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY) + info.hash_tree_meta.importData(fs_header.hash_superblock, nn::hac::nca::kFsHeaderHashSuperblockLen, HashTreeMeta::HASH_TYPE_INTEGRITY); // create reader try @@ -510,8 +510,8 @@ void NcaProcess::generatePartitionConfiguration() // filter out unrecognised format types switch (info.format_type) { - case (nx::nca::FORMAT_PFS0): - case (nx::nca::FORMAT_ROMFS): + case (nn::hac::nca::FORMAT_PFS0): + case (nn::hac::nca::FORMAT_ROMFS): break; default: error.clear(); @@ -520,17 +520,17 @@ void NcaProcess::generatePartitionConfiguration() } // create reader based on encryption type0 - if (info.enc_type == nx::nca::CRYPT_NONE) + if (info.enc_type == nn::hac::nca::CRYPT_NONE) { info.reader = new OffsetAdjustedIFile(mFile, SHARED_IFILE, info.offset, info.size); } - else if (info.enc_type == nx::nca::CRYPT_AESCTR) + else if (info.enc_type == nn::hac::nca::CRYPT_AESCTR) { if (mBodyKeys.aes_ctr.isSet == false) throw fnd::Exception(kModuleName, "AES-CTR Key was not determined"); info.reader = new OffsetAdjustedIFile(new AesCtrWrappedIFile(mFile, SHARED_IFILE, mBodyKeys.aes_ctr.var, info.aes_ctr), OWN_IFILE, info.offset, info.size); } - else if (info.enc_type == nx::nca::CRYPT_AESXTS || info.enc_type == nx::nca::CRYPT_AESCTREX) + else if (info.enc_type == nn::hac::nca::CRYPT_AESXTS || info.enc_type == nn::hac::nca::CRYPT_AESCTREX) { error.clear(); error << "EncryptionType(" << getEncryptionTypeStr(info.enc_type) << "): UNSUPPORTED"; @@ -544,13 +544,13 @@ void NcaProcess::generatePartitionConfiguration() } // filter out unrecognised hash types, and hash based readers - if (info.hash_type == nx::nca::HASH_HIERARCHICAL_SHA256 || info.hash_type == nx::nca::HASH_HIERARCHICAL_INTERGRITY) + if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256 || info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY) { fnd::IFile* tmp = info.reader; info.reader = nullptr; info.reader = new HashTreeWrappedIFile(tmp, OWN_IFILE, info.hash_tree_meta); } - else if (info.hash_type != nx::nca::HASH_NONE) + else if (info.hash_type != nn::hac::nca::HASH_NONE) { error.clear(); error << "HashType(" << info.hash_type << "): UNKNOWN"; @@ -576,24 +576,24 @@ void NcaProcess::validateNcaSignatures() } // validate signature[1] - if (mHdr.getContentType() == nx::nca::TYPE_PROGRAM) + if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM) { - if (mPartitions[nx::nca::PARTITION_CODE].format_type == nx::nca::FORMAT_PFS0) + if (mPartitions[nn::hac::nca::PARTITION_CODE].format_type == nn::hac::nca::FORMAT_PFS0) { - if (mPartitions[nx::nca::PARTITION_CODE].reader != nullptr) + if (mPartitions[nn::hac::nca::PARTITION_CODE].reader != nullptr) { PfsProcess exefs; - exefs.setInputFile(mPartitions[nx::nca::PARTITION_CODE].reader, SHARED_IFILE); + exefs.setInputFile(mPartitions[nn::hac::nca::PARTITION_CODE].reader, SHARED_IFILE); exefs.setCliOutputMode(0); exefs.process(); // open main.npdm if (exefs.getPfsHeader().getFileList().hasElement(kNpdmExefsPath) == true) { - const nx::PfsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath); + const nn::hac::PfsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath); NpdmProcess npdm; - npdm.setInputFile(new OffsetAdjustedIFile(mPartitions[nx::nca::PARTITION_CODE].reader, SHARED_IFILE, file.offset, file.size), OWN_IFILE); + npdm.setInputFile(new OffsetAdjustedIFile(mPartitions[nn::hac::nca::PARTITION_CODE].reader, SHARED_IFILE, file.offset, file.size), OWN_IFILE); npdm.setCliOutputMode(0); npdm.process(); @@ -630,7 +630,7 @@ void NcaProcess::displayHeader() printf(" Dist. Type: %s\n", getDistributionTypeStr(mHdr.getDistributionType())); printf(" Content Type: %s\n", getContentTypeStr(mHdr.getContentType())); printf(" Key Generation: %d\n", mHdr.getKeyGeneration()); - printf(" Kaek Index: %s (%d)\n", getKaekIndexStr((nx::nca::KeyAreaEncryptionKeyIndex)mHdr.getKaekIndex()), mHdr.getKaekIndex()); + printf(" Kaek Index: %s (%d)\n", getKaekIndexStr((nn::hac::nca::KeyAreaEncryptionKeyIndex)mHdr.getKaekIndex()), mHdr.getKaekIndex()); printf(" Size: 0x%" PRIx64 "\n", mHdr.getContentSize()); printf(" ProgID: 0x%016" PRIx64 "\n", mHdr.getProgramId()); printf(" Content Index: %" PRIu32 "\n", mHdr.getContentIndex()); @@ -640,7 +640,7 @@ void NcaProcess::displayHeader() if (mHdr.hasRightsId()) { printf(" RightsId: "); - fnd::SimpleTextOutput::hexDump(mHdr.getRightsId(), nx::nca::kRightsIdLen); + fnd::SimpleTextOutput::hexDump(mHdr.getRightsId(), nn::hac::nca::kRightsIdLen); } @@ -683,14 +683,14 @@ void NcaProcess::displayHeader() printf(" Format Type: %s\n", getFormatTypeStr(info.format_type)); printf(" Hash Type: %s\n", getHashTypeStr(info.hash_type)); printf(" Enc. Type: %s\n", getEncryptionTypeStr(info.enc_type)); - if (info.enc_type == nx::nca::CRYPT_AESCTR) + if (info.enc_type == nn::hac::nca::CRYPT_AESCTR) { printf(" AES-CTR: "); crypto::aes::sAesIvCtr ctr; crypto::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv); fnd::SimpleTextOutput::hexDump(ctr.iv, sizeof(crypto::aes::sAesIvCtr)); } - if (info.hash_type == nx::nca::HASH_HIERARCHICAL_INTERGRITY) + if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY) { HashTreeMeta& hash_hdr = info.hash_tree_meta; printf(" HierarchicalIntegrity Header:\n"); @@ -715,7 +715,7 @@ void NcaProcess::displayHeader() fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[j].bytes, sizeof(crypto::sha::sSha256Hash)); } } - else if (info.hash_type == nx::nca::HASH_HIERARCHICAL_SHA256) + else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256) { HashTreeMeta& hash_hdr = info.hash_tree_meta; printf(" HierarchicalSha256 Header:\n"); @@ -733,7 +733,7 @@ void NcaProcess::displayHeader() //else //{ // printf(" Hash Superblock:\n"); - // fnd::SimpleTextOutput::hxdStyleDump(fs_header.hash_superblock, nx::nca::kFsHeaderHashSuperblockLen); + // fnd::SimpleTextOutput::hxdStyleDump(fs_header.hash_superblock, nn::hac::nca::kFsHeaderHashSuperblockLen); //} } } @@ -762,13 +762,13 @@ void NcaProcess::processPartitions() continue; } - if (partition.format_type == nx::nca::FORMAT_PFS0) + if (partition.format_type == nn::hac::nca::FORMAT_PFS0) { PfsProcess pfs; pfs.setInputFile(partition.reader, SHARED_IFILE); pfs.setCliOutputMode(mCliOutputMode); pfs.setListFs(mListFs); - if (mHdr.getContentType() == nx::nca::TYPE_PROGRAM) + if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM) { pfs.setMountPointName(std::string(getContentTypeForMountStr(mHdr.getContentType())) + ":/" + std::string(getProgramPartitionNameStr(index))); } @@ -783,13 +783,13 @@ void NcaProcess::processPartitions() pfs.process(); //printf("pfs.process() end\n"); } - else if (partition.format_type == nx::nca::FORMAT_ROMFS) + else if (partition.format_type == nn::hac::nca::FORMAT_ROMFS) { RomfsProcess romfs; romfs.setInputFile(partition.reader, SHARED_IFILE); romfs.setCliOutputMode(mCliOutputMode); romfs.setListFs(mListFs); - if (mHdr.getContentType() == nx::nca::TYPE_PROGRAM) + if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM) { romfs.setMountPointName(std::string(getContentTypeForMountStr(mHdr.getContentType())) + ":/" + std::string(getProgramPartitionNameStr(index))); } diff --git a/programs/nstool/source/NcaProcess.h b/programs/nstool/source/NcaProcess.h index dd5033c..d79ab5a 100644 --- a/programs/nstool/source/NcaProcess.h +++ b/programs/nstool/source/NcaProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "HashTreeMeta.h" @@ -44,14 +44,14 @@ private: { std::string path; bool doExtract; - } mPartitionPath[nx::nca::kPartitionNum]; + } mPartitionPath[nn::hac::nca::kPartitionNum]; bool mListFs; // data - nx::sNcaHeaderBlock mHdrBlock; + nn::hac::sNcaHeaderBlock mHdrBlock; crypto::sha::sSha256Hash mHdrHash; - nx::NcaHeader mHdr; + nn::hac::NcaHeader mHdr; // crypto struct sKeys @@ -98,12 +98,12 @@ private: size_t size; // meta data - nx::nca::FormatType format_type; - nx::nca::HashType hash_type; - nx::nca::EncryptionType enc_type; + nn::hac::nca::FormatType format_type; + nn::hac::nca::HashType hash_type; + nn::hac::nca::EncryptionType enc_type; HashTreeMeta hash_tree_meta; crypto::aes::sAesIvCtr aes_ctr; - } mPartitions[nx::nca::kPartitionNum]; + } mPartitions[nn::hac::nca::kPartitionNum]; void generateNcaBodyEncryptionKeys(); void generatePartitionConfiguration(); diff --git a/programs/nstool/source/NpdmProcess.cpp b/programs/nstool/source/NpdmProcess.cpp index 4c51bed..6a7f977 100644 --- a/programs/nstool/source/NpdmProcess.cpp +++ b/programs/nstool/source/NpdmProcess.cpp @@ -80,7 +80,7 @@ void NpdmProcess::setVerifyMode(bool verify) mVerify = verify; } -const nx::NpdmBinary& NpdmProcess::getNpdmBinary() const +const nn::hac::NpdmBinary& NpdmProcess::getNpdmBinary() const { return mNpdm; } @@ -336,7 +336,7 @@ const std::string kMemMapType[2] = { "Io", "Static" }; const std::string kAcidTarget[2] = { "Development", "Production" }; -void NpdmProcess::validateAcidSignature(const nx::AccessControlInfoDescBinary& acid) +void NpdmProcess::validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid) { try { acid.validateSignature(mKeyset->acid_sign_key); @@ -347,7 +347,7 @@ void NpdmProcess::validateAcidSignature(const nx::AccessControlInfoDescBinary& a } -void NpdmProcess::validateAciFromAcid(const nx::AccessControlInfoBinary& aci, const nx::AccessControlInfoDescBinary& acid) +void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid) { // check Program ID if (acid.getProgramIdRestrict().min > 0 && aci.getProgramId() < acid.getProgramIdRestrict().min) @@ -468,7 +468,7 @@ void NpdmProcess::validateAciFromAcid(const nx::AccessControlInfoBinary& aci, co if (rightFound == false) { - const nx::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getMemoryMaps()[i]; + const nn::hac::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getMemoryMaps()[i]; printf("[WARNING] ACI/KC MemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, kMemMapPerm[map.perm].c_str(), kMemMapType[map.type].c_str()); } @@ -484,7 +484,7 @@ void NpdmProcess::validateAciFromAcid(const nx::AccessControlInfoBinary& aci, co if (rightFound == false) { - const nx::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getIoMemoryMaps()[i]; + const nn::hac::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getIoMemoryMaps()[i]; printf("[WARNING] ACI/KC IoMemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, kMemMapPerm[map.perm].c_str(), kMemMapType[map.type].c_str()); } @@ -538,7 +538,7 @@ void NpdmProcess::validateAciFromAcid(const nx::AccessControlInfoBinary& aci, co } } -void NpdmProcess::displayNpdmHeader(const nx::NpdmBinary& hdr) +void NpdmProcess::displayNpdmHeader(const nn::hac::NpdmBinary& hdr) { printf("[NPDM HEADER]\n"); printf(" Process Architecture Params:\n"); @@ -557,13 +557,13 @@ void NpdmProcess::displayNpdmHeader(const nx::NpdmBinary& hdr) } } -void NpdmProcess::displayAciHdr(const nx::AccessControlInfoBinary& aci) +void NpdmProcess::displayAciHdr(const nn::hac::AccessControlInfoBinary& aci) { printf("[Access Control Info]\n"); printf(" ProgramID: 0x%016" PRIx64 "\n", aci.getProgramId()); } -void NpdmProcess::displayAciDescHdr(const nx::AccessControlInfoDescBinary& acid) +void NpdmProcess::displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& acid) { printf("[Access Control Info Desc]\n"); if (acid.getFlagList().size() > 0 || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)) @@ -579,7 +579,7 @@ void NpdmProcess::displayAciDescHdr(const nx::AccessControlInfoDescBinary& acid) printf(" Max: 0x%016" PRIx64 "\n", acid.getProgramIdRestrict().max); } -void NpdmProcess::displayFac(const nx::FileSystemAccessControlBinary& fac) +void NpdmProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac) { printf("[FS Access Control]\n"); printf(" Format Version: %d\n", fac.getFormatVersion()); @@ -620,7 +620,7 @@ void NpdmProcess::displayFac(const nx::FileSystemAccessControlBinary& fac) } -void NpdmProcess::displaySac(const nx::ServiceAccessControlBinary& sac) +void NpdmProcess::displaySac(const nn::hac::ServiceAccessControlBinary& sac) { printf("[Service Access Control]\n"); printf(" Service List:\n"); @@ -634,12 +634,12 @@ void NpdmProcess::displaySac(const nx::ServiceAccessControlBinary& sac) } } -void NpdmProcess::displayKernelCap(const nx::KernelCapabilityBinary& kern) +void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) { printf("[Kernel Capabilities]\n"); if (kern.getThreadInfo().isSet()) { - nx::ThreadInfoHandler threadInfo = kern.getThreadInfo(); + nn::hac::ThreadInfoHandler threadInfo = kern.getThreadInfo(); printf(" Thread Priority:\n"); printf(" Min: %d\n", threadInfo.getMinPriority()); printf(" Max: %d\n", threadInfo.getMaxPriority()); @@ -666,8 +666,8 @@ void NpdmProcess::displayKernelCap(const nx::KernelCapabilityBinary& kern) } if (kern.getMemoryMaps().isSet()) { - fnd::List maps = kern.getMemoryMaps().getMemoryMaps(); - fnd::List ioMaps = kern.getMemoryMaps().getIoMemoryMaps(); + fnd::List maps = kern.getMemoryMaps().getMemoryMaps(); + fnd::List ioMaps = kern.getMemoryMaps().getIoMemoryMaps(); printf(" MemoryMaps:\n"); for (size_t i = 0; i < maps.size(); i++) @@ -707,7 +707,7 @@ void NpdmProcess::displayKernelCap(const nx::KernelCapabilityBinary& kern) } if (kern.getMiscFlags().isSet()) { - fnd::List flagList = kern.getMiscFlags().getFlagList(); + fnd::List flagList = kern.getMiscFlags().getFlagList(); printf(" Misc Flags:\n"); for (uint32_t i = 0; i < flagList.size(); i++) diff --git a/programs/nstool/source/NpdmProcess.h b/programs/nstool/source/NpdmProcess.h index 12264c8..6ed8959 100644 --- a/programs/nstool/source/NpdmProcess.h +++ b/programs/nstool/source/NpdmProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -19,7 +19,7 @@ public: void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); - const nx::NpdmBinary& getNpdmBinary() const; + const nn::hac::NpdmBinary& getNpdmBinary() const; private: const std::string kModuleName = "NpdmProcess"; @@ -30,15 +30,15 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - nx::NpdmBinary mNpdm; + nn::hac::NpdmBinary mNpdm; - void validateAcidSignature(const nx::AccessControlInfoDescBinary& acid); - void validateAciFromAcid(const nx::AccessControlInfoBinary& aci, const nx::AccessControlInfoDescBinary& acid); + void validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid); + void validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid); - void displayNpdmHeader(const nx::NpdmBinary& hdr); - void displayAciHdr(const nx::AccessControlInfoBinary& aci); - void displayAciDescHdr(const nx::AccessControlInfoDescBinary& aci); - void displayFac(const nx::FileSystemAccessControlBinary& fac); - void displaySac(const nx::ServiceAccessControlBinary& sac); - void displayKernelCap(const nx::KernelCapabilityBinary& kern); + void displayNpdmHeader(const nn::hac::NpdmBinary& hdr); + void displayAciHdr(const nn::hac::AccessControlInfoBinary& aci); + void displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& aci); + void displayFac(const nn::hac::FileSystemAccessControlBinary& fac); + void displaySac(const nn::hac::ServiceAccessControlBinary& sac); + void displayKernelCap(const nn::hac::KernelCapabilityBinary& kern); }; \ No newline at end of file diff --git a/programs/nstool/source/NroProcess.cpp b/programs/nstool/source/NroProcess.cpp index 1ecb652..694ad38 100644 --- a/programs/nstool/source/NroProcess.cpp +++ b/programs/nstool/source/NroProcess.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "OffsetAdjustedIFile.h" #include "NroProcess.h" @@ -56,7 +56,7 @@ void NroProcess::setVerifyMode(bool verify) mVerify = verify; } -void NroProcess::setInstructionType(nx::npdm::InstructionType type) +void NroProcess::setInstructionType(nn::hac::npdm::InstructionType type) { mRoMeta.setInstructionType(type); } @@ -99,19 +99,19 @@ const RoMetadataProcess& NroProcess::getRoMetadataProcess() const void NroProcess::importHeader() { fnd::Vec scratch; - if (mFile->size() < sizeof(nx::sNroHeader)) + if (mFile->size() < sizeof(nn::hac::sNroHeader)) { throw fnd::Exception(kModuleName, "Corrupt NRO: file too small"); } - scratch.alloc(sizeof(nx::sNroHeader)); + scratch.alloc(sizeof(nn::hac::sNroHeader)); mFile->read(scratch.data(), 0, scratch.size()); mHdr.fromBytes(scratch.data(), scratch.size()); // setup homebrew extension - nx::sNroHeader* raw_hdr = (nx::sNroHeader*)scratch.data(); - if (((le_uint64_t*)raw_hdr->reserved_0)->get() == nx::nro::kNroHomebrewStructMagic && mFile->size() > mHdr.getNroSize()) + nn::hac::sNroHeader* raw_hdr = (nn::hac::sNroHeader*)scratch.data(); + if (((le_uint64_t*)raw_hdr->reserved_0)->get() == nn::hac::nro::kNroHomebrewStructMagic && mFile->size() > mHdr.getNroSize()) { mIsHomebrewNro = true; mAssetProc.setInputFile(new OffsetAdjustedIFile(mFile, false, mHdr.getNroSize(), mFile->size() - mHdr.getNroSize()), true); @@ -137,10 +137,10 @@ void NroProcess::displayHeader() #define _HEXDUMP_L(var, len) do { for (size_t a__a__A = 0; a__a__A < len; a__a__A++) printf("%02x", var[a__a__A]); } while(0) printf("[NRO Header]\n"); printf(" RoCrt: "); - _HEXDUMP_L(mHdr.getRoCrt().data, nx::nro::kRoCrtSize); + _HEXDUMP_L(mHdr.getRoCrt().data, nn::hac::nro::kRoCrtSize); printf("\n"); printf(" ModuleId: "); - _HEXDUMP_L(mHdr.getModuleId().data, nx::nro::kModuleIdSize); + _HEXDUMP_L(mHdr.getModuleId().data, nn::hac::nro::kModuleIdSize); printf("\n"); printf(" NroSize: 0x%" PRIx32 "\n", mHdr.getNroSize()); printf(" Program Sections:\n"); diff --git a/programs/nstool/source/NroProcess.h b/programs/nstool/source/NroProcess.h index 6fbdf59..12f1eb8 100644 --- a/programs/nstool/source/NroProcess.h +++ b/programs/nstool/source/NroProcess.h @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include #include "AssetProcess.h" #include "nstool.h" @@ -22,7 +22,7 @@ public: void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); - void setInstructionType(nx::npdm::InstructionType type); + void setInstructionType(nn::hac::npdm::InstructionType type); void setListApi(bool listApi); void setListSymbols(bool listSymbols); @@ -42,7 +42,7 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - nx::NroHeader mHdr; + nn::hac::NroHeader mHdr; fnd::Vec mTextBlob, mRoBlob, mDataBlob; RoMetadataProcess mRoMeta; bool mIsHomebrewNro; diff --git a/programs/nstool/source/NsoProcess.cpp b/programs/nstool/source/NsoProcess.cpp index ff81e7f..3f5653f 100644 --- a/programs/nstool/source/NsoProcess.cpp +++ b/programs/nstool/source/NsoProcess.cpp @@ -51,7 +51,7 @@ void NsoProcess::setVerifyMode(bool verify) mVerify = verify; } -void NsoProcess::setInstructionType(nx::npdm::InstructionType type) +void NsoProcess::setInstructionType(nn::hac::npdm::InstructionType type) { mRoMeta.setInstructionType(type); } @@ -74,12 +74,12 @@ const RoMetadataProcess& NsoProcess::getRoMetadataProcess() const void NsoProcess::importHeader() { fnd::Vec scratch; - if (mFile->size() < sizeof(nx::sNsoHeader)) + if (mFile->size() < sizeof(nn::hac::sNsoHeader)) { throw fnd::Exception(kModuleName, "Corrupt NSO: file too small"); } - scratch.alloc(sizeof(nx::sNsoHeader)); + scratch.alloc(sizeof(nn::hac::sNsoHeader)); mFile->read(scratch.data(), 0, scratch.size()); mHdr.fromBytes(scratch.data(), scratch.size()); @@ -176,7 +176,7 @@ void NsoProcess::displayNsoHeader() printf("[NSO Header]\n"); printf(" ModuleId: "); - _HEXDUMP_L(mHdr.getModuleId().data, nx::nso::kModuleIdSize); + _HEXDUMP_L(mHdr.getModuleId().data, nn::hac::nso::kModuleIdSize); printf("\n"); if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT)) { diff --git a/programs/nstool/source/NsoProcess.h b/programs/nstool/source/NsoProcess.h index 9088da2..0cf57c0 100644 --- a/programs/nstool/source/NsoProcess.h +++ b/programs/nstool/source/NsoProcess.h @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include #include "nstool.h" #include "RoMetadataProcess.h" @@ -21,7 +21,7 @@ public: void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); - void setInstructionType(nx::npdm::InstructionType type); + void setInstructionType(nn::hac::npdm::InstructionType type); void setListApi(bool listApi); void setListSymbols(bool listSymbols); @@ -34,11 +34,11 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - nx::npdm::InstructionType mInstructionType; + nn::hac::npdm::InstructionType mInstructionType; bool mListApi; bool mListSymbols; - nx::NsoHeader mHdr; + nn::hac::NsoHeader mHdr; fnd::Vec mTextBlob, mRoBlob, mDataBlob; RoMetadataProcess mRoMeta; diff --git a/programs/nstool/source/PfsProcess.cpp b/programs/nstool/source/PfsProcess.cpp index 59f2921..646f83f 100644 --- a/programs/nstool/source/PfsProcess.cpp +++ b/programs/nstool/source/PfsProcess.cpp @@ -33,13 +33,13 @@ void PfsProcess::process() } // open minimum header to get full header size - scratch.alloc(sizeof(nx::sPfsHeader)); + scratch.alloc(sizeof(nn::hac::sPfsHeader)); mFile->read(scratch.data(), 0, scratch.size()); - if (validateHeaderMagic(((nx::sPfsHeader*)scratch.data())) == false) + if (validateHeaderMagic(((nn::hac::sPfsHeader*)scratch.data())) == false) { throw fnd::Exception(kModuleName, "Corrupt Header"); } - size_t pfsHeaderSize = determineHeaderSize(((nx::sPfsHeader*)scratch.data())); + size_t pfsHeaderSize = determineHeaderSize(((nn::hac::sPfsHeader*)scratch.data())); // open minimum header to get full header size scratch.alloc(pfsHeaderSize); @@ -90,7 +90,7 @@ void PfsProcess::setListFs(bool list_fs) mListFs = list_fs; } -const nx::PfsHeader& PfsProcess::getPfsHeader() const +const nn::hac::PfsHeader& PfsProcess::getPfsHeader() const { return mPfs; } @@ -124,26 +124,26 @@ void PfsProcess::displayFs() } } -size_t PfsProcess::determineHeaderSize(const nx::sPfsHeader* hdr) +size_t PfsProcess::determineHeaderSize(const nn::hac::sPfsHeader* hdr) { size_t fileEntrySize = 0; - if (hdr->st_magic.get() == nx::pfs::kPfsStructMagic) - fileEntrySize = sizeof(nx::sPfsFile); + if (hdr->st_magic.get() == nn::hac::pfs::kPfsStructMagic) + fileEntrySize = sizeof(nn::hac::sPfsFile); else - fileEntrySize = sizeof(nx::sHashedPfsFile); + fileEntrySize = sizeof(nn::hac::sHashedPfsFile); - return sizeof(nx::sPfsHeader) + hdr->file_num.get() * fileEntrySize + hdr->name_table_size.get(); + return sizeof(nn::hac::sPfsHeader) + hdr->file_num.get() * fileEntrySize + hdr->name_table_size.get(); } -bool PfsProcess::validateHeaderMagic(const nx::sPfsHeader* hdr) +bool PfsProcess::validateHeaderMagic(const nn::hac::sPfsHeader* hdr) { - return hdr->st_magic.get() == nx::pfs::kPfsStructMagic || hdr->st_magic.get() == nx::pfs::kHashedPfsStructMagic; + return hdr->st_magic.get() == nn::hac::pfs::kPfsStructMagic || hdr->st_magic.get() == nn::hac::pfs::kHashedPfsStructMagic; } void PfsProcess::validateHfs() { crypto::sha::sSha256Hash hash; - const fnd::List& file = mPfs.getFileList(); + const fnd::List& file = mPfs.getFileList(); for (size_t i = 0; i < file.size(); i++) { mCache.alloc(file[i].hash_protected_size); @@ -165,7 +165,7 @@ void PfsProcess::extractFs() fnd::io::makeDirectory(mExtractPath); fnd::SimpleFile outFile; - const fnd::List& file = mPfs.getFileList(); + const fnd::List& file = mPfs.getFileList(); std::string file_path; for (size_t i = 0; i < file.size(); i++) diff --git a/programs/nstool/source/PfsProcess.h b/programs/nstool/source/PfsProcess.h index 3c90db9..4b15c05 100644 --- a/programs/nstool/source/PfsProcess.h +++ b/programs/nstool/source/PfsProcess.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -24,7 +24,7 @@ public: void setExtractPath(const std::string& path); void setListFs(bool list_fs); - const nx::PfsHeader& getPfsHeader() const; + const nn::hac::PfsHeader& getPfsHeader() const; private: const std::string kModuleName = "PfsProcess"; @@ -42,12 +42,12 @@ private: fnd::Vec mCache; - nx::PfsHeader mPfs; + nn::hac::PfsHeader mPfs; void displayHeader(); void displayFs(); - size_t determineHeaderSize(const nx::sPfsHeader* hdr); - bool validateHeaderMagic(const nx::sPfsHeader* hdr); + size_t determineHeaderSize(const nn::hac::sPfsHeader* hdr); + bool validateHeaderMagic(const nn::hac::sPfsHeader* hdr); void validateHfs(); void extractFs(); }; \ No newline at end of file diff --git a/programs/nstool/source/PkiCertProcess.cpp b/programs/nstool/source/PkiCertProcess.cpp index 80f3b20..47b3267 100644 --- a/programs/nstool/source/PkiCertProcess.cpp +++ b/programs/nstool/source/PkiCertProcess.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "OffsetAdjustedIFile.h" #include "PkiCertProcess.h" #include "PkiValidator.h" diff --git a/programs/nstool/source/PkiCertProcess.h b/programs/nstool/source/PkiCertProcess.h index 31c63b2..b071ec6 100644 --- a/programs/nstool/source/PkiCertProcess.h +++ b/programs/nstool/source/PkiCertProcess.h @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include "nstool.h" class PkiCertProcess diff --git a/programs/nstool/source/PkiValidator.cpp b/programs/nstool/source/PkiValidator.cpp index 00b2088..70f5728 100644 --- a/programs/nstool/source/PkiValidator.cpp +++ b/programs/nstool/source/PkiValidator.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include PkiValidator::PkiValidator() { diff --git a/programs/nstool/source/PkiValidator.h b/programs/nstool/source/PkiValidator.h index 217dfad..51d383f 100644 --- a/programs/nstool/source/PkiValidator.h +++ b/programs/nstool/source/PkiValidator.h @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include #include class PkiValidator diff --git a/programs/nstool/source/RoMetadataProcess.cpp b/programs/nstool/source/RoMetadataProcess.cpp index af06e44..3c44d2b 100644 --- a/programs/nstool/source/RoMetadataProcess.cpp +++ b/programs/nstool/source/RoMetadataProcess.cpp @@ -5,7 +5,7 @@ RoMetadataProcess::RoMetadataProcess() : mCliOutputMode(_BIT(OUTPUT_BASIC)), - mInstructionType(nx::npdm::INSTR_64BIT), + mInstructionType(nn::hac::npdm::INSTR_64BIT), mListApi(false), mListSymbols(false), mApiInfo(), @@ -59,7 +59,7 @@ void RoMetadataProcess::setCliOutputMode(CliOutputMode type) mCliOutputMode = type; } -void RoMetadataProcess::setInstructionType(nx::npdm::InstructionType type) +void RoMetadataProcess::setInstructionType(nn::hac::npdm::InstructionType type) { mInstructionType = type; } @@ -123,7 +123,7 @@ void RoMetadataProcess::importApiList() if (mDynSym.size > 0) { - mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nx::npdm::INSTR_64BIT); + mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nn::hac::npdm::INSTR_64BIT); } } @@ -174,30 +174,30 @@ void RoMetadataProcess::displayRoMetaData() } } -const char* RoMetadataProcess::getSectionIndexStr(nx::elf::SpecialSectionIndex shn_index) const +const char* RoMetadataProcess::getSectionIndexStr(nn::hac::elf::SpecialSectionIndex shn_index) const { const char* str; switch (shn_index) { - case (nx::elf::SHN_UNDEF): + case (nn::hac::elf::SHN_UNDEF): str = "UNDEF"; break; - case (nx::elf::SHN_LOPROC): + case (nn::hac::elf::SHN_LOPROC): str = "LOPROC"; break; - case (nx::elf::SHN_HIPROC): + case (nn::hac::elf::SHN_HIPROC): str = "HIPROC"; break; - case (nx::elf::SHN_LOOS): + case (nn::hac::elf::SHN_LOOS): str = "LOOS"; break; - case (nx::elf::SHN_HIOS): + case (nn::hac::elf::SHN_HIOS): str = "HIOS"; break; - case (nx::elf::SHN_ABS): + case (nn::hac::elf::SHN_ABS): str = "ABS"; break; - case (nx::elf::SHN_COMMON): + case (nn::hac::elf::SHN_COMMON): str = "COMMON"; break; default: @@ -207,36 +207,36 @@ const char* RoMetadataProcess::getSectionIndexStr(nx::elf::SpecialSectionIndex s return str; } -const char* RoMetadataProcess::getSymbolTypeStr(nx::elf::SymbolType symbol_type) const +const char* RoMetadataProcess::getSymbolTypeStr(nn::hac::elf::SymbolType symbol_type) const { const char* str; switch (symbol_type) { - case (nx::elf::STT_NOTYPE): + case (nn::hac::elf::STT_NOTYPE): str = "NOTYPE"; break; - case (nx::elf::STT_OBJECT): + case (nn::hac::elf::STT_OBJECT): str = "OBJECT"; break; - case (nx::elf::STT_FUNC): + case (nn::hac::elf::STT_FUNC): str = "FUNC"; break; - case (nx::elf::STT_SECTION): + case (nn::hac::elf::STT_SECTION): str = "SECTION"; break; - case (nx::elf::STT_FILE): + case (nn::hac::elf::STT_FILE): str = "FILE"; break; - case (nx::elf::STT_LOOS): + case (nn::hac::elf::STT_LOOS): str = "LOOS"; break; - case (nx::elf::STT_HIOS): + case (nn::hac::elf::STT_HIOS): str = "HIOS"; break; - case (nx::elf::STT_LOPROC): + case (nn::hac::elf::STT_LOPROC): str = "LOPROC"; break; - case (nx::elf::STT_HIPROC): + case (nn::hac::elf::STT_HIPROC): str = "HIPROC"; break; default: @@ -246,30 +246,30 @@ const char* RoMetadataProcess::getSymbolTypeStr(nx::elf::SymbolType symbol_type) return str; } -const char* RoMetadataProcess::getSymbolBindingStr(nx::elf::SymbolBinding symbol_binding) const +const char* RoMetadataProcess::getSymbolBindingStr(nn::hac::elf::SymbolBinding symbol_binding) const { const char* str; switch (symbol_binding) { - case (nx::elf::STB_LOCAL): + case (nn::hac::elf::STB_LOCAL): str = "LOCAL"; break; - case (nx::elf::STB_GLOBAL): + case (nn::hac::elf::STB_GLOBAL): str = "GLOBAL"; break; - case (nx::elf::STB_WEAK): + case (nn::hac::elf::STB_WEAK): str = "WEAK"; break; - case (nx::elf::STB_LOOS): + case (nn::hac::elf::STB_LOOS): str = "LOOS"; break; - case (nx::elf::STB_HIOS): + case (nn::hac::elf::STB_HIOS): str = "HIOS"; break; - case (nx::elf::STB_LOPROC): + case (nn::hac::elf::STB_LOPROC): str = "LOPROC"; break; - case (nx::elf::STB_HIPROC): + case (nn::hac::elf::STB_HIPROC): str = "HIPROC"; break; default: diff --git a/programs/nstool/source/RoMetadataProcess.h b/programs/nstool/source/RoMetadataProcess.h index 477374f..84ff4af 100644 --- a/programs/nstool/source/RoMetadataProcess.h +++ b/programs/nstool/source/RoMetadataProcess.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include "nstool.h" #include "SdkApiString.h" @@ -24,7 +24,7 @@ public: void setCliOutputMode(CliOutputMode type); - void setInstructionType(nx::npdm::InstructionType type); + void setInstructionType(nn::hac::npdm::InstructionType type); void setListApi(bool listApi); void setListSymbols(bool listSymbols); @@ -37,7 +37,7 @@ private: const std::string kModuleName = "RoMetadataProcess"; CliOutputMode mCliOutputMode; - nx::npdm::InstructionType mInstructionType; + nn::hac::npdm::InstructionType mInstructionType; bool mListApi; bool mListSymbols; @@ -62,7 +62,7 @@ private: void importApiList(); void displayRoMetaData(); - const char* getSectionIndexStr(nx::elf::SpecialSectionIndex shn_index) const; - const char* getSymbolTypeStr(nx::elf::SymbolType symbol_type) const; - const char* getSymbolBindingStr(nx::elf::SymbolBinding symbol_binding) const; + const char* getSectionIndexStr(nn::hac::elf::SpecialSectionIndex shn_index) const; + const char* getSymbolTypeStr(nn::hac::elf::SymbolType symbol_type) const; + const char* getSymbolBindingStr(nn::hac::elf::SymbolBinding symbol_binding) const; }; \ No newline at end of file diff --git a/programs/nstool/source/RomfsProcess.cpp b/programs/nstool/source/RomfsProcess.cpp index 47982f5..c2baf8c 100644 --- a/programs/nstool/source/RomfsProcess.cpp +++ b/programs/nstool/source/RomfsProcess.cpp @@ -182,17 +182,17 @@ void RomfsProcess::extractFs() extractDir(mExtractPath, mRootDir); } -bool RomfsProcess::validateHeaderLayout(const nx::sRomfsHeader* hdr) const +bool RomfsProcess::validateHeaderLayout(const nn::hac::sRomfsHeader* hdr) const { bool validLayout = true; - if (hdr->header_size.get() != sizeof(nx::sRomfsHeader)) + if (hdr->header_size.get() != sizeof(nn::hac::sRomfsHeader)) { validLayout = false; } uint64_t pos = hdr->sections[0].offset.get(); - for (size_t i = 0; i < nx::romfs::SECTION_NUM; i++) + for (size_t i = 0; i < nn::hac::romfs::SECTION_NUM; i++) { if (hdr->sections[i].offset.get() != pos) { @@ -206,7 +206,7 @@ bool RomfsProcess::validateHeaderLayout(const nx::sRomfsHeader* hdr) const void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir) { - nx::sRomfsDirEntry* d_node = get_dir_node(dir_offset); + nn::hac::sRomfsDirEntry* d_node = get_dir_node(dir_offset); /* printf("[DIR-NODE]\n"); @@ -219,9 +219,9 @@ void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir) printf(" name=%s\n", d_node->name); */ - for (uint32_t file_addr = d_node->file.get(); file_addr != nx::romfs::kInvalidAddr; ) + for (uint32_t file_addr = d_node->file.get(); file_addr != nn::hac::romfs::kInvalidAddr; ) { - nx::sRomfsFileEntry* f_node = get_file_node(file_addr); + nn::hac::sRomfsFileEntry* f_node = get_file_node(file_addr); /* printf("[FILE-NODE]\n"); @@ -240,9 +240,9 @@ void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir) mFileNum++; } - for (uint32_t child_addr = d_node->child.get(); child_addr != nx::romfs::kInvalidAddr; ) + for (uint32_t child_addr = d_node->child.get(); child_addr != nn::hac::romfs::kInvalidAddr; ) { - nx::sRomfsDirEntry* c_node = get_dir_node(child_addr); + nn::hac::sRomfsDirEntry* c_node = get_dir_node(child_addr); dir.dir_list.addElement({std::string(c_node->name(), c_node->name_size.get())}); importDirectory(child_addr, dir.dir_list.atBack()); @@ -255,7 +255,7 @@ void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir) void RomfsProcess::resolveRomfs() { // read header - mFile->read((byte_t*)&mHdr, 0, sizeof(nx::sRomfsHeader)); + mFile->read((byte_t*)&mHdr, 0, sizeof(nn::hac::sRomfsHeader)); // logic check on the header layout if (validateHeaderLayout(&mHdr) == false) @@ -264,21 +264,21 @@ void RomfsProcess::resolveRomfs() } // read directory nodes - mDirNodes.alloc(mHdr.sections[nx::romfs::DIR_NODE_TABLE].size.get()); - mFile->read(mDirNodes.data(), mHdr.sections[nx::romfs::DIR_NODE_TABLE].offset.get(), mDirNodes.size()); + mDirNodes.alloc(mHdr.sections[nn::hac::romfs::DIR_NODE_TABLE].size.get()); + mFile->read(mDirNodes.data(), mHdr.sections[nn::hac::romfs::DIR_NODE_TABLE].offset.get(), mDirNodes.size()); //printf("[RAW DIR NODES]\n"); //fnd::SimpleTextOutput::hxdStyleDump(mDirNodes.data(), mDirNodes.size()); // read file nodes - mFileNodes.alloc(mHdr.sections[nx::romfs::FILE_NODE_TABLE].size.get()); - mFile->read(mFileNodes.data(), mHdr.sections[nx::romfs::FILE_NODE_TABLE].offset.get(), mFileNodes.size()); + mFileNodes.alloc(mHdr.sections[nn::hac::romfs::FILE_NODE_TABLE].size.get()); + mFile->read(mFileNodes.data(), mHdr.sections[nn::hac::romfs::FILE_NODE_TABLE].offset.get(), mFileNodes.size()); //printf("[RAW FILE NODES]\n"); //fnd::SimpleTextOutput::hxdStyleDump(mFileNodes.data(), mFileNodes.size()); // A logic check on the root directory node if ( get_dir_node(0)->parent.get() != 0 \ - || get_dir_node(0)->sibling.get() != nx::romfs::kInvalidAddr \ - || get_dir_node(0)->hash.get() != nx::romfs::kInvalidAddr \ + || get_dir_node(0)->sibling.get() != nn::hac::romfs::kInvalidAddr \ + || get_dir_node(0)->hash.get() != nn::hac::romfs::kInvalidAddr \ || get_dir_node(0)->name_size.get() != 0) { throw fnd::Exception(kModuleName, "Invalid root directory node"); diff --git a/programs/nstool/source/RomfsProcess.h b/programs/nstool/source/RomfsProcess.h index 032139c..475576c 100644 --- a/programs/nstool/source/RomfsProcess.h +++ b/programs/nstool/source/RomfsProcess.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -110,13 +110,13 @@ private: size_t mDirNum; size_t mFileNum; - nx::sRomfsHeader mHdr; + nn::hac::sRomfsHeader mHdr; fnd::Vec mDirNodes; fnd::Vec mFileNodes; sDirectory mRootDir; - inline nx::sRomfsDirEntry* get_dir_node(uint32_t offset) { return (nx::sRomfsDirEntry*)(mDirNodes.data() + offset); } - inline nx::sRomfsFileEntry* get_file_node(uint32_t offset) { return (nx::sRomfsFileEntry*)(mFileNodes.data() + offset); } + inline nn::hac::sRomfsDirEntry* get_dir_node(uint32_t offset) { return (nn::hac::sRomfsDirEntry*)(mDirNodes.data() + offset); } + inline nn::hac::sRomfsFileEntry* get_file_node(uint32_t offset) { return (nn::hac::sRomfsFileEntry*)(mFileNodes.data() + offset); } void printTab(size_t tab) const; @@ -129,7 +129,7 @@ private: void extractDir(const std::string& path, const sDirectory& dir); void extractFs(); - bool validateHeaderLayout(const nx::sRomfsHeader* hdr) const; + bool validateHeaderLayout(const nn::hac::sRomfsHeader* hdr) const; void importDirectory(uint32_t dir_offset, sDirectory& dir); void resolveRomfs(); }; \ No newline at end of file diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp index f2c5297..57b5c84 100644 --- a/programs/nstool/source/UserSettings.cpp +++ b/programs/nstool/source/UserSettings.cpp @@ -11,22 +11,22 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include UserSettings::UserSettings() {} @@ -129,7 +129,7 @@ bool UserSettings::isListSymbols() const return mListSymbols; } -nx::npdm::InstructionType UserSettings::getInstType() const +nn::hac::npdm::InstructionType UserSettings::getInstType() const { return mInstructionType; } @@ -639,9 +639,9 @@ void UserSettings::populateKeyset(sCmdArgs& args) if (mKeyset.nca.header_key == zeros_aes_xts_key) { crypto::aes::sAes128Key nca_header_kek; - nx::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key); - nx::AesKeygen::generateKey(mKeyset.nca.header_key.key[0], nca_header_key_source.key[0], nca_header_kek.key); - nx::AesKeygen::generateKey(mKeyset.nca.header_key.key[1], nca_header_key_source.key[1], nca_header_kek.key); + nn::hac::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key); + nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[0], nca_header_key_source.key[0], nca_header_kek.key); + nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[1], nca_header_key_source.key[1], nca_header_kek.key); //printf("nca header key[0] "); //fnd::SimpleTextOutput::hexDump(mKeyset.nca.header_key.key[0], 0x10); //printf("nca header key[1] "); @@ -649,11 +649,11 @@ void UserSettings::populateKeyset(sCmdArgs& args) } } - for (size_t j = 0; j < nx::nca::kKeyAreaEncryptionKeyNum; j++) + for (size_t j = 0; j < nn::hac::nca::kKeyAreaEncryptionKeyNum; j++) { if (key_area_key_source[j] != zeros_aes_key && mKeyset.nca.key_area_key[j][i] == zeros_aes_key) { - nx::AesKeygen::generateKey(mKeyset.nca.key_area_key[j][i].key, aes_kek_generation_source.key, key_area_key_source[j].key, aes_key_generation_source.key, master_key[i].key); + nn::hac::AesKeygen::generateKey(mKeyset.nca.key_area_key[j][i].key, aes_kek_generation_source.key, key_area_key_source[j].key, aes_key_generation_source.key, master_key[i].key); //printf("nca keak %d/%02d ", j, i); //fnd::SimpleTextOutput::hexDump(mKeyset.nca.key_area_key[j][i].key, 0x10); } @@ -662,19 +662,19 @@ void UserSettings::populateKeyset(sCmdArgs& args) if (ticket_titlekek_source != zeros_aes_key && mKeyset.ticket.titlekey_kek[i] == zeros_aes_key) { - nx::AesKeygen::generateKey(mKeyset.ticket.titlekey_kek[i].key, ticket_titlekek_source.key, master_key[i].key); + nn::hac::AesKeygen::generateKey(mKeyset.ticket.titlekey_kek[i].key, ticket_titlekek_source.key, master_key[i].key); //printf("ticket titlekek %02d ", i); //fnd::SimpleTextOutput::hexDump(mKeyset.ticket.titlekey_kek[i].key, 0x10); } if (package2_key_source != zeros_aes_key && mKeyset.package2_key[i] == zeros_aes_key) { - nx::AesKeygen::generateKey(mKeyset.package2_key[i].key, package2_key_source.key, master_key[i].key); + nn::hac::AesKeygen::generateKey(mKeyset.package2_key[i].key, package2_key_source.key, master_key[i].key); //printf("package2 key %02d ", i); //fnd::SimpleTextOutput::hexDump(mKeyset.package2_key[i].key, 0x10); } } /* - for (size_t j = 0; j < nx::nca::kKeyAreaEncryptionKeyNum; j++) + for (size_t j = 0; j < nn::hac::nca::kKeyAreaEncryptionKeyNum; j++) { if (mKeyset.nca.key_area_key[j][i] != zeros_aes_key) { @@ -711,7 +711,7 @@ void UserSettings::populateUserSettings(sCmdArgs& args) if (args.inst_type.isSet) mInstructionType = getInstructionTypeFromString(*args.inst_type); else - mInstructionType = nx::npdm::INSTR_64BIT; // default 64bit + mInstructionType = nn::hac::npdm::INSTR_64BIT; // default 64bit mListApi = args.list_api.isSet; mListSymbols = args.list_sym.isSet; @@ -823,19 +823,19 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path) #define _ASSERT_SIZE(sz) (scratch.size() >= (sz)) // test npdm - if (_ASSERT_SIZE(sizeof(nx::sXciHeaderPage)) && _TYPE_PTR(nx::sXciHeaderPage)->header.st_magic.get() == nx::xci::kXciStructMagic) + if (_ASSERT_SIZE(sizeof(nn::hac::sXciHeaderPage)) && _TYPE_PTR(nn::hac::sXciHeaderPage)->header.st_magic.get() == nn::hac::xci::kXciStructMagic) file_type = FILE_XCI; // test pfs0 - else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && _TYPE_PTR(nx::sPfsHeader)->st_magic.get() == nx::pfs::kPfsStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sPfsHeader)) && _TYPE_PTR(nn::hac::sPfsHeader)->st_magic.get() == nn::hac::pfs::kPfsStructMagic) file_type = FILE_PARTITIONFS; // test hfs0 - else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && _TYPE_PTR(nx::sPfsHeader)->st_magic.get() == nx::pfs::kHashedPfsStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sPfsHeader)) && _TYPE_PTR(nn::hac::sPfsHeader)->st_magic.get() == nn::hac::pfs::kHashedPfsStructMagic) file_type = FILE_PARTITIONFS; // test romfs - else if (_ASSERT_SIZE(sizeof(nx::sRomfsHeader)) && _TYPE_PTR(nx::sRomfsHeader)->header_size.get() == sizeof(nx::sRomfsHeader) && _TYPE_PTR(nx::sRomfsHeader)->sections[1].offset.get() == (_TYPE_PTR(nx::sRomfsHeader)->sections[0].offset.get() + _TYPE_PTR(nx::sRomfsHeader)->sections[0].size.get())) + else if (_ASSERT_SIZE(sizeof(nn::hac::sRomfsHeader)) && _TYPE_PTR(nn::hac::sRomfsHeader)->header_size.get() == sizeof(nn::hac::sRomfsHeader) && _TYPE_PTR(nn::hac::sRomfsHeader)->sections[1].offset.get() == (_TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].offset.get() + _TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].size.get())) file_type = FILE_ROMFS; // test npdm - else if (_ASSERT_SIZE(sizeof(nx::sNpdmHeader)) && _TYPE_PTR(nx::sNpdmHeader)->st_magic.get() == nx::npdm::kNpdmStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sNpdmHeader)) && _TYPE_PTR(nn::hac::sNpdmHeader)->st_magic.get() == nn::hac::npdm::kNpdmStructMagic) file_type = FILE_NPDM; // test nca else if (determineValidNcaFromSample(scratch)) @@ -847,10 +847,10 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path) else if (determineValidNacpFromSample(scratch)) file_type = FILE_NACP; // test nso - else if (_ASSERT_SIZE(sizeof(nx::sNsoHeader)) && _TYPE_PTR(nx::sNsoHeader)->st_magic.get() == nx::nso::kNsoStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic) file_type = FILE_NSO; // test nso - else if (_ASSERT_SIZE(sizeof(nx::sNroHeader)) && _TYPE_PTR(nx::sNroHeader)->st_magic.get() == nx::nro::kNroStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sNroHeader)) && _TYPE_PTR(nn::hac::sNroHeader)->st_magic.get() == nn::hac::nro::kNroStructMagic) file_type = FILE_NRO; // test pki certificate else if (determineValidEsCertFromSample(scratch)) @@ -859,7 +859,7 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path) else if (determineValidEsTikFromSample(scratch)) file_type = FILE_ES_TIK; // test hb asset - else if (_ASSERT_SIZE(sizeof(nx::sAssetHeader)) && _TYPE_PTR(nx::sAssetHeader)->st_magic.get() == nx::aset::kAssetStructMagic) + else if (_ASSERT_SIZE(sizeof(nn::hac::sAssetHeader)) && _TYPE_PTR(nn::hac::sAssetHeader)->st_magic.get() == nn::hac::aset::kAssetStructMagic) file_type = FILE_HB_ASSET; // else unrecognised else @@ -874,15 +874,15 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path) bool UserSettings::determineValidNcaFromSample(const fnd::Vec& sample) const { // prepare decrypted NCA data - byte_t nca_raw[nx::nca::kHeaderSize]; - nx::sNcaHeader* nca_header = (nx::sNcaHeader*)(nca_raw + nx::NcaUtils::sectorToOffset(1)); + byte_t nca_raw[nn::hac::nca::kHeaderSize]; + nn::hac::sNcaHeader* nca_header = (nn::hac::sNcaHeader*)(nca_raw + nn::hac::NcaUtils::sectorToOffset(1)); - if (sample.size() < nx::nca::kHeaderSize) + if (sample.size() < nn::hac::nca::kHeaderSize) return false; - nx::NcaUtils::decryptNcaHeader(sample.data(), nca_raw, mKeyset.nca.header_key); + nn::hac::NcaUtils::decryptNcaHeader(sample.data(), nca_raw, mKeyset.nca.header_key); - if (nca_header->st_magic.get() != nx::nca::kNca2StructMagic && nca_header->st_magic.get() != nx::nca::kNca3StructMagic) + if (nca_header->st_magic.get() != nn::hac::nca::kNca2StructMagic && nca_header->st_magic.get() != nn::hac::nca::kNca3StructMagic) return false; return true; @@ -890,39 +890,39 @@ bool UserSettings::determineValidNcaFromSample(const fnd::Vec& sample) c bool UserSettings::determineValidCnmtFromSample(const fnd::Vec& sample) const { - if (sample.size() < sizeof(nx::sContentMetaHeader)) + if (sample.size() < sizeof(nn::hac::sContentMetaHeader)) return false; - const nx::sContentMetaHeader* data = (const nx::sContentMetaHeader*)sample.data(); + const nn::hac::sContentMetaHeader* data = (const nn::hac::sContentMetaHeader*)sample.data(); - size_t minimum_size = sizeof(nx::sContentMetaHeader) + data->exhdr_size.get() + data->content_count.get() * sizeof(nx::sContentInfo) + data->content_meta_count.get() * sizeof(nx::sContentMetaInfo) + nx::cnmt::kDigestLen; + size_t minimum_size = sizeof(nn::hac::sContentMetaHeader) + data->exhdr_size.get() + data->content_count.get() * sizeof(nn::hac::sContentInfo) + data->content_meta_count.get() * sizeof(nn::hac::sContentMetaInfo) + nn::hac::cnmt::kDigestLen; if (sample.size() < minimum_size) return false; - if (data->type == nx::cnmt::METATYPE_APPLICATION) + if (data->type == nn::hac::cnmt::METATYPE_APPLICATION) { - const nx::sApplicationMetaExtendedHeader* meta = (const nx::sApplicationMetaExtendedHeader*)(sample.data() + sizeof(nx::sContentMetaHeader)); + const nn::hac::sApplicationMetaExtendedHeader* meta = (const nn::hac::sApplicationMetaExtendedHeader*)(sample.data() + sizeof(nn::hac::sContentMetaHeader)); if ((meta->patch_id.get() & data->id.get()) != data->id.get()) return false; } - else if (data->type == nx::cnmt::METATYPE_PATCH) + else if (data->type == nn::hac::cnmt::METATYPE_PATCH) { - const nx::sPatchMetaExtendedHeader* meta = (const nx::sPatchMetaExtendedHeader*)(sample.data() + sizeof(nx::sContentMetaHeader)); + const nn::hac::sPatchMetaExtendedHeader* meta = (const nn::hac::sPatchMetaExtendedHeader*)(sample.data() + sizeof(nn::hac::sContentMetaHeader)); if ((meta->application_id.get() & data->id.get()) != meta->application_id.get()) return false; minimum_size += meta->extended_data_size.get(); } - else if (data->type == nx::cnmt::METATYPE_ADD_ON_CONTENT) + else if (data->type == nn::hac::cnmt::METATYPE_ADD_ON_CONTENT) { - const nx::sAddOnContentMetaExtendedHeader* meta = (const nx::sAddOnContentMetaExtendedHeader*)(sample.data() + sizeof(nx::sContentMetaHeader)); + const nn::hac::sAddOnContentMetaExtendedHeader* meta = (const nn::hac::sAddOnContentMetaExtendedHeader*)(sample.data() + sizeof(nn::hac::sContentMetaHeader)); if ((meta->application_id.get() & data->id.get()) != meta->application_id.get()) return false; } - else if (data->type == nx::cnmt::METATYPE_DELTA) + else if (data->type == nn::hac::cnmt::METATYPE_DELTA) { - const nx::sDeltaMetaExtendedHeader* meta = (const nx::sDeltaMetaExtendedHeader*)(sample.data() + sizeof(nx::sContentMetaHeader)); + const nn::hac::sDeltaMetaExtendedHeader* meta = (const nn::hac::sDeltaMetaExtendedHeader*)(sample.data() + sizeof(nn::hac::sContentMetaHeader)); if ((meta->application_id.get() & data->id.get()) != meta->application_id.get()) return false; @@ -937,12 +937,12 @@ bool UserSettings::determineValidCnmtFromSample(const fnd::Vec& sample) bool UserSettings::determineValidNacpFromSample(const fnd::Vec& sample) const { - if (sample.size() != sizeof(nx::sApplicationControlProperty)) + if (sample.size() != sizeof(nn::hac::sApplicationControlProperty)) return false; - const nx::sApplicationControlProperty* data = (const nx::sApplicationControlProperty*)sample.data(); + const nn::hac::sApplicationControlProperty* data = (const nn::hac::sApplicationControlProperty*)sample.data(); - if (data->logo_type > nx::nacp::LOGO_Nintendo) + if (data->logo_type > nn::hac::nacp::LOGO_Nintendo) return false; if (data->display_version[0] == 0) @@ -1004,16 +1004,16 @@ bool UserSettings::determineValidEsTikFromSample(const fnd::Vec& sample) return true; } -nx::npdm::InstructionType UserSettings::getInstructionTypeFromString(const std::string & type_str) +nn::hac::npdm::InstructionType UserSettings::getInstructionTypeFromString(const std::string & type_str) { std::string str = type_str; std::transform(str.begin(), str.end(), str.begin(), ::tolower); - nx::npdm::InstructionType type; + nn::hac::npdm::InstructionType type; if (str == "32bit") - type = nx::npdm::INSTR_32BIT; + type = nn::hac::npdm::INSTR_32BIT; else if (str == "64bit") - type = nx::npdm::INSTR_64BIT; + type = nn::hac::npdm::INSTR_64BIT; else throw fnd::Exception(kModuleName, "Unsupported instruction type: " + str); diff --git a/programs/nstool/source/UserSettings.h b/programs/nstool/source/UserSettings.h index fd53077..2643243 100644 --- a/programs/nstool/source/UserSettings.h +++ b/programs/nstool/source/UserSettings.h @@ -4,9 +4,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include "nstool.h" class UserSettings @@ -28,7 +28,7 @@ public: bool isListFs() const; bool isListApi() const; bool isListSymbols() const; - nx::npdm::InstructionType getInstType() const; + nn::hac::npdm::InstructionType getInstType() const; // specialised paths const sOptional& getXciUpdatePath() const; @@ -104,7 +104,7 @@ private: bool mListApi; bool mListSymbols; - nx::npdm::InstructionType mInstructionType; + nn::hac::npdm::InstructionType mInstructionType; void populateCmdArgs(const std::vector& arg_list, sCmdArgs& cmd_args); void populateKeyset(sCmdArgs& args); @@ -117,5 +117,5 @@ private: bool determineValidNacpFromSample(const fnd::Vec& sample) const; bool determineValidEsCertFromSample(const fnd::Vec& sample) const; bool determineValidEsTikFromSample(const fnd::Vec& sample) const; - nx::npdm::InstructionType getInstructionTypeFromString(const std::string& type_str); + nn::hac::npdm::InstructionType getInstructionTypeFromString(const std::string& type_str); }; \ No newline at end of file diff --git a/programs/nstool/source/XciProcess.cpp b/programs/nstool/source/XciProcess.cpp index 5def29e..9408e42 100644 --- a/programs/nstool/source/XciProcess.cpp +++ b/programs/nstool/source/XciProcess.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "OffsetAdjustedIFile.h" #include "XciProcess.h" @@ -33,11 +33,11 @@ void XciProcess::process() } // read header page - mFile->read((byte_t*)&mHdrPage, 0, sizeof(nx::sXciHeaderPage)); + mFile->read((byte_t*)&mHdrPage, 0, sizeof(nn::hac::sXciHeaderPage)); // allocate memory for and decrypt sXciHeader - scratch.alloc(sizeof(nx::sXciHeader)); - nx::XciUtils::decryptXciHeader((const byte_t*)&mHdrPage.header, scratch.data(), mKeyset->xci.header_key.key); + scratch.alloc(sizeof(nn::hac::sXciHeader)); + nn::hac::XciUtils::decryptXciHeader((const byte_t*)&mHdrPage.header, scratch.data(), mKeyset->xci.header_key.key); // validate header signature if (mVerify) @@ -130,22 +130,22 @@ void XciProcess::displayHeader() { printf(" RomAreaStartPage: 0x%0x", mHdr.getRomAreaStartPage()); if (mHdr.getRomAreaStartPage() != (uint32_t)(-1)) - printf(" (0x%" PRIx64 ")", nx::XciUtils::blockToAddr(mHdr.getRomAreaStartPage())); + printf(" (0x%" PRIx64 ")", nn::hac::XciUtils::blockToAddr(mHdr.getRomAreaStartPage())); printf("\n"); printf(" BackupAreaStartPage: 0x%0x", mHdr.getBackupAreaStartPage()); if (mHdr.getBackupAreaStartPage() != (uint32_t)(-1)) - printf(" (0x%" PRIx64 ")", nx::XciUtils::blockToAddr(mHdr.getBackupAreaStartPage())); + printf(" (0x%" PRIx64 ")", nn::hac::XciUtils::blockToAddr(mHdr.getBackupAreaStartPage())); printf("\n"); printf(" ValidDataEndPage: 0x%x", mHdr.getValidDataEndPage()); if (mHdr.getValidDataEndPage() != (uint32_t)(-1)) - printf(" (0x%" PRIx64 ")", nx::XciUtils::blockToAddr(mHdr.getValidDataEndPage())); + printf(" (0x%" PRIx64 ")", nn::hac::XciUtils::blockToAddr(mHdr.getValidDataEndPage())); printf("\n"); printf(" LimArea: 0x%x", mHdr.getLimAreaPage()); if (mHdr.getLimAreaPage() != (uint32_t)(-1)) - printf(" (0x%" PRIx64 ")", nx::XciUtils::blockToAddr(mHdr.getLimAreaPage())); + printf(" (0x%" PRIx64 ")", nn::hac::XciUtils::blockToAddr(mHdr.getLimAreaPage())); printf("\n"); printf(" PartitionFs Header:\n"); @@ -193,7 +193,7 @@ bool XciProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* t void XciProcess::validateXciSignature() { crypto::sha::sSha256Hash calc_hash; - crypto::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nx::sXciHeader), calc_hash.bytes); + crypto::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes); if (crypto::rsa::pkcs::rsaVerify(mKeyset->xci.header_sign_key, crypto::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0) { printf("[WARNING] XCI Header Signature: FAIL \n"); @@ -216,7 +216,7 @@ void XciProcess::processRootPfs() void XciProcess::processPartitionPfs() { - const fnd::List& rootPartitions = mRootPfs.getPfsHeader().getFileList(); + const fnd::List& rootPartitions = mRootPfs.getPfsHeader().getFileList(); for (size_t i = 0; i < rootPartitions.size(); i++) { // this must be validated here because only the size of the root partiton header is known at verification time @@ -243,22 +243,22 @@ const char* XciProcess::getRomSizeStr(byte_t rom_size) const const char* str = "unknown"; switch (rom_size) { - case (nx::xci::ROM_SIZE_1GB): + case (nn::hac::xci::ROM_SIZE_1GB): str = "1GB"; break; - case (nx::xci::ROM_SIZE_2GB): + case (nn::hac::xci::ROM_SIZE_2GB): str = "2GB"; break; - case (nx::xci::ROM_SIZE_4GB): + case (nn::hac::xci::ROM_SIZE_4GB): str = "4GB"; break; - case (nx::xci::ROM_SIZE_8GB): + case (nn::hac::xci::ROM_SIZE_8GB): str = "8GB"; break; - case (nx::xci::ROM_SIZE_16GB): + case (nn::hac::xci::ROM_SIZE_16GB): str = "16GB"; break; - case (nx::xci::ROM_SIZE_32GB): + case (nn::hac::xci::ROM_SIZE_32GB): str = "32GB"; break; } @@ -270,13 +270,13 @@ const char* XciProcess::getHeaderFlagStr(byte_t flag) const const char* str = "unknown"; switch (flag) { - case (nx::xci::FLAG_AUTOBOOT): + case (nn::hac::xci::FLAG_AUTOBOOT): str = "AutoBoot"; break; - case (nx::xci::FLAG_HISTORY_ERASE): + case (nn::hac::xci::FLAG_HISTORY_ERASE): str = "HistoryErase"; break; - case (nx::xci::FLAG_REPAIR_TOOL): + case (nn::hac::xci::FLAG_REPAIR_TOOL): str = "RepairTool"; break; } @@ -289,10 +289,10 @@ const char* XciProcess::getCardClockRate(uint32_t acc_ctrl_1) const const char* str = "unknown"; switch (acc_ctrl_1) { - case (nx::xci::CLOCK_RATE_25): + case (nn::hac::xci::CLOCK_RATE_25): str = "20 MHz"; break; - case (nx::xci::CLOCK_RATE_50): + case (nn::hac::xci::CLOCK_RATE_50): str = "50 MHz"; break; diff --git a/programs/nstool/source/XciProcess.h b/programs/nstool/source/XciProcess.h index 68d8f54..32fc038 100644 --- a/programs/nstool/source/XciProcess.h +++ b/programs/nstool/source/XciProcess.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "nstool.h" @@ -57,8 +57,8 @@ private: bool mListFs; - nx::sXciHeaderPage mHdrPage; - nx::XciHeader mHdr; + nn::hac::sXciHeaderPage mHdrPage; + nn::hac::XciHeader mHdr; PfsProcess mRootPfs; fnd::List mExtractInfo; diff --git a/programs/nstool/source/main.cpp b/programs/nstool/source/main.cpp index 7eefe54..6a30e29 100644 --- a/programs/nstool/source/main.cpp +++ b/programs/nstool/source/main.cpp @@ -46,13 +46,13 @@ int main(int argc, char** argv) xci.setVerifyMode(user_set.isVerifyFile()); if (user_set.getXciUpdatePath().isSet) - xci.setPartitionForExtract(nx::xci::kUpdatePartitionStr, user_set.getXciUpdatePath().var); + xci.setPartitionForExtract(nn::hac::xci::kUpdatePartitionStr, user_set.getXciUpdatePath().var); if (user_set.getXciLogoPath().isSet) - xci.setPartitionForExtract(nx::xci::kLogoPartitionStr, user_set.getXciLogoPath().var); + xci.setPartitionForExtract(nn::hac::xci::kLogoPartitionStr, user_set.getXciLogoPath().var); if (user_set.getXciNormalPath().isSet) - xci.setPartitionForExtract(nx::xci::kNormalPartitionStr, user_set.getXciNormalPath().var); + xci.setPartitionForExtract(nn::hac::xci::kNormalPartitionStr, user_set.getXciNormalPath().var); if (user_set.getXciSecurePath().isSet) - xci.setPartitionForExtract(nx::xci::kSecurePartitionStr, user_set.getXciSecurePath().var); + xci.setPartitionForExtract(nn::hac::xci::kSecurePartitionStr, user_set.getXciSecurePath().var); xci.setListFs(user_set.isListFs()); xci.process(); diff --git a/programs/nstool/source/nstool.h b/programs/nstool/source/nstool.h index a52c571..3e2043e 100644 --- a/programs/nstool/source/nstool.h +++ b/programs/nstool/source/nstool.h @@ -4,10 +4,10 @@ #include #include #include -#include +#include static const size_t kMasterKeyNum = 0x20; -static const size_t kNcaKeakNum = nx::nca::kKeyAreaEncryptionKeyNum; +static const size_t kNcaKeakNum = nn::hac::nca::kKeyAreaEncryptionKeyNum; enum IFileOwnershipMode { From ebbdbcd364d49db3d2a2416538bc74b10b89bff6 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 16:13:18 +0800 Subject: [PATCH 10/16] Fix project files and typos. --- lib/libes/libes.vcxproj | 6 +-- lib/libes/libes.vcxproj.filters | 6 +-- lib/libpki/include/nn/pki/SignedData.h | 2 +- programs/nstool/README.md | 1 + programs/nstool/makefile | 2 +- programs/nstool/nstool.vcxproj | 8 ++-- programs/nstool/source/EsTikProcess.cpp | 46 ++++++++++----------- programs/nstool/source/EsTikProcess.h | 6 +-- programs/nstool/source/PkiCertProcess.cpp | 32 +++++++-------- programs/nstool/source/PkiCertProcess.h | 8 ++-- programs/nstool/source/PkiValidator.cpp | 50 +++++++++++------------ programs/nstool/source/PkiValidator.h | 14 +++---- programs/nstool/source/UserSettings.cpp | 22 +++++----- programs/nstool/source/UserSettings.h | 4 +- 14 files changed, 104 insertions(+), 103 deletions(-) diff --git a/lib/libes/libes.vcxproj b/lib/libes/libes.vcxproj index 2373da0..2c3482d 100644 --- a/lib/libes/libes.vcxproj +++ b/lib/libes/libes.vcxproj @@ -120,9 +120,9 @@ - - - + + + diff --git a/lib/libes/libes.vcxproj.filters b/lib/libes/libes.vcxproj.filters index f933a32..d55625c 100644 --- a/lib/libes/libes.vcxproj.filters +++ b/lib/libes/libes.vcxproj.filters @@ -18,13 +18,13 @@ - + Header Files - + Header Files - + Header Files diff --git a/lib/libpki/include/nn/pki/SignedData.h b/lib/libpki/include/nn/pki/SignedData.h index 112e9f9..0997cd4 100644 --- a/lib/libpki/include/nn/pki/SignedData.h +++ b/lib/libpki/include/nn/pki/SignedData.h @@ -136,4 +136,4 @@ namespace pki mBody = body; } } - +} \ No newline at end of file diff --git a/programs/nstool/README.md b/programs/nstool/README.md index 9fb5dab..55490fd 100644 --- a/programs/nstool/README.md +++ b/programs/nstool/README.md @@ -48,6 +48,7 @@ Usage: nstool [options... ] --titlekey Specify title key extracted from ticket. --bodykey Specify body encryption key. --tik Specify ticket to source title key. + --cert Specify certificate chain to verify ticket. --part0 Extract "partition 0" to directory. --part1 Extract "partition 1" to directory. --part2 Extract "partition 2" to directory. diff --git a/programs/nstool/makefile b/programs/nstool/makefile index 4359763..a20fbb5 100644 --- a/programs/nstool/makefile +++ b/programs/nstool/makefile @@ -3,7 +3,7 @@ SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = hac-hb hac es pki crypto compress polarssl lz4 fnd +DEPENDS = hac-hb hac es pki crypto compress fnd polarssl lz4 LIB_DIR = ../../lib LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep)) INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") diff --git a/programs/nstool/nstool.vcxproj b/programs/nstool/nstool.vcxproj index d9e7aed..9110d28 100644 --- a/programs/nstool/nstool.vcxproj +++ b/programs/nstool/nstool.vcxproj @@ -90,7 +90,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;..\..\lib\libnx-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -105,7 +105,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;..\..\lib\libnx-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -122,7 +122,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;..\..\lib\libnx-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -141,7 +141,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;..\..\lib\libnx-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console diff --git a/programs/nstool/source/EsTikProcess.cpp b/programs/nstool/source/EsTikProcess.cpp index fb897de..9f98521 100644 --- a/programs/nstool/source/EsTikProcess.cpp +++ b/programs/nstool/source/EsTikProcess.cpp @@ -47,7 +47,7 @@ void EsTikProcess::setKeyset(const sKeyset* keyset) mKeyset = keyset; } -void EsTikProcess::setCertificateChain(const fnd::List>& certs) +void EsTikProcess::setCertificateChain(const fnd::List>& certs) { mCerts = certs; } @@ -80,13 +80,13 @@ void EsTikProcess::verifyTicket() PkiValidator pki_validator; fnd::Vec tik_hash; - switch (pki::sign::getHashAlgo(mTik.getSignature().getSignType())) + switch (nn::pki::sign::getHashAlgo(mTik.getSignature().getSignType())) { - case (pki::sign::HASH_ALGO_SHA1): + case (nn::pki::sign::HASH_ALGO_SHA1): tik_hash.alloc(crypto::sha::kSha1HashLen); crypto::sha::Sha1(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); break; - case (pki::sign::HASH_ALGO_SHA256): + case (nn::pki::sign::HASH_ALGO_SHA256): tik_hash.alloc(crypto::sha::kSha256HashLen); crypto::sha::Sha256(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); break; @@ -110,7 +110,7 @@ void EsTikProcess::displayTicket() #define _HEXDUMP_U(var, len) do { for (size_t a__a__A = 0; a__a__A < len; a__a__A++) printf("%02X", var[a__a__A]); } while(0) #define _HEXDUMP_L(var, len) do { for (size_t a__a__A = 0; a__a__A < len; a__a__A++) printf("%02x", var[a__a__A]); } while(0) - const es::TicketBody_V2& body = mTik.getBody(); + const nn::es::TicketBody_V2& body = mTik.getBody(); std::cout << "[ES Ticket]" << std::endl; @@ -124,7 +124,7 @@ void EsTikProcess::displayTicket() std::cout << " EncMode: " << getTitleKeyPersonalisationStr(body.getTitleKeyEncType()) << std::endl; std::cout << " KeyGeneration: " << std::dec << (uint32_t)body.getCommonKeyId() << std::endl; std::cout << " Data:" << std::endl; - size_t size = body.getTitleKeyEncType() == es::ticket::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; + size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6); printf(" Version: v%d.%d.%d", _SPLIT_VER(body.getTicketVersion())); @@ -174,22 +174,22 @@ const char* EsTikProcess::getSignTypeStr(uint32_t type) const const char* str = nullptr; switch(type) { - case (pki::sign::SIGN_ID_RSA4096_SHA1): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA1): str = "RSA4096-SHA1"; break; - case (pki::sign::SIGN_ID_RSA2048_SHA1): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA1): str = "RSA2048-SHA1"; break; - case (pki::sign::SIGN_ID_ECDSA240_SHA1): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1): str = "ECDSA240-SHA1"; break; - case (pki::sign::SIGN_ID_RSA4096_SHA256): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA256): str = "RSA4096-SHA256"; break; - case (pki::sign::SIGN_ID_RSA2048_SHA256): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA256): str = "RSA2048-SHA256"; break; - case (pki::sign::SIGN_ID_ECDSA240_SHA256): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256): str = "ECDSA240-SHA256"; break; default: @@ -204,10 +204,10 @@ const char* EsTikProcess::getTitleKeyPersonalisationStr(byte_t flag) const const char* str = nullptr; switch(flag) { - case (es::ticket::AES128_CBC): + case (nn::es::ticket::AES128_CBC): str = "Generic (AESCBC)"; break; - case (es::ticket::RSA2048): + case (nn::es::ticket::RSA2048): str = "Personalised (RSA2048)"; break; default: @@ -222,22 +222,22 @@ const char* EsTikProcess::getLicenseTypeStr(byte_t flag) const const char* str = nullptr; switch(flag) { - case (es::ticket::LICENSE_PERMANENT): + case (nn::es::ticket::LICENSE_PERMANENT): str = "Permanent"; break; - case (es::ticket::LICENSE_DEMO): + case (nn::es::ticket::LICENSE_DEMO): str = "Demo"; break; - case (es::ticket::LICENSE_TRIAL): + case (nn::es::ticket::LICENSE_TRIAL): str = "Trial"; break; - case (es::ticket::LICENSE_RENTAL): + case (nn::es::ticket::LICENSE_RENTAL): str = "Rental"; break; - case (es::ticket::LICENSE_SUBSCRIPTION): + case (nn::es::ticket::LICENSE_SUBSCRIPTION): str = "Subscription"; break; - case (es::ticket::LICENSE_SERVICE): + case (nn::es::ticket::LICENSE_SERVICE): str = "Service"; break; default: @@ -252,13 +252,13 @@ const char* EsTikProcess::getPropertyFlagStr(byte_t flag) const const char* str = nullptr; switch(flag) { - case (es::ticket::FLAG_PRE_INSTALL): + case (nn::es::ticket::FLAG_PRE_INSTALL): str = "PreInstall"; break; - case (es::ticket::FLAG_SHARED_TITLE): + case (nn::es::ticket::FLAG_SHARED_TITLE): str = "SharedTitle"; break; - case (es::ticket::FLAG_ALLOW_ALL_CONTENT): + case (nn::es::ticket::FLAG_ALLOW_ALL_CONTENT): str = "AllContent"; break; default: diff --git a/programs/nstool/source/EsTikProcess.h b/programs/nstool/source/EsTikProcess.h index 2424156..82d82d0 100644 --- a/programs/nstool/source/EsTikProcess.h +++ b/programs/nstool/source/EsTikProcess.h @@ -18,7 +18,7 @@ public: void setInputFile(fnd::IFile* file, bool ownIFile); void setKeyset(const sKeyset* keyset); - void setCertificateChain(const fnd::List>& certs); + void setCertificateChain(const fnd::List>& certs); void setCliOutputMode(CliOutputMode mode); void setVerifyMode(bool verify); @@ -31,9 +31,9 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - fnd::List> mCerts; + fnd::List> mCerts; - pki::SignedData mTik; + nn::pki::SignedData mTik; void importTicket(); void verifyTicket(); diff --git a/programs/nstool/source/PkiCertProcess.cpp b/programs/nstool/source/PkiCertProcess.cpp index 47b3267..5de3e01 100644 --- a/programs/nstool/source/PkiCertProcess.cpp +++ b/programs/nstool/source/PkiCertProcess.cpp @@ -66,7 +66,7 @@ void PkiCertProcess::importCerts() scratch.alloc(mFile->size()); mFile->read(scratch.data(), 0, scratch.size()); - pki::SignedData cert; + nn::pki::SignedData cert; for (size_t f_pos = 0; f_pos < scratch.size(); f_pos += cert.getBytes().size()) { cert.fromBytes(scratch.data() + f_pos, scratch.size() - f_pos); @@ -98,7 +98,7 @@ void PkiCertProcess::displayCerts() } } -void PkiCertProcess::displayCert(const pki::SignedData& cert) +void PkiCertProcess::displayCert(const nn::pki::SignedData& cert) { #define _SPLIT_VER(ver) ( (ver>>26) & 0x3f), ( (ver>>20) & 0x3f), ( (ver>>16) & 0xf), (ver & 0xffff) #define _HEXDUMP_U(var, len) do { for (size_t a__a__A = 0; a__a__A < len; a__a__A++) printf("%02X", var[a__a__A]); } while(0) @@ -119,7 +119,7 @@ void PkiCertProcess::displayCert(const pki::SignedData& ce std::cout << std::endl; std::cout << " CertID: 0x" << std::hex << cert.getBody().getCertId() << std::endl; - if (cert.getBody().getPublicKeyType() == pki::cert::RSA4096) + if (cert.getBody().getPublicKeyType() == nn::pki::cert::RSA4096) { std::cout << " PublicKey:" << std::endl; std::cout << " Modulus:" << std::endl; @@ -127,7 +127,7 @@ void PkiCertProcess::displayCert(const pki::SignedData& ce std::cout << " Public Exponent:" << std::endl; fnd::SimpleTextOutput::hexDump(cert.getBody().getRsa4098PublicKey().public_exponent, crypto::rsa::kRsaPublicExponentSize, 0x10, 6); } - else if (cert.getBody().getPublicKeyType() == pki::cert::RSA2048) + else if (cert.getBody().getPublicKeyType() == nn::pki::cert::RSA2048) { std::cout << " PublicKey:" << std::endl; std::cout << " Public Exponent:" << std::endl; @@ -135,7 +135,7 @@ void PkiCertProcess::displayCert(const pki::SignedData& ce std::cout << " Modulus:" << std::endl; fnd::SimpleTextOutput::hexDump(cert.getBody().getRsa2048PublicKey().public_exponent, crypto::rsa::kRsaPublicExponentSize, 0x10, 6); } - else if (cert.getBody().getPublicKeyType() == pki::cert::ECDSA240) + else if (cert.getBody().getPublicKeyType() == nn::pki::cert::ECDSA240) { std::cout << " PublicKey:" << std::endl; std::cout << " R:" << std::endl; @@ -156,27 +156,27 @@ size_t PkiCertProcess::getHexDumpLen(size_t max_size) const return _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED) ? max_size : kSmallHexDumpLen; } -const char* PkiCertProcess::getSignTypeStr(pki::sign::SignatureId type) const +const char* PkiCertProcess::getSignTypeStr(nn::pki::sign::SignatureId type) const { const char* str; switch (type) { - case (pki::sign::SIGN_ID_RSA4096_SHA1): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA1): str = "RSA4096-SHA1"; break; - case (pki::sign::SIGN_ID_RSA2048_SHA1): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA1): str = "RSA2048-SHA1"; break; - case (pki::sign::SIGN_ID_ECDSA240_SHA1): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1): str = "ECDSA240-SHA1"; break; - case (pki::sign::SIGN_ID_RSA4096_SHA256): + case (nn::pki::sign::SIGN_ID_RSA4096_SHA256): str = "RSA4096-SHA256"; break; - case (pki::sign::SIGN_ID_RSA2048_SHA256): + case (nn::pki::sign::SIGN_ID_RSA2048_SHA256): str = "RSA2048-SHA256"; break; - case (pki::sign::SIGN_ID_ECDSA240_SHA256): + case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256): str = "ECDSA240-SHA256"; break; default: @@ -191,18 +191,18 @@ const char* PkiCertProcess::getEndiannessStr(bool isLittleEndian) const return isLittleEndian ? "LittleEndian" : "BigEndian"; } -const char* PkiCertProcess::getPublicKeyTypeStr(pki::cert::PublicKeyType type) const +const char* PkiCertProcess::getPublicKeyTypeStr(nn::pki::cert::PublicKeyType type) const { const char* str; switch (type) { - case (pki::cert::RSA4096): + case (nn::pki::cert::RSA4096): str = "RSA4096"; break; - case (pki::cert::RSA2048): + case (nn::pki::cert::RSA2048): str = "RSA2048"; break; - case (pki::cert::ECDSA240): + case (nn::pki::cert::ECDSA240): str = "ECDSA240"; break; default: diff --git a/programs/nstool/source/PkiCertProcess.h b/programs/nstool/source/PkiCertProcess.h index b071ec6..e7dd144 100644 --- a/programs/nstool/source/PkiCertProcess.h +++ b/programs/nstool/source/PkiCertProcess.h @@ -31,15 +31,15 @@ private: CliOutputMode mCliOutputMode; bool mVerify; - fnd::List> mCert; + fnd::List> mCert; void importCerts(); void validateCerts(); void displayCerts(); - void displayCert(const pki::SignedData& cert); + void displayCert(const nn::pki::SignedData& cert); size_t getHexDumpLen(size_t max_size) const; - const char* getSignTypeStr(pki::sign::SignatureId type) const; + const char* getSignTypeStr(nn::pki::sign::SignatureId type) const; const char* getEndiannessStr(bool isLittleEndian) const; - const char* getPublicKeyTypeStr(pki::cert::PublicKeyType type) const; + const char* getPublicKeyTypeStr(nn::pki::cert::PublicKeyType type) const; }; \ No newline at end of file diff --git a/programs/nstool/source/PkiValidator.cpp b/programs/nstool/source/PkiValidator.cpp index 70f5728..971ecc7 100644 --- a/programs/nstool/source/PkiValidator.cpp +++ b/programs/nstool/source/PkiValidator.cpp @@ -12,7 +12,7 @@ PkiValidator::PkiValidator() void PkiValidator::setRootKey(const crypto::rsa::sRsa4096Key& root_key) { // save a copy of the certificate bank - fnd::List> old_certs = mCertificateBank; + fnd::List> old_certs = mCertificateBank; // clear the certificate bank mCertificateBank.clear(); @@ -27,7 +27,7 @@ void PkiValidator::setRootKey(const crypto::rsa::sRsa4096Key& root_key) } } -void PkiValidator::addCertificates(const fnd::List>& certs) +void PkiValidator::addCertificates(const fnd::List>& certs) { for (size_t i = 0; i < certs.size(); i++) { @@ -35,11 +35,11 @@ void PkiValidator::addCertificates(const fnd::List& cert) +void PkiValidator::addCertificate(const nn::pki::SignedData& cert) { std::string cert_ident; - pki::sign::SignatureAlgo cert_sign_algo; - pki::sign::HashAlgo cert_hash_algo; + nn::pki::sign::SignatureAlgo cert_sign_algo; + nn::pki::sign::HashAlgo cert_hash_algo; fnd::Vec cert_hash; try @@ -51,17 +51,17 @@ void PkiValidator::addCertificate(const pki::SignedData& c throw fnd::Exception(kModuleName, "Certificate already exists"); } - cert_sign_algo = pki::sign::getSignatureAlgo(cert.getSignature().getSignType()); - cert_hash_algo = pki::sign::getHashAlgo(cert.getSignature().getSignType()); + cert_sign_algo = nn::pki::sign::getSignatureAlgo(cert.getSignature().getSignType()); + cert_hash_algo = nn::pki::sign::getHashAlgo(cert.getSignature().getSignType()); // get cert hash switch (cert_hash_algo) { - case (pki::sign::HASH_ALGO_SHA1): + case (nn::pki::sign::HASH_ALGO_SHA1): cert_hash.alloc(crypto::sha::kSha1HashLen); crypto::sha::Sha1(cert.getBody().getBytes().data(), cert.getBody().getBytes().size(), cert_hash.data()); break; - case (pki::sign::HASH_ALGO_SHA256): + case (nn::pki::sign::HASH_ALGO_SHA256): cert_hash.alloc(crypto::sha::kSha256HashLen); crypto::sha::Sha256(cert.getBody().getBytes().data(), cert.getBody().getBytes().size(), cert_hash.data()); break; @@ -86,19 +86,19 @@ void PkiValidator::clearCertificates() mCertificateBank.clear(); } -void PkiValidator::validateSignature(const std::string& issuer, pki::sign::SignatureId signature_id, const fnd::Vec& signature, const fnd::Vec& hash) const +void PkiValidator::validateSignature(const std::string& issuer, nn::pki::sign::SignatureId signature_id, const fnd::Vec& signature, const fnd::Vec& hash) const { - pki::sign::SignatureAlgo sign_algo = pki::sign::getSignatureAlgo(signature_id); - pki::sign::HashAlgo hash_algo = pki::sign::getHashAlgo(signature_id); + nn::pki::sign::SignatureAlgo sign_algo = nn::pki::sign::getSignatureAlgo(signature_id); + nn::pki::sign::HashAlgo hash_algo = nn::pki::sign::getHashAlgo(signature_id); // validate signature int sig_validate_res = -1; // special case if signed by Root - if (issuer == pki::sign::kRootIssuerStr) + if (issuer == nn::pki::sign::kRootIssuerStr) { - if (sign_algo != pki::sign::SIGN_ALGO_RSA4096) + if (sign_algo != nn::pki::sign::SIGN_ALGO_RSA4096) { throw fnd::Exception(kModuleName, "Issued by Root, but does not have a RSA4096 signature"); } @@ -107,18 +107,18 @@ void PkiValidator::validateSignature(const std::string& issuer, pki::sign::Signa else { // try to find issuer cert - const pki::CertificateBody& issuer_cert = getCert(issuer).getBody(); - pki::cert::PublicKeyType issuer_pubk_type = issuer_cert.getPublicKeyType(); + const nn::pki::CertificateBody& issuer_cert = getCert(issuer).getBody(); + nn::pki::cert::PublicKeyType issuer_pubk_type = issuer_cert.getPublicKeyType(); - if (issuer_pubk_type == pki::cert::RSA4096 && sign_algo == pki::sign::SIGN_ALGO_RSA4096) + if (issuer_pubk_type == nn::pki::cert::RSA4096 && sign_algo == nn::pki::sign::SIGN_ALGO_RSA4096) { sig_validate_res = crypto::rsa::pkcs::rsaVerify(issuer_cert.getRsa4098PublicKey(), getCryptoHashAlgoFromEsSignHashAlgo(hash_algo), hash.data(), signature.data()); } - else if (issuer_pubk_type == pki::cert::RSA2048 && sign_algo == pki::sign::SIGN_ALGO_RSA2048) + else if (issuer_pubk_type == nn::pki::cert::RSA2048 && sign_algo == nn::pki::sign::SIGN_ALGO_RSA2048) { sig_validate_res = crypto::rsa::pkcs::rsaVerify(issuer_cert.getRsa2048PublicKey(), getCryptoHashAlgoFromEsSignHashAlgo(hash_algo), hash.data(), signature.data()); } - else if (issuer_pubk_type == pki::cert::ECDSA240 && sign_algo == pki::sign::SIGN_ALGO_ECDSA240) + else if (issuer_pubk_type == nn::pki::cert::ECDSA240 && sign_algo == nn::pki::sign::SIGN_ALGO_ECDSA240) { throw fnd::Exception(kModuleName, "ECDSA signatures are not supported"); } @@ -136,14 +136,14 @@ void PkiValidator::validateSignature(const std::string& issuer, pki::sign::Signa } -void PkiValidator::makeCertIdent(const pki::SignedData& cert, std::string& ident) const +void PkiValidator::makeCertIdent(const nn::pki::SignedData& cert, std::string& ident) const { makeCertIdent(cert.getBody().getIssuer(), cert.getBody().getSubject(), ident); } void PkiValidator::makeCertIdent(const std::string& issuer, const std::string& subject, std::string& ident) const { - ident = issuer + pki::sign::kIdentDelimiter + subject; + ident = issuer + nn::pki::sign::kIdentDelimiter + subject; ident = ident.substr(0, _MIN(ident.length(),64)); } @@ -164,7 +164,7 @@ bool PkiValidator::doesCertExist(const std::string& ident) const return exists; } -const pki::SignedData& PkiValidator::getCert(const std::string& ident) const +const nn::pki::SignedData& PkiValidator::getCert(const std::string& ident) const { std::string full_cert_name; for (size_t i = 0; i < mCertificateBank.size(); i++) @@ -179,16 +179,16 @@ const pki::SignedData& PkiValidator::getCert(const std::st throw fnd::Exception(kModuleName, "Issuer certificate does not exist"); } -crypto::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(pki::sign::HashAlgo hash_algo) const +crypto::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const { crypto::sha::HashType hash_type = crypto::sha::HASH_SHA1; switch (hash_algo) { - case (pki::sign::HASH_ALGO_SHA1): + case (nn::pki::sign::HASH_ALGO_SHA1): hash_type = crypto::sha::HASH_SHA1; break; - case (pki::sign::HASH_ALGO_SHA256): + case (nn::pki::sign::HASH_ALGO_SHA256): hash_type = crypto::sha::HASH_SHA256; break; }; diff --git a/programs/nstool/source/PkiValidator.h b/programs/nstool/source/PkiValidator.h index 51d383f..1183c80 100644 --- a/programs/nstool/source/PkiValidator.h +++ b/programs/nstool/source/PkiValidator.h @@ -13,22 +13,22 @@ public: PkiValidator(); void setRootKey(const crypto::rsa::sRsa4096Key& root_key); - void addCertificates(const fnd::List>& certs); - void addCertificate(const pki::SignedData& cert); + void addCertificates(const fnd::List>& certs); + void addCertificate(const nn::pki::SignedData& cert); void clearCertificates(); - void validateSignature(const std::string& issuer, pki::sign::SignatureId signature_id, const fnd::Vec& signature, const fnd::Vec& hash) const; + void validateSignature(const std::string& issuer, nn::pki::sign::SignatureId signature_id, const fnd::Vec& signature, const fnd::Vec& hash) const; private: const std::string kModuleName = "NNPkiValidator"; crypto::rsa::sRsa4096Key mRootKey; - fnd::List> mCertificateBank; + fnd::List> mCertificateBank; - void makeCertIdent(const pki::SignedData& cert, std::string& ident) const; + void makeCertIdent(const nn::pki::SignedData& cert, std::string& ident) const; void makeCertIdent(const std::string& issuer, const std::string& subject, std::string& ident) const; bool doesCertExist(const std::string& ident) const; - const pki::SignedData& getCert(const std::string& ident) const; - crypto::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(pki::sign::HashAlgo hash_algo) const; + const nn::pki::SignedData& getCert(const std::string& ident) const; + crypto::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const; }; \ No newline at end of file diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp index 57b5c84..0c0cf06 100644 --- a/programs/nstool/source/UserSettings.cpp +++ b/programs/nstool/source/UserSettings.cpp @@ -189,7 +189,7 @@ const sOptional& UserSettings::getAssetNacpPath() const return mAssetNacpPath; } -const fnd::List>& UserSettings::getCertificateChain() const +const fnd::List>& UserSettings::getCertificateChain() const { return mCertChain; } @@ -555,7 +555,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) { fnd::SimpleFile cert_file; fnd::Vec cert_raw; - pki::SignedData cert; + nn::pki::SignedData cert; cert_file.open(args.cert_path.var, fnd::SimpleFile::Read); cert_raw.alloc(cert_file.size()); @@ -573,7 +573,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) { fnd::SimpleFile tik_file; fnd::Vec tik_raw; - pki::SignedData tik; + nn::pki::SignedData tik; // open and import ticket tik_file.open(args.ticket_path.var, fnd::SimpleFile::Read); @@ -587,13 +587,13 @@ void UserSettings::populateKeyset(sCmdArgs& args) PkiValidator pki_validator; fnd::Vec tik_hash; - switch (pki::sign::getHashAlgo(tik.getSignature().getSignType())) + switch (nn::pki::sign::getHashAlgo(tik.getSignature().getSignType())) { - case (pki::sign::HASH_ALGO_SHA1): + case (nn::pki::sign::HASH_ALGO_SHA1): tik_hash.alloc(crypto::sha::kSha1HashLen); crypto::sha::Sha1(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); break; - case (pki::sign::HASH_ALGO_SHA256): + case (nn::pki::sign::HASH_ALGO_SHA256): tik_hash.alloc(crypto::sha::kSha256HashLen); crypto::sha::Sha256(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); break; @@ -613,7 +613,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) } // extract title key - if (tik.getBody().getTitleKeyEncType() == es::ticket::AES128_CBC) + if (tik.getBody().getTitleKeyEncType() == nn::es::ticket::AES128_CBC) { memcpy(mKeyset.nca.manual_title_key_aesctr.key, tik.getBody().getEncTitleKey(), crypto::aes::kAes128KeySize); } @@ -962,7 +962,7 @@ bool UserSettings::determineValidNacpFromSample(const fnd::Vec& sample) bool UserSettings::determineValidEsCertFromSample(const fnd::Vec& sample) const { - pki::SignatureBlock sign; + nn::pki::SignatureBlock sign; try { @@ -976,7 +976,7 @@ bool UserSettings::determineValidEsCertFromSample(const fnd::Vec& sample if (sign.isLittleEndian() == true) return false; - if (sign.getSignType() != pki::sign::SIGN_ID_RSA4096_SHA256 && sign.getSignType() != pki::sign::SIGN_ID_RSA2048_SHA256 && sign.getSignType() != pki::sign::SIGN_ID_ECDSA240_SHA256) + if (sign.getSignType() != nn::pki::sign::SIGN_ID_RSA4096_SHA256 && sign.getSignType() != nn::pki::sign::SIGN_ID_RSA2048_SHA256 && sign.getSignType() != nn::pki::sign::SIGN_ID_ECDSA240_SHA256) return false; return true; @@ -984,7 +984,7 @@ bool UserSettings::determineValidEsCertFromSample(const fnd::Vec& sample bool UserSettings::determineValidEsTikFromSample(const fnd::Vec& sample) const { - pki::SignatureBlock sign; + nn::pki::SignatureBlock sign; try { @@ -998,7 +998,7 @@ bool UserSettings::determineValidEsTikFromSample(const fnd::Vec& sample) if (sign.isLittleEndian() == false) return false; - if (sign.getSignType() != pki::sign::SIGN_ID_RSA2048_SHA256) + if (sign.getSignType() != nn::pki::sign::SIGN_ID_RSA2048_SHA256) return false; return true; diff --git a/programs/nstool/source/UserSettings.h b/programs/nstool/source/UserSettings.h index 2643243..a3fd6ed 100644 --- a/programs/nstool/source/UserSettings.h +++ b/programs/nstool/source/UserSettings.h @@ -42,7 +42,7 @@ public: const sOptional& getNcaPart3Path() const; const sOptional& getAssetIconPath() const; const sOptional& getAssetNacpPath() const; - const fnd::List>& getCertificateChain() const; + const fnd::List>& getCertificateChain() const; private: const std::string kModuleName = "UserSettings"; @@ -100,7 +100,7 @@ private: sOptional mAssetIconPath; sOptional mAssetNacpPath; - fnd::List> mCertChain; + fnd::List> mCertChain; bool mListApi; bool mListSymbols; From 99420f28bf8cf4f491c2d3507f545266247446ec Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 16:35:03 +0800 Subject: [PATCH 11/16] Condense crypto and compress wrapper libraries into foundation. --- NNTools.sln | 22 --- lib/libcompress/libcompress.vcxproj | 133 ----------------- lib/libcompress/libcompress.vcxproj.filters | 30 ---- lib/libcompress/libcompress.vcxproj.user | 4 - lib/libcompress/makefile | 46 ------ lib/libcompress/source/lz4_wrapper.cpp | 14 -- lib/libcrypto/libcrypto.vcxproj | 139 ------------------ lib/libcrypto/libcrypto.vcxproj.filters | 51 ------- lib/libcrypto/libcrypto.vcxproj.user | 4 - lib/libcrypto/makefile | 45 ------ lib/libcrypto/source/base64_wrapper.cpp | 30 ---- lib/libcrypto/source/sha_wrapper.cpp | 15 -- lib/libes/include/nn/es/ticket.h | 4 +- lib/libes/libes.vcxproj | 8 +- .../crypto => libfnd/include/fnd}/aes.h | 2 +- .../crypto => libfnd/include/fnd}/base64.h | 2 +- .../crypto => libfnd/include/fnd}/ecdsa.h | 2 +- .../compress => libfnd/include/fnd}/lz4.h | 2 +- .../crypto => libfnd/include/fnd}/rsa.h | 4 +- .../crypto => libfnd/include/fnd}/sha.h | 2 +- lib/libfnd/makefile | 2 +- .../source/aes_wrapper.cpp | 24 +-- lib/libfnd/source/base64_wrapper.cpp | 30 ++++ lib/libfnd/source/lz4_wrapper.cpp | 14 ++ .../source/rsa_wrapper.cpp | 20 +-- lib/libfnd/source/sha_wrapper.cpp | 15 ++ lib/libhac-hb/libhac-hb.vcxproj | 8 +- .../nn/hac/AccessControlInfoDescBinary.h | 10 +- lib/libhac/include/nn/hac/AesKeygen.h | 2 +- lib/libhac/include/nn/hac/ContentMetaBinary.h | 2 +- .../nn/hac/HierarchicalIntegrityHeader.h | 8 +- .../include/nn/hac/HierarchicalSha256Header.h | 6 +- lib/libhac/include/nn/hac/NcaHeader.h | 8 +- lib/libhac/include/nn/hac/NcaUtils.h | 2 +- lib/libhac/include/nn/hac/NsoHeader.h | 2 +- lib/libhac/include/nn/hac/PfsHeader.h | 4 +- lib/libhac/include/nn/hac/XciHeader.h | 18 +-- lib/libhac/include/nn/hac/aci.h | 6 +- lib/libhac/include/nn/hac/cnmt.h | 4 +- .../include/nn/hac/hierarchicalsha256.h | 4 +- lib/libhac/include/nn/hac/kc.h | 2 +- lib/libhac/include/nn/hac/nca.h | 14 +- lib/libhac/include/nn/hac/nrr.h | 8 +- lib/libhac/include/nn/hac/nso.h | 8 +- lib/libhac/include/nn/hac/pfs.h | 4 +- lib/libhac/include/nn/hac/xci.h | 18 +-- lib/libhac/libhac.vcxproj | 8 +- .../source/AccessControlInfoDescBinary.cpp | 26 ++-- lib/libhac/source/AesKeygen.cpp | 6 +- .../source/HierarchicalIntegrityHeader.cpp | 8 +- .../source/HierarchicalSha256Header.cpp | 6 +- lib/libhac/source/NcaHeader.cpp | 4 +- lib/libhac/source/NcaUtils.cpp | 12 +- lib/libhac/source/PfsHeader.cpp | 2 +- lib/libhac/source/XciHeader.cpp | 14 +- lib/libhac/source/XciUtils.cpp | 4 +- lib/libpki/include/nn/pki/CertificateBody.h | 18 +-- lib/libpki/include/nn/pki/SignUtils.h | 2 +- lib/libpki/include/nn/pki/cert.h | 16 +- lib/libpki/include/nn/pki/sign.h | 10 +- lib/libpki/libpki.vcxproj | 8 +- lib/libpki/source/CertificateBody.cpp | 18 +-- lib/libpki/source/SignatureBlock.cpp | 12 +- makefile | 2 +- programs/nstool/makefile | 2 +- programs/nstool/nstool.vcxproj | 14 +- programs/nstool/source/AesCtrWrappedIFile.cpp | 14 +- programs/nstool/source/AesCtrWrappedIFile.h | 10 +- programs/nstool/source/EsTikProcess.cpp | 10 +- programs/nstool/source/HashTreeMeta.cpp | 4 +- programs/nstool/source/HashTreeMeta.h | 6 +- .../nstool/source/HashTreeWrappedIFile.cpp | 18 +-- programs/nstool/source/HashTreeWrappedIFile.h | 4 +- programs/nstool/source/NcaProcess.cpp | 32 ++-- programs/nstool/source/NcaProcess.h | 12 +- programs/nstool/source/NroProcess.cpp | 2 +- programs/nstool/source/NsoProcess.cpp | 16 +- programs/nstool/source/PfsProcess.cpp | 4 +- programs/nstool/source/PkiCertProcess.cpp | 12 +- programs/nstool/source/PkiValidator.cpp | 24 +-- programs/nstool/source/PkiValidator.h | 8 +- programs/nstool/source/UserSettings.cpp | 68 ++++----- programs/nstool/source/XciProcess.cpp | 10 +- programs/nstool/source/nstool.h | 36 ++--- 84 files changed, 402 insertions(+), 882 deletions(-) delete mode 100644 lib/libcompress/libcompress.vcxproj delete mode 100644 lib/libcompress/libcompress.vcxproj.filters delete mode 100644 lib/libcompress/libcompress.vcxproj.user delete mode 100644 lib/libcompress/makefile delete mode 100644 lib/libcompress/source/lz4_wrapper.cpp delete mode 100644 lib/libcrypto/libcrypto.vcxproj delete mode 100644 lib/libcrypto/libcrypto.vcxproj.filters delete mode 100644 lib/libcrypto/libcrypto.vcxproj.user delete mode 100644 lib/libcrypto/makefile delete mode 100644 lib/libcrypto/source/base64_wrapper.cpp delete mode 100644 lib/libcrypto/source/sha_wrapper.cpp rename lib/{libcrypto/include/crypto => libfnd/include/fnd}/aes.h (99%) rename lib/{libcrypto/include/crypto => libfnd/include/fnd}/base64.h (95%) rename lib/{libcrypto/include/crypto => libfnd/include/fnd}/ecdsa.h (98%) rename lib/{libcompress/include/compress => libfnd/include/fnd}/lz4.h (94%) rename lib/{libcrypto/include/crypto => libfnd/include/fnd}/rsa.h (99%) rename lib/{libcrypto/include/crypto => libfnd/include/fnd}/sha.h (99%) rename lib/{libcrypto => libfnd}/source/aes_wrapper.cpp (70%) create mode 100644 lib/libfnd/source/base64_wrapper.cpp create mode 100644 lib/libfnd/source/lz4_wrapper.cpp rename lib/{libcrypto => libfnd}/source/rsa_wrapper.cpp (77%) create mode 100644 lib/libfnd/source/sha_wrapper.cpp diff --git a/NNTools.sln b/NNTools.sln index d196221..b46668d 100644 --- a/NNTools.sln +++ b/NNTools.sln @@ -28,10 +28,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "lib\libpolar EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "lib\liblz4\liblz4.vcxproj", "{AB0C3362-63AB-480A-ADBC-2EF7D859778B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\libcrypto\libcrypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcompress", "lib\libcompress\libcompress.vcxproj", "{CF01B5B7-730A-447F-9BB2-5EDA9B082177}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpki", "lib\libpki\libpki.vcxproj", "{B9113734-6E84-44FF-8CF7-58199AA815C5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\libes.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}" @@ -74,14 +70,6 @@ Global {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.Build.0 = Release|x64 {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.ActiveCfg = Release|Win32 {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.Build.0 = Release|Win32 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.ActiveCfg = Debug|x64 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.Build.0 = Debug|x64 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x86.ActiveCfg = Debug|Win32 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x86.Build.0 = Debug|Win32 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x64.ActiveCfg = Release|x64 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x64.Build.0 = Release|x64 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x86.ActiveCfg = Release|Win32 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x86.Build.0 = Release|Win32 {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.ActiveCfg = Debug|x64 {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.Build.0 = Debug|x64 {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.ActiveCfg = Debug|Win32 @@ -98,14 +86,6 @@ Global {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64 {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32 {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.ActiveCfg = Debug|x64 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.Build.0 = Debug|x64 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x86.ActiveCfg = Debug|Win32 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x86.Build.0 = Debug|Win32 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x64.ActiveCfg = Release|x64 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x64.Build.0 = Release|x64 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x86.ActiveCfg = Release|Win32 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x86.Build.0 = Release|Win32 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.ActiveCfg = Debug|x64 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.Build.0 = Debug|x64 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.ActiveCfg = Debug|Win32 @@ -138,10 +118,8 @@ Global {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {CF01B5B7-730A-447F-9BB2-5EDA9B082177} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {B9113734-6E84-44FF-8CF7-58199AA815C5} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} diff --git a/lib/libcompress/libcompress.vcxproj b/lib/libcompress/libcompress.vcxproj deleted file mode 100644 index 56a6671..0000000 --- a/lib/libcompress/libcompress.vcxproj +++ /dev/null @@ -1,133 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {CF01B5B7-730A-447F-9BB2-5EDA9B082177} - libcompress - 10.0.16299.0 - - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - ..\libcompress\include;..\liblz4\include; - - - - - Level3 - Disabled - true - true - ..\libcompress\include;..\liblz4\include; - - - - - Level3 - MaxSpeed - true - true - true - true - ..\libcompress\include;..\liblz4\include; - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - ..\libcompress\include;..\liblz4\include; - - - true - true - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/libcompress/libcompress.vcxproj.filters b/lib/libcompress/libcompress.vcxproj.filters deleted file mode 100644 index ef951e4..0000000 --- a/lib/libcompress/libcompress.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - - - Source Files - - - - - - \ No newline at end of file diff --git a/lib/libcompress/libcompress.vcxproj.user b/lib/libcompress/libcompress.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/lib/libcompress/libcompress.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/lib/libcompress/makefile b/lib/libcompress/makefile deleted file mode 100644 index 3f009cb..0000000 --- a/lib/libcompress/makefile +++ /dev/null @@ -1,46 +0,0 @@ -# Sources -SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) - -# External dependencies -DEPENDS = lz4 -LIB_DIR = .. -INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - -# Compiler Settings -CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value -CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value -ARFLAGS = cr -o -ifeq ($(OS),Windows_NT) - # Windows Only Flags/Libs - CC = x86_64-w64-mingw32-gcc - CXX = x86_64-w64-mingw32-g++ - CFLAGS += -Wno-unused-but-set-variable - CXXFLAGS += -Wno-unused-but-set-variable -else - UNAME = $(shell uname -s) - ifeq ($(UNAME), Darwin) - # MacOS Only Flags/Libs - CFLAGS += -Wno-unused-private-field - CXXFLAGS += -Wno-unused-private-field - ARFLAGS = rc - else - # *nix Only Flags/Libs - CFLAGS += -Wno-unused-but-set-variable - CXXFLAGS += -Wno-unused-but-set-variable - endif - -endif - -# Output -OUTPUT = $(shell basename $(CURDIR)).a - -main: build - -rebuild: clean build - -build: $(OBJS) - ar $(ARFLAGS) $(OUTPUT) $(OBJS) - -clean: - rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libcompress/source/lz4_wrapper.cpp b/lib/libcompress/source/lz4_wrapper.cpp deleted file mode 100644 index 68b773c..0000000 --- a/lib/libcompress/source/lz4_wrapper.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -void compress::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size) -{ - compressed_size = LZ4_compress_default((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity); -} - -void compress::lz4::decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size) -{ - decompressed_size = LZ4_decompress_safe((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity); -} - - \ No newline at end of file diff --git a/lib/libcrypto/libcrypto.vcxproj b/lib/libcrypto/libcrypto.vcxproj deleted file mode 100644 index c401526..0000000 --- a/lib/libcrypto/libcrypto.vcxproj +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} - 10.0.15063.0 - - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; - _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - - - Level3 - Disabled - true - ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; - _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - - - Level3 - MaxSpeed - true - true - true - ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; - _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include; - _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/libcrypto/libcrypto.vcxproj.filters b/lib/libcrypto/libcrypto.vcxproj.filters deleted file mode 100644 index 3c65bd5..0000000 --- a/lib/libcrypto/libcrypto.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - \ No newline at end of file diff --git a/lib/libcrypto/libcrypto.vcxproj.user b/lib/libcrypto/libcrypto.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/lib/libcrypto/libcrypto.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/lib/libcrypto/makefile b/lib/libcrypto/makefile deleted file mode 100644 index f41f545..0000000 --- a/lib/libcrypto/makefile +++ /dev/null @@ -1,45 +0,0 @@ -# Sources -SRC_DIR = source -OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) - -# External dependencies -DEPENDS = fnd polarssl -LIB_DIR = .. -INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") - -# Compiler Settings -CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value -CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value -ARFLAGS = cr -o -ifeq ($(OS),Windows_NT) - # Windows Only Flags/Libs - CC = x86_64-w64-mingw32-gcc - CXX = x86_64-w64-mingw32-g++ - CFLAGS += -Wno-unused-but-set-variable - CXXFLAGS += -Wno-unused-but-set-variable -else - UNAME = $(shell uname -s) - ifeq ($(UNAME), Darwin) - # MacOS Only Flags/Libs - CFLAGS += -arch x86_64 -Wno-unused-private-field - CXXFLAGS += -arch x86_64 -Wno-unused-private-field - ARFLAGS = rc - else - # *nix Only Flags/Libs - CFLAGS += -Wno-unused-but-set-variable - CXXFLAGS += -Wno-unused-but-set-variable - endif -endif - -# Output -OUTPUT = $(shell basename $(CURDIR)).a - -main: build - -rebuild: clean build - -build: $(OBJS) - ar $(ARFLAGS) $(OUTPUT) $(OBJS) - -clean: - rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/libcrypto/source/base64_wrapper.cpp b/lib/libcrypto/source/base64_wrapper.cpp deleted file mode 100644 index 1bc6f66..0000000 --- a/lib/libcrypto/source/base64_wrapper.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -size_t crypto::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen) -{ - size_t dlen = 0; - - base64_encode(nullptr, &dlen, src, slen); - - return dlen; -} - -void crypto::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) -{ - base64_encode(dst, &dlen, src, slen); -} - -size_t crypto::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen) -{ - size_t dlen = 0; - - base64_decode(nullptr, &dlen, src, slen); - - return dlen; -} - -void crypto::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) -{ - base64_decode(dst, &dlen, src, slen); -} \ No newline at end of file diff --git a/lib/libcrypto/source/sha_wrapper.cpp b/lib/libcrypto/source/sha_wrapper.cpp deleted file mode 100644 index c625c95..0000000 --- a/lib/libcrypto/source/sha_wrapper.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -using namespace crypto::sha; - -void crypto::sha::Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen]) -{ - sha1(in, size, hash); -} - -void crypto::sha::Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen]) -{ - sha2(in, size, hash, false); -} \ No newline at end of file diff --git a/lib/libes/include/nn/es/ticket.h b/lib/libes/include/nn/es/ticket.h index ffb483b..d2e953d 100644 --- a/lib/libes/include/nn/es/ticket.h +++ b/lib/libes/include/nn/es/ticket.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include namespace nn { @@ -44,7 +44,7 @@ namespace es static const size_t kIssuerSize = 0x40; static const byte_t kFormatVersion = 2; - static const size_t kEncTitleKeySize = crypto::rsa::kRsa2048Size; + static const size_t kEncTitleKeySize = fnd::rsa::kRsa2048Size; static const size_t kReservedRegionSize = 8; static const size_t kRightsIdSize = 16; } diff --git a/lib/libes/libes.vcxproj b/lib/libes/libes.vcxproj index 2c3482d..9c25a22 100644 --- a/lib/libes/libes.vcxproj +++ b/lib/libes/libes.vcxproj @@ -73,7 +73,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libes\include; + ..\libfnd\include;..\libes\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -82,7 +82,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libes\include; + ..\libfnd\include;..\libes\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -93,7 +93,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libes\include; + ..\libfnd\include;..\libes\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -108,7 +108,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libes\include; + ..\libfnd\include;..\libes\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/lib/libcrypto/include/crypto/aes.h b/lib/libfnd/include/fnd/aes.h similarity index 99% rename from lib/libcrypto/include/crypto/aes.h rename to lib/libfnd/include/fnd/aes.h index eb78ade..2c3016f 100644 --- a/lib/libcrypto/include/crypto/aes.h +++ b/lib/libfnd/include/fnd/aes.h @@ -2,7 +2,7 @@ #include #include -namespace crypto +namespace fnd { namespace aes { diff --git a/lib/libcrypto/include/crypto/base64.h b/lib/libfnd/include/fnd/base64.h similarity index 95% rename from lib/libcrypto/include/crypto/base64.h rename to lib/libfnd/include/fnd/base64.h index 67c6ecd..f9bbc08 100644 --- a/lib/libcrypto/include/crypto/base64.h +++ b/lib/libfnd/include/fnd/base64.h @@ -2,7 +2,7 @@ #include #include -namespace crypto +namespace fnd { namespace base64 { diff --git a/lib/libcrypto/include/crypto/ecdsa.h b/lib/libfnd/include/fnd/ecdsa.h similarity index 98% rename from lib/libcrypto/include/crypto/ecdsa.h rename to lib/libfnd/include/fnd/ecdsa.h index 70f2803..e06880e 100644 --- a/lib/libcrypto/include/crypto/ecdsa.h +++ b/lib/libfnd/include/fnd/ecdsa.h @@ -2,7 +2,7 @@ #include #include -namespace crypto +namespace fnd { namespace ecdsa { diff --git a/lib/libcompress/include/compress/lz4.h b/lib/libfnd/include/fnd/lz4.h similarity index 94% rename from lib/libcompress/include/compress/lz4.h rename to lib/libfnd/include/fnd/lz4.h index 482ee64..2d76857 100644 --- a/lib/libcompress/include/compress/lz4.h +++ b/lib/libfnd/include/fnd/lz4.h @@ -1,7 +1,7 @@ #pragma once #include -namespace compress +namespace fnd { namespace lz4 { diff --git a/lib/libcrypto/include/crypto/rsa.h b/lib/libfnd/include/fnd/rsa.h similarity index 99% rename from lib/libcrypto/include/crypto/rsa.h rename to lib/libfnd/include/fnd/rsa.h index 6588e8c..455fd21 100644 --- a/lib/libcrypto/include/crypto/rsa.h +++ b/lib/libfnd/include/fnd/rsa.h @@ -1,9 +1,9 @@ #pragma once #include #include -#include +#include -namespace crypto +namespace fnd { namespace rsa { diff --git a/lib/libcrypto/include/crypto/sha.h b/lib/libfnd/include/fnd/sha.h similarity index 99% rename from lib/libcrypto/include/crypto/sha.h rename to lib/libfnd/include/fnd/sha.h index fdd11ea..55d042d 100644 --- a/lib/libcrypto/include/crypto/sha.h +++ b/lib/libfnd/include/fnd/sha.h @@ -2,7 +2,7 @@ #include #include -namespace crypto +namespace fnd { namespace sha { diff --git a/lib/libfnd/makefile b/lib/libfnd/makefile index d453126..73af097 100644 --- a/lib/libfnd/makefile +++ b/lib/libfnd/makefile @@ -3,7 +3,7 @@ SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = +DEPENDS = polarssl lz4 LIB_DIR = .. INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") diff --git a/lib/libcrypto/source/aes_wrapper.cpp b/lib/libfnd/source/aes_wrapper.cpp similarity index 70% rename from lib/libcrypto/source/aes_wrapper.cpp rename to lib/libfnd/source/aes_wrapper.cpp index 43f37d7..0013dce 100644 --- a/lib/libcrypto/source/aes_wrapper.cpp +++ b/lib/libfnd/source/aes_wrapper.cpp @@ -1,7 +1,7 @@ -#include +#include #include -using namespace crypto::aes; +using namespace fnd::aes; inline void XorBlock(const uint8_t a[kAesBlockSize], const uint8_t b[kAesBlockSize], uint8_t out[kAesBlockSize]) { @@ -16,7 +16,7 @@ inline void putbe32(uint8_t* data, uint32_t val) { data[0] = val >> 24; data[1] -void crypto::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out) +void fnd::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out) { aes_context ctx; aes_setkey_dec(&ctx, key, 128); @@ -28,7 +28,7 @@ void crypto::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t } -void crypto::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out) +void fnd::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out) { aes_context ctx; aes_setkey_enc(&ctx, key, 128); @@ -38,7 +38,7 @@ void crypto::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t } } -void crypto::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out) +void fnd::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out) { aes_context ctx; uint8_t block[kAesBlockSize] = { 0 }; @@ -48,7 +48,7 @@ void crypto::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAe aes_crypt_ctr(&ctx, size, &counterOffset, ctr, block, in, out); } -void crypto::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize]) +void fnd::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize]) { memcpy(out, in, kAesBlockSize); @@ -78,21 +78,21 @@ void crypto::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t bl putbe32(&out[12], ctr[0]); } -void crypto::aes::AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out) +void fnd::aes::AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out) { aes_context ctx; aes_setkey_dec(&ctx, key, 128); aes_crypt_cbc(&ctx, AES_DECRYPT, size, iv, in, out); } -void crypto::aes::AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out) +void fnd::aes::AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out) { aes_context ctx; aes_setkey_enc(&ctx, key, 128); aes_crypt_cbc(&ctx, AES_ENCRYPT, size, iv, in, out); } -void crypto::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out) +void fnd::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out) { aes_context data_ctx; aes_setkey_dec(&data_ctx, key1, 128); @@ -116,7 +116,7 @@ void crypto::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, } } -void crypto::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out) +void fnd::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out) { aes_context data_ctx; aes_setkey_enc(&data_ctx, key1, 128); @@ -140,13 +140,13 @@ void crypto::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, } } -void crypto::aes::AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index) +void fnd::aes::AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index) { memset(tweak, 0, kAesBlockSize); AesIncrementCounter(tweak, block_index, tweak); } -void crypto::aes::GaloisFunc(uint8_t x[kAesBlockSize]) +void fnd::aes::GaloisFunc(uint8_t x[kAesBlockSize]) { uint8_t t = x[15]; diff --git a/lib/libfnd/source/base64_wrapper.cpp b/lib/libfnd/source/base64_wrapper.cpp new file mode 100644 index 0000000..cd3e48b --- /dev/null +++ b/lib/libfnd/source/base64_wrapper.cpp @@ -0,0 +1,30 @@ +#include +#include + +size_t fnd::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen) +{ + size_t dlen = 0; + + base64_encode(nullptr, &dlen, src, slen); + + return dlen; +} + +void fnd::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) +{ + base64_encode(dst, &dlen, src, slen); +} + +size_t fnd::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen) +{ + size_t dlen = 0; + + base64_decode(nullptr, &dlen, src, slen); + + return dlen; +} + +void fnd::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) +{ + base64_decode(dst, &dlen, src, slen); +} \ No newline at end of file diff --git a/lib/libfnd/source/lz4_wrapper.cpp b/lib/libfnd/source/lz4_wrapper.cpp new file mode 100644 index 0000000..7dee71e --- /dev/null +++ b/lib/libfnd/source/lz4_wrapper.cpp @@ -0,0 +1,14 @@ +#include +#include + +void fnd::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size) +{ + compressed_size = LZ4_compress_default((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity); +} + +void fnd::lz4::decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size) +{ + decompressed_size = LZ4_decompress_safe((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity); +} + + \ No newline at end of file diff --git a/lib/libcrypto/source/rsa_wrapper.cpp b/lib/libfnd/source/rsa_wrapper.cpp similarity index 77% rename from lib/libcrypto/source/rsa_wrapper.cpp rename to lib/libfnd/source/rsa_wrapper.cpp index dc2fefc..197a813 100644 --- a/lib/libcrypto/source/rsa_wrapper.cpp +++ b/lib/libfnd/source/rsa_wrapper.cpp @@ -1,9 +1,9 @@ -#include +#include #include #include -using namespace crypto::rsa; -using namespace crypto::sha; +using namespace fnd::rsa; +using namespace fnd::sha; int getWrappedHashType(HashType type) { @@ -57,7 +57,7 @@ uint32_t getWrappedHashSize(HashType type) return size; } -int crypto::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa1024Size]) +int fnd::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa1024Size]) { int ret; rsa_context ctx; @@ -74,7 +74,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, cons return ret; } -int crypto::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa1024Size]) +int fnd::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa1024Size]) { static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 }; @@ -93,7 +93,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, co return ret; } -int crypto::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size]) +int fnd::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size]) { int ret; rsa_context ctx; @@ -110,7 +110,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, cons return ret; } -int crypto::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size]) +int fnd::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size]) { static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 }; @@ -129,7 +129,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, co return ret; } -int crypto::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa4096Size]) +int fnd::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa4096Size]) { int ret; rsa_context ctx; @@ -146,7 +146,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, cons return ret; } -int crypto::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa4096Size]) +int fnd::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa4096Size]) { static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 }; @@ -165,7 +165,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, co return ret; } -int crypto::rsa::pss::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size]) +int fnd::rsa::pss::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size]) { static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 }; diff --git a/lib/libfnd/source/sha_wrapper.cpp b/lib/libfnd/source/sha_wrapper.cpp new file mode 100644 index 0000000..a1c7eb4 --- /dev/null +++ b/lib/libfnd/source/sha_wrapper.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using namespace fnd::sha; + +void fnd::sha::Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen]) +{ + sha1(in, size, hash); +} + +void fnd::sha::Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen]) +{ + sha2(in, size, hash, false); +} \ No newline at end of file diff --git a/lib/libhac-hb/libhac-hb.vcxproj b/lib/libhac-hb/libhac-hb.vcxproj index 06ec389..bcee07e 100644 --- a/lib/libhac-hb/libhac-hb.vcxproj +++ b/lib/libhac-hb/libhac-hb.vcxproj @@ -77,7 +77,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; + ..\libfnd\include;..\libhac\include;..\libhac-hb\include; true @@ -90,7 +90,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; + ..\libfnd\include;..\libhac\include;..\libhac-hb\include; @@ -99,7 +99,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; + ..\libfnd\include;..\libhac\include;..\libhac-hb\include; @@ -110,7 +110,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include; + ..\libfnd\include;..\libhac\include;..\libhac-hb\include; true diff --git a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h index f42b195..df7b004 100644 --- a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h +++ b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h @@ -50,14 +50,14 @@ namespace hac void fromBytes(const byte_t* data, size_t len); const fnd::Vec& getBytes() const; - void generateSignature(const crypto::rsa::sRsa2048Key& key); - void validateSignature(const crypto::rsa::sRsa2048Key& key) const; + void generateSignature(const fnd::rsa::sRsa2048Key& key); + void validateSignature(const fnd::rsa::sRsa2048Key& key) const; // variables void clear(); - const crypto::rsa::sRsa2048Key& getNcaHeaderSignature2Key() const; - void setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key); + const fnd::rsa::sRsa2048Key& getNcaHeaderSignature2Key() const; + void setNcaHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key); const fnd::List& getFlagList() const; void setFlagList(const fnd::List& flags); @@ -80,7 +80,7 @@ namespace hac fnd::Vec mRawBinary; // variables - crypto::rsa::sRsa2048Key mNcaHeaderSignature2Key; + fnd::rsa::sRsa2048Key mNcaHeaderSignature2Key; fnd::List mFlags; sProgramIdRestrict mProgramIdRestrict; nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl; diff --git a/lib/libhac/include/nn/hac/AesKeygen.h b/lib/libhac/include/nn/hac/AesKeygen.h index 8d30eba..e3caef6 100644 --- a/lib/libhac/include/nn/hac/AesKeygen.h +++ b/lib/libhac/include/nn/hac/AesKeygen.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include namespace nn { diff --git a/lib/libhac/include/nn/hac/ContentMetaBinary.h b/lib/libhac/include/nn/hac/ContentMetaBinary.h index 2b44913..e742a6f 100644 --- a/lib/libhac/include/nn/hac/ContentMetaBinary.h +++ b/lib/libhac/include/nn/hac/ContentMetaBinary.h @@ -14,7 +14,7 @@ namespace hac public: struct ContentInfo { - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; byte_t nca_id[cnmt::kContentIdLen]; size_t size; cnmt::ContentType type; diff --git a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h index e8c9a3a..953b225 100644 --- a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h +++ b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include namespace nn { @@ -54,8 +54,8 @@ namespace hac const fnd::List& getLayerInfo() const; void setLayerInfo(const fnd::List& layer_info); - const fnd::List& getMasterHashList() const; - void setMasterHashList(const fnd::List& master_hash_list); + const fnd::List& getMasterHashList() const; + void setMasterHashList(const fnd::List& master_hash_list); private: const std::string kModuleName = "HIERARCHICAL_INTEGRITY_HEADER"; @@ -64,7 +64,7 @@ namespace hac // data fnd::List mLayerInfo; - fnd::List mMasterHashList; + fnd::List mMasterHashList; }; } } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h index eea54be..fe38b87 100644 --- a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h +++ b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h @@ -48,8 +48,8 @@ namespace hac // variables void clear(); - const crypto::sha::sSha256Hash& getMasterHash() const; - void setMasterHash(const crypto::sha::sSha256Hash& master_hash); + const fnd::sha::sSha256Hash& getMasterHash() const; + void setMasterHash(const fnd::sha::sSha256Hash& master_hash); size_t getHashBlockSize() const; void setHashBlockSize(size_t hash_block_size); @@ -63,7 +63,7 @@ namespace hac fnd::Vec mRawBinary; // data - crypto::sha::sSha256Hash mMasterHash; + fnd::sha::sSha256Hash mMasterHash; size_t mHashBlockSize; fnd::List mLayerInfo; }; diff --git a/lib/libhac/include/nn/hac/NcaHeader.h b/lib/libhac/include/nn/hac/NcaHeader.h index f08ed53..5793ed2 100644 --- a/lib/libhac/include/nn/hac/NcaHeader.h +++ b/lib/libhac/include/nn/hac/NcaHeader.h @@ -22,7 +22,7 @@ namespace hac byte_t index; uint64_t offset; uint64_t size; - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; const sPartition& operator=(const sPartition& other) { @@ -88,8 +88,8 @@ namespace hac void setRightsId(const byte_t* rights_id); const fnd::List& getPartitions() const; void setPartitions(const fnd::List& partitions); - const fnd::List& getEncAesKeys() const; - void setEncAesKeys(const fnd::List& keys); + const fnd::List& getEncAesKeys() const; + void setEncAesKeys(const fnd::List& keys); private: const std::string kModuleName = "NCA_HEADER"; @@ -109,7 +109,7 @@ namespace hac uint32_t mSdkAddonVersion; byte_t mRightsId[nca::kRightsIdLen]; fnd::List mPartitions; - fnd::List mEncAesKeys; + fnd::List mEncAesKeys; uint64_t blockNumToSize(uint32_t block_num) const; uint32_t sizeToBlockNum(uint64_t real_size) const; diff --git a/lib/libhac/include/nn/hac/NcaUtils.h b/lib/libhac/include/nn/hac/NcaUtils.h index b3b14a6..0b4da75 100644 --- a/lib/libhac/include/nn/hac/NcaUtils.h +++ b/lib/libhac/include/nn/hac/NcaUtils.h @@ -9,7 +9,7 @@ namespace hac { public: static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; } - static void decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key); + static void decryptNcaHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key); static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation); static void getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr); }; diff --git a/lib/libhac/include/nn/hac/NsoHeader.h b/lib/libhac/include/nn/hac/NsoHeader.h index 1593c7e..dbf08b6 100644 --- a/lib/libhac/include/nn/hac/NsoHeader.h +++ b/lib/libhac/include/nn/hac/NsoHeader.h @@ -60,7 +60,7 @@ namespace hac sLayout memory_layout; bool is_compressed; bool is_hashed; - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; void operator=(const sCodeSegment& other) { diff --git a/lib/libhac/include/nn/hac/PfsHeader.h b/lib/libhac/include/nn/hac/PfsHeader.h index 4eab512..f3556f3 100644 --- a/lib/libhac/include/nn/hac/PfsHeader.h +++ b/lib/libhac/include/nn/hac/PfsHeader.h @@ -25,7 +25,7 @@ namespace hac size_t offset; size_t size; size_t hash_protected_size; - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; sFile& operator=(const sFile& other) { @@ -84,7 +84,7 @@ namespace hac void setFsType(FsType type); const fnd::List& getFileList() const; void addFile(const std::string& name, size_t size); - void addFile(const std::string& name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash); + void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash); private: const std::string kModuleName = "PFS_HEADER"; diff --git a/lib/libhac/include/nn/hac/XciHeader.h b/lib/libhac/include/nn/hac/XciHeader.h index 89ff730..8ed9d4c 100644 --- a/lib/libhac/include/nn/hac/XciHeader.h +++ b/lib/libhac/include/nn/hac/XciHeader.h @@ -43,16 +43,16 @@ namespace hac void setPackageId(uint64_t id); uint32_t getValidDataEndPage() const; void setValidDataEndPage(uint32_t page); - const crypto::aes::sAesIvCtr& getAesCbcIv() const; - void setAesCbcIv(const crypto::aes::sAesIvCtr& iv); + const fnd::aes::sAesIvCtr& getAesCbcIv() const; + void setAesCbcIv(const fnd::aes::sAesIvCtr& iv); uint64_t getPartitionFsAddress() const; void setPartitionFsAddress(uint64_t address); uint64_t getPartitionFsSize() const; void setPartitionFsSize(uint64_t size); - const crypto::sha::sSha256Hash& getPartitionFsHash() const; - void setPartitionFsHash(const crypto::sha::sSha256Hash& hash); - const crypto::sha::sSha256Hash& getInitialDataHash() const; - void setInitialDataHash(const crypto::sha::sSha256Hash& hash); + const fnd::sha::sSha256Hash& getPartitionFsHash() const; + void setPartitionFsHash(const fnd::sha::sSha256Hash& hash); + const fnd::sha::sSha256Hash& getInitialDataHash() const; + void setInitialDataHash(const fnd::sha::sSha256Hash& hash); uint32_t getSelSec() const; void setSelSec(uint32_t sel_sec); uint32_t getSelT1Key() const; @@ -101,11 +101,11 @@ namespace hac byte_t mFlags; uint64_t mPackageId; uint32_t mValidDataEndPage; - crypto::aes::sAesIvCtr mAesCbcIv; + fnd::aes::sAesIvCtr mAesCbcIv; uint64_t mPartitionFsHeaderAddress; uint64_t mPartitionFsHeaderSize; - crypto::sha::sSha256Hash mPartitionFsHeaderHash; - crypto::sha::sSha256Hash mInitialDataHash; + fnd::sha::sSha256Hash mPartitionFsHeaderHash; + fnd::sha::sSha256Hash mInitialDataHash; uint32_t mSelSec; uint32_t mSelT1Key; uint32_t mSelKey; diff --git a/lib/libhac/include/nn/hac/aci.h b/lib/libhac/include/nn/hac/aci.h index e426469..55742e1 100644 --- a/lib/libhac/include/nn/hac/aci.h +++ b/lib/libhac/include/nn/hac/aci.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace nn @@ -39,8 +39,8 @@ namespace hac struct sAciDescHeader { - byte_t signature[crypto::rsa::kRsa2048Size]; - byte_t nca_rsa_signature2_modulus[crypto::rsa::kRsa2048Size]; + byte_t signature[fnd::rsa::kRsa2048Size]; + byte_t nca_rsa_signature2_modulus[fnd::rsa::kRsa2048Size]; le_uint32_t st_magic; le_uint32_t signed_size; byte_t reserved_00[0x4]; diff --git a/lib/libhac/include/nn/hac/cnmt.h b/lib/libhac/include/nn/hac/cnmt.h index ededd0b..f7c8eb3 100644 --- a/lib/libhac/include/nn/hac/cnmt.h +++ b/lib/libhac/include/nn/hac/cnmt.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace nn { @@ -83,7 +83,7 @@ namespace hac struct sContentInfo { - crypto::sha::sSha256Hash content_hash; + fnd::sha::sSha256Hash content_hash; byte_t content_id[cnmt::kContentIdLen]; le_uint32_t size_lower; le_uint16_t size_higher; diff --git a/lib/libhac/include/nn/hac/hierarchicalsha256.h b/lib/libhac/include/nn/hac/hierarchicalsha256.h index e392c8c..fd424bb 100644 --- a/lib/libhac/include/nn/hac/hierarchicalsha256.h +++ b/lib/libhac/include/nn/hac/hierarchicalsha256.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace nn { @@ -15,7 +15,7 @@ namespace hac #pragma pack(push,1) struct sHierarchicalSha256Header { - crypto::sha::sSha256Hash master_hash; + fnd::sha::sSha256Hash master_hash; le_uint32_t hash_block_size; le_uint32_t layer_num; struct sLayer diff --git a/lib/libhac/include/nn/hac/kc.h b/lib/libhac/include/nn/hac/kc.h index e4f5949..e15d487 100644 --- a/lib/libhac/include/nn/hac/kc.h +++ b/lib/libhac/include/nn/hac/kc.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace nn diff --git a/lib/libhac/include/nn/hac/nca.h b/lib/libhac/include/nn/hac/nca.h index 3a3207c..4dac6f0 100644 --- a/lib/libhac/include/nn/hac/nca.h +++ b/lib/libhac/include/nn/hac/nca.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include -#include +#include +#include +#include #include namespace nn @@ -108,8 +108,8 @@ namespace hac byte_t enabled; byte_t reserved[7]; } partition[nca::kPartitionNum]; - crypto::sha::sSha256Hash partition_hash[nca::kPartitionNum]; - crypto::aes::sAes128Key enc_aes_key[nca::kAesKeyNum]; + fnd::sha::sSha256Hash partition_hash[nca::kPartitionNum]; + fnd::aes::sAes128Key enc_aes_key[nca::kAesKeyNum]; }; struct sNcaFsHeader @@ -126,8 +126,8 @@ namespace hac struct sNcaHeaderBlock { - byte_t signature_main[crypto::rsa::kRsa2048Size]; - byte_t signature_acid[crypto::rsa::kRsa2048Size]; + byte_t signature_main[fnd::rsa::kRsa2048Size]; + byte_t signature_acid[fnd::rsa::kRsa2048Size]; sNcaHeader header; sNcaFsHeader fs_header[nn::hac::nca::kPartitionNum]; }; diff --git a/lib/libhac/include/nn/hac/nrr.h b/lib/libhac/include/nn/hac/nrr.h index eae5180..452cc71 100644 --- a/lib/libhac/include/nn/hac/nrr.h +++ b/lib/libhac/include/nn/hac/nrr.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace nn @@ -17,8 +17,8 @@ namespace hac { le_uint64_t application_id_mask; le_uint64_t application_id_pattern; - byte_t nrr_body_modulus[crypto::rsa::kRsa2048Size]; - byte_t nrr_cert_signature[crypto::rsa::kRsa2048Size]; + byte_t nrr_body_modulus[fnd::rsa::kRsa2048Size]; + byte_t nrr_cert_signature[fnd::rsa::kRsa2048Size]; }; struct sNrrHeader @@ -26,7 +26,7 @@ namespace hac le_uint32_t st_magic; byte_t reserved_0[28]; sNrrCertificate certificate; - byte_t nrr_body_signature[crypto::rsa::kRsa2048Size]; + byte_t nrr_body_signature[fnd::rsa::kRsa2048Size]; le_uint64_t application_id; le_uint32_t size; byte_t reserved_1[4]; diff --git a/lib/libhac/include/nn/hac/nso.h b/lib/libhac/include/nn/hac/nso.h index 4223b37..1b4a10b 100644 --- a/lib/libhac/include/nn/hac/nso.h +++ b/lib/libhac/include/nn/hac/nso.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace nn @@ -58,9 +58,9 @@ namespace hac sNsoSection embedded; sNsoSection dyn_str; sNsoSection dyn_sym; - crypto::sha::sSha256Hash text_hash; - crypto::sha::sSha256Hash ro_hash; - crypto::sha::sSha256Hash data_hash; + fnd::sha::sSha256Hash text_hash; + fnd::sha::sSha256Hash ro_hash; + fnd::sha::sSha256Hash data_hash; }; #pragma pack(pop) diff --git a/lib/libhac/include/nn/hac/pfs.h b/lib/libhac/include/nn/hac/pfs.h index 18f4e5c..4b7d189 100644 --- a/lib/libhac/include/nn/hac/pfs.h +++ b/lib/libhac/include/nn/hac/pfs.h @@ -1,5 +1,5 @@ #include -#include +#include #include namespace nn @@ -37,7 +37,7 @@ namespace hac le_uint32_t name_offset; le_uint32_t hash_protected_size; byte_t padding[8]; - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; }; // sizeof(0x40) #pragma pack(pop) } diff --git a/lib/libhac/include/nn/hac/xci.h b/lib/libhac/include/nn/hac/xci.h index 79be4d9..a995fa4 100644 --- a/lib/libhac/include/nn/hac/xci.h +++ b/lib/libhac/include/nn/hac/xci.h @@ -1,9 +1,9 @@ #pragma once #include #include -#include -#include -#include +#include +#include +#include #include namespace nn @@ -80,11 +80,11 @@ namespace hac le_uint64_t package_id; le_uint32_t valid_data_end_page; byte_t reserved_00[4]; - crypto::aes::sAesIvCtr aescbc_iv; + fnd::aes::sAesIvCtr aescbc_iv; le_uint64_t partition_fs_header_address; le_uint64_t partition_fs_header_size; - crypto::sha::sSha256Hash partition_fs_header_hash; - crypto::sha::sSha256Hash initial_data_hash; + fnd::sha::sSha256Hash partition_fs_header_hash; + fnd::sha::sSha256Hash initial_data_hash; le_uint32_t sel_sec; le_uint32_t sel_t1_key; le_uint32_t sel_key; @@ -107,7 +107,7 @@ namespace hac struct sXciHeaderPage { - byte_t signature[crypto::rsa::kRsa2048Size]; + byte_t signature[fnd::rsa::kRsa2048Size]; sXciHeader header; }; // sizeof() = 512 (1 page) @@ -124,8 +124,8 @@ namespace hac { sInitialData initial_data; // AES128-CCM encrypted {titlekey[16]} byte_t encrypted_00[xci::kPageSize * 6]; // AES128-CTR encrypted {titlekey[16]} - byte_t encrypted_00_aesctr_data[crypto::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]} - byte_t reserved[xci::kPageSize - crypto::rsa::kRsa2048Size]; + byte_t encrypted_00_aesctr_data[fnd::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]} + byte_t reserved[xci::kPageSize - fnd::rsa::kRsa2048Size]; }; // sizeof() = 512*8 (8 pages) #pragma pack(pop) diff --git a/lib/libhac/libhac.vcxproj b/lib/libhac/libhac.vcxproj index 3ea2410..3ff63ae 100644 --- a/lib/libhac/libhac.vcxproj +++ b/lib/libhac/libhac.vcxproj @@ -175,7 +175,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libhac\include; + ..\libfnd\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -184,7 +184,7 @@ Level3 Disabled true - ..\libfnd\include;..\libcrypto\include;..\libhac\include; + ..\libfnd\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -195,7 +195,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include; + ..\libfnd\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -210,7 +210,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libhac\include; + ..\libfnd\include;..\libhac\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/lib/libhac/source/AccessControlInfoDescBinary.cpp b/lib/libhac/source/AccessControlInfoDescBinary.cpp index d7c24d4..50ac86e 100644 --- a/lib/libhac/source/AccessControlInfoDescBinary.cpp +++ b/lib/libhac/source/AccessControlInfoDescBinary.cpp @@ -66,13 +66,13 @@ void nn::hac::AccessControlInfoDescBinary::toBytes() sAciDescHeader* hdr = (sAciDescHeader*)mRawBinary.data(); // set rsa modulus - memcpy(hdr->nca_rsa_signature2_modulus, mNcaHeaderSignature2Key.modulus, crypto::rsa::kRsa2048Size); + memcpy(hdr->nca_rsa_signature2_modulus, mNcaHeaderSignature2Key.modulus, fnd::rsa::kRsa2048Size); // set type hdr->st_magic = aci::kAciDescStructMagic; // set "acid size" - hdr->signed_size = (uint32_t)(total_size - crypto::rsa::kRsa2048Size); + hdr->signed_size = (uint32_t)(total_size - fnd::rsa::kRsa2048Size); // set flags uint32_t flags = 0; @@ -128,7 +128,7 @@ void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t memcpy(mRawBinary.data(), data, mRawBinary.size()); // save variables - memcpy(mNcaHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, crypto::rsa::kRsa2048Size); + memcpy(mNcaHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, fnd::rsa::kRsa2048Size); for (size_t i = 0; i < 32; i++) { @@ -149,29 +149,29 @@ const fnd::Vec& nn::hac::AccessControlInfoDescBinary::getBytes() const return mRawBinary; } -void nn::hac::AccessControlInfoDescBinary::generateSignature(const crypto::rsa::sRsa2048Key& key) +void nn::hac::AccessControlInfoDescBinary::generateSignature(const fnd::rsa::sRsa2048Key& key) { if (mRawBinary.size() == 0) toBytes(); - byte_t hash[crypto::sha::kSha256HashLen]; - crypto::sha::Sha256(mRawBinary.data() + crypto::rsa::kRsa2048Size, mRawBinary.size() - crypto::rsa::kRsa2048Size, hash); + byte_t hash[fnd::sha::kSha256HashLen]; + fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash); - if (crypto::rsa::pkcs::rsaSign(key, crypto::sha::HASH_SHA256, hash, mRawBinary.data()) != 0) + if (fnd::rsa::pkcs::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0) { throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc"); } } -void nn::hac::AccessControlInfoDescBinary::validateSignature(const crypto::rsa::sRsa2048Key& key) const +void nn::hac::AccessControlInfoDescBinary::validateSignature(const fnd::rsa::sRsa2048Key& key) const { if (mRawBinary.size() == 0) throw fnd::Exception(kModuleName, "No Access Control Info Desc binary exists to verify"); - byte_t hash[crypto::sha::kSha256HashLen]; - crypto::sha::Sha256(mRawBinary.data() + crypto::rsa::kRsa2048Size, mRawBinary.size() - crypto::rsa::kRsa2048Size, hash); + byte_t hash[fnd::sha::kSha256HashLen]; + fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash); - if (crypto::rsa::pss::rsaVerify(key, crypto::sha::HASH_SHA256, hash, mRawBinary.data()) != 0) + if (fnd::rsa::pss::rsaVerify(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0) { throw fnd::Exception(kModuleName, "Failed to verify Access Control Info Desc"); } @@ -189,12 +189,12 @@ void nn::hac::AccessControlInfoDescBinary::clear() mKernelCapabilities.clear(); } -const crypto::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const +const fnd::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const { return mNcaHeaderSignature2Key; } -void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key) +void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key) { mNcaHeaderSignature2Key = key; } diff --git a/lib/libhac/source/AesKeygen.cpp b/lib/libhac/source/AesKeygen.cpp index 7233394..12d7878 100644 --- a/lib/libhac/source/AesKeygen.cpp +++ b/lib/libhac/source/AesKeygen.cpp @@ -2,18 +2,18 @@ void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key) { - crypto::aes::AesEcbDecrypt(src, sizeof(crypto::aes::sAes128Key), src_key, dst); + fnd::aes::AesEcbDecrypt(src, sizeof(fnd::aes::sAes128Key), src_key, dst); } void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key) { - crypto::aes::sAes128Key src2_key; + fnd::aes::sAes128Key src2_key; generateKey(src2_key.key, src1, src1_key); generateKey(dst, src2, src2_key.key); } void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key) { - crypto::aes::sAes128Key src3_key; + fnd::aes::sAes128Key src3_key; generateKey(src3_key.key, src1, src2, src1_key); generateKey(dst, src3, src3_key.key); } \ No newline at end of file diff --git a/lib/libhac/source/HierarchicalIntegrityHeader.cpp b/lib/libhac/source/HierarchicalIntegrityHeader.cpp index 3075a1c..c842a4e 100644 --- a/lib/libhac/source/HierarchicalIntegrityHeader.cpp +++ b/lib/libhac/source/HierarchicalIntegrityHeader.cpp @@ -98,8 +98,8 @@ void nn::hac::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t } // save hash list - const crypto::sha::sSha256Hash* hash_list = (const crypto::sha::sSha256Hash*)(mRawBinary.data() + master_hash_offset); - for (size_t i = 0; i < hdr->master_hash_size.get()/sizeof(crypto::sha::sSha256Hash); i++) + const fnd::sha::sSha256Hash* hash_list = (const fnd::sha::sSha256Hash*)(mRawBinary.data() + master_hash_offset); + for (size_t i = 0; i < hdr->master_hash_size.get()/sizeof(fnd::sha::sSha256Hash); i++) { mMasterHashList.addElement(hash_list[i]); } @@ -126,12 +126,12 @@ void nn::hac::HierarchicalIntegrityHeader::setLayerInfo(const fnd::List& mLayerInfo = layer_info; } -const fnd::List& nn::hac::HierarchicalIntegrityHeader::getMasterHashList() const +const fnd::List& nn::hac::HierarchicalIntegrityHeader::getMasterHashList() const { return mMasterHashList; } -void nn::hac::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list) +void nn::hac::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list) { mMasterHashList = master_hash_list; } \ No newline at end of file diff --git a/lib/libhac/source/HierarchicalSha256Header.cpp b/lib/libhac/source/HierarchicalSha256Header.cpp index 6b3f42c..e959f0b 100644 --- a/lib/libhac/source/HierarchicalSha256Header.cpp +++ b/lib/libhac/source/HierarchicalSha256Header.cpp @@ -76,17 +76,17 @@ const fnd::Vec& nn::hac::HierarchicalSha256Header::getBytes() const void nn::hac::HierarchicalSha256Header::clear() { - memset(mMasterHash.bytes, 0, sizeof(crypto::sha::sSha256Hash)); + memset(mMasterHash.bytes, 0, sizeof(fnd::sha::sSha256Hash)); mHashBlockSize = 0; mLayerInfo.clear(); } -const crypto::sha::sSha256Hash & nn::hac::HierarchicalSha256Header::getMasterHash() const +const fnd::sha::sSha256Hash & nn::hac::HierarchicalSha256Header::getMasterHash() const { return mMasterHash; } -void nn::hac::HierarchicalSha256Header::setMasterHash(const crypto::sha::sSha256Hash & master_hash) +void nn::hac::HierarchicalSha256Header::setMasterHash(const fnd::sha::sSha256Hash & master_hash) { mMasterHash = master_hash; } diff --git a/lib/libhac/source/NcaHeader.cpp b/lib/libhac/source/NcaHeader.cpp index 4a546da..12edd1d 100644 --- a/lib/libhac/source/NcaHeader.cpp +++ b/lib/libhac/source/NcaHeader.cpp @@ -306,12 +306,12 @@ void nn::hac::NcaHeader::setPartitions(const fnd::List& nn::hac::NcaHeader::getEncAesKeys() const +const fnd::List& nn::hac::NcaHeader::getEncAesKeys() const { return mEncAesKeys; } -void nn::hac::NcaHeader::setEncAesKeys(const fnd::List& keys) +void nn::hac::NcaHeader::setEncAesKeys(const fnd::List& keys) { mEncAesKeys = keys; } diff --git a/lib/libhac/source/NcaUtils.cpp b/lib/libhac/source/NcaUtils.cpp index 12f78c1..9b71878 100644 --- a/lib/libhac/source/NcaUtils.cpp +++ b/lib/libhac/source/NcaUtils.cpp @@ -1,21 +1,21 @@ #include -void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key) +void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key) { - byte_t tweak[crypto::aes::kAesBlockSize]; + byte_t tweak[fnd::aes::kAesBlockSize]; // decrypt main header byte_t raw_hdr[nn::hac::nca::kSectorSize]; - crypto::aes::AesXtsMakeTweak(tweak, 1); - crypto::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr); + fnd::aes::AesXtsMakeTweak(tweak, 1); + fnd::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr); bool useNca2SectorIndex = ((nn::hac::sNcaHeader*)(raw_hdr))->st_magic.get() == nn::hac::nca::kNca2StructMagic; // decrypt whole header for (size_t i = 0; i < nn::hac::nca::kHeaderSectorNum; i++) { - crypto::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i); - crypto::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i)); + fnd::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i); + fnd::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i)); } } diff --git a/lib/libhac/source/PfsHeader.cpp b/lib/libhac/source/PfsHeader.cpp index 7923992..14cd2ec 100644 --- a/lib/libhac/source/PfsHeader.cpp +++ b/lib/libhac/source/PfsHeader.cpp @@ -222,7 +222,7 @@ void nn::hac::PfsHeader::addFile(const std::string & name, size_t size) mFileList.addElement({ name, 0, size, 0 }); } -void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash) +void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash) { mFileList.addElement({ name, 0, size, hash_protected_size, hash }); } diff --git a/lib/libhac/source/XciHeader.cpp b/lib/libhac/source/XciHeader.cpp index 390f529..e786a7f 100644 --- a/lib/libhac/source/XciHeader.cpp +++ b/lib/libhac/source/XciHeader.cpp @@ -119,7 +119,7 @@ void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len) mFlags = hdr->flags; mPackageId = hdr->package_id.get(); mValidDataEndPage = hdr->valid_data_end_page.get(); - for (size_t i = 0; i < crypto::aes::kAesBlockSize; i++) + for (size_t i = 0; i < fnd::aes::kAesBlockSize; i++) mAesCbcIv.iv[i] = hdr->aescbc_iv.iv[15-i]; mPartitionFsHeaderAddress = hdr->partition_fs_header_address.get(); mPartitionFsHeaderSize = hdr->partition_fs_header_size.get(); @@ -277,12 +277,12 @@ void nn::hac::XciHeader::setValidDataEndPage(uint32_t page) mValidDataEndPage = page; } -const crypto::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const +const fnd::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const { return mAesCbcIv; } -void nn::hac::XciHeader::setAesCbcIv(const crypto::aes::sAesIvCtr& iv) +void nn::hac::XciHeader::setAesCbcIv(const fnd::aes::sAesIvCtr& iv) { mAesCbcIv = iv; } @@ -307,22 +307,22 @@ void nn::hac::XciHeader::setPartitionFsSize(uint64_t size) mPartitionFsHeaderSize = size; } -const crypto::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const +const fnd::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const { return mPartitionFsHeaderHash; } -void nn::hac::XciHeader::setPartitionFsHash(const crypto::sha::sSha256Hash& hash) +void nn::hac::XciHeader::setPartitionFsHash(const fnd::sha::sSha256Hash& hash) { mPartitionFsHeaderHash = hash; } -const crypto::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const +const fnd::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const { return mInitialDataHash; } -void nn::hac::XciHeader::setInitialDataHash(const crypto::sha::sSha256Hash& hash) +void nn::hac::XciHeader::setInitialDataHash(const fnd::sha::sSha256Hash& hash) { mInitialDataHash = hash; } diff --git a/lib/libhac/source/XciUtils.cpp b/lib/libhac/source/XciUtils.cpp index 40aa00a..1954699 100644 --- a/lib/libhac/source/XciUtils.cpp +++ b/lib/libhac/source/XciUtils.cpp @@ -10,7 +10,7 @@ void nn::hac::XciUtils::getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key) { - byte_t iv[crypto::aes::kAesBlockSize]; + byte_t iv[fnd::aes::kAesBlockSize]; getXciHeaderAesIv((const nn::hac::sXciHeader*)src, iv); @@ -18,5 +18,5 @@ void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const b memcpy(dst, src, nn::hac::xci::kHeaderEncOffset); // decrypt encrypted data - crypto::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset); + fnd::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset); } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/CertificateBody.h b/lib/libpki/include/nn/pki/CertificateBody.h index 497cca1..ea9042a 100644 --- a/lib/libpki/include/nn/pki/CertificateBody.h +++ b/lib/libpki/include/nn/pki/CertificateBody.h @@ -38,14 +38,14 @@ namespace pki uint32_t getCertId() const; void setCertId(uint32_t id); - const crypto::rsa::sRsa4096Key& getRsa4098PublicKey() const; - void setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key); + const fnd::rsa::sRsa4096Key& getRsa4098PublicKey() const; + void setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key); - const crypto::rsa::sRsa2048Key& getRsa2048PublicKey() const; - void setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key); + const fnd::rsa::sRsa2048Key& getRsa2048PublicKey() const; + void setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key); - const crypto::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const; - void setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key); + const fnd::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const; + void setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key); private: const std::string kModuleName = "CERTIFICATE_BODY"; @@ -59,9 +59,9 @@ namespace pki uint32_t mCertId; cert::PublicKeyType mPublicKeyType; - crypto::rsa::sRsa4096Key mRsa4096PublicKey; - crypto::rsa::sRsa2048Key mRsa2048PublicKey; - crypto::ecdsa::sEcdsa240Point mEcdsa240PublicKey; + fnd::rsa::sRsa4096Key mRsa4096PublicKey; + fnd::rsa::sRsa2048Key mRsa2048PublicKey; + fnd::ecdsa::sEcdsa240Point mEcdsa240PublicKey; }; } } \ No newline at end of file diff --git a/lib/libpki/include/nn/pki/SignUtils.h b/lib/libpki/include/nn/pki/SignUtils.h index 873ff41..c3035fd 100644 --- a/lib/libpki/include/nn/pki/SignUtils.h +++ b/lib/libpki/include/nn/pki/SignUtils.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace nn { diff --git a/lib/libpki/include/nn/pki/cert.h b/lib/libpki/include/nn/pki/cert.h index 1fd7a1b..fc2ea54 100644 --- a/lib/libpki/include/nn/pki/cert.h +++ b/lib/libpki/include/nn/pki/cert.h @@ -1,9 +1,9 @@ #pragma once #include #include -#include -#include -#include +#include +#include +#include namespace nn { @@ -32,21 +32,21 @@ namespace pki struct sRsa4096PublicKeyBlock { - byte_t modulus[crypto::rsa::kRsa4096Size]; - byte_t public_exponent[crypto::rsa::kRsaPublicExponentSize]; + byte_t modulus[fnd::rsa::kRsa4096Size]; + byte_t public_exponent[fnd::rsa::kRsaPublicExponentSize]; byte_t padding[0x34]; }; struct sRsa2048PublicKeyBlock { - byte_t modulus[crypto::rsa::kRsa2048Size]; - byte_t public_exponent[crypto::rsa::kRsaPublicExponentSize]; + byte_t modulus[fnd::rsa::kRsa2048Size]; + byte_t public_exponent[fnd::rsa::kRsaPublicExponentSize]; byte_t padding[0x34]; }; struct sEcdsa240PublicKeyBlock { - crypto::ecdsa::sEcdsa240Point public_key; + fnd::ecdsa::sEcdsa240Point public_key; byte_t padding[0x3C]; }; #pragma pack(pop) diff --git a/lib/libpki/include/nn/pki/sign.h b/lib/libpki/include/nn/pki/sign.h index 7d31f35..bc89d01 100644 --- a/lib/libpki/include/nn/pki/sign.h +++ b/lib/libpki/include/nn/pki/sign.h @@ -1,9 +1,9 @@ #pragma once #include #include -#include -#include -#include +#include +#include +#include namespace nn { @@ -43,14 +43,14 @@ namespace pki struct sRsa4096SignBlock { be_uint32_t sign_type; - byte_t signature[crypto::rsa::kRsa4096Size]; + byte_t signature[fnd::rsa::kRsa4096Size]; byte_t padding[0x3C]; }; struct sRsa2048SignBlock { be_uint32_t sign_type; - byte_t signature[crypto::rsa::kRsa2048Size]; + byte_t signature[fnd::rsa::kRsa2048Size]; byte_t padding[0x3C]; }; diff --git a/lib/libpki/libpki.vcxproj b/lib/libpki/libpki.vcxproj index ef497f5..f638e1e 100644 --- a/lib/libpki/libpki.vcxproj +++ b/lib/libpki/libpki.vcxproj @@ -77,7 +77,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libpki\include; + ..\libfnd\include;..\libpki\include; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -91,7 +91,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libpki\include; + ..\libfnd\include;..\libpki\include; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -101,7 +101,7 @@ Disabled true true - ..\libfnd\include;..\libcrypto\include;..\libpki\include; + ..\libfnd\include;..\libpki\include; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -113,7 +113,7 @@ true true true - ..\libfnd\include;..\libcrypto\include;..\libpki\include; + ..\libfnd\include;..\libpki\include; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/lib/libpki/source/CertificateBody.cpp b/lib/libpki/source/CertificateBody.cpp index bcf3d03..2c2b8c6 100644 --- a/lib/libpki/source/CertificateBody.cpp +++ b/lib/libpki/source/CertificateBody.cpp @@ -168,9 +168,9 @@ void nn::pki::CertificateBody::clear() mCertId = 0; mPublicKeyType = cert::RSA2048; - memset(&mRsa4096PublicKey, 0, sizeof(crypto::rsa::sRsa4096Key)); - memset(&mRsa2048PublicKey, 0, sizeof(crypto::rsa::sRsa2048Key)); - memset(&mEcdsa240PublicKey, 0, sizeof(crypto::ecdsa::sEcdsa240Point)); + memset(&mRsa4096PublicKey, 0, sizeof(fnd::rsa::sRsa4096Key)); + memset(&mRsa2048PublicKey, 0, sizeof(fnd::rsa::sRsa2048Key)); + memset(&mEcdsa240PublicKey, 0, sizeof(fnd::ecdsa::sEcdsa240Point)); } const std::string& nn::pki::CertificateBody::getIssuer() const @@ -223,32 +223,32 @@ void nn::pki::CertificateBody::setCertId(uint32_t id) mCertId = id; } -const crypto::rsa::sRsa4096Key& nn::pki::CertificateBody::getRsa4098PublicKey() const +const fnd::rsa::sRsa4096Key& nn::pki::CertificateBody::getRsa4098PublicKey() const { return mRsa4096PublicKey; } -void nn::pki::CertificateBody::setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key) +void nn::pki::CertificateBody::setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key) { mRsa4096PublicKey = key; } -const crypto::rsa::sRsa2048Key& nn::pki::CertificateBody::getRsa2048PublicKey() const +const fnd::rsa::sRsa2048Key& nn::pki::CertificateBody::getRsa2048PublicKey() const { return mRsa2048PublicKey; } -void nn::pki::CertificateBody::setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key) +void nn::pki::CertificateBody::setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key) { mRsa2048PublicKey = key; } -const crypto::ecdsa::sEcdsa240Point& nn::pki::CertificateBody::getEcdsa240PublicKey() const +const fnd::ecdsa::sEcdsa240Point& nn::pki::CertificateBody::getEcdsa240PublicKey() const { return mEcdsa240PublicKey; } -void nn::pki::CertificateBody::setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key) +void nn::pki::CertificateBody::setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key) { mEcdsa240PublicKey = key; } \ No newline at end of file diff --git a/lib/libpki/source/SignatureBlock.cpp b/lib/libpki/source/SignatureBlock.cpp index b25944a..1088ea4 100644 --- a/lib/libpki/source/SignatureBlock.cpp +++ b/lib/libpki/source/SignatureBlock.cpp @@ -40,12 +40,12 @@ void nn::pki::SignatureBlock::toBytes() case (sign::SIGN_ID_RSA4096_SHA1): case (sign::SIGN_ID_RSA4096_SHA256): totalSize = sizeof(sRsa4096SignBlock); - sigSize = crypto::rsa::kRsa4096Size; + sigSize = fnd::rsa::kRsa4096Size; break; case (sign::SIGN_ID_RSA2048_SHA1): case (sign::SIGN_ID_RSA2048_SHA256): totalSize = sizeof(sRsa2048SignBlock); - sigSize = crypto::rsa::kRsa2048Size; + sigSize = fnd::rsa::kRsa2048Size; break; case (sign::SIGN_ID_ECDSA240_SHA1): case (sign::SIGN_ID_ECDSA240_SHA256): @@ -83,12 +83,12 @@ void nn::pki::SignatureBlock::fromBytes(const byte_t* src, size_t size) case (sign::SIGN_ID_RSA4096_SHA1): case (sign::SIGN_ID_RSA4096_SHA256): totalSize = sizeof(sRsa4096SignBlock); - sigSize = crypto::rsa::kRsa4096Size; + sigSize = fnd::rsa::kRsa4096Size; break; case (sign::SIGN_ID_RSA2048_SHA1): case (sign::SIGN_ID_RSA2048_SHA256): totalSize = sizeof(sRsa2048SignBlock); - sigSize = crypto::rsa::kRsa2048Size; + sigSize = fnd::rsa::kRsa2048Size; break; case (sign::SIGN_ID_ECDSA240_SHA1): case (sign::SIGN_ID_ECDSA240_SHA256): @@ -106,12 +106,12 @@ void nn::pki::SignatureBlock::fromBytes(const byte_t* src, size_t size) case (sign::SIGN_ID_RSA4096_SHA1): case (sign::SIGN_ID_RSA4096_SHA256): totalSize = sizeof(sRsa4096SignBlock); - sigSize = crypto::rsa::kRsa4096Size; + sigSize = fnd::rsa::kRsa4096Size; break; case (sign::SIGN_ID_RSA2048_SHA1): case (sign::SIGN_ID_RSA2048_SHA256): totalSize = sizeof(sRsa2048SignBlock); - sigSize = crypto::rsa::kRsa2048Size; + sigSize = fnd::rsa::kRsa2048Size; break; case (sign::SIGN_ID_ECDSA240_SHA1): case (sign::SIGN_ID_ECDSA240_SHA256): diff --git a/makefile b/makefile index 3435159..ee116a5 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ LIB_DIR = $(PROJECT_DIR)/lib PROGRAM_DIR = $(PROJECT_DIR)/programs BIN_DIR = $(PROJECT_DIR)/bin -LIBS = libpolarssl liblz4 libfnd libcrypto libcompress libes libpki libhac libhac-hb +LIBS = libpolarssl liblz4 libfnd libes libpki libhac libhac-hb PROGS = nstool main: build diff --git a/programs/nstool/makefile b/programs/nstool/makefile index a20fbb5..d73e3b4 100644 --- a/programs/nstool/makefile +++ b/programs/nstool/makefile @@ -3,7 +3,7 @@ SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # External dependencies -DEPENDS = hac-hb hac es pki crypto compress fnd polarssl lz4 +DEPENDS = hac-hb hac es pki fnd polarssl lz4 LIB_DIR = ../../lib LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep)) INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") diff --git a/programs/nstool/nstool.vcxproj b/programs/nstool/nstool.vcxproj index 9110d28..8e10e2d 100644 --- a/programs/nstool/nstool.vcxproj +++ b/programs/nstool/nstool.vcxproj @@ -90,7 +90,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -105,7 +105,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -122,7 +122,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -141,7 +141,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include + ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include Console @@ -157,12 +157,6 @@ {AB0C3362-63AB-480A-ADBC-2EF7D859778B} - - {cf01b5b7-730a-447f-9bb2-5eda9b082177} - - - {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} - {7be99936-0d40-410d-944b-4513c2eff8dc} diff --git a/programs/nstool/source/AesCtrWrappedIFile.cpp b/programs/nstool/source/AesCtrWrappedIFile.cpp index 4dd5c05..06ea584 100644 --- a/programs/nstool/source/AesCtrWrappedIFile.cpp +++ b/programs/nstool/source/AesCtrWrappedIFile.cpp @@ -1,6 +1,6 @@ #include "AesCtrWrappedIFile.h" -AesCtrWrappedIFile::AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const crypto::aes::sAes128Key& key, const crypto::aes::sAesIvCtr& ctr) : +AesCtrWrappedIFile::AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr) : mOwnIFile(ownIfile), mFile(file), mKey(key), @@ -47,8 +47,8 @@ void AesCtrWrappedIFile::read(byte_t* out, size_t len) mFile->seek(read_pos); mFile->read(mCache.data(), kCacheSizeAllocSize); - crypto::aes::AesIncrementCounter(mBaseCtr.iv, read_pos>>4, mCurrentCtr.iv); - crypto::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data()); + fnd::aes::AesIncrementCounter(mBaseCtr.iv, read_pos>>4, mCurrentCtr.iv); + fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data()); memcpy(out + (i * kCacheSize), mCache.data() + (mFileOffset & 0xf), read_len); } @@ -78,8 +78,8 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len) memcpy(mCache.data() + (mFileOffset & 0xf), in + (i * kCacheSize), write_len); - crypto::aes::AesIncrementCounter(mBaseCtr.iv, write_pos>>4, mCurrentCtr.iv); - crypto::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data()); + fnd::aes::AesIncrementCounter(mBaseCtr.iv, write_pos>>4, mCurrentCtr.iv); + fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data()); mFile->seek(write_pos); mFile->write(mCache.data(), kCacheSizeAllocSize); @@ -91,7 +91,7 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len) for (size_t i = 0; i < (len / kAesCtrScratchSize); i++) { memcpy(mScratch.data() + mBlockOffset, out + (i * kAesCtrScratchSize), kAesCtrScratchSize); - crypto::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data()); + fnd::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data()); mFile->write(mScratch.data() + mBlockOffset, kAesCtrScratchSize); } @@ -100,7 +100,7 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len) size_t write_len = len % kAesCtrScratchSize; size_t write_pos = ((len / kAesCtrScratchSize) * kAesCtrScratchSize); memcpy(mScratch.data() + mBlockOffset, out + write_pos, write_len); - crypto::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data()); + fnd::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data()); mFile->write(mScratch.data() + mBlockOffset, write_len); } */ diff --git a/programs/nstool/source/AesCtrWrappedIFile.h b/programs/nstool/source/AesCtrWrappedIFile.h index dbbd3e0..1703bc8 100644 --- a/programs/nstool/source/AesCtrWrappedIFile.h +++ b/programs/nstool/source/AesCtrWrappedIFile.h @@ -1,11 +1,11 @@ #include #include -#include +#include class AesCtrWrappedIFile : public fnd::IFile { public: - AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const crypto::aes::sAes128Key& key, const crypto::aes::sAesIvCtr& ctr); + AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr); ~AesCtrWrappedIFile(); size_t size(); @@ -17,12 +17,12 @@ public: private: const std::string kModuleName = "AesCtrWrappedIFile"; static const size_t kCacheSize = 0x10000; - static const size_t kCacheSizeAllocSize = kCacheSize + crypto::aes::kAesBlockSize; + static const size_t kCacheSizeAllocSize = kCacheSize + fnd::aes::kAesBlockSize; bool mOwnIFile; fnd::IFile* mFile; - crypto::aes::sAes128Key mKey; - crypto::aes::sAesIvCtr mBaseCtr, mCurrentCtr; + fnd::aes::sAes128Key mKey; + fnd::aes::sAesIvCtr mBaseCtr, mCurrentCtr; size_t mFileOffset; fnd::Vec mCache; diff --git a/programs/nstool/source/EsTikProcess.cpp b/programs/nstool/source/EsTikProcess.cpp index 9f98521..cec162a 100644 --- a/programs/nstool/source/EsTikProcess.cpp +++ b/programs/nstool/source/EsTikProcess.cpp @@ -83,12 +83,12 @@ void EsTikProcess::verifyTicket() switch (nn::pki::sign::getHashAlgo(mTik.getSignature().getSignType())) { case (nn::pki::sign::HASH_ALGO_SHA1): - tik_hash.alloc(crypto::sha::kSha1HashLen); - crypto::sha::Sha1(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); + tik_hash.alloc(fnd::sha::kSha1HashLen); + fnd::sha::Sha1(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); break; case (nn::pki::sign::HASH_ALGO_SHA256): - tik_hash.alloc(crypto::sha::kSha256HashLen); - crypto::sha::Sha256(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); + tik_hash.alloc(fnd::sha::kSha256HashLen); + fnd::sha::Sha256(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data()); break; } @@ -124,7 +124,7 @@ void EsTikProcess::displayTicket() std::cout << " EncMode: " << getTitleKeyPersonalisationStr(body.getTitleKeyEncType()) << std::endl; std::cout << " KeyGeneration: " << std::dec << (uint32_t)body.getCommonKeyId() << std::endl; std::cout << " Data:" << std::endl; - size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; + size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? fnd::rsa::kRsa2048Size : fnd::aes::kAes128KeySize; fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6); printf(" Version: v%d.%d.%d", _SPLIT_VER(body.getTicketVersion())); diff --git a/programs/nstool/source/HashTreeMeta.cpp b/programs/nstool/source/HashTreeMeta.cpp index 4822164..3276d41 100644 --- a/programs/nstool/source/HashTreeMeta.cpp +++ b/programs/nstool/source/HashTreeMeta.cpp @@ -72,12 +72,12 @@ void HashTreeMeta::setDataLayer(const sLayer& data_info) mDataLayer = data_info; } -const fnd::List& HashTreeMeta::getMasterHashList() const +const fnd::List& HashTreeMeta::getMasterHashList() const { return mMasterHashList; } -void HashTreeMeta::setMasterHashList(const fnd::List& master_hash_list) +void HashTreeMeta::setMasterHashList(const fnd::List& master_hash_list) { mMasterHashList = master_hash_list; } diff --git a/programs/nstool/source/HashTreeMeta.h b/programs/nstool/source/HashTreeMeta.h index ecdbdda..1568b5e 100644 --- a/programs/nstool/source/HashTreeMeta.h +++ b/programs/nstool/source/HashTreeMeta.h @@ -50,8 +50,8 @@ public: const sLayer& getDataLayer() const; void setDataLayer(const sLayer& data_info); - const fnd::List& getMasterHashList() const; - void setMasterHashList(const fnd::List& master_hash_list); + const fnd::List& getMasterHashList() const; + void setMasterHashList(const fnd::List& master_hash_list); bool getAlignHashToBlock() const; void setAlignHashToBlock(bool doAlign); @@ -60,7 +60,7 @@ private: // data fnd::List mLayerInfo; sLayer mDataLayer; - fnd::List mMasterHashList; + fnd::List mMasterHashList; bool mDoAlignHashToBlock; void importHierarchicalIntergityHeader(const nn::hac::HierarchicalIntegrityHeader& hdr); diff --git a/programs/nstool/source/HashTreeWrappedIFile.cpp b/programs/nstool/source/HashTreeWrappedIFile.cpp index e8e5140..3b147e9 100644 --- a/programs/nstool/source/HashTreeWrappedIFile.cpp +++ b/programs/nstool/source/HashTreeWrappedIFile.cpp @@ -96,16 +96,16 @@ void HashTreeWrappedIFile::write(const byte_t* out, size_t offset, size_t len) void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr) { - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; fnd::Vec cur, prev; mAlignHashCalcToBlock = hdr.getAlignHashToBlock(); // copy master hash into prev - prev.alloc(sizeof(crypto::sha::sSha256Hash) * hdr.getMasterHashList().size()); + prev.alloc(sizeof(fnd::sha::sSha256Hash) * hdr.getMasterHashList().size()); for (size_t i = 0; i < hdr.getMasterHashList().size(); i++) { - ((crypto::sha::sSha256Hash*)prev.data())[i] = hdr.getMasterHashList()[i]; + ((fnd::sha::sSha256Hash*)prev.data())[i] = hdr.getMasterHashList()[i]; } // check each hash layer @@ -125,8 +125,8 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr) for (size_t j = 0; j < cur.size() / layer.block_size; j++) { validate_size = mAlignHashCalcToBlock? layer.block_size : _MIN(layer.size - (j * layer.block_size), layer.block_size); - crypto::sha::Sha256(cur.data() + (j * layer.block_size), validate_size, hash.bytes); - if (hash.compare(prev.data() + j * sizeof(crypto::sha::sSha256Hash)) == false) + fnd::sha::Sha256(cur.data() + (j * layer.block_size), validate_size, hash.bytes); + if (hash.compare(prev.data() + j * sizeof(fnd::sha::sSha256Hash)) == false) { mErrorSs << "Hash tree layer verification failed (layer: " << i << ", block: " << j << ")"; throw fnd::Exception(kModuleName, mErrorSs.str()); @@ -138,8 +138,8 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr) } // save last layer as hash table for data layer - crypto::sha::sSha256Hash* hash_list = (crypto::sha::sSha256Hash*)prev.data(); - for (size_t i = 0; i < prev.size() / sizeof(crypto::sha::sSha256Hash); i++) + fnd::sha::sSha256Hash* hash_list = (fnd::sha::sSha256Hash*)prev.data(); + for (size_t i = 0; i < prev.size() / sizeof(fnd::sha::sSha256Hash); i++) { mDataHashLayer.addElement(hash_list[i]); } @@ -161,7 +161,7 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr) void HashTreeWrappedIFile::readData(size_t block_offset, size_t block_num) { mData->seek(block_offset * mDataBlockSize); - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; // determine read size size_t read_len = 0; @@ -194,7 +194,7 @@ void HashTreeWrappedIFile::readData(size_t block_offset, size_t block_num) for (size_t i = 0; i < block_num; i++) { validate_size = mAlignHashCalcToBlock? mDataBlockSize : _MIN(read_len - (i * mDataBlockSize), mDataBlockSize); - crypto::sha::Sha256(mCache.data() + (i * mDataBlockSize), validate_size, hash.bytes); + fnd::sha::Sha256(mCache.data() + (i * mDataBlockSize), validate_size, hash.bytes); if (hash != mDataHashLayer[block_offset + i]) { mErrorSs << "Hash tree layer verification failed (layer: data, block: " << (block_offset + i) << " ( " << i << "/" << block_num-1 << " ), offset: 0x" << std::hex << ((block_offset + i) * mDataBlockSize) << ", size: 0x" << std::hex << validate_size <<")"; diff --git a/programs/nstool/source/HashTreeWrappedIFile.h b/programs/nstool/source/HashTreeWrappedIFile.h index fa65e13..6e97181 100644 --- a/programs/nstool/source/HashTreeWrappedIFile.h +++ b/programs/nstool/source/HashTreeWrappedIFile.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "HashTreeMeta.h" @@ -30,7 +30,7 @@ private: fnd::IFile* mData; size_t mDataOffset; size_t mDataBlockSize; - fnd::List mDataHashLayer; + fnd::List mDataHashLayer; bool mAlignHashCalcToBlock; fnd::Vec mCache; diff --git a/programs/nstool/source/NcaProcess.cpp b/programs/nstool/source/NcaProcess.cpp index bf7838b..bfc9f3f 100644 --- a/programs/nstool/source/NcaProcess.cpp +++ b/programs/nstool/source/NcaProcess.cpp @@ -265,7 +265,7 @@ void NcaProcess::process() nn::hac::NcaUtils::decryptNcaHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, mKeyset->nca.header_key); // generate header hash - crypto::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader), mHdrHash.bytes); + fnd::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader), mHdrHash.bytes); // proccess main header mHdr.fromBytes((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader)); @@ -341,9 +341,9 @@ void NcaProcess::setListFs(bool list_fs) void NcaProcess::generateNcaBodyEncryptionKeys() { // create zeros key - crypto::aes::sAes128Key zero_aesctr_key; + fnd::aes::sAes128Key zero_aesctr_key; memset(zero_aesctr_key.key, 0, sizeof(zero_aesctr_key)); - crypto::aes::sAesXts128Key zero_aesxts_key; + fnd::aes::sAesXts128Key zero_aesxts_key; memset(zero_aesxts_key.key, 0, sizeof(zero_aesxts_key)); // get key data from header @@ -398,8 +398,8 @@ void NcaProcess::generateNcaBodyEncryptionKeys() // otherwise decrypt key area else { - crypto::aes::sAes128Key keak_aesctr_key = zero_aesctr_key; - crypto::aes::sAesXts128Key keak_aesxts_key = zero_aesxts_key; + fnd::aes::sAes128Key keak_aesctr_key = zero_aesctr_key; + fnd::aes::sAesXts128Key keak_aesxts_key = zero_aesxts_key; for (size_t i = 0; i < mBodyKeys.keak_list.size(); i++) { if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESCTR && mBodyKeys.keak_list[i].decrypted) @@ -408,11 +408,11 @@ void NcaProcess::generateNcaBodyEncryptionKeys() } else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_0 && mBodyKeys.keak_list[i].decrypted) { - memcpy(keak_aesxts_key.key[0], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key)); + memcpy(keak_aesxts_key.key[0], mBodyKeys.keak_list[i].dec.key, sizeof(fnd::aes::sAes128Key)); } else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_1 && mBodyKeys.keak_list[i].decrypted) { - memcpy(keak_aesxts_key.key[1], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key)); + memcpy(keak_aesxts_key.key[1], mBodyKeys.keak_list[i].dec.key, sizeof(fnd::aes::sAes128Key)); } } @@ -472,8 +472,8 @@ void NcaProcess::generatePartitionConfiguration() sPartitionInfo& info = mPartitions[partition.index]; // validate header hash - crypto::sha::sSha256Hash calc_hash; - crypto::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nn::hac::sNcaFsHeader), calc_hash.bytes); + fnd::sha::sSha256Hash calc_hash; + fnd::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nn::hac::sNcaFsHeader), calc_hash.bytes); if (calc_hash.compare(partition.hash) == false) { error.clear(); @@ -570,7 +570,7 @@ void NcaProcess::generatePartitionConfiguration() void NcaProcess::validateNcaSignatures() { // validate signature[0] - if (crypto::rsa::pss::rsaVerify(mKeyset->nca.header_sign_key, crypto::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_main) != 0) + if (fnd::rsa::pss::rsaVerify(mKeyset->nca.header_sign_key, fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_main) != 0) { printf("[WARNING] NCA Header Main Signature: FAIL \n"); } @@ -597,7 +597,7 @@ void NcaProcess::validateNcaSignatures() npdm.setCliOutputMode(0); npdm.process(); - if (crypto::rsa::pss::rsaVerify(npdm.getNpdmBinary().getAcid().getNcaHeaderSignature2Key(), crypto::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0) + if (fnd::rsa::pss::rsaVerify(npdm.getNpdmBinary().getAcid().getNcaHeaderSignature2Key(), fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0) { printf("[WARNING] NCA Header ACID Signature: FAIL \n"); } @@ -686,9 +686,9 @@ void NcaProcess::displayHeader() if (info.enc_type == nn::hac::nca::CRYPT_AESCTR) { printf(" AES-CTR: "); - crypto::aes::sAesIvCtr ctr; - crypto::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv); - fnd::SimpleTextOutput::hexDump(ctr.iv, sizeof(crypto::aes::sAesIvCtr)); + fnd::aes::sAesIvCtr ctr; + fnd::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv); + fnd::SimpleTextOutput::hexDump(ctr.iv, sizeof(fnd::aes::sAesIvCtr)); } if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY) { @@ -712,7 +712,7 @@ void NcaProcess::displayHeader() for (size_t j = 0; j < hash_hdr.getMasterHashList().size(); j++) { printf(" Master Hash %d: ", (int)j); - fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[j].bytes, sizeof(crypto::sha::sSha256Hash)); + fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[j].bytes, sizeof(fnd::sha::sSha256Hash)); } } else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256) @@ -720,7 +720,7 @@ void NcaProcess::displayHeader() HashTreeMeta& hash_hdr = info.hash_tree_meta; printf(" HierarchicalSha256 Header:\n"); printf(" Master Hash: "); - fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[0].bytes, sizeof(crypto::sha::sSha256Hash)); + fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[0].bytes, sizeof(fnd::sha::sSha256Hash)); printf(" HashBlockSize: 0x%" PRIx32 "\n", (uint32_t)hash_hdr.getDataLayer().block_size); //printf(" LayerNum: %d\n", hash_hdr.getLayerInfo().size()); printf(" Hash Layer:\n"); diff --git a/programs/nstool/source/NcaProcess.h b/programs/nstool/source/NcaProcess.h index d79ab5a..e21ded8 100644 --- a/programs/nstool/source/NcaProcess.h +++ b/programs/nstool/source/NcaProcess.h @@ -50,7 +50,7 @@ private: // data nn::hac::sNcaHeaderBlock mHdrBlock; - crypto::sha::sSha256Hash mHdrHash; + fnd::sha::sSha256Hash mHdrHash; nn::hac::NcaHeader mHdr; // crypto @@ -60,8 +60,8 @@ private: { byte_t index; bool decrypted; - crypto::aes::sAes128Key enc; - crypto::aes::sAes128Key dec; + fnd::aes::sAes128Key enc; + fnd::aes::sAes128Key dec; void operator=(const sKeyAreaKey& other) { @@ -86,8 +86,8 @@ private: }; fnd::List keak_list; - sOptional aes_ctr; - sOptional aes_xts; + sOptional aes_ctr; + sOptional aes_xts; } mBodyKeys; struct sPartitionInfo @@ -102,7 +102,7 @@ private: nn::hac::nca::HashType hash_type; nn::hac::nca::EncryptionType enc_type; HashTreeMeta hash_tree_meta; - crypto::aes::sAesIvCtr aes_ctr; + fnd::aes::sAesIvCtr aes_ctr; } mPartitions[nn::hac::nca::kPartitionNum]; void generateNcaBodyEncryptionKeys(); diff --git a/programs/nstool/source/NroProcess.cpp b/programs/nstool/source/NroProcess.cpp index 694ad38..3beb776 100644 --- a/programs/nstool/source/NroProcess.cpp +++ b/programs/nstool/source/NroProcess.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include "OffsetAdjustedIFile.h" #include "NroProcess.h" diff --git a/programs/nstool/source/NsoProcess.cpp b/programs/nstool/source/NsoProcess.cpp index 3f5653f..3113be5 100644 --- a/programs/nstool/source/NsoProcess.cpp +++ b/programs/nstool/source/NsoProcess.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "OffsetAdjustedIFile.h" #include "NsoProcess.h" @@ -89,7 +89,7 @@ void NsoProcess::importCodeSegments() { fnd::Vec scratch; uint32_t decompressed_len; - crypto::sha::sSha256Hash calc_hash; + fnd::sha::sSha256Hash calc_hash; // process text segment if (mHdr.getTextSegmentInfo().is_compressed) @@ -97,7 +97,7 @@ void NsoProcess::importCodeSegments() scratch.alloc(mHdr.getTextSegmentInfo().file_layout.size); mFile->read(scratch.data(), mHdr.getTextSegmentInfo().file_layout.offset, scratch.size()); mTextBlob.alloc(mHdr.getTextSegmentInfo().memory_layout.size); - compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len); + fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len); if (decompressed_len != mTextBlob.size()) { throw fnd::Exception(kModuleName, "NSO text segment failed to decompress"); @@ -110,7 +110,7 @@ void NsoProcess::importCodeSegments() } if (mHdr.getTextSegmentInfo().is_hashed) { - crypto::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes); + fnd::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes); if (calc_hash != mHdr.getTextSegmentInfo().hash) { throw fnd::Exception(kModuleName, "NSO text segment failed SHA256 verification"); @@ -123,7 +123,7 @@ void NsoProcess::importCodeSegments() scratch.alloc(mHdr.getRoSegmentInfo().file_layout.size); mFile->read(scratch.data(), mHdr.getRoSegmentInfo().file_layout.offset, scratch.size()); mRoBlob.alloc(mHdr.getRoSegmentInfo().memory_layout.size); - compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len); + fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len); if (decompressed_len != mRoBlob.size()) { throw fnd::Exception(kModuleName, "NSO ro segment failed to decompress"); @@ -136,7 +136,7 @@ void NsoProcess::importCodeSegments() } if (mHdr.getRoSegmentInfo().is_hashed) { - crypto::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes); + fnd::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes); if (calc_hash != mHdr.getRoSegmentInfo().hash) { throw fnd::Exception(kModuleName, "NSO ro segment failed SHA256 verification"); @@ -149,7 +149,7 @@ void NsoProcess::importCodeSegments() scratch.alloc(mHdr.getDataSegmentInfo().file_layout.size); mFile->read(scratch.data(), mHdr.getDataSegmentInfo().file_layout.offset, scratch.size()); mDataBlob.alloc(mHdr.getDataSegmentInfo().memory_layout.size); - compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len); + fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len); if (decompressed_len != mDataBlob.size()) { throw fnd::Exception(kModuleName, "NSO data segment failed to decompress"); @@ -162,7 +162,7 @@ void NsoProcess::importCodeSegments() } if (mHdr.getDataSegmentInfo().is_hashed) { - crypto::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes); + fnd::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes); if (calc_hash != mHdr.getDataSegmentInfo().hash) { throw fnd::Exception(kModuleName, "NSO data segment failed SHA256 verification"); diff --git a/programs/nstool/source/PfsProcess.cpp b/programs/nstool/source/PfsProcess.cpp index 646f83f..c44fca0 100644 --- a/programs/nstool/source/PfsProcess.cpp +++ b/programs/nstool/source/PfsProcess.cpp @@ -142,13 +142,13 @@ bool PfsProcess::validateHeaderMagic(const nn::hac::sPfsHeader* hdr) void PfsProcess::validateHfs() { - crypto::sha::sSha256Hash hash; + fnd::sha::sSha256Hash hash; const fnd::List& file = mPfs.getFileList(); for (size_t i = 0; i < file.size(); i++) { mCache.alloc(file[i].hash_protected_size); mFile->read(mCache.data(), file[i].offset, file[i].hash_protected_size); - crypto::sha::Sha256(mCache.data(), file[i].hash_protected_size, hash.bytes); + fnd::sha::Sha256(mCache.data(), file[i].hash_protected_size, hash.bytes); if (hash != file[i].hash) { printf("[WARNING] HFS0 %s%s%s: FAIL (bad hash)\n", !mMountName.empty()? mMountName.c_str() : "", (!mMountName.empty() && mMountName.at(mMountName.length()-1) != '/' )? "/" : "", file[i].name.c_str()); diff --git a/programs/nstool/source/PkiCertProcess.cpp b/programs/nstool/source/PkiCertProcess.cpp index 5de3e01..db7c629 100644 --- a/programs/nstool/source/PkiCertProcess.cpp +++ b/programs/nstool/source/PkiCertProcess.cpp @@ -123,25 +123,25 @@ void PkiCertProcess::displayCert(const nn::pki::SignedData> old_certs = mCertificateBank; @@ -58,12 +58,12 @@ void PkiValidator::addCertificate(const nn::pki::SignedData& PkiValidator::getCert(const throw fnd::Exception(kModuleName, "Issuer certificate does not exist"); } -crypto::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const +fnd::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const { - crypto::sha::HashType hash_type = crypto::sha::HASH_SHA1; + fnd::sha::HashType hash_type = fnd::sha::HASH_SHA1; switch (hash_algo) { case (nn::pki::sign::HASH_ALGO_SHA1): - hash_type = crypto::sha::HASH_SHA1; + hash_type = fnd::sha::HASH_SHA1; break; case (nn::pki::sign::HASH_ALGO_SHA256): - hash_type = crypto::sha::HASH_SHA256; + hash_type = fnd::sha::HASH_SHA256; break; }; diff --git a/programs/nstool/source/PkiValidator.h b/programs/nstool/source/PkiValidator.h index 1183c80..6ef0bd2 100644 --- a/programs/nstool/source/PkiValidator.h +++ b/programs/nstool/source/PkiValidator.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -12,7 +12,7 @@ class PkiValidator public: PkiValidator(); - void setRootKey(const crypto::rsa::sRsa4096Key& root_key); + void setRootKey(const fnd::rsa::sRsa4096Key& root_key); void addCertificates(const fnd::List>& certs); void addCertificate(const nn::pki::SignedData& cert); void clearCertificates(); @@ -23,12 +23,12 @@ private: const std::string kModuleName = "NNPkiValidator"; - crypto::rsa::sRsa4096Key mRootKey; + fnd::rsa::sRsa4096Key mRootKey; fnd::List> mCertificateBank; void makeCertIdent(const nn::pki::SignedData& cert, std::string& ident) const; void makeCertIdent(const std::string& issuer, const std::string& subject, std::string& ident) const; bool doesCertExist(const std::string& ident) const; const nn::pki::SignedData& getCert(const std::string& ident) const; - crypto::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const; + fnd::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const; }; \ No newline at end of file diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp index 0c0cf06..936ac00 100644 --- a/programs/nstool/source/UserSettings.cpp +++ b/programs/nstool/source/UserSettings.cpp @@ -385,10 +385,10 @@ void UserSettings::populateCmdArgs(const std::vector& arg_list, sCm void UserSettings::populateKeyset(sCmdArgs& args) { - crypto::aes::sAes128Key zeros_aes_key; - crypto::aes::sAesXts128Key zeros_aes_xts_key; - memset((void*)&zeros_aes_key, 0, sizeof(crypto::aes::sAes128Key)); - memset((void*)&zeros_aes_xts_key, 0, sizeof(crypto::aes::sAesXts128Key)); + fnd::aes::sAes128Key zeros_aes_key; + fnd::aes::sAesXts128Key zeros_aes_xts_key; + memset((void*)&zeros_aes_key, 0, sizeof(fnd::aes::sAes128Key)); + memset((void*)&zeros_aes_xts_key, 0, sizeof(fnd::aes::sAesXts128Key)); memset((void*)&mKeyset, 0, sizeof(sKeyset)); fnd::ResourceFileReader res; @@ -446,14 +446,14 @@ void UserSettings::populateKeyset(sCmdArgs& args) // sources - crypto::aes::sAes128Key master_key[kMasterKeyNum] = { zeros_aes_key }; - crypto::aes::sAes128Key package2_key_source = zeros_aes_key; - crypto::aes::sAes128Key ticket_titlekek_source = zeros_aes_key; - crypto::aes::sAes128Key key_area_key_source[3] = { zeros_aes_key, zeros_aes_key, zeros_aes_key }; - crypto::aes::sAes128Key aes_kek_generation_source = zeros_aes_key; - crypto::aes::sAes128Key aes_key_generation_source = zeros_aes_key; - crypto::aes::sAes128Key nca_header_kek_source = zeros_aes_key; - crypto::aes::sAesXts128Key nca_header_key_source = zeros_aes_xts_key; + fnd::aes::sAes128Key master_key[kMasterKeyNum] = { zeros_aes_key }; + fnd::aes::sAes128Key package2_key_source = zeros_aes_key; + fnd::aes::sAes128Key ticket_titlekek_source = zeros_aes_key; + fnd::aes::sAes128Key key_area_key_source[3] = { zeros_aes_key, zeros_aes_key, zeros_aes_key }; + fnd::aes::sAes128Key aes_kek_generation_source = zeros_aes_key; + fnd::aes::sAes128Key aes_key_generation_source = zeros_aes_key; + fnd::aes::sAes128Key nca_header_kek_source = zeros_aes_key; + fnd::aes::sAesXts128Key nca_header_key_source = zeros_aes_xts_key; #define _CONCAT_2_STRINGS(str1, str2) ((str1) + "_" + (str2)) @@ -509,44 +509,44 @@ void UserSettings::populateKeyset(sCmdArgs& args) _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kKeyStr), mKeyset.xci.header_key.key, 0x10); // store rsa keys - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[0]), mKeyset.nca.header_sign_key.priv_exponent, crypto::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[1]), mKeyset.nca.header_sign_key.modulus, crypto::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[0]), mKeyset.nca.header_sign_key.priv_exponent, fnd::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[1]), mKeyset.nca.header_sign_key.modulus, fnd::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[0]), mKeyset.xci.header_sign_key.priv_exponent, crypto::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[1]), mKeyset.xci.header_sign_key.modulus, crypto::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[0]), mKeyset.xci.header_sign_key.priv_exponent, fnd::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[1]), mKeyset.xci.header_sign_key.modulus, fnd::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[0]), mKeyset.acid_sign_key.priv_exponent, crypto::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[1]), mKeyset.acid_sign_key.modulus, crypto::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[0]), mKeyset.acid_sign_key.priv_exponent, fnd::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[1]), mKeyset.acid_sign_key.modulus, fnd::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[0]), mKeyset.package2_sign_key.priv_exponent, crypto::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[1]), mKeyset.package2_sign_key.modulus, crypto::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[0]), mKeyset.package2_sign_key.priv_exponent, fnd::rsa::kRsa2048Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[1]), mKeyset.package2_sign_key.modulus, fnd::rsa::kRsa2048Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[0]), mKeyset.pki.root_sign_key.priv_exponent, crypto::rsa::kRsa4096Size); - _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[1]), mKeyset.pki.root_sign_key.modulus, crypto::rsa::kRsa4096Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[0]), mKeyset.pki.root_sign_key.priv_exponent, fnd::rsa::kRsa4096Size); + _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[1]), mKeyset.pki.root_sign_key.modulus, fnd::rsa::kRsa4096Size); // save keydata from input args if (args.nca_bodykey.isSet) { - if (args.nca_bodykey.var.length() == (sizeof(crypto::aes::sAes128Key)*2)) + if (args.nca_bodykey.var.length() == (sizeof(fnd::aes::sAes128Key)*2)) { - decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesctr.key, sizeof(crypto::aes::sAes128Key)); + decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesctr.key, sizeof(fnd::aes::sAes128Key)); } else { - decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesxts.key[0], sizeof(crypto::aes::sAesXts128Key)); + decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesxts.key[0], sizeof(fnd::aes::sAesXts128Key)); } } if (args.nca_titlekey.isSet) { - if (args.nca_titlekey.var.length() == (sizeof(crypto::aes::sAes128Key)*2)) + if (args.nca_titlekey.var.length() == (sizeof(fnd::aes::sAes128Key)*2)) { - decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesctr.key, sizeof(crypto::aes::sAes128Key)); + decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesctr.key, sizeof(fnd::aes::sAes128Key)); } else { - decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesxts.key[0], sizeof(crypto::aes::sAesXts128Key)); + decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesxts.key[0], sizeof(fnd::aes::sAesXts128Key)); } } @@ -590,12 +590,12 @@ void UserSettings::populateKeyset(sCmdArgs& args) switch (nn::pki::sign::getHashAlgo(tik.getSignature().getSignType())) { case (nn::pki::sign::HASH_ALGO_SHA1): - tik_hash.alloc(crypto::sha::kSha1HashLen); - crypto::sha::Sha1(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); + tik_hash.alloc(fnd::sha::kSha1HashLen); + fnd::sha::Sha1(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); break; case (nn::pki::sign::HASH_ALGO_SHA256): - tik_hash.alloc(crypto::sha::kSha256HashLen); - crypto::sha::Sha256(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); + tik_hash.alloc(fnd::sha::kSha256HashLen); + fnd::sha::Sha256(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data()); break; } @@ -615,7 +615,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) // extract title key if (tik.getBody().getTitleKeyEncType() == nn::es::ticket::AES128_CBC) { - memcpy(mKeyset.nca.manual_title_key_aesctr.key, tik.getBody().getEncTitleKey(), crypto::aes::kAes128KeySize); + memcpy(mKeyset.nca.manual_title_key_aesctr.key, tik.getBody().getEncTitleKey(), fnd::aes::kAes128KeySize); } else { @@ -638,7 +638,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) { if (mKeyset.nca.header_key == zeros_aes_xts_key) { - crypto::aes::sAes128Key nca_header_kek; + fnd::aes::sAes128Key nca_header_kek; nn::hac::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key); nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[0], nca_header_key_source.key[0], nca_header_kek.key); nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[1], nca_header_key_source.key[1], nca_header_kek.key); diff --git a/programs/nstool/source/XciProcess.cpp b/programs/nstool/source/XciProcess.cpp index 9408e42..230b1b9 100644 --- a/programs/nstool/source/XciProcess.cpp +++ b/programs/nstool/source/XciProcess.cpp @@ -183,18 +183,18 @@ void XciProcess::displayHeader() bool XciProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash) { fnd::Vec scratch; - crypto::sha::sSha256Hash calc_hash; + fnd::sha::sSha256Hash calc_hash; scratch.alloc(len); mFile->read(scratch.data(), offset, scratch.size()); - crypto::sha::Sha256(scratch.data(), scratch.size(), calc_hash.bytes); + fnd::sha::Sha256(scratch.data(), scratch.size(), calc_hash.bytes); return calc_hash.compare(test_hash); } void XciProcess::validateXciSignature() { - crypto::sha::sSha256Hash calc_hash; - crypto::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes); - if (crypto::rsa::pkcs::rsaVerify(mKeyset->xci.header_sign_key, crypto::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0) + fnd::sha::sSha256Hash calc_hash; + fnd::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes); + if (fnd::rsa::pkcs::rsaVerify(mKeyset->xci.header_sign_key, fnd::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0) { printf("[WARNING] XCI Header Signature: FAIL \n"); } diff --git a/programs/nstool/source/nstool.h b/programs/nstool/source/nstool.h index 3e2043e..ba36f7a 100644 --- a/programs/nstool/source/nstool.h +++ b/programs/nstool/source/nstool.h @@ -2,8 +2,8 @@ #pragma once #include #include -#include -#include +#include +#include #include static const size_t kMasterKeyNum = 0x20; @@ -63,38 +63,38 @@ struct sOptional struct sKeyset { - crypto::rsa::sRsa2048Key acid_sign_key; - crypto::aes::sAes128Key package1_key[kMasterKeyNum]; - crypto::rsa::sRsa2048Key package2_sign_key; - crypto::aes::sAes128Key package2_key[kMasterKeyNum]; + fnd::rsa::sRsa2048Key acid_sign_key; + fnd::aes::sAes128Key package1_key[kMasterKeyNum]; + fnd::rsa::sRsa2048Key package2_sign_key; + fnd::aes::sAes128Key package2_key[kMasterKeyNum]; struct sNcaData { - crypto::rsa::sRsa2048Key header_sign_key; - crypto::aes::sAesXts128Key header_key; - crypto::aes::sAes128Key key_area_key[kNcaKeakNum][kMasterKeyNum]; + fnd::rsa::sRsa2048Key header_sign_key; + fnd::aes::sAesXts128Key header_key; + fnd::aes::sAes128Key key_area_key[kNcaKeakNum][kMasterKeyNum]; - crypto::aes::sAes128Key manual_title_key_aesctr; - crypto::aes::sAesXts128Key manual_title_key_aesxts; - crypto::aes::sAes128Key manual_body_key_aesctr; - crypto::aes::sAesXts128Key manual_body_key_aesxts; + fnd::aes::sAes128Key manual_title_key_aesctr; + fnd::aes::sAesXts128Key manual_title_key_aesxts; + fnd::aes::sAes128Key manual_body_key_aesctr; + fnd::aes::sAesXts128Key manual_body_key_aesxts; } nca; struct sXciData { - crypto::rsa::sRsa2048Key header_sign_key; - crypto::aes::sAes128Key header_key; + fnd::rsa::sRsa2048Key header_sign_key; + fnd::aes::sAes128Key header_key; } xci; struct sTicketData { - crypto::rsa::sRsa2048Key sign_key; - crypto::aes::sAes128Key titlekey_kek[kMasterKeyNum]; + fnd::rsa::sRsa2048Key sign_key; + fnd::aes::sAes128Key titlekey_kek[kMasterKeyNum]; } ticket; struct sPkiData { - crypto::rsa::sRsa4096Key root_sign_key; + fnd::rsa::sRsa4096Key root_sign_key; } pki; }; From d663efe30bf98179d95446abcccac990a7dcaa8c Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 17:30:00 +0800 Subject: [PATCH 12/16] Update VS Project Files. --- lib/libfnd/libfnd.vcxproj | 19 ++++++++++++++---- lib/libfnd/libfnd.vcxproj.filters | 33 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/lib/libfnd/libfnd.vcxproj b/lib/libfnd/libfnd.vcxproj index ae0fc8a..b7d30e7 100644 --- a/lib/libfnd/libfnd.vcxproj +++ b/lib/libfnd/libfnd.vcxproj @@ -74,7 +74,7 @@ Level3 Disabled true - ..\libfnd\include; + ..\libfnd\include;..\libpolarssl\include;..\liblz4\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -83,7 +83,7 @@ Level3 Disabled true - ..\libfnd\include; + ..\libfnd\include;..\libpolarssl\include;..\liblz4\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -94,7 +94,7 @@ true true true - ..\libfnd\include; + ..\libfnd\include;..\libpolarssl\include;..\liblz4\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -109,7 +109,7 @@ true true true - ..\libfnd\include; + ..\libfnd\include;..\libpolarssl\include;..\liblz4\include; _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -121,7 +121,10 @@ + + + @@ -129,7 +132,10 @@ + + + @@ -137,9 +143,14 @@ + + + + + diff --git a/lib/libfnd/libfnd.vcxproj.filters b/lib/libfnd/libfnd.vcxproj.filters index 5becb28..d13edab 100644 --- a/lib/libfnd/libfnd.vcxproj.filters +++ b/lib/libfnd/libfnd.vcxproj.filters @@ -18,9 +18,18 @@ + + Header Files + + + Header Files + Header Files + + Header Files + Header Files @@ -42,9 +51,18 @@ Header Files + + Header Files + Header Files + + Header Files + + + Header Files + Header Files @@ -62,15 +80,30 @@ + + Source Files + + + Source Files + Source Files Source Files + + Source Files + Source Files + + Source Files + + + Source Files + Source Files From 6b5f90e68341591b3d3241a1255aae6a89775b11 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 17:31:06 +0800 Subject: [PATCH 13/16] [hac|hac-hb] Adds missing includes. --- lib/libhac-hb/source/AssetHeader.cpp | 1 + lib/libhac/include/nn/hac/ContentMetaBinary.h | 1 + lib/libhac/include/nn/hac/NcaHeader.h | 3 --- lib/libhac/include/nn/hac/NroHeader.h | 1 + lib/libhac/include/nn/hac/NsoHeader.h | 1 + lib/libhac/include/nn/hac/PfsHeader.h | 3 --- lib/libhac/include/nn/hac/ServiceAccessControlEntry.h | 3 --- lib/libhac/include/nn/hac/pfs.h | 1 + lib/libhac/source/ApplicationControlPropertyBinary.cpp | 1 + lib/libhac/source/FileSystemAccessControlBinary.cpp | 3 +-- lib/libhac/source/ServiceAccessControlBinary.cpp | 1 + lib/libhac/source/ServiceAccessControlEntry.cpp | 1 + 12 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/libhac-hb/source/AssetHeader.cpp b/lib/libhac-hb/source/AssetHeader.cpp index aab6fe4..666ebe0 100644 --- a/lib/libhac-hb/source/AssetHeader.cpp +++ b/lib/libhac-hb/source/AssetHeader.cpp @@ -1,3 +1,4 @@ +#include #include nn::hac::AssetHeader::AssetHeader() diff --git a/lib/libhac/include/nn/hac/ContentMetaBinary.h b/lib/libhac/include/nn/hac/ContentMetaBinary.h index e742a6f..84f5d9c 100644 --- a/lib/libhac/include/nn/hac/ContentMetaBinary.h +++ b/lib/libhac/include/nn/hac/ContentMetaBinary.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include #include diff --git a/lib/libhac/include/nn/hac/NcaHeader.h b/lib/libhac/include/nn/hac/NcaHeader.h index 5793ed2..0ddbe76 100644 --- a/lib/libhac/include/nn/hac/NcaHeader.h +++ b/lib/libhac/include/nn/hac/NcaHeader.h @@ -55,9 +55,6 @@ namespace hac bool operator==(const NcaHeader& other) const; bool operator!=(const NcaHeader& other) const; - // to be used after export - size_t getSize() const; - // export/import binary void toBytes(); void fromBytes(const byte_t* bytes, size_t len); diff --git a/lib/libhac/include/nn/hac/NroHeader.h b/lib/libhac/include/nn/hac/NroHeader.h index 840563a..7bd33dd 100644 --- a/lib/libhac/include/nn/hac/NroHeader.h +++ b/lib/libhac/include/nn/hac/NroHeader.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include #include diff --git a/lib/libhac/include/nn/hac/NsoHeader.h b/lib/libhac/include/nn/hac/NsoHeader.h index dbf08b6..8fb1c6b 100644 --- a/lib/libhac/include/nn/hac/NsoHeader.h +++ b/lib/libhac/include/nn/hac/NsoHeader.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include #include diff --git a/lib/libhac/include/nn/hac/PfsHeader.h b/lib/libhac/include/nn/hac/PfsHeader.h index f3556f3..828e218 100644 --- a/lib/libhac/include/nn/hac/PfsHeader.h +++ b/lib/libhac/include/nn/hac/PfsHeader.h @@ -69,9 +69,6 @@ namespace hac bool operator==(const PfsHeader& other) const; bool operator!=(const PfsHeader& other) const; - // to be used after export - size_t getSize() const; - // export/import binary void toBytes(); void fromBytes(const byte_t* bytes, size_t len); diff --git a/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h b/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h index cfd999b..72fd1be 100644 --- a/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h +++ b/lib/libhac/include/nn/hac/ServiceAccessControlEntry.h @@ -46,9 +46,6 @@ namespace hac // variables bool mIsServer; std::string mName; - - bool isEqual(const ServiceAccessControlEntry& other) const; - void copyFrom(const ServiceAccessControlEntry& other); }; } } \ No newline at end of file diff --git a/lib/libhac/include/nn/hac/pfs.h b/lib/libhac/include/nn/hac/pfs.h index 4b7d189..60f12fa 100644 --- a/lib/libhac/include/nn/hac/pfs.h +++ b/lib/libhac/include/nn/hac/pfs.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/lib/libhac/source/ApplicationControlPropertyBinary.cpp b/lib/libhac/source/ApplicationControlPropertyBinary.cpp index 14f9125..e8bd9c3 100644 --- a/lib/libhac/source/ApplicationControlPropertyBinary.cpp +++ b/lib/libhac/source/ApplicationControlPropertyBinary.cpp @@ -1,3 +1,4 @@ +#include #include nn::hac::ApplicationControlPropertyBinary::ApplicationControlPropertyBinary() diff --git a/lib/libhac/source/FileSystemAccessControlBinary.cpp b/lib/libhac/source/FileSystemAccessControlBinary.cpp index 81e007f..c8c7e94 100644 --- a/lib/libhac/source/FileSystemAccessControlBinary.cpp +++ b/lib/libhac/source/FileSystemAccessControlBinary.cpp @@ -1,7 +1,6 @@ +#include #include -#include - nn::hac::FileSystemAccessControlBinary::FileSystemAccessControlBinary() { clear(); diff --git a/lib/libhac/source/ServiceAccessControlBinary.cpp b/lib/libhac/source/ServiceAccessControlBinary.cpp index 3aac03d..dd53c27 100644 --- a/lib/libhac/source/ServiceAccessControlBinary.cpp +++ b/lib/libhac/source/ServiceAccessControlBinary.cpp @@ -1,3 +1,4 @@ +#include #include nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary() diff --git a/lib/libhac/source/ServiceAccessControlEntry.cpp b/lib/libhac/source/ServiceAccessControlEntry.cpp index 1e6e7ef..3c7a311 100644 --- a/lib/libhac/source/ServiceAccessControlEntry.cpp +++ b/lib/libhac/source/ServiceAccessControlEntry.cpp @@ -1,3 +1,4 @@ +#include #include nn::hac::ServiceAccessControlEntry::ServiceAccessControlEntry() From 226421f5be138cdaf2829484a49124aea2169765 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 17:33:54 +0800 Subject: [PATCH 14/16] Update VSCode Project files. --- .vscode/c_cpp_properties.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 263f098..f658b73 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -12,8 +12,6 @@ "${workspaceRoot}/lib/libfnd/include", "${workspaceRoot}/lib/libpolarssl/include", "${workspaceRoot}/lib/liblz4/include", - "${workspaceRoot}/lib/libcrypto/include", - "${workspaceRoot}/lib/libcompress/include", "${workspaceRoot}/lib/libes/include", "${workspaceRoot}/lib/libpki/include", "${workspaceRoot}/lib/libhac/include", From 6abb66e6d5ae738cceaf8eec8c7f7fe6b70333e7 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 17:38:31 +0800 Subject: [PATCH 15/16] Fix VS Project file misconfiguration. --- NNTools.sln | 62 ++++++++++++-------------- programs/nstool/nstool.vcxproj | 1 + programs/nstool/nstool.vcxproj.filters | 1 + 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/NNTools.sln b/NNTools.sln index b46668d..346a39a 100644 --- a/NNTools.sln +++ b/NNTools.sln @@ -4,22 +4,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 15.0.27428.2015 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{170B4A09-1B67-4A62-93AB-116EBCFF4A8C}" - ProjectSection(SolutionItems) = preProject - lib\makefile = lib\makefile - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Programs", "Programs", "{E0863FCC-8E72-490D-BE1B-458F12CA8298}" - ProjectSection(SolutionItems) = preProject - programs\makefile = programs\makefile - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8F6C846D-35E2-47FD-AF42-7A3FD036346E}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + LICENSE = LICENSE makefile = makefile README.md = README.md SWITCH_KEYS.md = SWITCH_KEYS.md - LICENSE = LICENSE EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\libfnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" @@ -70,30 +64,6 @@ Global {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.Build.0 = Release|x64 {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.ActiveCfg = Release|Win32 {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.Build.0 = Release|Win32 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.ActiveCfg = Debug|x64 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.Build.0 = Debug|x64 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.ActiveCfg = Debug|Win32 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.Build.0 = Debug|Win32 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.ActiveCfg = Release|x64 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.Build.0 = Release|x64 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.ActiveCfg = Release|Win32 - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.Build.0 = Release|Win32 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.ActiveCfg = Debug|x64 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.Build.0 = Debug|x64 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.ActiveCfg = Debug|Win32 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.Build.0 = Debug|Win32 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.ActiveCfg = Release|x64 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32 - {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.ActiveCfg = Debug|x64 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.Build.0 = Debug|x64 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.ActiveCfg = Debug|Win32 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.Build.0 = Debug|Win32 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.ActiveCfg = Release|x64 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.Build.0 = Release|x64 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.ActiveCfg = Release|Win32 - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.Build.0 = Release|Win32 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x64.ActiveCfg = Debug|x64 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x64.Build.0 = Debug|x64 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x86.ActiveCfg = Debug|Win32 @@ -102,6 +72,30 @@ Global {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x64.Build.0 = Release|x64 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x86.ActiveCfg = Release|Win32 {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x86.Build.0 = Release|Win32 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.ActiveCfg = Debug|x64 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.Build.0 = Debug|x64 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.ActiveCfg = Debug|Win32 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.Build.0 = Debug|Win32 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.ActiveCfg = Release|x64 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32 + {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.ActiveCfg = Debug|x64 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.Build.0 = Debug|x64 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.ActiveCfg = Debug|Win32 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.Build.0 = Debug|Win32 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.ActiveCfg = Release|x64 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.Build.0 = Release|x64 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.ActiveCfg = Release|Win32 + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.Build.0 = Release|Win32 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.ActiveCfg = Debug|x64 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.Build.0 = Debug|x64 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.ActiveCfg = Debug|Win32 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.Build.0 = Debug|Win32 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.ActiveCfg = Release|x64 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.Build.0 = Release|x64 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.ActiveCfg = Release|Win32 + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.Build.0 = Release|Win32 {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64 {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64 {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32 @@ -118,10 +112,10 @@ Global {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {B9113734-6E84-44FF-8CF7-58199AA815C5} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} + {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/programs/nstool/nstool.vcxproj b/programs/nstool/nstool.vcxproj index 8e10e2d..882f63e 100644 --- a/programs/nstool/nstool.vcxproj +++ b/programs/nstool/nstool.vcxproj @@ -175,6 +175,7 @@ + diff --git a/programs/nstool/nstool.vcxproj.filters b/programs/nstool/nstool.vcxproj.filters index 3d906bf..2227147 100644 --- a/programs/nstool/nstool.vcxproj.filters +++ b/programs/nstool/nstool.vcxproj.filters @@ -16,6 +16,7 @@ + From d4d0358352cd0e32742ab31f6f657f09ea837841 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 7 Aug 2018 17:48:19 +0800 Subject: [PATCH 16/16] misc --- NNTools.sln | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/NNTools.sln b/NNTools.sln index 346a39a..3abe916 100644 --- a/NNTools.sln +++ b/NNTools.sln @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution SWITCH_KEYS.md = SWITCH_KEYS.md EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\libfnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "lib\libpolarssl\libpolarssl.vcxproj", "{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}" @@ -30,8 +32,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac", "lib\libhac\libhac EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac-hb", "lib\libhac-hb\libhac-hb.vcxproj", "{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -40,6 +40,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.Build.0 = Debug|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.ActiveCfg = Release|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.Build.0 = Release|x64 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.ActiveCfg = Release|Win32 + {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.Build.0 = Release|Win32 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x64.ActiveCfg = Debug|x64 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x64.Build.0 = Debug|x64 {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x86.ActiveCfg = Debug|Win32 @@ -96,19 +104,12 @@ Global {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.Build.0 = Release|x64 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.ActiveCfg = Release|Win32 {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.Build.0 = Release|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.Build.0 = Debug|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.ActiveCfg = Release|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.Build.0 = Release|x64 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.ActiveCfg = Release|Win32 - {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} @@ -116,7 +117,6 @@ Global {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C} - {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {07DCCACC-D10D-47C9-85AE-FB9C54DB7D62}