| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <memory> |
| 8 |
|
| 9 |
#include "Common/CommonTypes.h" |
| 10 |
#include "DiscIO/VolumeWii.h" |
| 11 |
|
| 12 |
namespace DiscIO |
| 13 |
{ |
| 14 |
class BlobReader; |
| 15 |
|
| 16 |
class WiiEncryptionCache |
| 17 |
{ |
| 18 |
public: |
| 19 |
using Key = std::array<u8, VolumeWii::AES_KEY_SIZE>; |
| 20 |
using HashExceptionCallback = std::function<void( |
| 21 |
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP], u64 offset)>; |
| 22 |
|
| 23 |
|
| 24 |
explicit WiiEncryptionCache(BlobReader* blob); |
| 25 |
~WiiEncryptionCache(); |
| 26 |
|
| 27 |
WiiEncryptionCache(WiiEncryptionCache&&) = default; |
| 28 |
WiiEncryptionCache& operator=(WiiEncryptionCache&&) = default; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
WiiEncryptionCache(const WiiEncryptionCache&) = delete; |
| 33 |
WiiEncryptionCache& operator=(const WiiEncryptionCache&) = delete; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
const std::array<u8, VolumeWii::GROUP_TOTAL_SIZE>* |
| 40 |
EncryptGroup(u64 offset, u64 partition_data_offset, u64 partition_data_decrypted_size, |
| 41 |
const Key& key, const HashExceptionCallback& hash_exception_callback = {}); |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
bool EncryptGroups(u64 offset, u64 size, u8* out_ptr, u64 partition_data_offset, |
| 46 |
u64 partition_data_decrypted_size, const Key& key, |
| 47 |
const HashExceptionCallback& hash_exception_callback = {}); |
| 48 |
|
| 49 |
private: |
| 50 |
BlobReader* m_blob; |
| 51 |
std::unique_ptr<std::array<u8, VolumeWii::GROUP_TOTAL_SIZE>> m_cache; |
| 52 |
u64 m_cached_offset = 0; |
| 53 |
}; |
| 54 |
|
| 55 |
} |