summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-08-11 03:34:43 +0200
committerLiam <byteslice@airmail.cc>2023-08-15 23:47:25 +0200
commit86f6b6b7b2d930e8203114332b04a5c49a780b06 (patch)
treebf7ff58b0a36051d3c3489a40999d80357c570d0 /src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h
parentMerge pull request #11287 from liamwhite/replaced-bytes (diff)
downloadyuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar.gz
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar.bz2
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar.lz
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar.xz
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.tar.zst
yuzu-86f6b6b7b2d930e8203114332b04a5c49a780b06.zip
Diffstat (limited to 'src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h')
-rw-r--r--src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h b/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h
new file mode 100644
index 000000000..bceb1f9ad
--- /dev/null
+++ b/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.h
@@ -0,0 +1,43 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <optional>
+
+#include "core/crypto/aes_util.h"
+#include "core/crypto/key_manager.h"
+#include "core/file_sys/errors.h"
+#include "core/file_sys/fssystem/fs_i_storage.h"
+#include "core/file_sys/vfs.h"
+
+namespace FileSys {
+
+class AesCtrStorage : public IStorage {
+ YUZU_NON_COPYABLE(AesCtrStorage);
+ YUZU_NON_MOVEABLE(AesCtrStorage);
+
+public:
+ static constexpr size_t BlockSize = 0x10;
+ static constexpr size_t KeySize = 0x10;
+ static constexpr size_t IvSize = 0x10;
+
+private:
+ VirtualFile m_base_storage;
+ std::array<u8, KeySize> m_key;
+ std::array<u8, IvSize> m_iv;
+ mutable std::optional<Core::Crypto::AESCipher<Core::Crypto::Key128>> m_cipher;
+
+public:
+ static void MakeIv(void* dst, size_t dst_size, u64 upper, s64 offset);
+
+public:
+ AesCtrStorage(VirtualFile base, const void* key, size_t key_size, const void* iv,
+ size_t iv_size);
+
+ virtual size_t Read(u8* buffer, size_t size, size_t offset) const override;
+ virtual size_t Write(const u8* buffer, size_t size, size_t offset) override;
+ virtual size_t GetSize() const override;
+};
+
+} // namespace FileSys