From 561b227b7794fbccec71dff368e892efbfa88ba4 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 8 May 2011 00:37:44 +0000 Subject: [PATCH] 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 --- .../Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp b/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp index a6883ee9a2..db5deacccf 100644 --- a/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp +++ b/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp @@ -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))