mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
[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:
parent
13d1e31bab
commit
1cec2aa598
@ -280,6 +280,8 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf,
|
|||||||
// NAND上のフルパスをハッシュに含めている
|
// NAND上のフルパスをハッシュに含めている
|
||||||
context.Update(nandPath, std::wcslen(nandPath) * sizeof(wchar_t));
|
context.Update(nandPath, std::wcslen(nandPath) * sizeof(wchar_t));
|
||||||
|
|
||||||
|
size_t totalReadSize = 0;
|
||||||
|
|
||||||
BackupDataHeader enc;
|
BackupDataHeader enc;
|
||||||
BackupDataHeader dec;
|
BackupDataHeader dec;
|
||||||
std::memset(&enc, 0, sizeof(enc));
|
std::memset(&enc, 0, sizeof(enc));
|
||||||
@ -291,10 +293,10 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf,
|
|||||||
ret_value = false;
|
ret_value = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
totalReadSize += readSize;
|
||||||
context.Update(&enc, sizeof(enc));
|
context.Update(&enc, sizeof(enc));
|
||||||
swAesCtrContext.Decrypt(&dec, &enc, sizeof(enc));
|
swAesCtrContext.Decrypt(&dec, &enc, sizeof(enc));
|
||||||
|
|
||||||
size_t totalReadSize = 0;
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
result = sdFile.TryRead(&readSize, buf, bufSize);
|
result = sdFile.TryRead(&readSize, buf, bufSize);
|
||||||
@ -313,7 +315,7 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf,
|
|||||||
ret_value = CalculateAndCompareCmac(&context, sdCmac);
|
ret_value = CalculateAndCompareCmac(&context, sdCmac);
|
||||||
if(!ret_value)
|
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++;
|
s_VerifyFail++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -327,9 +329,9 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf,
|
|||||||
{
|
{
|
||||||
bool readDone = false;;
|
bool readDone = false;;
|
||||||
// CMACまで読んだかどうか
|
// 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;
|
readDone = true;
|
||||||
}
|
}
|
||||||
context.Update(buf, readSize);
|
context.Update(buf, readSize);
|
||||||
@ -339,7 +341,7 @@ bool VerifyDirectory(const wchar_t * from_path, void* buf,
|
|||||||
ret_value = CalculateAndCompareCmac(&context, sdCmac);
|
ret_value = CalculateAndCompareCmac(&context, sdCmac);
|
||||||
if(!ret_value)
|
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++;
|
s_VerifyFail++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user