DiscIO: Implement re-encryption of Wii partition data

This commit is contained in:
JosJuice
2020-01-23 16:47:49 +01:00
parent a4c7100bcc
commit 319c508978
9 changed files with 335 additions and 23 deletions

View File

@ -4,13 +4,15 @@
#pragma once
#include <array>
#include <map>
#include <mbedtls/aes.h>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <mbedtls/aes.h>
#include "Common/CommonTypes.h"
#include "Common/Lazy.h"
#include "Core/IOS/ES/Formats.h"
@ -30,6 +32,20 @@ enum class Platform;
class VolumeWii : public VolumeDisc
{
public:
static constexpr size_t AES_KEY_SIZE = 16;
static constexpr size_t SHA1_SIZE = 20;
static constexpr u32 H3_TABLE_SIZE = 0x18000;
static constexpr u32 BLOCKS_PER_GROUP = 0x40;
static constexpr u64 BLOCK_HEADER_SIZE = 0x0400;
static constexpr u64 BLOCK_DATA_SIZE = 0x7C00;
static constexpr u64 BLOCK_TOTAL_SIZE = BLOCK_HEADER_SIZE + BLOCK_DATA_SIZE;
static constexpr u64 GROUP_HEADER_SIZE = BLOCK_HEADER_SIZE * BLOCKS_PER_GROUP;
static constexpr u64 GROUP_DATA_SIZE = BLOCK_DATA_SIZE * BLOCKS_PER_GROUP;
static constexpr u64 GROUP_TOTAL_SIZE = GROUP_HEADER_SIZE + GROUP_DATA_SIZE;
VolumeWii(std::unique_ptr<BlobReader> reader);
~VolumeWii();
bool Read(u64 offset, u64 length, u8* buffer, const Partition& partition) const override;
@ -69,11 +85,9 @@ public:
bool IsSizeAccurate() const override;
u64 GetRawSize() const override;
static constexpr unsigned int H3_TABLE_SIZE = 0x18000;
static constexpr unsigned int BLOCK_HEADER_SIZE = 0x0400;
static constexpr unsigned int BLOCK_DATA_SIZE = 0x7C00;
static constexpr unsigned int BLOCK_TOTAL_SIZE = BLOCK_HEADER_SIZE + BLOCK_DATA_SIZE;
static bool EncryptGroup(u64 offset, u64 partition_data_offset, u64 partition_data_decrypted_size,
const std::array<u8, AES_KEY_SIZE>& key, BlobReader* blob,
std::array<u8, GROUP_TOTAL_SIZE>* out);
protected:
u32 GetOffsetShift() const override { return 2; }