IOS: Reuse more code for crypto operations
This changes some parts of IOS (actually just ES) to reuse more crypto code from IOSC or Common::AES. TicketReader still returns the title key directly as opposed to having ES use IOSC directly to avoid duplicating the title key IV stuff. Side effects: * A nasty unbounded array access bug is now fixed. * ES_Decrypt/ES_Encrypt now returns sane results for keys other than the SD key. * Titles with a Korean ticket can now be decrypted properly. And in the future, we can look into implementing ioctlv 0x3c and 0x3d now that we have the proper "infra" for IOSC calls.
This commit is contained in:
1 parent
f8fb9e2d03
commit
08f6c31287
9 files changed
+63
-107
No files matched your search
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "Core/ec_wii.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@@ -180,19 +179,6 @@ const u8* EcWii::GetNGSig() const
|
||||
return BootMiiKeysBin.ng_sig;
|
||||
}
|
||||
|
||||
std::array<u8, 16> EcWii::GetSharedSecret(const EcWii::ECCKey& peer_public_key) const
|
||||
{
|
||||
EcWii::ECCKey shared_secret;
|
||||
point_mul(shared_secret.data(), GetNGPriv(), peer_public_key.data());
|
||||
|
||||
std::array<u8, 20> sha1;
|
||||
mbedtls_sha1(shared_secret.data(), shared_secret.size() / 2, sha1.data());
|
||||
|
||||
std::array<u8, 16> aes_key;
|
||||
std::copy_n(sha1.cbegin(), aes_key.size(), aes_key.begin());
|
||||
return aes_key;
|
||||
}
|
||||
|
||||
void EcWii::InitDefaults()
|
||||
{
|
||||
memset(&BootMiiKeysBin, 0, sizeof(BootMiiKeysBin));
|
||||
|
||||
Reference in new issue
Block a user