This commit is contained in:
2024-05-11 23:24:13 +02:00
commit e66c5afde0
130 changed files with 17039 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
package npdrm
import "core:c"
import sce "../common"
foreign import npdrm "system:SceNpDrm_stub"
foreign import npdrmpackage "system:SceNpDrmPackage_stub"
foreign npdrm {
/**
* Get rif name
*
* @param[out] rif_name - RIF name buffer (48 bytes)
*
* @param[in] aid - Account ID
*
* @return 0 on success, < 0 on error.
*/
_sceNpDrmGetRifName :: proc(rif_name: [^]c.char, aid: c.uint64_t) -> c.int ---
/**
* Get fixed rif name
*
* @param[out] rif_name - RIF name buffer (48 bytes)
*
* @param[in] aid - Account ID
*
* @return 0 on success, < 0 on error.
*/
_sceNpDrmGetFixedRifName :: proc(rif_name: [^]c.char, aid: c.uint64_t) -> c.int ---
/**
* Check you have npdrm activation data, and get information from it
*
* @param[out] act_type - The pointer of activation type output.
*
* @param[out] version_flag - The pointer of version flag output.
*
* @param[out] account_id - The pointer of activated account id output.
*
* @param[out] act_exp_time - The pointer of activation expire time output, [0] is start_date, [1] is end_date
*
* @return 0 on success, < 0 on error.
*/
_sceNpDrmCheckActData :: proc(act_type: ^c.int, version_flag: ^c.int, account_id: ^sce.UInt64, act_exp_time: [2]sce.UInt64) -> c.int ---
/**
* Get rif name for install
*
* @param[out] rif_name - RIF name buffer (48 bytes)
*
* @param[in] rif_data - Data of RIF file (512 bytes)
*
* @param[in] unk - Unknown, use 0
*
* @return 0 on success, < 0 on error.
*/
_sceNpDrmGetRifNameForInstall :: proc(rif_name: [^]c.char, rif_data: rawptr, unk: c.int) -> c.int ---
/**
* Get PSM rif key
*
* @param[in] license_buf - RIF buffer (1024 bytes)
*
* @param[out] keydata - Decrypted key data
*
* @param[in] flags - Unknown
*
* @return 0 on success, < 0 on error
*/
scePsmDrmGetRifKey :: proc(#by_ptr license_buf: ScePsmDrmLicense, keydata: [^]c.char, flags: c.int) -> c.int ---
}
@(link_prefix = "_sceNpDrmPackage")
foreign npdrmpackage {
/**
* Read the header of the PKG and initialize the context
*
* @param buffer - The buffer containing the header of PKG.
* @param size - The size of buffer. The minimum confirmed value is 0x8000.
* @param zero - Unknown. Supposed to be set to 0.
* @param identifier - arbitrary value [0, 6) ORed with (1 << 8) or 0.
* If it is set to 0, the function just checks the header
* and doesn't create the context.
*
* @return 0 on success, != 0 on error
*/
Check :: proc(buffer: rawptr, size: sce.Size, zero: c.int, identifier: c.uint) -> c.int ---
/**
* Decrypt a PKG
*
* @param buffer - The buffer containing the content of the PKG.
* @param size - The size of the buffer. The minimum confirmed value is 0x20.
* @param opt - The options.
*
* @return 0 on success, != 0 on error
*/
Decrypt :: proc(#no_alias buffer: rawptr, size: sce.Size, #no_alias opt: ^_sceNpDrmPackageDecrypt_opt) -> c.int ---
}
+80
View File
@@ -0,0 +1,80 @@
package npdrm
import "core:c"
import sce "../common"
SceNpDrmActivationData :: struct { // size is 0x1038
act_type: sce.Int16,
version_flag: sce.Int16,
version: sce.Int32,
account_id: sce.UInt64,
primary_key_table: [0x80][0x10]sce.UInt8,
unk1: [0x40]sce.UInt8,
openpsid: [0x10]sce.UInt8,
unk2: [0x10]sce.UInt8,
unk3: [0x10]sce.UInt8,
secondary_key_table: [0x65][0x10]sce.UInt8,
rsa_signature: [0x100]sce.UInt8,
unk_sigmature: [0x40]sce.UInt8,
ecdsa_signature: [0x28]sce.UInt8, // checked by pspemu, and SceNpDrm.
}
#assert(size_of(SceNpDrmActivationData) == 0x1038)
SceNpDrmLicense :: struct { // size is 0x200
version: sce.Int16, // -1 VITA, 0 PSP, 1 PSP-VITA
version_flags: sce.Int16, // 0, 1
license_type: sce.Int16, // 1
license_flags: sce.Int16, // 0x400:non-check ecdsa
account_id: sce.UInt64,
content_id: [0x30]c.char,
key_table: [0x10]c.char,
key1: [0x10]c.char,
start_time: sce.Int64,
expiration_time: sce.Int64,
ecdsa_signature: [0x28]c.char,
flags: sce.Int64,
key2: [0x10]c.char,
unk_0xB0: [0x10]c.char,
open_psid: [0x10]c.char,
unk_0xD0: [0x10]c.char,
cmd56_handshake_part: [0x14]c.char,
debug_upgradable: c.int,
unk_0xF8: c.int,
sku_flag: c.int,
rsa_signature: [0x100]c.char,
}
#assert(size_of(SceNpDrmLicense) == 0x200)
ScePsmDrmLicense :: struct {
magic: [0x8]c.char,
unk1: sce.UInt32,
unk2: sce.UInt32,
account_id: sce.UInt64,
unk3: sce.UInt32,
unk4: sce.UInt32,
start_time: sce.UInt64,
expiration_time: sce.UInt64,
activation_checksum: [0x20]sce.UInt8,
content_id: [0x30]c.char,
unk5: [0x80]sce.UInt8,
unk6: [0x20]sce.UInt8,
key: [0x10]sce.UInt8,
signature: [0x1D0]sce.UInt8,
rsa_signature: [0x100]sce.UInt8,
}
#assert(size_of(ScePsmDrmLicense) == 0x400)
/** Options for _sceNpDrmPackageDecrypt */
_sceNpDrmPackageDecrypt_opt :: struct {
/** The offset in the encrypted data */
offset: sce.Off,
/**
* The identifier specified for _sceNpDrmPackageCheck but NOT ORed
* with (1 << 8)
*/
identifier: c.uint,
}
#assert(size_of(_sceNpDrmPackageDecrypt_opt) == 0x10)