mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-31 11:33:27 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
// Copyright 2020 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#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>;
|
|
using HashExceptionCallback = std::function<void(
|
|
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP], u64 offset)>;
|
|
|
|
// The blob pointer is kept around for the lifetime of this object.
|
|
explicit WiiEncryptionCache(BlobReader* blob);
|
|
~WiiEncryptionCache();
|
|
|
|
WiiEncryptionCache(WiiEncryptionCache&&) = default;
|
|
WiiEncryptionCache& operator=(WiiEncryptionCache&&) = default;
|
|
|
|
// It would be possible to write a custom copy constructor and assignment operator
|
|
// for this class, but there has been no reason to do so.
|
|
WiiEncryptionCache(const WiiEncryptionCache&) = delete;
|
|
WiiEncryptionCache& operator=(const WiiEncryptionCache&) = delete;
|
|
|
|
// 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, const HashExceptionCallback& hash_exception_callback = {});
|
|
|
|
// 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,
|
|
const HashExceptionCallback& hash_exception_callback = {});
|
|
|
|
private:
|
|
BlobReader* m_blob;
|
|
std::unique_ptr<std::array<u8, VolumeWii::GROUP_TOTAL_SIZE>> m_cache;
|
|
u64 m_cached_offset = 0;
|
|
};
|
|
|
|
} // namespace DiscIO
|