2020-05-11 22:04:51 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-05-11 22:04:51 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
|
|
|
namespace ams::fssystem {
|
|
|
|
|
2022-03-12 21:03:17 +00:00
|
|
|
Result IntegrityRomFsStorage::Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf) {
|
2020-05-11 22:04:51 +00:00
|
|
|
/* Validate preconditions. */
|
|
|
|
AMS_ASSERT(bm != nullptr);
|
|
|
|
|
|
|
|
/* Set master hash. */
|
2021-10-10 07:14:06 +00:00
|
|
|
m_master_hash = master_hash;
|
|
|
|
m_master_hash_storage = std::make_unique<fs::MemoryStorage>(std::addressof(m_master_hash), sizeof(Hash));
|
|
|
|
R_UNLESS(m_master_hash_storage != nullptr, fs::ResultAllocationFailureInIntegrityRomFsStorageA());
|
2020-05-11 22:04:51 +00:00
|
|
|
|
|
|
|
/* Set the master hash storage. */
|
2021-10-10 07:14:06 +00:00
|
|
|
storage_info[0] = fs::SubStorage(m_master_hash_storage.get(), 0, sizeof(Hash));
|
2020-05-11 22:04:51 +00:00
|
|
|
|
|
|
|
/* Set buffers. */
|
2021-10-10 07:14:06 +00:00
|
|
|
for (size_t i = 0; i < util::size(m_buffers.buffers); ++i) {
|
|
|
|
m_buffers.buffers[i] = bm;
|
2020-05-11 22:04:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize our integrity storage. */
|
2021-12-14 06:42:32 +00:00
|
|
|
return m_integrity_storage.Initialize(level_hash_info, storage_info, std::addressof(m_buffers), hgf, std::addressof(m_mutex), fs::StorageType_RomFs);
|
2020-05-11 22:04:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IntegrityRomFsStorage::Finalize() {
|
2021-10-10 07:14:06 +00:00
|
|
|
m_integrity_storage.Finalize();
|
2020-05-11 22:04:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|