Commit graph

521 commits

Author SHA1 Message Date
Alex Barney
be55aa7e9c Add BaseFileSystemService 2020-10-14 14:48:34 -07:00
Alex Barney
9f81b933e8 KeySet.DeriveKeys now derives both sets automatically 2020-10-13 21:34:08 -07:00
Alex Barney
9bb2c3a843 Support more key parser situations
Support comments, ignoring lines that are too long, properly reading the last line in a file. Probably some bug fixes too.
2020-10-13 20:55:48 -07:00
Alex Barney
b6499a6c12 Rename IsEmpty to IsZeros
Renames the IsEmpty() functions that check if an array is all zeros. This helps avoid confusion because Span has an IsEmpty property that returns true if the span's length is 0.

The change actually revealed a tiny bug in KeyDerivation where the property was accidentally used instead of the function.
2020-10-11 23:47:26 -07:00
Alex Barney
c39895080b hactoolnet: Always read both prod and dev key sets 2020-10-11 22:25:02 -07:00
Alex Barney
8f011387a0 Improve key parser performance a bit 2020-10-11 01:26:43 -07:00
Alex Barney
b5dabe78f5 Replace hex string converter and move StringUtils 2020-10-10 20:17:07 -07:00
Alex Barney
a9632c8d00 Rewrite the key file parser 2020-10-10 17:19:40 -07:00
Alex Barney
fa79db2285 Split ExternalKeyReader 2020-10-07 17:54:29 -07:00
Alex Barney
bac541947f Embed key sources in the library
Embedded keys are generated at build-time from the IncludedKeys.txt file under the build directory.

A separate codegen build project was created because generating the embedded keys requires the same LibHac that is being built.

_buildCodeGen.csproj is located under CodeGen because NUKE doesn't like having two build projects in the same directory.
2020-10-06 22:18:34 -07:00
Alex Barney
770406e9c2 Remove the old Keyset class 2020-10-05 12:25:39 -07:00
Alex Barney
e3bb1f1fac Allow reading dev keys from key files 2020-10-05 01:26:54 -07:00
Alex Barney
7a7cded4f2 Add RSA keys 2020-10-04 20:18:30 -07:00
Alex Barney
333ef8729f Fix RSA regression from 5f755bc7 and add a test 2020-10-02 01:33:44 -07:00
Alex Barney
f7030aef4f Add a new KeySet class 2020-10-01 18:06:32 -07:00
Alex Barney
61ce892697 Rewrite the Package1 class, updating it to handle newer package1s 2020-09-28 01:18:15 -07:00
Alex Barney
49711b12db Tweaks and cleanup for PR #164
- Fully span-ify CalculateCmac and update callers.
- Modify CalculateCmac signature to match Nintendo's.
- Avoid doing stackalloc based on an input length parameter.
- Use ReadOnlySpan instead of Span where appropriate.
- Standardize XML comments to use triple slashes.
- Make use of the entire rented buffer when copying.

Unrelated to the PR
- Slip in a missed enum to string conversion in hactoolnet for CoreRT reflection-free mode.
2020-09-05 21:10:39 -07:00
Xpl0itR
265147b678
Changes to CryptoOld
- Remove AES functions and replace references with functions from the Crypto.Aes class
- Edit and move the AES-CMAC function into the Crypto.Aes class
- Move BigInteger functions to the Utilities class
- Reduce duplication between the RSA functions
- Edit and move the Rsa parameter recovery function into the Crypto.Rsa class
2020-09-02 19:09:27 +01:00
Xpl0itR
49a8ffd3e2
Expose bufferSize as a variable in CopyTo and CopyToStream 2020-08-30 10:32:52 +01:00
Xpl0itR
771663786d
Use LibHac's RentedArray<T> struct 2020-08-30 10:32:52 +01:00
Alex Barney
d138a52d06 Add some docs for EmulatedBisFileSystemCreator 2020-08-29 21:53:45 -07:00
Alex Barney
30f306f637 Add additional documentation to the access control classes 2020-08-26 17:10:12 -07:00
Alex Barney
4552a2d94f Add permission checks to DeleteSaveDataFileSystem 2020-08-26 17:10:12 -07:00
Alex Barney
1f25b87d20 Add RegisterProgramIndexMapInfo shim and tests 2020-08-26 17:10:12 -07:00
Alex Barney
6496a2c1bc Honor permissions in OpenFileSystemWithId. Add basic AC test 2020-08-26 17:10:12 -07:00
Alex Barney
3184e6ca7e Add IFileSystemProxyForLoader and IProgramRegistry interfaces 2020-08-26 17:10:12 -07:00
Alex Barney
071b608f5f Tweak how the Horizon class and service manager work
- Store IServiceObjects in the service manager that return the usable objects instead of storing the objects directly
- Register FS services in the service manager instead of giving them special treatment
- Give each created HorizonClient its own "process ID"
2020-08-26 17:10:12 -07:00
Alex Barney
deaf111ac3 Add functions to ProgramRegistryService
Adds RegisterProgramIndexMapInfo and GetProgramIndexForAccessLog to both FileSystemProxy and ProgramRegistryService
2020-08-26 17:10:12 -07:00
Alex Barney
0b050d2189 Add ProgramIndexMapInfoManager 2020-08-26 17:10:12 -07:00
Alex Barney
004e46cacc Add the program registry 2020-08-26 17:10:12 -07:00
Alex Barney
76d21263da Add AccessControl 2020-08-26 17:10:12 -07:00
Alex Barney
3a3c4822be hactoolnet: Remove use of enum reflection 2020-08-19 11:07:28 -07:00
Alex Barney
2242fc6371 Miscellaneous code style cleanup 2020-08-18 21:47:46 -07:00
Alex Barney
71824f06dc Fixes in Nca and U8Span 2020-08-17 19:23:30 -07:00
Alex Barney
f2f2111729 hactoolnet: Add functions to convert some enums to strings 2020-08-17 19:23:30 -07:00
Alex Barney
a005b40022 Build updates
Use the version in the .csproj if there is no local git repository.
Always use Windows line endings in codegen output.
Update build dependency versions. We're still using GitVersion 5.1.3 because of https://github.com/nuke-build/nuke/issues/509.
2020-08-15 23:34:48 -07:00
Alex Barney
30273bf3ef Avoid false positives in detection of unencrypted NCAs 2020-08-15 17:13:28 -07:00
Alex Barney
a07e17c369 Make file option struct constructors public. 2020-08-14 23:40:03 -07:00
Alex Barney
f20337d774 Add support for NCA0 files.
Any operation that is supported with other NCAs is supported NCA0s. This includes reading both encrypted and decrypted NCA0s, and encrypting and decrypting NCA0s.
2020-08-14 22:09:11 -07:00
Alex Barney
6bab1d9273 Support extracting INI binaries embedded in the kernel 2020-08-12 14:27:58 -07:00
Alex Barney
8491ec2117 Add Package2StorageReader and InitialProcessBinaryReader 2020-08-12 14:27:58 -07:00
Alex Barney
81340027fc Rename FsService to FsSrv 2020-08-07 18:32:01 -07:00
Alex Barney
24ba7c6b5b Set the next version to 0.12.0 2020-08-07 10:22:14 -07:00
Alex Barney
9e57cc174e Add documentation for SaveDataIndexer and related classes 2020-08-07 10:02:50 -07:00
Alex Barney
c1b9eb8903 Change ref to in where possible in SaveDataIndexer and kvdb 2020-08-07 10:02:50 -07:00
Alex Barney
d575415b0e Remove the old KeyValueDatabase 2020-08-07 10:02:50 -07:00
Alex Barney
a551360da0 Use FlatMapKeyValueStore in SaveDataIndexer
FS 10.0 tweaks how the SaveDataIndexerManager is accessed. SaveDataFileSystemServiceImpl's configuration now includes an ISaveDataIndexerManager instead of using global state.

FS 10.0 uses the new nn::fssrv::storage namespace for abstracting the interface to nn::gc and nn::sdmmc. A tiny bit of the namespace has been added so we can create mock SD card handles for SaveDataIndexerManager.

ReferenceCountedDisposable<T> is now being used for returning ISaveDataInfoReader objects from IFileSystemProxy. I've tried coming up with a pattern to cleanly return a ReferenceCountedDisposable<T>, but the lack of features like RAII or move semantics makes this difficult without either lots of allocations or lots of boilerplate code.
2020-08-07 10:02:50 -07:00
Alex Barney
37251968c0 Add FlatMapKeyValueStore with tests 2020-08-07 10:02:50 -07:00
Alex Barney
672a0016b3 Use "in" instead of "ref" for read-only SpanHelper methods 2020-08-07 10:02:50 -07:00
Alex Barney
717e54fe4e Rename TitleId to ProgramId and add other NCM ID types 2020-08-07 10:02:50 -07:00
Alex Barney
3819cfdca7 Flesh out NCA encryption
Allows opening decrypted NCAs.
Allows opening encrypted and decrypted storages of any NCA, whether encrypted or decrypted.
hactoolnet: Allow saving an encrypted version of any NCA.
2020-07-24 22:41:45 -07:00
Xpl0itR
e0ddf17945 Implement function in NCA class to re-encrypt decrypted NCAs 2020-07-24 22:41:45 -07:00
leo60228
c56c8ba8ed Include title ID in --listapps when possible 2020-07-24 15:35:20 -07:00
Alex Barney
7dd21ae05b SubStorage in AesXtsFile should be resizable 2020-07-06 11:43:48 -07:00
Alex Barney
d04e713356 Add some docs to SubStorage 2020-07-06 11:43:48 -07:00
Alex Barney
d7ae809cf3 Add TruncatedSubStorage 2020-07-06 11:43:48 -07:00
Alex Barney
e9c38dc7ba Remove old SubStorage 2020-07-06 11:43:48 -07:00
Alex Barney
f02c84e8dd Add ReferenceCountedDisposable<T>
This class is meant to be used in the same types of places std::shared_ptr is used but with manual instead of automatic ref counting.

SubStorage now uses the class to optionally dispose its base storage object.
2020-07-06 11:43:48 -07:00
Alex Barney
b6eac5ddb5 Rename Util class to Utilities
Preparation to split it up into the Util namespace and to add nn::util code
2020-07-06 11:43:48 -07:00
Alex Barney
88983d39e5 Remove use of code that involves reflection
This allows over 40% of the CoreRT native binary size to be removed by removing reflection capabilities.

The "--noreflection" option for the build script can be used to build hactoolnet with no reflection.

The Linux build won't always work because creating a new thread for the progress bar runs into some issue with EventSource being removed.
2020-06-27 16:28:32 -07:00
Alex Barney
83dc874df1 Rent arrays in BucketTree.Visitor 2020-06-26 09:11:06 -07:00
Alex Barney
33b414a15c Remove old BucketTree 2020-06-25 20:50:54 -07:00
Alex Barney
d3abdeacc4 Use the new BucketTree in Aes128CtrExStorage 2020-06-25 19:03:51 -07:00
Alex Barney
33af34cefc Rewrite IndirectStorage 2020-06-25 15:26:55 -07:00
Alex Barney
c2247e583f Address compiler warnings 2020-06-19 22:01:22 -07:00
Alex Barney
4b4b354a7e Use IStorage for the bucket tree builder instead of Spans 2020-06-19 22:01:22 -07:00
Alex Barney
9589f681a6 Add a bucket tree builder 2020-06-19 22:01:22 -07:00
Alex Barney
0c06d9e0b3 Implement most of Nintendo's bucket tree code 2020-06-19 22:01:22 -07:00
Alex Barney
9ec00eed3b
Merge pull request #146 from Thealexbarney/fs-classes
Change the file system accessor interfaces to abstract classes
2020-06-14 20:19:56 -07:00
Alex Barney
395fabd171 Make IStorage an abstract class 2020-06-13 00:37:21 -07:00
Alex Barney
49d42c5d1f Fix some checks being ignored in savedata classes
- Return an error when an allocation table seek fails
- Fix a copy/paste bug to properly error when resizing an AllocationTableStorage with not enough free space
2020-06-10 16:27:43 -07:00
Alex Barney
106c36492b Move IFileSystem etc. into fsa namespace 2020-06-09 22:55:59 -07:00
Alex Barney
ef1481b04c Replace old fsa classes with new ones 2020-06-07 15:23:51 -07:00
Alex Barney
ba1bf2f1c8 Add XML docs 2020-06-07 00:05:33 -07:00
Alex Barney
7c9584a6af Add new IFileSystem and IDirectory 2020-06-06 22:48:20 -07:00
Alex Barney
dd54249125 Rename FileBase "Impl" methods 2020-06-06 15:20:02 -07:00
Alex Barney
e1ff89060c Add new IFile 2020-06-06 15:18:50 -07:00
Alex Barney
064da36453 Rename old IFile option enums 2020-06-06 14:18:03 -07:00
Alex Barney
8c61820e46 Increment version to 0.11.3 and apply "var" code style 2020-06-05 22:59:00 -07:00
Alex Barney
5dd1ed2687 hactoolnet: Allow listing an XCI's program RomFS files 2020-06-05 22:32:16 -07:00
Alex Barney
13648b4cec
Merge pull request #140 from Thealexbarney/build-ver-fix
Fix a logic error in the build script loader and update MyGet publishing
2020-06-04 11:27:26 -07:00
Alex Barney
3de2a4b90b Update MyGet package publishing 2020-06-04 11:17:30 -07:00
Alex Barney
dfb2560707 Fix ini1 reading and fix a blz decompression bug 2020-06-04 01:09:27 -07:00
Alex Barney
a59dc611c2 Don't timeout when ensuring a local FS entry is deleted 2020-06-02 23:32:50 -07:00
Xpl0itR
2171f2ae21 Update Calibration 2020-06-02 21:15:45 -07:00
Alex Barney
99f6a0054b Version 0.11.2 2020-05-12 19:23:05 -07:00
Alex Barney
8d5e24d061 Ensure csv column counts are consistent 2020-05-12 19:02:48 -07:00
Alex Barney
cb8b088487
Misc additions and warning fixes (#134)
* Run codegen and fix DeliveryCacheFileMetaEntry layout

* Use KipReader instead of Kip

* Ensure feature parity between U8String structs

* Don't use the obsolete Nacp class

* Add some null checks

* Address ReSharper warnings

* The Result structs should be readonly
2020-05-12 17:06:55 -07:00
Alex Barney
44e4c7a311
Add some fssystem utility functions and use them in DirectorySaveDataFileSystem (#133)
* Accurately implement DirectorySaveDataFileSystem

* DirectorySaveDataFileSystem updates from FS 10.0
2020-05-12 13:17:06 -07:00
Alex Barney
0188c4579c Update version to 0.11.1 2020-04-30 14:21:34 -07:00
Alex Barney
32405fee5f Add EnumerateDeliveryCacheDirectory 2020-04-30 14:08:31 -07:00
Alex Barney
1974adb33e Don't use in-place decompression for NSOs
Move back to using in-place decompression in the future when the decompress function has been fixed
2020-04-28 23:03:33 -07:00
Alex Barney
fdf11b2621
Merge pull request #129 from Thealexbarney/bcat-storage
Implement BCAT delivery cache access

- Add BCAT delivery cache reading services
- Add methods to `U8StringBuilder` for writing formatted values
- Add a `HorizonClient` class which mimics nnsdk from Horizon
- Add a simple service manager that tracks registered objects
2020-04-28 22:54:58 -07:00
Alex Barney
be29ad714f Add the option to initialize Horizon with a FileSystemServer 2020-04-24 11:35:04 -07:00
Alex Barney
e80be498e5 Add a simple service manager and HorizonClient class
Modifies bdat to use the HorizonClient and adds an ArpClient. The arp server still needs to be provided.
2020-04-23 17:49:15 -07:00
Alex Barney
9b1ced7d3b Small tweaks to U8StringBuilder 2020-04-22 13:47:01 -07:00
Alex Barney
f3452bb314 BCAT fixes. Tweak how U8StringBuilder is used 2020-04-11 22:18:43 -07:00
Alex Barney
6e4372ce58 Implement DeliveryCacheDirectoryService 2020-04-10 11:31:46 -07:00
Alex Barney
ef36568a8d Implement DeliveryCacheFileService and supporting code 2020-04-10 10:54:37 -07:00
Alex Barney
939c495db6 Add U8StringBuilder format options 2020-04-10 10:49:44 -07:00