core: Generalize QuickDecryptor

This is now a class template. This would be useful when we implement NCCH decryption.
This commit is contained in:
zhupengfei
2020-04-30 18:05:58 +08:00
parent 576053d995
commit c831a0785e
4 changed files with 73 additions and 73 deletions
+15 -4
View File
@@ -17,8 +17,7 @@
namespace Core {
SDMCDecryptor::SDMCDecryptor(const std::string& root_folder_)
: root_folder(root_folder_), quick_decryptor(root_folder) {
SDMCDecryptor::SDMCDecryptor(const std::string& root_folder_) : root_folder(root_folder_) {
ASSERT_MSG(Key::IsNormalKeyAvailable(Key::SDKey),
"SD Key must be available in order to decrypt");
@@ -54,8 +53,20 @@ void SDMCDecryptor::Reset(std::size_t total_size) {
}
bool SDMCDecryptor::DecryptAndWriteFile(const std::string& source, const std::string& destination,
const QuickDecryptor::ProgressCallback& callback) {
return quick_decryptor.DecryptAndWriteFile(source, destination, callback);
const ProgressCallback& callback) {
if (!FileUtil::CreateFullPath(destination)) {
LOG_ERROR(Core, "Could not create path {}", destination);
return false;
}
auto source_file = std::make_unique<FileUtil::IOFile>(root_folder + source, "rb");
auto size = source_file->GetSize();
auto destination_file = std::make_unique<FileUtil::IOFile>(destination, "wb");
auto key = Key::GetNormalKey(Key::SDKey);
auto ctr = GetFileCTR(source);
return quick_decryptor.DecryptAndWriteFile(std::move(source_file), size,
std::move(destination_file), std::move(key),
std::move(ctr), callback);
}
void SDMCDecryptor::Abort() {