2013-04-29 12:40:09 +09:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-10-08 15:54:28 +08:00
|
|
|
#include "zlib.h"
|
2014-01-01 22:31:03 +02:00
|
|
|
#include <stdio.h>
|
2013-04-29 12:40:09 +09:00
|
|
|
|
2014-03-15 11:22:19 -07:00
|
|
|
#include "Core/MemMap.h"
|
2013-12-30 00:11:29 +01:00
|
|
|
#include "Core/System.h"
|
2020-01-11 15:33:51 +00:00
|
|
|
#include "Core/ELF/PrxDecrypter.h"
|
2013-12-29 23:28:31 +01:00
|
|
|
#include "Core/FileSystems/MetaFileSystem.h"
|
|
|
|
#include "Core/HLE/scePauth.h"
|
|
|
|
#include "Core/HLE/HLE.h"
|
2014-03-15 11:22:19 -07:00
|
|
|
#include "Core/HLE/FunctionWrappers.h"
|
2020-10-04 20:48:47 +02:00
|
|
|
#include "Common/File/FileUtil.h"
|
2013-12-29 23:28:31 +01:00
|
|
|
|
2014-12-08 04:40:08 -05:00
|
|
|
static int scePauth_F7AA47F6(u32 srcPtr, int srcLength, u32 destLengthPtr, u32 workArea)
|
2013-04-29 12:40:09 +09:00
|
|
|
{
|
2020-01-11 15:33:51 +00:00
|
|
|
auto src = Memory::GetPointer(srcPtr);
|
|
|
|
auto key = Memory::GetPointer(workArea);
|
2014-04-27 16:25:18 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
const auto decryptResult = pspDecryptPRX(src, src, srcLength, key);
|
2014-04-27 16:25:18 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
if (decryptResult < 0)
|
|
|
|
{
|
|
|
|
ERROR_LOG(HLE, "Pauth decryption failed 0x%08X", decryptResult);
|
|
|
|
return decryptResult;
|
|
|
|
}
|
2014-04-27 16:25:18 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
Memory::Write_U32(decryptResult, destLengthPtr);
|
2017-06-05 17:03:43 +02:00
|
|
|
return 0;
|
2013-04-29 12:40:09 +09:00
|
|
|
}
|
|
|
|
|
2014-12-08 04:40:08 -05:00
|
|
|
static int scePauth_98B83B5D(u32 srcPtr, int srcLength, u32 destLengthPtr, u32 workArea)
|
2013-04-29 12:40:09 +09:00
|
|
|
{
|
2020-01-11 15:33:51 +00:00
|
|
|
auto src = Memory::GetPointer(srcPtr);
|
|
|
|
auto key = Memory::GetPointer(workArea);
|
2013-10-08 15:54:28 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
const auto decryptResult = pspDecryptPRX(src, src, srcLength, key);
|
2013-10-08 15:54:28 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
if (decryptResult < 0)
|
|
|
|
{
|
|
|
|
ERROR_LOG(HLE, "Pauth decryption failed 0x%08X", decryptResult);
|
|
|
|
return decryptResult;
|
|
|
|
}
|
2013-10-08 15:54:28 +08:00
|
|
|
|
2020-01-11 15:33:51 +00:00
|
|
|
Memory::Write_U32(decryptResult, destLengthPtr);
|
|
|
|
return 0;
|
2013-04-29 12:40:09 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const HLEFunction scePauth[] = {
|
2015-03-22 16:57:56 -07:00
|
|
|
{0XF7AA47F6, &WrapI_UIUU<scePauth_F7AA47F6>, "scePauth_F7AA47F6", 'i', "xixx"},
|
|
|
|
{0X98B83B5D, &WrapI_UIUU<scePauth_98B83B5D>, "scePauth_98B83B5D", 'i', "xixx"},
|
2013-04-29 12:40:09 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
void Register_scePauth()
|
|
|
|
{
|
|
|
|
RegisterModule("scePauth", ARRAY_SIZE(scePauth), scePauth);
|
2013-10-08 15:54:28 +08:00
|
|
|
}
|