Commit Graph
30 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 12fa56d842 PrxDecrypter: require a whole header before decrypting
Every decrypt type reads the tag at 0xD0, the compressed size at 0xB0 and key
data as far as 0x150, and writes a KIRK header into outbuf at a fixed offset
derived from sizeof(PSP_Header) - all without checking that either buffer is
that big. A PRX declaring a tiny psp_size therefore read past the end of its
input, wrote a 0xE0-byte header past the end of an equally tiny output buffer,
and handed KIRK "size - offset" as an unsigned underflow. The header write sits
behind the SHA-1 check, but the tag keys are compiled in and every hashed input
comes from the file, so that's arithmetic rather than luck. One size check at
the top of pspDecryptPRX covers all five types.

The module loader needed two things to go with it. Its "maybe it just isn't
encrypted" fallback checked for ELF magic at 0x150 of the *output* buffer, which
on the paths where decryption bails early has nothing written to it yet - so it
read uninitialized heap to decide, and then, if psp_size was under 0x150,
memcpy'd a negative length. It reads the input buffer now, which is what it goes
on to copy from anyway, and only when psp_size is big enough to hold what's
being tested.

Second, the returned size is just comp_size out of the file header, checked
against the allocated buffer by a _dbg_assert_ that isn't there in release. That
check is a real one now, folded into the existing sanity test next to it.

pspautotests cpu 11/11.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 19:19:06 +02:00
Henrik Rydgård c29e370e29 Remove global state from kirk engine 2025-06-05 22:46:24 +02:00
Henrik Rydgård 6bc625ecde More const-ness corrections 2025-06-05 22:46:23 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
LunaMoo eaf488fb7b Oops 2023-12-17 06:35:53 +01:00
LunaMoo 0fd3f00a19 Add xor to other update functions looking at killzone liberation issue #12343 which needs 2 keys as well(seeds) 2023-12-17 03:34:20 +01:00
LunaMoo bd7df8a675 Add more crypto keys from https://www.consolex.ru/forum/showthread.php?t=85431 2023-12-17 03:00:17 +01:00
Henrik Rydgård 989e353482 Common.h shouldn't include Log.h.
Buildfixes

More buildfixes. Move JSON code to common.
2020-10-04 11:42:14 +02:00
Henrik Rydgård 0586338d5e Add some comments and const-correctness, and a pointer type fix, to the "semaphore" crypto stuff. 2020-08-01 23:11:48 +02:00
Davee Morgan 4c9e7b7424 PRX Decryption: add pauth decryption 2020-01-11 20:43:38 +00:00
Davee Morgan 1d7bbdd006 PRX Decryption: add support for type 0/1/2/5/6 decryption 2020-01-11 15:00:07 +00:00
Henrik Rydgård 6a1fa728d8 Remove Globals.h 2017-08-31 17:15:22 +02:00
Henrik Rydgård 440e72d250 Clean up among the logs. Remove MASTER_LOG. 2017-03-06 13:10:23 +01:00
chinhodado 422764e077 Remove an unnecessary memcpy 2014-12-14 23:59:55 -05:00
ppsspp213 8e18d0ff94 Update PrxDecrypter.cpp
Unknown Key ADF305F0
2014-06-24 15:48:59 +01:00
Henrik Rydgård e5e17fbc6e More include cleanup. Hoping for very slightly faster compile times.. 2013-12-30 10:49:05 +01:00
Henrik Rydgård 00c32ddadb Mostly get rid of including "Globals.h" 2013-12-30 10:17:11 +01:00
Ced2911 ae358d2898 fix prx decryption 2013-07-30 19:36:07 +02:00
tpunix aae16cd732 improve of prsDecrypt2. support decrypt type 6. 2013-07-08 12:41:08 +08:00
Sacha b39a572043 Buildfixes.
Fix C++11 usage.
Remove redundancy.
Fix st_*time re-usage.
2013-06-02 13:26:39 +10:00
Henrik Rydgard a842c46208 Some operations were doing things in 16-byte blocks. Adjust some buffer sizes to allow for this. Also remove a global. 2013-01-03 22:54:40 +01:00
Henrik Rydgard 98fd202730 Constify a couple of globals 2013-01-03 12:05:16 +01:00
Arthur Blot 1519600441 Implemented sceKernelLoadModuleByID, better logs 2013-01-02 19:42:15 +01:00
Henrik Rydgård 875f3569ee Don't let DecryptPRX1 scramble the keys in-place (!), make a copy
instead. Could now make all the keys const, as they should be.
2012-12-25 09:02:02 +01:00
raven02 49e9a5738c Put back byte array to stack and increase buffer size 2012-12-25 09:06:27 +08:00
Henrik Rydgard 91eeed6408 Hack to prevent stack checker from alerting 2012-11-06 15:46:00 +01:00
Arthur Blot 6a1af73b37 Better module blacklisting, export fix 2012-11-05 18:03:02 +01:00
Arthur Blot d0542e3531 Fixed a few issues related to encrypted PRXes 2012-11-05 16:56:40 +01:00
Henrik Rydgard ac910d7e75 Fix Windows and Android builds. 2012-11-05 15:42:21 +01:00
Arthur Blot 5b5618d32d Added ~PSP decryption system using kirk-engine 2012-11-05 14:59:38 +01:00