diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2020-04-24 15:01:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-24 15:01:04 +0200 |
| commit | 0a71dda8a0c615e8f387dc12d519cf3415a5ef79 (patch) | |
| tree | d988a05e13e5cf27800a43392aa96718bbae2e87 /Source/Core/DiscIO/WiiEncryptionCache.h | |
| parent | 7e94d6ed375cecae59717626f6ab1b32674a15dc (diff) | |
| parent | 432f342bc86fe43ffbecfd6657d2331e79e47ffc (diff) | |
Merge pull request #8591 from JosJuice/wii-reencryption
DiscIO: Implement re-encryption of Wii partition data
Diffstat (limited to 'Source/Core/DiscIO/WiiEncryptionCache.h')
| -rw-r--r-- | Source/Core/DiscIO/WiiEncryptionCache.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/WiiEncryptionCache.h b/Source/Core/DiscIO/WiiEncryptionCache.h new file mode 100644 index 0000000000..0c8f4b489a --- /dev/null +++ b/Source/Core/DiscIO/WiiEncryptionCache.h @@ -0,0 +1,47 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include <limits> +#include <memory> + +#include "Common/CommonTypes.h" +#include "DiscIO/VolumeWii.h" + +namespace DiscIO +{ +class BlobReader; + +class WiiEncryptionCache +{ +public: + using Key = std::array<u8, VolumeWii::AES_KEY_SIZE>; + + // The blob pointer is kept around for the lifetime of this object. + explicit WiiEncryptionCache(BlobReader* blob); + ~WiiEncryptionCache(); + + // Encrypts exactly one group. + // If the returned pointer is nullptr, reading from the blob failed. + // If the returned pointer is not nullptr, it is guaranteed to be valid until + // the next call of this function or the destruction of this object. + const std::array<u8, VolumeWii::GROUP_TOTAL_SIZE>* EncryptGroup(u64 offset, + u64 partition_data_offset, + u64 partition_data_decrypted_size, + const Key& key); + + // Encrypts a variable number of groups, as determined by the offset and size parameters. + // Supports reading groups partially. + bool EncryptGroups(u64 offset, u64 size, u8* out_ptr, u64 partition_data_offset, + u64 partition_data_decrypted_size, const Key& key); + +private: + BlobReader* m_blob; + std::unique_ptr<std::array<u8, VolumeWii::GROUP_TOTAL_SIZE>> m_cache; + u64 m_cached_offset = std::numeric_limits<u64>::max(); +}; + +} // namespace DiscIO |
