Commit Graph

387 Commits

Author SHA1 Message Date
David Korth
81ebf5a03d [wadresign] resource.rc: Updated for wadresign. 2019-03-07 20:29:50 -05:00
David Korth
6e5bd84957 [wadresign] librvth isn't used here. 2019-03-07 20:29:13 -05:00
David Korth
c02fd5b4b0 [wadresign] Use macros for the various buffer sizes and maximum sizes. 2019-03-07 20:22:08 -05:00
David Korth
851c7b76db [wadresign] resign-wad.c: Copy the footer, or name for early devkit WADs.
Maximum size of 128 KB.

Added some likely() and unlikely() hints.
2019-03-07 20:18:35 -05:00
David Korth
06ea34f6de [wadresign] resign-wad.c: s/fseek(/fseeko(/g, again. 2019-03-07 20:12:26 -05:00
David Korth
96eac4b247 [wadresign] resign-wad.c: Convert early WAD headers to the standard format. 2019-03-07 20:10:43 -05:00
David Korth
0e78170c20 [libwiicrypto] wii_structs.h: Added content type bits.
TODO: Use these somewhere.
2019-03-07 02:00:15 -05:00
David Korth
bf046fdc3c [wadresign] print-info.c: Implement SHA-1 verification.
The contents are verified and compared, and both the expected and
actual SHA-1s are printed. If any of the SHA-1s fail, an error code
is returned.

The previous commit, which fixed data copying, was committed before
this commit, though I had already written the SHA-1 code. That's how
I found out the data copying was broken: SHA-1s in the resigned WADs
were completely broken, even though the originals were fine.

TODO: Check how block alignment works with early devkit WADs.
2019-03-07 01:58:22 -05:00
David Korth
631bdd4966 [wadresign] resign-wad.c: Seek to the start of the data area before copying.
Otherwise, we end up copying junk, resulting in a completely broken
WAD file.
2019-03-07 01:53:41 -05:00
David Korth
842a303ceb [wadresign] resign-wad.c: Fix certificate chain ordering; fix retail/debug copy/paste error.
The WADs actually use CA/TMD/Ticket ordering, not CA/Ticket/TMD.

Fixed a copy/paste issue that caused debug certificates to be used
when resigning to retail.
2019-03-07 01:47:37 -05:00
David Korth
a6e11afe3e [libwiicrypto] sig_tools.c: Explicitly specify "title key", not just "key". 2019-03-07 01:32:58 -05:00
David Korth
6b08e86582 [wadresign] print-info.c: More preparations for the 'verify' command.
- Determine the key to use when getting the ticket and
  TMD issuers.

- Moved the invalid common key index warning from resign_wad()
  to print_wad_info().

- New verify_content() function that doesn't do anything yet.
2019-03-07 01:31:58 -05:00
David Korth
21f45eb360 [wadresign] print-info.c: Print the contents table.
This is the initial step towards adding the new 'verify' command, which
will verify the SHA-1 of each content entry.
2019-03-07 01:16:10 -05:00
David Korth
80345ed8b5 [wadresign] resign-wad.c: Indicate the From and To keys.
The To keys are indicated as fakesigned for retail and Korean.
2019-03-07 01:01:03 -05:00
David Korth
ab09ff38ab [wadresign] resign-wad.c: Copy the data and align to 64 bytes.
This should be enough for basic testing.

TODO:
- Copy the footer.
- Handle early devkit WADs properly.
2019-03-07 00:56:00 -05:00
David Korth
d623c0d905 [wadresign] resign-wad.c: Resign the TMD. 2019-03-07 00:28:26 -05:00
David Korth
d099828962 [wadresign] resign-wad.c: Recrypt and resign the ticket. 2019-03-07 00:15:40 -05:00
David Korth
f09261ae7b [wadresign] Initial 'resign' command implementation.
Currently writes the WAD header and certificate chain, including the
extra debug certificate if recrypting as debug.

TODO:
- Write the extra debug certificate when recrypting discs.
- Verify certificate chain ordering for discs. For WADs, it's
  CA, ticket, TMD, dev; for discs, it seems to be ticket, CA, TMD.
- Convert early WAD headers to final. This also requires converting
  the name, if present, to a footer.
2019-03-06 23:58:00 -05:00
David Korth
6088b79dde [librvth] recrypt.cpp: Actually fix the ALIGN() issue.
It seems that offsetof() has too many ampersands in MSVC 2010.
Move the ALIGN() macro to a separate line.
2019-03-06 23:16:28 -05:00
David Korth
91f44c4acf [libwiicrypto] common.h: Added spaces to the ALIGN() macros.
It seems that without the spaces, use of ALIGN() with offsetof() causes
an error in MSVC 2010:

..\..\..\src\librvth\recrypt.cpp(563): error C2102: '&' requires l-value
2019-03-06 23:12:37 -05:00
David Korth
6197cdf804 [wadresign] print-info.c: Actually return ret.
Set `ret = 0` on success.
2019-03-06 23:06:59 -05:00
David Korth
3b7b36bed2 Use the ALIGN() macro instead of toNext64() and related.
NOTE: declspec() isn't available in MSVC in C mode.
Cast to uint64_t as a workaround.
2019-03-06 23:00:06 -05:00
David Korth
826701eb07 [wadresign] print-info.c: Use fseeko() instead of fseek(). 2019-03-06 22:51:08 -05:00
David Korth
cabdf3486c Explicitly clear the buffer before changing the issuer.
MSVC Secure Overloads will change strncpy() to strncpy_s(), which
doesn't clear the buffer. Hence, we'll need to explicitly clear
the buffer ourselves.

Note that this shouldn't usually be a problem, since the issuer length
is the same for both retail and debug.
2019-03-06 22:48:43 -05:00
David Korth
563e9f07ed Moved rvth_recrypt_ticket() from librvth/recrypt.cpp to libwiicrypto/sig_tools.c.
It's now called sig_recrypt_ticket().
2019-03-06 22:18:57 -05:00
David Korth
dd4fe6f5ab [libwiicrypto] sig_tools.h: Simplified signature handling.
Moved the crypto type, signature type, and signature status enums here.
Renamed them to have RVL_ prefixes instead of RVTH_/RvtH_.

Added functions to convert the enums to strings.

sig_verify(): Wrapper around cert_verify() that returns an RVL_SigType_e
value.
2019-03-06 22:17:31 -05:00
David Korth
891dbe7a43 [wadresign] print-info.c: Added ticket and TMD signature verification.
TODO: Consolidate into libwiicrypto.
2019-03-06 21:43:47 -05:00
David Korth
9ca1c4b7aa [wadresign] Initial implementation of the WAD Resigner.
Currently shows basic information about a WAD file.

Next: Check the signatures and identify them.
2019-03-06 21:21:51 -05:00
David Korth
0bf21fadf5 Merge branch 'feature/librvth-rewrite-cpp'
More C++ rewriting can be done later.
2019-03-06 20:42:37 -05:00
David Korth
d31763f792 [librvth] Converted struct RvtH into a C++ class.
All RVT-H functions that operated directly on an RVT-H obejct are
now member functions.

Moved some accessor functions to the class declaration in rvth.hpp.

rvth_open() and rvth_create_gcm() are now RvtH constructors.

extract_crypt.h, rvth_p.h: Deleted. These declarations are now in
rvth.hpp.

Removed the "rvth_" prefix from some of the source files, since it's
redundant.

Some fixes here and there for memory leaks and/or error correctness.
2019-02-06 20:01:12 -05:00
David Korth
441eb7c5b5 [librvth] Renamed rvth_imagetype.h to rvth_enums.h; moved more enums from rvth.h here. 2019-02-06 00:22:46 -05:00
David Korth
cf7bbbc350 [librvth] rvth_recrypt_partitions(): Debug realsigning has been implemented since v0.9.
Remove the TODO and set the bank entry status correctly.

The bank entry status probably isn't too important right now with the
command line rvthtool, but it might be important later with qrvthtool.
2019-02-05 23:41:38 -05:00
David Korth
ff595c96e0 [librvth] rvth_copy_to_hdd(): rvth_dest and bank_dest are both 'in' parameters, not 'out'. 2019-02-05 23:36:39 -05:00
David Korth
0887402329 [librvth] rvth.cpp, rvth_open_gcm(): CISO and WBFS are automatically handled by the Reader class. 2019-02-05 23:31:40 -05:00
David Korth
dc8bcfd4c8 [librvth] rvth_error.c: #include <assert.h> for static_assert().
This broke the Linux build, but not MSVC...
2019-02-05 22:16:28 -05:00
David Korth
20e4d28b2a [librvth] rvth_get_BankEntry(): Set *pErr to -ERANGE if the bank number is out of range.
Copy/paste error from the !rvth branch.
2019-02-05 22:08:40 -05:00
David Korth
b47aa064e0 [librvth] Split error codes from rvth.cpp to rvth_error.c.
Also split from rvth.h to rvth_error.h, so anything using the error codes
will need to #include "rvth_error.h".
2019-02-05 21:58:34 -05:00
David Korth
d382e2d585 [librvth] Reader::write(): Made this function non-pure virtual.
The base class implementation now returns an error.

Removed the CisoReader and WbfsReader implementations, since the base
class version handles it.
2019-02-05 21:35:55 -05:00
David Korth
3751e7ee8e [librvth] Rewrote the Reader base class and all subclasses as C++ classes.
- Moved the files to a subdirectory.
- Renamed the files to match the class names.

Renamed various other .c files to .cpp in order to use the new
C++ Reader base class.
2019-02-05 21:26:37 -05:00
David Korth
b79e4d149a [libwiicrypto] byteswap.h: Don't define inline if compiling as C++ with MSVC.
bank_init.c failed to compile with MSVC 2017 once switched to C++:

c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\xkeycheck.h(207): error C4005: 'inline': macro redefinition
2019-02-05 21:06:27 -05:00
David Korth
d54c98cb78 [librvth] Renamed ref_file.hpp to RefFile.hpp.
We should use title case for C++ class filenames.
2019-02-04 23:41:50 -05:00
David Korth
34171a2231 [librvth] Rewrote RefFile as a C++ class.
This is the first step in porting librvth to C++, which will make it
easier to maintain. For example, it will allow us to add Apploader
DOL verification for encrypted images more easily, since we will be
able to layer a decrypted partition reader, similar to rom-properties.

Renamed many files to .cpp in order to compile as C++.

TODO:
- RefFile's wrapper functions still use errno instead of m_lastError.
- Remove the C compatibility hack later. (`struct RefFile;`)
2019-02-04 23:35:38 -05:00
David Korth
1011bde8aa travis.sh: Disable NLS.
Ubuntu 14.04 doesn't have FindQt5LinguistTools.cmake, so we can't
build the localization files in the travis-ci build.
2018-09-30 21:53:02 -04:00
David Korth
56929bf421 [locale] Added localization files.
Based on similar files from mcrecover.

[qrvthtool] TranslationManager: Search for rvthtool_*.qm,
not mcrecover_*.qm.
2018-09-30 21:48:58 -04:00
David Korth
6404db3781 [qrvthtool] Added LanguageMenu and TranslationManager.
Based on the same classes from mcrecover.

TODO:
- Add some translations.
- Persistent configuration. I don't think porting mcrecover's ConfigStore
  is the right thing to do here.
2018-09-30 21:24:22 -04:00
David Korth
7ae8c89218 [qrvthtool] RvtHModel: Show ICON_WII if the encryption is unknown.
Something isn't quite right here, but the application icon shouldn't show
an RVT-H Reader if this is a standalone disc image.
2018-09-30 21:02:13 -04:00
David Korth
2326cc648a [qrvthtool] RvtHModel: Return ICON_WII for retail-encrypted Wii games, not ICON_GCN.
Forgot to update this when adding the Wii icons earlier.

This should have been done in commit e822d9042f.
([qrvthtool] Added icons for Wii, RVT-R Reader, and RVT-H Reader.)
2018-09-30 21:00:44 -04:00
David Korth
cdd338bd48 [qrvthtool] BankEntryView: Display "Unknown" for RVTH_CryptoType_Unknown.
Only show the ID if it's out of range.
2018-09-30 20:57:53 -04:00
David Korth
d7557ede05 [qrvthtool] resource.h: Use IDI_QRVTHTOOL instead of IDI_APPLICATION.
IDI_APPLICATION is defined in Windows headers as the "default" application
icon, with resource ID 32512.

resource.rc: IDI_QRVTHTOOL, not IDI_KEY_VALID. Besides the fact that this
is wrong (and is a copy/paste error from rom-properties), this caused the
icon to be defined using a name instead of an ID.
2018-09-30 20:51:05 -04:00
David Korth
bbcc6c2b38 Added the C++ 2011 compatibility headers from rom-properties.
Updated copyright headers.

This is needed to build the GUI with MSVC 2010 because MSVC 2010
doesn't support C++ 2011's `final` keyword.
2018-09-30 20:48:41 -04:00