feat(libSceNpCommon): implement sce::np::NpTitleSecret #12919
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12919"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-29T14:21:43Z.
What
Implements 24
sce::np::NpTitleSecretexports fromlibSceNpCommon.sprxof firmware 13.60 (read from disassembly, not measured on a console). Two of them wereNotImplementedstubs with placeholderint (void)declarations (C2(const NpTitleSecret&)andC2(const SceNpTitleSecret&)). The other 22 are exported by the module but were missing from AnyPS5.Two exports of the class stay stubs, because open PRs implement them:
Clear(#12823);operator!=(const NpTitleSecret&, const SceNpTitleSecret&)(#12866).The object is 136 bytes: a vtable pointer, then the existing 128-byte
NpTitleSecret(SceNpTitleSecret). It is declared asNpTitleSecretObjectinApi.hpp, next toNpTitleIdObjectfrom #12899.NpTitleSecretor from aSceNpTitleSecret;(const void*, size_t)copies 128 bytes. The module assertssize == (128)and panics otherwise; AnyPS5 throwsstd::invalid_argumentthere, as for the other firmware assertions, and the debt file says so.operator=: copies the 128 bytes and leaves the vtable unchanged.D1/D2do nothing.D0frees throughsce::np::Object::operator delete(void*)(#12836). The vtable is{0, 0, D1, D0}.SetSecretData(const void*, size_t): returns0x80559E11with the object unchanged unless the size is 128.IsEmpty: checks whether all 128 bytes are zero.Equals:NpTitleSecretandSceNpTitleSecretforms,operator==(3 forms) andoperator!=(2 forms) compare all 128 bytes.ParseHex(NpTitleSecret*, const char*, size_t)/BuildHex(const NpTitleSecret&, char*, size_t, bool): callsceNpStrnParseHex/sceNpStrBuildHexon the 128 bytes and return only negative results, as the module does (result & (result >> 31)).Tested
Linux (CachyOS, GCC 16.2, Release):
ctest --test-dir build -R 'np_common|public_headers' --output-on-failure, 70/70 passed.TestTitleSecretObjectsinGuestNpCommonRuntime.cppchecks:SetSecretData,Equalsand the data constructor (including its assertion);BuildHexbuffer size and aBuildHex→ParseHexround trip with ParseHex's length errors;D0freeing through the allocator stored byObject::operator new.Comparison against the firmware code: I relinked the 13.60 module with this repo's relinker and ran the exports under unicorn (x86-64 emulation on a PC, not a console).
operator=: 300 each;SetSecretDataandBuildHex: 2,000 each;ParseHex: 3,000;Equalswith a size: 1,000;IsEmptyand each other comparison: 600 each.main, which includes thesceNpStrnParseHexfix from #12913. Before #12913 was merged, the 289ParseHexcases with a refused low digit differed because of that function. 20 corrupted expectations add exactly 20 mismatches.The generator and harness are
np_title_secret_make_cases.py/np_title_secret_replay.cppin https://gist.github.com/hypermoist/1834cf221fd737cdb4cca272cc1156d1. The gist has no module or recorded output.Windows not built. Not run on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)NpTitleIdObject), which is merged withmain. #12836 (D0usessce::np::Object::operator delete) and #12913 (theParseHexfix) are merged. Other open PRs touching neighbouring lines: #11601, #12825, #12829, #12830 and #12859 touch neighbouring stub, declaration or include lines. Whichever lands second needs a trivial merge, and I will do it.Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:54:13Z.
Review: COMMENTED
Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (
Unblocks: noneis allowed), and it contained no code review.