From ad42a7ae64ae439fc8b342fd43e3887a96be540d Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 25 Mar 2011 02:59:36 +0000 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E5=90=8D=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E5=85=A5=E3=82=8C=E6=9B=BF=E3=81=88=E6=94=BB?= =?UTF-8?q?=E6=92=83=E3=82=92=E9=98=B2=E3=81=90=E3=81=9F=E3=82=81=E3=83=95?= =?UTF-8?q?=E3=83=AB=E3=83=91=E3=82=B9=E3=82=92=E3=83=8F=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E8=A8=88=E7=AE=97=E3=81=AB=E5=90=AB=E3=82=81=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=20NAND=E6=9B=B8=E3=81=8D=E8=BE=BC?= =?UTF-8?q?=E3=81=BF=E5=A4=B1=E6=95=97=E6=99=82=E3=81=AB=E3=81=AF=E9=80=B2?= =?UTF-8?q?=E6=8D=97=E3=82=92=E6=B8=9B=E3=82=89=E3=81=99=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@158 385bec56-5757-e545-9c3a-d8741f4650f1 --- trunk/ConsoleDataMigration/common/FileTransfer.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/trunk/ConsoleDataMigration/common/FileTransfer.cpp b/trunk/ConsoleDataMigration/common/FileTransfer.cpp index 8d1f80c..547bfd3 100644 --- a/trunk/ConsoleDataMigration/common/FileTransfer.cpp +++ b/trunk/ConsoleDataMigration/common/FileTransfer.cpp @@ -40,7 +40,7 @@ u64 s_Progress = 0; } bool VerifyMac(nn::fs::FileInputStream* sdFile, nn::fs::FileStream* nandFile, s64 sdFileSize, s64 nandFileSize, - void* buf, size_t bufSize); + const wchar_t* nandPath, void* buf, size_t bufSize); bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file, s64 sdFileSize, s64 nandFileSize, void* buf, size_t bufSize, const wchar_t* sdPath, const wchar_t* tmpPath, const wchar_t* truePath); void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize); @@ -288,6 +288,9 @@ bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wc ret_value = false; } + // フルパスをハッシュに含める + context.Update(target_from.str().c_str(), target_from.str().size() * sizeof(wchar_t)); + BackupDataHeader header; BackupDataHeader enc; std::memset(&header, 0, sizeof(header)); @@ -458,6 +461,7 @@ bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wc target_from.str().c_str(), target_tmp.str().c_str(), target_to.str().c_str())) { + s_FinishedFileSize -= readsize; ret_value = false; } break; @@ -516,7 +520,7 @@ bool CalculateAndCompareCmac(nn::crypto::Sha256Context* context, bit8* sdCmac) bool VerifyMac(nn::fs::FileInputStream* sdFile, nn::fs::FileStream* nandFile, s64 sdFileSize, s64 nandFileSize, - void* buf, size_t bufSize) + const wchar_t* nandPath, void* buf, size_t bufSize) { nn::Result result; bit8 sdCmac[nn::crypto::AES_CMAC_MAC_SIZE]; @@ -557,6 +561,9 @@ bool VerifyMac(nn::fs::FileInputStream* sdFile, nn::fs::FileStream* nandFile, s6 nn::crypto::Sha256Context context; context.Initialize(); + // NAND上のフルパスをハッシュに含めている + context.Update(nandPath, std::wcslen(nandPath) * sizeof(wchar_t)); + BackupDataHeader header; BackupDataHeader enc; std::memset(&header, 0, sizeof(header)); @@ -616,7 +623,7 @@ bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file bool ret_value = true; NN_LOG("Verify CMAC %ls\n", sdPath); - if (!VerifyMac(from_file, to_file, sdFileSize, nandFileSize, buf, bufSize)) + if (!VerifyMac(from_file, to_file, sdFileSize, nandFileSize, truePath, buf, bufSize)) { // 検証に失敗したので削除する COMMON_LOGGER("**********Verification Failed %s, Delete**********\n", GetCharStr(sdPath));