diff --git a/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp b/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp index 06b7f13..755abad 100644 --- a/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp +++ b/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp @@ -280,6 +280,8 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf, // NAND上のフルパスをハッシュに含めている context.Update(nandPath, std::wcslen(nandPath) * sizeof(wchar_t)); + size_t totalReadSize = 0; + BackupDataHeader enc; BackupDataHeader dec; std::memset(&enc, 0, sizeof(enc)); @@ -291,10 +293,10 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf, ret_value = false; break; } + totalReadSize += readSize; context.Update(&enc, sizeof(enc)); swAesCtrContext.Decrypt(&dec, &enc, sizeof(enc)); - size_t totalReadSize = 0; while (1) { result = sdFile.TryRead(&readSize, buf, bufSize); @@ -313,7 +315,7 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf, ret_value = CalculateAndCompareCmac(&context, sdCmac); if(!ret_value) { - COMMON_LOGGER("********** Verification Failed **********\n %s\n", common::GetCharStr(target_from.str().c_str())); + COMMON_LOGGER("********** Verification Failed ********** %s\n", common::GetCharStr(target_from.str().c_str())); s_VerifyFail++; } else @@ -327,9 +329,9 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf, { bool readDone = false;; // CMACまで読んだかどうか - if (sdFileSize - (sizeof(BackupDataHeader) + nn::crypto::AES_CMAC_MAC_SIZE) < totalReadSize) + if (sdFileSize - nn::crypto::AES_CMAC_MAC_SIZE < totalReadSize) { - readSize -= totalReadSize - (sdFileSize - (sizeof(BackupDataHeader) + nn::crypto::AES_CMAC_MAC_SIZE)); + readSize -= totalReadSize - (sdFileSize - nn::crypto::AES_CMAC_MAC_SIZE); readDone = true; } context.Update(buf, readSize); @@ -339,7 +341,7 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf, ret_value = CalculateAndCompareCmac(&context, sdCmac); if(!ret_value) { - COMMON_LOGGER("********** Verification Failed **********\n %s\n", common::GetCharStr(target_from.str().c_str())); + COMMON_LOGGER("********** Verification Failed ********** %s\n", common::GetCharStr(target_from.str().c_str())); s_VerifyFail++; } else