2012-12-06 15:24:25 +00: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/.
|
|
|
|
|
2014-03-15 18:22:19 +00:00
|
|
|
#include "Core/HLE/HLE.h"
|
|
|
|
#include "Core/HLE/FunctionWrappers.h"
|
|
|
|
#include "Core/MemMap.h"
|
|
|
|
#include "Common/ChunkFile.h"
|
2012-12-06 15:24:25 +00:00
|
|
|
|
2014-03-15 18:22:19 +00:00
|
|
|
#include "Core/HLE/sceSsl.h"
|
2012-12-06 15:24:25 +00:00
|
|
|
|
2014-03-03 16:16:53 +00:00
|
|
|
#define ERROR_SSL_NOT_INIT 0x80435001;
|
|
|
|
#define ERROR_SSL_ALREADY_INIT 0x80435020;
|
|
|
|
#define ERROR_SSL_OUT_OF_MEMORY 0x80435022;
|
2012-12-06 15:24:25 +00:00
|
|
|
#define ERROR_SSL_INVALID_PARAMETER 0x804351FE;
|
|
|
|
|
|
|
|
bool isSslInit;
|
|
|
|
u32 maxMemSize;
|
|
|
|
u32 currentMemSize;
|
|
|
|
|
|
|
|
void __SslInit()
|
|
|
|
{
|
|
|
|
isSslInit = 0;
|
|
|
|
maxMemSize = 0;
|
|
|
|
currentMemSize = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-28 07:00:04 +00:00
|
|
|
void __SslDoState(PointerWrap &p)
|
|
|
|
{
|
2013-09-15 03:23:03 +00:00
|
|
|
auto s = p.Section("sceSsl", 1);
|
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
2012-12-28 07:00:04 +00:00
|
|
|
p.Do(isSslInit);
|
|
|
|
p.Do(maxMemSize);
|
|
|
|
p.Do(currentMemSize);
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static int sceSslInit(int heapSize)
|
2012-12-06 15:24:25 +00:00
|
|
|
{
|
|
|
|
DEBUG_LOG(HLE, "sceSslInit %d", heapSize);
|
|
|
|
if (isSslInit)
|
|
|
|
{
|
|
|
|
return ERROR_SSL_ALREADY_INIT;
|
|
|
|
}
|
|
|
|
if (heapSize <= 0)
|
|
|
|
{
|
|
|
|
return ERROR_SSL_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxMemSize = heapSize;
|
|
|
|
currentMemSize = heapSize / 2; // As per jpcsp
|
|
|
|
isSslInit = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static int sceSslEnd()
|
2012-12-06 15:24:25 +00:00
|
|
|
{
|
|
|
|
DEBUG_LOG(HLE, "sceSslEnd");
|
|
|
|
if (!isSslInit)
|
|
|
|
{
|
|
|
|
return ERROR_SSL_NOT_INIT;
|
|
|
|
}
|
|
|
|
isSslInit = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static int sceSslGetUsedMemoryMax(u32 maxMemPtr)
|
2012-12-06 15:24:25 +00:00
|
|
|
{
|
|
|
|
DEBUG_LOG(HLE, "sceSslGetUsedMemoryMax %d", maxMemPtr);
|
|
|
|
if (!isSslInit)
|
|
|
|
{
|
|
|
|
return ERROR_SSL_NOT_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Memory::IsValidAddress(maxMemPtr))
|
|
|
|
{
|
|
|
|
Memory::Write_U32(maxMemSize, maxMemPtr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static int sceSslGetUsedMemoryCurrent(u32 currentMemPtr)
|
2012-12-06 15:24:25 +00:00
|
|
|
{
|
|
|
|
DEBUG_LOG(HLE, "sceSslGetUsedMemoryCurrent %d", currentMemPtr);
|
|
|
|
if (!isSslInit)
|
|
|
|
{
|
|
|
|
return ERROR_SSL_NOT_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Memory::IsValidAddress(currentMemPtr))
|
|
|
|
{
|
|
|
|
Memory::Write_U32(currentMemSize, currentMemPtr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const HLEFunction sceSsl[] =
|
|
|
|
{
|
2015-03-22 23:57:56 +00:00
|
|
|
{0X957ECBE2, &WrapI_I<sceSslInit>, "sceSslInit", 'i', "i"},
|
|
|
|
{0X191CDEFF, &WrapI_V<sceSslEnd>, "sceSslEnd", 'i', "" },
|
|
|
|
{0X5BFB6B61, nullptr, "sceSslGetNotAfter", '?', "" },
|
|
|
|
{0X17A10DCC, nullptr, "sceSslGetNotBefore", '?', "" },
|
|
|
|
{0X3DD5E023, nullptr, "sceSslGetSubjectName", '?', "" },
|
|
|
|
{0X1B7C8191, nullptr, "sceSslGetIssuerName", '?', "" },
|
|
|
|
{0XCC0919B0, nullptr, "sceSslGetSerialNumber", '?', "" },
|
|
|
|
{0X058D21C0, nullptr, "sceSslGetNameEntryCount", '?', "" },
|
|
|
|
{0XD6D097B4, nullptr, "sceSslGetNameEntryInfo", '?', "" },
|
|
|
|
{0XB99EDE6A, &WrapI_U<sceSslGetUsedMemoryMax>, "sceSslGetUsedMemoryMax", 'i', "x"},
|
|
|
|
{0X0EB43B06, &WrapI_U<sceSslGetUsedMemoryCurrent>, "sceSslGetUsedMemoryCurrent", 'i', "x"},
|
|
|
|
{0XF57765D3, nullptr, "sceSslGetKeyUsage", '?', "" },
|
2012-12-06 15:24:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void Register_sceSsl()
|
|
|
|
{
|
|
|
|
RegisterModule("sceSsl", ARRAY_SIZE(sceSsl), sceSsl);
|
|
|
|
}
|