[Verifier]ヘッダも読み込み済みのファイルサイズとして計算するように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@409 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-07-28 07:32:11 +00:00
parent 13d1e31bab
commit 1cec2aa598

View File

@ -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