correctly decrypt the files when importing a wii save

fixes issue 4462.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7526 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-05-08 00:37:44 +00:00
parent e29e317580
commit 561b227b77
1 changed files with 6 additions and 5 deletions

View File

@ -286,10 +286,11 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
if (_tmpFileHDR.type == 1)
{
_fileSize = Common::swap32(_tmpFileHDR.size);
lastpos += ROUND_UP(_fileSize, BLOCK_SZ);
_encryptedData = new u8[_fileSize];
_data = new u8[_fileSize];
if (!fpData_bin.ReadBytes(_encryptedData, _fileSize))
u32 RoundedFileSize = ROUND_UP(_fileSize, BLOCK_SZ);
lastpos += RoundedFileSize;
_encryptedData = new u8[RoundedFileSize];
_data = new u8[RoundedFileSize];
if (!fpData_bin.ReadBytes(_encryptedData, RoundedFileSize))
{
PanicAlertT("Failed to read data from file %d", i);
b_valid = false;
@ -298,7 +299,7 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
memcpy(IV, _tmpFileHDR.IV, 0x10);
AES_cbc_encrypt((const unsigned char *)_encryptedData, _data, _fileSize, &m_AES_KEY, IV, AES_DECRYPT);
AES_cbc_encrypt((const unsigned char *)_encryptedData, _data, RoundedFileSize, &m_AES_KEY, IV, AES_DECRYPT);
delete []_encryptedData;
if (!File::Exists(pathRawSave) || AskYesNoT("%s already exists, overwrite?", pathRawSave))