mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #8084 from leoetlino/wiisave-sign
WiiSave: Fix save signing
This commit is contained in:
commit
91f5d577cc
@ -15,6 +15,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <mbedtls/md5.h>
|
#include <mbedtls/md5.h>
|
||||||
|
#include <mbedtls/sha1.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -403,17 +404,21 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read data to sign.
|
// Read data to sign.
|
||||||
const u32 data_size = bk_header->size_of_files + sizeof(BkHeader);
|
std::array<u8, 20> data_sha1;
|
||||||
auto data = std::make_unique<u8[]>(data_size);
|
{
|
||||||
m_file.Seek(sizeof(Header), SEEK_SET);
|
const u32 data_size = bk_header->size_of_files + sizeof(BkHeader);
|
||||||
if (!m_file.ReadBytes(data.get(), data_size))
|
auto data = std::make_unique<u8[]>(data_size);
|
||||||
return false;
|
m_file.Seek(sizeof(Header), SEEK_SET);
|
||||||
|
if (!m_file.ReadBytes(data.get(), data_size))
|
||||||
|
return false;
|
||||||
|
mbedtls_sha1(data.get(), data_size, data_sha1.data());
|
||||||
|
}
|
||||||
|
|
||||||
// Sign the data.
|
// Sign the data.
|
||||||
IOS::CertECC ap_cert;
|
IOS::CertECC ap_cert;
|
||||||
Common::ec::Signature ap_sig;
|
Common::ec::Signature ap_sig;
|
||||||
m_iosc.Sign(ap_sig.data(), reinterpret_cast<u8*>(&ap_cert), Titles::SYSTEM_MENU, data.get(),
|
m_iosc.Sign(ap_sig.data(), reinterpret_cast<u8*>(&ap_cert), Titles::SYSTEM_MENU,
|
||||||
data_size);
|
data_sha1.data(), static_cast<u32>(data_sha1.size()));
|
||||||
|
|
||||||
// Write signatures.
|
// Write signatures.
|
||||||
if (!m_file.Seek(0, SEEK_END))
|
if (!m_file.Seek(0, SEEK_END))
|
||||||
|
Loading…
Reference in New Issue
Block a user