Commit Graph

89 Commits

Author SHA1 Message Date
bunnei
2409fedacf
Merge pull request #3697 from lioncash/declarations
CMakeLists: Enable -Wmissing-declarations on Linux builds
2020-04-23 02:18:52 -04:00
Lioncash
e2d8be1ca2 General: Resolve warnings related to missing declarations 2020-04-16 23:43:34 -04:00
Lioncash
8f9c599c9f key_manager: Resolve missing field initializer warning 2020-04-16 22:45:44 -04:00
bunnei
3e0e4f146b
Merge pull request #3091 from lioncash/core-conversion
core: Make most implicit type conversion warnings errors on MSVC
2019-11-15 12:08:50 -05:00
bunnei
360b0d1b30
Merge pull request #3093 from lioncash/mbedtls
core: Migrate off deprecated mbedtls functions
2019-11-14 13:47:23 -05:00
Lioncash
64cbebc58f key_manager: Make use of IOFile in WriteKeyToFile()
This properly handles unicode-based paths on Windows, while opening a
raw stream doesn't out-of-the-box.

Prevents file creation from potentially failing on Windows PCs that make
use of unicode characters in their save paths (e.g. writing to a user's
AppData folder, where the user has a name with non-ASCII characters).
2019-11-12 08:52:18 -05:00
Lioncash
e0c46e6879 core: Migrate off deprecated mbedtls functions
These functions are marked for deprecation and it's recommended that the
*_ret variants be used instead.
2019-11-12 08:45:56 -05:00
Lioncash
47a6bb2d5b externals: Update httplib
Since the introduction of this library, numerous improvements have been
made. Notably, many of the warnings we would get by simply including the
library header have now been fixed. This makes it much easier to make
conversion warning an error.
2019-11-12 08:31:27 -05:00
Lioncash
581d2e36e5 crypto: Resolve sign-conversion warnings 2019-11-12 07:55:22 -05:00
vperus
29b1d0db0f [crypto] Use IsAllZeroArray helper function 2019-10-02 19:20:45 +03:00
Zach Hilman
b4164d295b partition_data_manager: Add accessor for decrypted PRODINFO partition 2019-09-21 16:43:10 -04:00
Zach Hilman
50d5414075 key_manager: Convert Ticket union to std::variant 2019-07-07 21:38:33 -04:00
Zach Hilman
d9ef20e5a5 es: Populate/synthesize tickets on construction 2019-07-07 21:38:33 -04:00
Zach Hilman
f8718ae779 key_manager: Add structure for Ticket parsing 2019-07-07 21:38:33 -04:00
Zach Hilman
e35fac2054 key_manager: Add accessors/helpers for ticket management 2019-07-07 21:38:33 -04:00
Zach Hilman
5275fd2789 key_manager: Add equality operator for RSAKeyPair 2019-07-07 21:38:33 -04:00
bunnei
e2f7933b3f
Merge pull request #2546 from DarkLordZach/kips
loader, file_sys: Add support for parsing and loading KIP (Kernel Internal Process) files
2019-06-21 14:28:18 -04:00
Lioncash
a62088539e
common/hex_util: Combine HexVectorToString() and HexArrayToString()
These can be generified together by using a concept type to designate
them. This also has the benefit of not making copies of potentially very
large arrays.
2019-06-12 17:54:05 -04:00
Zach Hilman
0f37096820 partition_data_manager: Remove KIP processing and use FileSys
Previously, this TU contained the necessary headers to parse KIP/INI but now it should just use the FileSys class.
2019-06-05 00:19:29 -04:00
Zach Hilman
60f39060c6 core: Port current uses of RegisteredCache to ContentProvider 2019-03-26 22:05:37 -04:00
Jungy
3273f93cd5 Fixes Unicode Key File Directories (#2120)
* Fixes Unicode Key File Directories

Adds code so that when loading a file it converts to UTF16 first, to
ensure the files can be opened. Code borrowed from FileUtil::Exists.

* Update src/core/crypto/key_manager.cpp

Co-Authored-By: Jungorend <Jungorend@users.noreply.github.com>

* Update src/core/crypto/key_manager.cpp

Co-Authored-By: Jungorend <Jungorend@users.noreply.github.com>

* Using FileUtil instead to be cleaner.

* Update src/core/crypto/key_manager.cpp

Co-Authored-By: Jungorend <Jungorend@users.noreply.github.com>
2019-02-20 21:24:25 -05:00
bunnei
173073c722
Merge pull request #1836 from lioncash/unused
crypto/key_manager: Remove unused variable in GetTicketblob()
2018-12-04 18:28:15 -05:00
Lioncash
db4523f1ec filesystem: De-globalize registered_cache_union
We can just return a new instance of this when it's requested. This only
ever holds pointers to the existing registed caches, so it's not a large
object. Plus, this also gets rid of the need to keep around a separate
member function just to properly clear out the union.

Gets rid of one of five globals in the filesystem code.
2018-12-01 23:43:23 -05:00
Lioncash
a8aca4306d crypto/key_manager: Remove unused variable in GetTicketblob() 2018-12-01 22:37:51 -05:00
Frederic L
7a5eda5914 global: Use std::optional instead of boost::optional (#1578)
* get rid of boost::optional

* Remove optional references

* Use std::reference_wrapper for optional references

* Fix clang format

* Fix clang format part 2

* Adressed feedback

* Fix clang format and MacOS build
2018-10-30 00:03:25 -04:00
Zach Hilman
1fa31cf74d key_manager: Use isxdigit instead of isdigit when reading key file
Crypto revisions are hex numbers and this function only checks if the string is valid for stoul in base 16, so it should be isxdigit.
2018-10-27 21:56:10 -04:00
Lioncash
c6529688fc
key_manager: Remove unused variable in DeriveBase() 2018-10-24 00:00:12 -04:00
Zach Hilman
0aef2b9c26 crypto: Use compressed sizes in offset calculation for KIP decompression
Fixes a fatal crash on start when deriving keys.
2018-10-19 18:37:58 -04:00
Zach Hilman
720d36ca71 crypto: Various crypto fixes for quickstart guide 2018-10-14 21:57:52 -04:00
Lioncash
6467b01de2 partition_data_manager: Reserve and insert data within output vector in DecryptPackage2()
We can just reserve the memory then perform successive insertions
instead of needing to use memcpy. This also avoids the need to zero out
the output vector's memory before performing the insertions.

We can also std::move the output std::vector into the destination so
that we don't need to make a completely new copy of the vector, getting
rid of an unnecessary allocation.

Additionally, we can use iterators to determine the beginning and end
ranges of the std::vector instances that comprise the output vector, as
the end of one range just becomes the beginning for the next successive
range, and since std::vector's iterator constructor copies data within
the range [begin, end), this is more straightforward and gets rid of the
need to have an offset variable that keeps getting incremented to
determine where to do the next std::memcpy.
2018-10-13 09:50:08 -04:00
Lioncash
781fd7983c partition_data_manager: Remove unused std::map instance within DecryptPackage2()
Aside from emplacing elements into the map, the map itself is never
actually queried for contained data.
2018-10-13 09:27:12 -04:00
Lioncash
e0c76226ad partition_data_manager: Take package2_keys by const reference
These are only ever read from, so we don't need to make a copy of all
the keys here.
2018-10-13 09:24:41 -04:00
Lioncash
3d9df49619 partition_data_manager: Move IV data to where it's needed in DecryptPackage2()
Given it's only used in one spot and has a fairly generic name, we can
just specify it directly in the function call. This also the benefit of
automatically moving it.
2018-10-13 09:20:21 -04:00
Lioncash
bc2196bb09 partition_data_manager: Remove commented out code
Commented out code shouldn't be left in without a reason indicating why
in a comment.
2018-10-13 09:17:02 -04:00
Lioncash
6da2ed4232 key_manager/partition_data_manager: Silence truncation compiler warnings 2018-10-13 09:13:19 -04:00
Lioncash
f56a8da46a partition_data_manager: Dehardcode array bounds
Instead, we can make it part of the type and make named variables for
them, so they only require one definition (and if they ever change for
whatever reason, they only need to be changed in one spot).
2018-10-13 08:52:37 -04:00
Lioncash
d257a3b56c partition_data_manager: Take VirtualFile by const reference in constructor
Given the VirtualFile instance isn't stored into the class as a data
member, or written to, this can just be turned into a const reference,
as the constructor doesn't need to make a copy of it.
2018-10-13 08:39:05 -04:00
Lioncash
e96d69c328 partition_data_manager: Amend constructor initializer list order
Orders the members in the exact order they would be initialized. This
also prevents compiler warnings about this sort of thing.
2018-10-13 08:36:26 -04:00
Lioncash
aaca7543f0 partition_data_manager: Remove unused includes
Gets unused includes out of the headers and moves them into the cpp file
if they're used there instead.
2018-10-13 08:33:49 -04:00
Lioncash
06898263f6 key_manager: Use std::vector's insert() instead of std::copy with a back_inserter
If the data is unconditionally being appended to the back of a
std::vector, we can just directly insert it there without the need to
insert all of the elements one-by-one with a std::back_inserter.
2018-10-13 08:29:35 -04:00
Lioncash
e70c08b543 key_manager: Brace long conditional body
If a conditional (or it's body) travels more than one line, it should be
braced.
2018-10-13 08:24:21 -04:00
Lioncash
ef5639bfbb key_manager: Don't assume file seeks and reads will always succeed
Given the filesystem should always be assumed to be volatile, we should
check and bail out if a seek operation isn't successful. This'll prevent
potentially writing/returning garbage data from the function in rare
cases.

This also allows removing a check to see if an offset is within the
bounds of a file before perfoming a seek operation. If a seek is
attempted beyond the end of a file, it will fail, so this essentially
combines two checks into one in one place.
2018-10-13 08:24:18 -04:00
Lioncash
82ea1cf35a key_manager: Remove unnecessary seek in DeriveSDSeed()
Given the file is opened a few lines above and no operations are done,
other than check if the file is in a valid state, the read/write pointer
will always be at the beginning of the file.
2018-10-13 08:08:44 -04:00
Zach Hilman
3ec054643e partition_data_manager: Rename system files for hekate
x
2018-10-07 13:16:23 -04:00
Zach Hilman
29dc6f4519 crypto: Add PartitionDataManager
Keeps track of system files for key derivation
2018-10-07 13:15:11 -04:00
Zach Hilman
4aad010f7a key_manager: Add support for loading keys from partition data 2018-10-07 13:15:11 -04:00
Zach Hilman
d041d6231c key_manager: Add ETicket key derivation
Derives titlekeys
2018-10-07 13:15:11 -04:00
Zach Hilman
a57aac5772 key_manager: Add base key derivation
Derives master keys, game encryption keys, and package1/2 keys
2018-10-07 13:15:11 -04:00
Zach Hilman
d7398283e3 key_manager: Add BIS key getter 2018-10-07 13:15:11 -04:00
Zach Hilman
d6a0d5d432 key_manager: Add support for more keys
TSEC, SBK, BIS, and other Sources for proper derivation
2018-10-07 13:15:11 -04:00