Editing PKG files
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 28: | Line 28: | ||
PS Vita: PSP securities + more Metadata (0xD-0x12) that embed digests of files embedded into the .pkg. | PS Vita: PSP securities + more Metadata (0xD-0x12) that embed digests of files embedded into the .pkg. | ||
=== | === 0x40 digest === | ||
See [[Keys# | See [[Keys#GPKG.2FSELF_ECDSA_signature]]. | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 36: | Line 36: | ||
! Name !! Offset !! Size !! Remark | ! Name !! Offset !! Size !! Remark | ||
|- | |- | ||
| cmac_hash || 0x0 || 0x10 || | | cmac_hash || 0x0 || 0x10 || CMAC OMAC hash. PS3 gpkg_key used as key. | ||
|- | |- | ||
| npdrm_signature || 0x10 || 0x28 || PKG header NPDRM ECDSA | | npdrm_signature || 0x10 || 0x28 || PKG header NPDRM ECDSA (R_sig, S_sig) | ||
|- | |- | ||
| sha1_hash || 0x38 || 0x8 || | | sha1_hash || 0x38 || 0x8 || last 8 bytes of sha1 hash | ||
|} | |} | ||
<source lang="C"> | <source lang="C"> | ||
typedef struct | typedef struct { // size is 0x40 | ||
u8 cmac_hash[0x10]; | u8 cmac_hash[0x10]; | ||
u8 npdrm_signature[0x28]; | u8 npdrm_signature[0x28]; | ||
u8 sha1_hash[0x8]; | u8 sha1_hash[0x8]; | ||
} | } digest; | ||
</source> | </source> | ||
Line 97: | Line 97: | ||
===== PS3 / PSP Finalized Packages ===== | ===== PS3 / PSP Finalized Packages ===== | ||
For PS3 / PSP NPDRM packages, the file table and the data | For PS3 / PSP NPDRM packages, the file table and the data is AES128CTR encrypted/decrypted using pkg_data_riv as the IV along with the PS3/PSP constant AES Key. | ||
<source lang="C"> | <source lang="C"> | ||
Line 117: | Line 117: | ||
===== PS Vita / PSM Finalized Packages ===== | ===== PS Vita / PSM Finalized Packages ===== | ||
For PS Vita / PSM NPDRM packages type 2, 3 and 4, pkg_data_riv is | For PS Vita / PSM NPDRM packages type 2, 3 and 4, pkg_data_riv is AES128CTR encrypted to create an AES session key. Then it does the normal AES128CTR with pkg_data_riv as the IV and the session key as the AES128CTR key. | ||
<source lang="C"> | <source lang="C"> | ||
Line 136: | Line 136: | ||
memset(key, 0, sizeof key); | memset(key, 0, sizeof key); | ||
memcpy(key, pkg-> | memcpy(key, pkg->digest, 8); | ||
memcpy(key + 0x08, pkg-> | memcpy(key + 0x08, pkg->digest, 8); | ||
if (isArcade) | if (isArcade) | ||
memcpy(key + 0x10, pkg-> | memcpy(key + 0x10, pkg->digest, 8); | ||
else | else | ||
memcpy(key + 0x10, pkg-> | memcpy(key + 0x10, pkg->digest + 0x08, 8); | ||
memcpy(key + 0x18, pkg-> | memcpy(key + 0x18, pkg->digest + 0x08, 8); | ||
if (isArcade) | if (isArcade) | ||
memset(key + 0x20, 0xA0, 0x18); | memset(key + 0x20, 0xA0, 0x18); | ||
Line 215: | Line 215: | ||
| <span style="background-color:#000000; color:#ffffff;">digest || 0x60 || 0x10 || 09 8B A2 CA 2D 30 30 1F 8B 5B 82 79 C6 70 35 F3 || sha1 from debug files and attributes together merged in one block | | <span style="background-color:#000000; color:#ffffff;">digest || 0x60 || 0x10 || 09 8B A2 CA 2D 30 30 1F 8B 5B 82 79 C6 70 35 F3 || sha1 from debug files and attributes together merged in one block | ||
|- | |- | ||
| <span style="background-color:#ed1c24;">pkg_data_riv || 0x70 || 0x10 || D5 FA 15 9E 7F AC 82 70 BB 3E 0C EB 97 3D 30 11 || | | <span style="background-color:#ed1c24;">pkg_data_riv || 0x70 || 0x10 || D5 FA 15 9E 7F AC 82 70 BB 3E 0C EB 97 3D 30 11 || aes-128-ctr IV. Used with gpkg_aes_key to decrypt data. | ||
|- | |- | ||
| <span style="background-color:#808000;"> | | <span style="background-color:#808000;">header_cmac_hash || 0x80 || 0x10 || 48 0D 86 60 9F 26 8E 7F 4F B4 DA A4 33 1E 9A A1 || CMAC OMAC hash from 0x00-0x7F. PS3 gpkg_key used as key. | ||
|- | |||
| <span style="background-color:#3f48cc; color:#FFFFFF;">header_npdrm_signature || 0x90 || 0x28 || || PKG header NPDRM ECDSA (R_sig, S_sig) | |||
|- | |||
| <span style="background-color:#a349a4; color:#FFFFFF;">header_sha1_hash || 0xB8 || 0x08 || EC 61 40 39 A6 5B DC BD || last 8 bytes of sha1 hash of 0x00-0x7F | |||
|} | |} | ||
Line 235: | Line 239: | ||
u8 digest[0x10]; | u8 digest[0x10]; | ||
u8 pkg_data_riv[0x10]; | u8 pkg_data_riv[0x10]; | ||
u8 header_cmac_hash[0x10]; | |||
u8 header_npdrm_signature[0x28]; | |||
u8 header_sha1_hash[0x8]; | |||
} PKG_HEADER; | } PKG_HEADER; | ||
</source> | </source> | ||
Line 253: | Line 259: | ||
u32 main_and_ext_headers_hmac_offset; // ex: 0x100 | u32 main_and_ext_headers_hmac_offset; // ex: 0x100 | ||
u32 metadata_header_hmac_offset; // ex: 0x360, 0x390, 0x490 | u32 metadata_header_hmac_offset; // ex: 0x360, 0x390, 0x490 | ||
u64 tail_offset; // | u64 tail_offset; // tail size seems to be always 0x1A0 | ||
u32 padding1; | u32 padding1; | ||
u32 pkg_key_id; // Id of the AES key used for decryption. PSP = 0x1, PS Vita = 0xC0000002, PSM = 0xC0000004 | u32 pkg_key_id; // Id of the AES key used for decryption. PSP = 0x1, PS Vita = 0xC0000002, PSM = 0xC0000004 | ||
Line 273: | Line 279: | ||
} ... | } ... | ||
// u8 padding[variable]; | // u8 padding[variable]; | ||
u8 digest[0x40]; // [[PKG_files#0x40_digest]] | |||
} PKG_METADATA; | } PKG_METADATA; | ||
</source> | </source> | ||
Line 1,024: | Line 1,030: | ||
PS Vita .pkg | PS Vita .pkg | ||
==== PSN_get_pkg_info.py by windsurfer1122 (2018) ==== | |||
[[PSN_get_pkg_info.py]] Extracts information from package file as text or JSON for further analysis.<br /> | |||
==== | |||
[ | |||
Extracts information from package file as text or JSON for further analysis.<br /> | |||
Provides Linux shell scripts for mass creation of analysis data and to quickly grep through them.<br /> | Provides Linux shell scripts for mass creation of analysis data and to quickly grep through them.<br /> | ||
Analysis data of 10.000+ packages already directly downloadable [https://mega.nz/#F!cyxSVACA!Lp8VFpFz4K-DQLb221d83A here].<br /> | Analysis data of 10.000+ packages already directly downloadable [https://mega.nz/#F!cyxSVACA!Lp8VFpFz4K-DQLb221d83A here].<br /> | ||
Decrypts package to an unencrypted raw package.<br /> | Decrypts package to an unencrypted raw package.<br /> | ||
Planned feature is package extraction like PkgDecrypt and pkg2zip. | Planned feature is package extraction like PkgDecrypt and pkg2zip.<br /> | ||
PS3/PSX/PSP/PSV/PSM .pkg | |||
== Package links == | == Package links == |