From 6c324c67828cbdf5154c976eaad40f7f1c47fe1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 1 Jan 2026 13:47:19 +0100 Subject: [PATCH] Minor cleanup --- Core/Dialog/SavedataParam.cpp | 15 ++++----------- Core/Dialog/SavedataParam.h | 4 ++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index b3712fc960..c565600b0d 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -892,7 +892,7 @@ std::set SavedataParam::GetSecureFileNames(const std::string &dirPa bool SavedataParam::GetExpectedHash(const std::string &dirPath, const std::string &filename, u8 hash[16]) { auto entries = GetSFOEntries(dirPath); - for (auto entry : entries) { + for (const auto &entry : entries) { if (strncmp(entry.filename, filename.c_str(), sizeof(entry.filename)) == 0) { memcpy(hash, entry.hash, sizeof(entry.hash)); return true; @@ -920,13 +920,7 @@ void SavedataParam::LoadFile(const std::string& dirPath, const std::string& file } // Note: The work is done in-place, hence the memmove etc. -int SavedataParam::EncryptData(unsigned int mode, - unsigned char *data, - int *dataLen, - int *alignedLen, - unsigned char *hash, - unsigned char *cryptkey) -{ +int SavedataParam::EncryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *hash, const u8 *cryptkey) { pspChnnlsvContext1 ctx1{}; pspChnnlsvContext2 ctx2{}; @@ -975,7 +969,7 @@ int SavedataParam::EncryptData(unsigned int mode, } // Note: The work is done in-place, hence the memmove etc. -int SavedataParam::DecryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *cryptkey, const u8 *expectedHash) { +int SavedataParam::DecryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, const u8 *cryptkey, const u8 *expectedHash) { pspChnnlsvContext1 ctx1{}; pspChnnlsvContext2 ctx2{}; @@ -1015,8 +1009,7 @@ int SavedataParam::DecryptData(unsigned int mode, unsigned char *data, int *data } // Requires sfoData to be padded with zeroes to the next 16-byte boundary (due to BuildHash) -int SavedataParam::UpdateHash(u8* sfoData, int sfoSize, int sfoDataParamsOffset, int encryptmode) -{ +int SavedataParam::UpdateHash(u8 *sfoData, int sfoSize, int sfoDataParamsOffset, int encryptmode) { int alignedLen = align16(sfoSize); memset(sfoData + sfoDataParamsOffset, 0, 128); u8 filehash[16]; diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index 5f643dd4fb..98daeb7046 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -374,8 +374,8 @@ private: bool LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath); void LoadFile(const std::string& dirPath, const std::string& filename, PspUtilitySavedataFileData *fileData); - int DecryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *cryptkey, const u8 *expectedHash); - int EncryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *hash, unsigned char *cryptkey); + int DecryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, const u8 *cryptkey, const u8 *expectedHash); + int EncryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, u8 *hash, const u8 *cryptkey); int UpdateHash(u8* sfoData, int sfoSize, int sfoDataParamsOffset, int encryptmode); // data must be zero-padded from len to alignedLen (which should be the next multiply of 16)!