Skip to content

Commit

Permalink
Merge pull request #836 from LiEnby/patch-2
Browse files Browse the repository at this point in the history
add missing arguments to scePsmDrmGetRifKey
  • Loading branch information
Princess-of-Sleeping authored Aug 9, 2024
2 parents 96b8721 + 3d3c84a commit 2aa3d05
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
11 changes: 7 additions & 4 deletions include/psp2/npdrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ int _sceNpDrmCheckActData(int *act_type, int *version_flag, SceUInt64 *account_i
*
* @return 0 on success, < 0 on error.
*/
int _sceNpDrmGetRifNameForInstall(char *rif_name, const void *rif_data, int unk);
int _sceNpDrmGetRifNameForInstall(char *rif_name, const SceNpDrmLicense *rif_data, int unk);

/**
* Get PSM rif key
*
* @param[in] license_buf - RIF buffer (1024 bytes)
*
* @param[out] keydata - Decrypted key data
* @param[out] keydata - Decrypted keyset
*
* @param[in] flags - Unknown
* @param[out] flags - License flags
*
* @param[out] exp_time - Expire times output
*
* @return 0 on success, < 0 on error
*/
int scePsmDrmGetRifKey(const ScePsmDrmLicense *license_buf, char *keydata, int flags);
int scePsmDrmGetRifKey(const ScePsmDrmLicense *license_buf, ScePsmDrmKeySet *keydata, int* flags, ScePsmDrmExpireTime* exp_time);


#ifdef __cplusplus
}
Expand Down
31 changes: 22 additions & 9 deletions include/psp2common/npdrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@
#define _PSP2COMMON_NPDRM_H_

#include <vitasdk/build_utils.h>
#include <psp2common/kernel/rtc.h>
#include <psp2common/types.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct ScePsmDrmKeySet {
SceUInt8 hmac_key[0x20];
SceUInt8 key[0x10];
SceUInt8 signature[0x1D0];
} ScePsmDrmKeySet;
VITASDK_BUILD_ASSERT_EQ(0x200, ScePsmDrmKeySet);

typedef struct ScePsmDrmExpireTime { // size is 0x10
SceRtcTick* start_date;
SceRtcTick* end_date;
int pad[2];
} ScePsmDrmExpireTime;
VITASDK_BUILD_ASSERT_EQ(0x10, ScePsmDrmExpireTime);

typedef struct SceNpDrmActivationData { // size is 0x1038
SceInt16 act_type;
SceInt16 version_flag;
Expand All @@ -31,16 +46,16 @@ typedef struct SceNpDrmActivationData { // size is 0x1038
VITASDK_BUILD_ASSERT_EQ(0x1038, SceNpDrmActivationData);

typedef struct SceNpDrmLicense { // size is 0x200
SceInt16 version; // -1 VITA, 0 PSP, 1 PSP-VITA
SceInt16 version; // -1 VITA (NPDRM_FREE), 0 PSP, 1 PSP-VITA
SceInt16 version_flags; // 0, 1
SceInt16 license_type; // 1
SceInt16 license_flags; // 0x400:non-check ecdsa
SceUInt64 account_id;
SceUInt64 account_id; // 0x0:NPDRM_FREE
char content_id[0x30];
char key_table[0x10];
char key1[0x10];
SceInt64 start_time;
SceInt64 expiration_time;
SceRtcTick start_time;
SceRtcTick expiration_time;
char ecdsa_signature[0x28];
SceInt64 flags;
char key2[0x10];
Expand All @@ -62,14 +77,12 @@ typedef struct ScePsmDrmLicense {
SceUInt64 account_id;
SceUInt32 unk3;
SceUInt32 unk4;
SceUInt64 start_time;
SceUInt64 expiration_time;
SceRtcTick start_time;
SceRtcTick expiration_time;
SceUInt8 activation_checksum[0x20];
char content_id[0x30];
SceUInt8 unk5[0x80];
SceUInt8 unk6[0x20];
SceUInt8 key[0x10];
SceUInt8 signature[0x1D0];
ScePsmDrmKeySet keyset;
SceUInt8 rsa_signature[0x100];
} ScePsmDrmLicense;
VITASDK_BUILD_ASSERT_EQ(0x400, ScePsmDrmLicense);
Expand Down
6 changes: 3 additions & 3 deletions include/psp2kern/npdrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int ksceNpDrmCheckActData(int *act_type, int *version_flag, SceUInt64 *account_i
*
* @return 0 on success, < 0 on error.
*/
int ksceNpDrmGetRifVitaKey(const void *license, void *klicense, int *flags, int *sku_flags, SceUInt64 *lic_start_time, SceUInt64 *lic_exp_time);
int ksceNpDrmGetRifVitaKey(const SceNpDrmLicense *license, void *klicense, int *flags, int *sku_flags, SceUInt64 *lic_start_time, SceUInt64 *lic_exp_time);

/**
* Get license key info for a PSP game
Expand All @@ -81,7 +81,7 @@ int ksceNpDrmGetRifVitaKey(const void *license, void *klicense, int *flags, int
*
* @return 0 on success, < 0 on error.
*/
int ksceNpDrmGetRifPspKey(const void *license, void *klicense, int *flags, SceUInt64 *lic_start_time, SceUInt64 *lic_exp_time);
int ksceNpDrmGetRifPspKey(const SceNpDrmLicense *license, void *klicense, int *flags, SceUInt64 *lic_start_time, SceUInt64 *lic_exp_time);

/**
* Get license info
Expand All @@ -101,7 +101,7 @@ int ksceNpDrmGetRifPspKey(const void *license, void *klicense, int *flags, SceUI
*
* @return 0 on success, < 0 on error.
*/
int ksceNpDrmGetRifInfo(const void *license, SceSize license_size, int check_sign, char *content_id, SceUInt64 *account_id, int *license_version, int *license_flags, int *flags, int *sku_flags, SceInt64 *lic_start_time, SceInt64 *lic_exp_time, SceUInt64 *flags2);
int ksceNpDrmGetRifInfo(const SceNpDrmLicense *license, SceSize license_size, int check_sign, char *content_id, SceUInt64 *account_id, int *license_version, int *license_flags, int *flags, int *sku_flags, SceInt64 *lic_start_time, SceInt64 *lic_exp_time, SceUInt64 *flags2);

/**
* Verify a eboot.pbp signature "__sce_ebootpbp"
Expand Down

0 comments on commit 2aa3d05

Please sign in to comment.