fs: add AesCtrStorage
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
namespace ams::fs {
|
||||
|
||||
struct QueryRangeInfo {
|
||||
u32 aes_ctr_key_type;
|
||||
u32 speed_emulation_type;
|
||||
u32 reserved[0x38 / sizeof(u32)];
|
||||
s32 aes_ctr_key_type;
|
||||
s32 speed_emulation_type;
|
||||
u8 reserved[0x38];
|
||||
|
||||
void Clear() {
|
||||
this->aes_ctr_key_type = 0;
|
||||
@@ -45,4 +45,8 @@ namespace ams::fs {
|
||||
|
||||
Result QueryRange(QueryRangeInfo *out, FileHandle handle, s64 offset, s64 size);
|
||||
|
||||
enum class AesCtrKeyTypeFlag : s32 {
|
||||
InternalKeyForSoftwareAes = (1 << 0),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <stratosphere/fssystem/fssystem_partition_file_system.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_partition_file_system_meta.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_path_tool.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_thread_priority_changer.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_aes_ctr_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/fs/fs_istorage.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
class AesCtrStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
|
||||
NON_COPYABLE(AesCtrStorage);
|
||||
NON_MOVEABLE(AesCtrStorage);
|
||||
public:
|
||||
static constexpr size_t BlockSize = crypto::Aes128CtrEncryptor::BlockSize;
|
||||
static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize;
|
||||
static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize;
|
||||
private:
|
||||
IStorage * const base_storage;
|
||||
char key[KeySize];
|
||||
char iv[IvSize];
|
||||
public:
|
||||
static void MakeIv(void *dst, size_t dst_size, u64 upper, s64 offset);
|
||||
public:
|
||||
AesCtrStorage(IStorage *base, const void *key, size_t key_size, const void *iv, size_t iv_size);
|
||||
|
||||
virtual Result Read(s64 offset, void *buffer, size_t size) override;
|
||||
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
|
||||
|
||||
virtual Result Flush() override;
|
||||
|
||||
virtual Result SetSize(s64 size) override;
|
||||
virtual Result GetSize(s64 *out) override;
|
||||
|
||||
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -105,4 +105,8 @@ namespace ams::fssystem {
|
||||
void UnregisterAdditionalDeviceAddress(uintptr_t address);
|
||||
bool IsAdditionalDeviceAddress(const void *ptr);
|
||||
|
||||
inline bool IsDeviceAddress(const void *buffer) {
|
||||
return IsPooledBuffer(buffer) || IsAdditionalDeviceAddress(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/os.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
class ScopedThreadPriorityChanger {
|
||||
public:
|
||||
enum class Mode {
|
||||
Absolute,
|
||||
Relative,
|
||||
};
|
||||
private:
|
||||
/* TODO */
|
||||
public:
|
||||
ALWAYS_INLINE explicit ScopedThreadPriorityChanger(s32 priority, Mode mode) {
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
ALWAYS_INLINE ~ScopedThreadPriorityChanger() {
|
||||
/* TODO */
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -170,4 +170,6 @@ namespace ams::fssystem {
|
||||
}
|
||||
}
|
||||
|
||||
void AddCounter(void *counter, size_t counter_size, u64 value);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user