Pass the new sha1/md5 test.

This commit is contained in:
Henrik Rydgard committed 2013-09-03 00:36:55 +02:00
1 parent 08d5190740
commit 9dcd67fc31
9 files changed
+120 -51

No files matched your search

-35
View File
@@ -1,35 +0,0 @@
set(SRCS
ColorUtil.cpp
ConsoleListener.cpp
ExtendedTrace.cpp
#FPURoundModeX86.cpp
FileSearch.cpp
FileUtil.cpp
Hash.cpp
IniFile.cpp
LogManager.cpp
MemArena.cpp
MemoryUtil.cpp
Misc.cpp
MsgHandler.cpp
StringUtils.cpp
Thread.cpp
ThreadPools.cpp
Timer.cpp
)
# TODO
if (ARM)
set(SRCS ${SRCS} ArmEmitter.cpp ArmABI.cpp)
else()
set(SRCS ${SRCS} CPUDetect.cpp MathUtil.cpp Thunk.cpp x64Analyzer.cpp x64Emitter.cpp ABI.cpp)
endif (ARM)
set(SRCS ${SRCS})
add_library(common STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)
+2
View File
@@ -178,6 +178,7 @@
<ClInclude Include="ConsoleListener.h" />
<ClInclude Include="CPUDetect.h" />
<ClInclude Include="Crypto\md5.h" />
<ClInclude Include="Crypto\sha1.h" />
<ClInclude Include="DebugInterface.h" />
<ClInclude Include="ExtendedTrace.h" />
<ClInclude Include="FifoQueue.h" />
@@ -222,6 +223,7 @@
<ClCompile Include="ConsoleListener.cpp" />
<ClCompile Include="CPUDetect.cpp" />
<ClCompile Include="Crypto\md5.cpp" />
<ClCompile Include="Crypto\sha1.cpp" />
<ClCompile Include="ExtendedTrace.cpp" />
<ClCompile Include="FileSearch.cpp" />
<ClCompile Include="FileUtil.cpp" />
+6
View File
@@ -48,6 +48,9 @@
<ClInclude Include="KeyMap.h" />
<ClInclude Include="Swap.h" />
<ClInclude Include="CommonWindows.h" />
<ClInclude Include="Crypto\sha1.h">
<Filter>Crypto</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp" />
@@ -78,6 +81,9 @@
<Filter>Crypto</Filter>
</ClCompile>
<ClCompile Include="KeyMap.cpp" />
<ClCompile Include="Crypto\sha1.cpp">
<Filter>Crypto</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
+8 -8
View File
@@ -91,14 +91,14 @@ const HLEFunction UtilsForUser[] =
{0x27CC57F0, WrapU_U<sceKernelLibcTime>, "sceKernelLibcTime"},
{0x71EC4271, WrapU_UU<sceKernelLibcGettimeofday>, "sceKernelLibcGettimeofday"},
{0xBFA98062, WrapI_UI<sceKernelDcacheInvalidateRange>, "sceKernelDcacheInvalidateRange"},
{0xC8186A58, 0, "sceKernelUtilsMd5Digest"},
{0x9E5C5086, 0, "sceKernelUtilsMd5BlockInit"},
{0x61E1E525, 0, "sceKernelUtilsMd5BlockUpdate"},
{0xB8D24E78, 0, "sceKernelUtilsMd5BlockResult"},
{0x840259F1, 0, "sceKernelUtilsSha1Digest"},
{0xF8FCD5BA, 0, "sceKernelUtilsSha1BlockInit"},
{0x346F6DA8, 0, "sceKernelUtilsSha1BlockUpdate"},
{0x585F1C09, 0, "sceKernelUtilsSha1BlockResult"},
{0xC8186A58, WrapI_UIU<sceKernelUtilsMd5Digest>, "sceKernelUtilsMd5Digest"},
{0x9E5C5086, WrapI_U<sceKernelUtilsMd5BlockInit>, "sceKernelUtilsMd5BlockInit"},
{0x61E1E525, WrapI_UUI<sceKernelUtilsMd5BlockUpdate>, "sceKernelUtilsMd5BlockUpdate"},
{0xB8D24E78, WrapI_UU<sceKernelUtilsMd5BlockResult>, "sceKernelUtilsMd5BlockResult"},
{0x840259F1, WrapI_UIU<sceKernelUtilsSha1Digest>, "sceKernelUtilsSha1Digest"},
{0xF8FCD5BA, WrapI_U<sceKernelUtilsSha1BlockInit>, "sceKernelUtilsSha1BlockInit"},
{0x346F6DA8, WrapI_UUI<sceKernelUtilsSha1BlockUpdate>, "sceKernelUtilsSha1BlockUpdate"},
{0x585F1C09, WrapI_UU<sceKernelUtilsSha1BlockResult>, "sceKernelUtilsSha1BlockResult"},
{0xE860E75E, WrapU_UU<sceKernelUtilsMt19937Init>, "sceKernelUtilsMt19937Init"},
{0x06FB8A63, WrapU_U<sceKernelUtilsMt19937UInt>, "sceKernelUtilsMt19937UInt"},
{0x37FB5C42, WrapU_V<sceKernelGetGPI>, "sceKernelGetGPI"},
+91 -7
View File
@@ -18,6 +18,7 @@
#include "Core/HLE/HLE.h"
#include "Core/Reporting.h"
#include "Common/Crypto/md5.h"
#include "Common/Crypto/sha1.h"
// Not really sure where these belong - is it worth giving them their own file?
u32 sceKernelUtilsMt19937Init(u32 ctx, u32 seed) {
@@ -43,6 +44,16 @@ u32 sceKernelUtilsMt19937UInt(u32 ctx) {
static md5_context md5_ctx;
int sceMd5Digest(u32 dataAddr, u32 len, u32 digestAddr) {
DEBUG_LOG(HLE, "sceMd5Digest(%08x, %d, %08x)", dataAddr, len, digestAddr);
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
return -1;
md5(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
return 0;
}
int sceMd5BlockInit(u32 ctxAddr) {
DEBUG_LOG(HLE, "sceMd5BlockInit(%08x)", ctxAddr);
if (!Memory::IsValidAddress(ctxAddr))
@@ -70,21 +81,94 @@ int sceMd5BlockResult(u32 ctxAddr, u32 digestAddr) {
return -1;
md5_finish(&md5_ctx, Memory::GetPointer(digestAddr));
// TODO: Should output be hex ascii?
return 0;
}
int sceMd5Digest(u32 dataPtr, u32 len, u32 digestAddr) {
WARN_LOG(HLE, "sceMd5Digest(%08x, %d, %08x)", dataPtr, len, digestAddr);
if (!Memory::IsValidAddress(dataPtr) || !Memory::IsValidAddress(digestAddr))
int sceKernelUtilsMd5Digest(u32 dataAddr, int len, u32 digestAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsMd5Digest(%08x, %d, %08x)", dataAddr, len, digestAddr);
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
return -1;
md5(Memory::GetPointer(dataPtr), (int)len, Memory::GetPointer(digestAddr));
// TODO: Should output be hex ascii?
md5(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
return 0;
}
int sceKernelUtilsMd5BlockInit(u32 ctxAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsMd5BlockInit(%08x)", ctxAddr);
if (!Memory::IsValidAddress(ctxAddr))
return -1;
// TODO: Until I know how large a context is, we just go all lazy and use a global context,
// which will work just fine unless games do several MD5 concurrently.
md5_starts(&md5_ctx);
return 0;
}
int sceKernelUtilsMd5BlockUpdate(u32 ctxAddr, u32 dataPtr, int len) {
DEBUG_LOG(HLE, "sceKernelUtilsMd5BlockUpdate(%08x, %08x, %d)", ctxAddr, dataPtr, len);
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataPtr))
return -1;
md5_update(&md5_ctx, Memory::GetPointer(dataPtr), (int)len);
return 0;
}
int sceKernelUtilsMd5BlockResult(u32 ctxAddr, u32 digestAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsMd5BlockResult(%08x, %08x)", ctxAddr, digestAddr);
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr))
return -1;
md5_finish(&md5_ctx, Memory::GetPointer(digestAddr));
return 0;
}
static sha1_context sha1_ctx;
int sceKernelUtilsSha1Digest(u32 dataAddr, int len, u32 digestAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsSha1Digest(%08x, %d, %08x)", dataAddr, len, digestAddr);
if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr))
return -1;
sha1(Memory::GetPointer(dataAddr), (int)len, Memory::GetPointer(digestAddr));
return 0;
}
int sceKernelUtilsSha1BlockInit(u32 ctxAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsSha1BlockInit(%08x)", ctxAddr);
if (!Memory::IsValidAddress(ctxAddr))
return -1;
// TODO: Until I know how large a context is, we just go all lazy and use a global context,
// which will work just fine unless games do several MD5 concurrently.
sha1_starts(&sha1_ctx);
return 0;
}
int sceKernelUtilsSha1BlockUpdate(u32 ctxAddr, u32 dataAddr, int len) {
DEBUG_LOG(HLE, "sceKernelUtilsSha1BlockUpdate(%08x, %08x, %d)", ctxAddr, dataAddr, len);
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataAddr))
return -1;
sha1_update(&sha1_ctx, Memory::GetPointer(dataAddr), (int)len);
return 0;
}
int sceKernelUtilsSha1BlockResult(u32 ctxAddr, u32 digestAddr) {
DEBUG_LOG(HLE, "sceKernelUtilsSha1BlockResult(%08x, %08x)", ctxAddr, digestAddr);
if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr))
return -1;
sha1_finish(&sha1_ctx, Memory::GetPointer(digestAddr));
return 0;
}
const HLEFunction sceMd5[] = {
{0x19884A15, WrapI_U<sceMd5BlockInit>, "sceMd5BlockInit"},
{0xA30206C2, WrapI_UUU<sceMd5BlockUpdate>, "sceMd5BlockUpdate"},
+10
View File
@@ -23,3 +23,13 @@ void Register_sceMd5();
u32 sceKernelUtilsMt19937Init(u32 ctx, u32 seed);
u32 sceKernelUtilsMt19937UInt(u32 ctx);
int sceKernelUtilsMd5Digest(u32 dataAddr, int len, u32 digestAddr);
int sceKernelUtilsMd5BlockInit(u32 ctxAddr);
int sceKernelUtilsMd5BlockUpdate(u32 ctxAddr, u32 dataAddr, int len);
int sceKernelUtilsMd5BlockResult(u32 ctxAddr, u32 digestAddr);
int sceKernelUtilsSha1Digest(u32 dataAddr, int len, u32 digestAddr);
int sceKernelUtilsSha1BlockInit(u32 ctxAddr);
int sceKernelUtilsSha1BlockUpdate(u32 ctxAddr, u32 dataAddr, int len);
int sceKernelUtilsSha1BlockResult(u32 ctxAddr, u32 digestAddr);
+1
View File
@@ -220,6 +220,7 @@ public:
// Integer value passed in a float. Wraps and all, required for Monster Hunter.
pos[2] = (float)((u16)(s32)pos[2]) * (1.0f / 65535.0f);
}
// See https://github.com/hrydgard/ppsspp/pull/3419, something is weird.
}
break;
case DEC_S16_3:
+1
View File
@@ -163,6 +163,7 @@ LOCAL_SRC_FILES := \
$(SRC)/ext/xbrz/xbrz.cpp \
$(SRC)/ext/xxhash.c \
$(SRC)/Common/Crypto/md5.cpp \
$(SRC)/Common/Crypto/sha1.cpp \
$(SRC)/Common/KeyMap.cpp \
$(SRC)/Common/LogManager.cpp \
$(SRC)/Common/MemArena.cpp \