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 1: | Line 1: | ||
See also {{talk}} page | See also {{talk}} page | ||
= Firmware Packages = | |||
= | == File Header == | ||
All values are in big endian format. | |||
typedef struct { | |||
u32 0x00, 0x53434500// magic | |||
u32 0x04, 2 // version | |||
u16 0x08, 0 // sdk type? | |||
u16 0x0a, 3 // SCE header type; pkg | |||
u32 0x0c, 0 // meta offset | |||
u64 0x10, // size of sce_hdr + sizeof meta_hdr | |||
u64 0x18, 0x80 // + content_size_real | |||
} | |||
== | = Game Packages = | ||
All game packages are signed with the ECDSA signature. The public key for it can be found in '''download_plugin.prx''' or in '''nas_plugin.prx''' (this also applies to NPDRM SELFs). Usually game packages are signed with two signatures - one for the header and the other for the entry table. | |||
All | |||
== File Header == | == File Header == | ||
=== Example from a retail PS3 .pkg === | |||
=== Example from a | |||
*Example: Scott Pilgrim VS. The World Unlock .pkg [http://zeus.dl.playstation.net/cdn/UP0001/NPUB30162_00/bG751I62Aych0U2E7hsxD5vKS28NurYg8CmJln6oQV4LUDAfXGSOyQHE45reFxIuwD5Qjo1xnQleHqulmmx9HmjNnXX8P5O5jcXlD.pkg file]: | *Example: Scott Pilgrim VS. The World Unlock .pkg [http://zeus.dl.playstation.net/cdn/UP0001/NPUB30162_00/bG751I62Aych0U2E7hsxD5vKS28NurYg8CmJln6oQV4LUDAfXGSOyQHE45reFxIuwD5Qjo1xnQleHqulmmx9HmjNnXX8P5O5jcXlD.pkg file]: | ||
Line 181: | Line 39: | ||
'''000000B0''' <span style="background-color:#3f48cc; color:#FFFFFF">CC 02 B4 35 2B 70 47 D6</span> <span style="background-color:#a349a4; color:#FFFFFF;">EC 61 40 39 A6 5B DC BD</span> М.ґ5+pGЦмa@9¦[ЬЅ | '''000000B0''' <span style="background-color:#3f48cc; color:#FFFFFF">CC 02 B4 35 2B 70 47 D6</span> <span style="background-color:#a349a4; color:#FFFFFF;">EC 61 40 39 A6 5B DC BD</span> М.ґ5+pGЦмa@9¦[ЬЅ | ||
=== | === PKG header === | ||
{| class="wikitable sortable" | |||
{| class="wikitable" | |||
|- | |- | ||
| style="background-color:#515243; color:#FFFFFF;" |'''Name''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Offset''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Size''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Example''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Remark''' | |||
|- | |- | ||
| <span style="background:#ff0000;">magic || 0x00 || 0x04 || 7F 50 4B 47 || | | <span style="background:#ff0000;">magic || 0x00 || 0x04 || 7F 50 4B 47 || '.PKG' | ||
|- | |- | ||
| <span style="background-color:#008000; color:#FFFFFF;">pkg_revision || 0x04 || 0x02 || 80 00 || 80 00 for finalized | | <span style="background-color:#008000; color:#FFFFFF;">pkg_revision || 0x04 || 0x02 || 80 00 || 80 00 for retail (finalized), 00 00 for debug (non finalized) | ||
|- | |- | ||
| <span style="background-color:#3F48CC; color:#FFFFFF;">pkg_type || 0x06 || 0x02 || 00 01 || 00 01 for PS3, 00 02 for PSP and | | <span style="background-color:#3F48CC; color:#FFFFFF;">pkg_type || 0x06 || 0x02 || 00 01 || 00 01 for PS3, 00 02 for PSP and PSVita | ||
|- | |- | ||
| <span style="background-color:#B5E61D;">pkg_metadata_offset || 0x08 || 0x04 || 00 00 00 C0 || | | <span style="background-color:#B5E61D;">pkg_metadata_offset || 0x08 || 0x04 || 00 00 00 C0 || 0xC0, usually 0x280 for PSP and PSVita | ||
|- | |- | ||
| <span style="background-color:#B97A57;">pkg_metadata_count || 0x0C || 0x04 || 00 00 00 08 || | | <span style="background-color:#B97A57;">pkg_metadata_count || 0x0C || 0x04 || 00 00 00 08 || item count | ||
|- | |- | ||
| <span style="background-color:#ff7f27;">pkg_metadata_size || 0x10 || 0x04 || 00 00 00 C0 || usually 0xC0 for PSP and PS3, usually 0x160 for | | <span style="background-color:#ff7f27;">pkg_metadata_size || 0x10 || 0x04 || 00 00 00 C0 || usually 0xC0 for PSP and PS3, usually 0x160 for PSVita | ||
|- | |- | ||
| <span style="background-color:#fff200;">item_count || 0x14 || 0x04 || 00 00 00 02 || files and folders into the encrypted data | | <span style="background-color:#fff200;">item_count || 0x14 || 0x04 || 00 00 00 02 || files and folders into the encrypted data | ||
Line 215: | Line 75: | ||
| <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_key to decrypt data. | ||
|- | |||
| <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:# | | <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 | |||
|} | |} | ||
All values are in big endian format. | |||
typedef struct { | typedef struct { | ||
u32 magic; | u32 magic; | ||
Line 235: | Line 101: | ||
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; | ||
=== PKG | === PKG metadata === | ||
typedef struct { | typedef struct { | ||
union { | union{ | ||
u32 packet_identifier; // 0-0x12 | u32 packet_identifier; // 0-0x12 | ||
u32 data_size; | u32 data_size; | ||
{ | { | ||
data | |||
} | } | ||
} ... | } ... | ||
// u8 padding[variable]; | // u8 padding[variable]; | ||
u8 unknown[0x40]; | |||
} PKG_METADATA; | } PKG_METADATA; | ||
{| class="wikitable" | {| class="wikitable" | ||
! Identifier !! | ! Identifier !! category name !! Possible size !! Possible values | ||
|- | |- | ||
|0x1 || | |0x1 || DRM Type || 4 || 0/5/6/7/8/9/0xA/0xB/0xC (unknown), 0x1 (network), 0x2 (local), 0x3 (DRMfree no license), 0x4 (PSP), 0xD (DRMfree with license), 0xE (PSM) | ||
|- | |- | ||
|0x2 | |0x2 || [[PKG_files#ContentType|Content Type]] || 4 || 00 00 00 07 | ||
|- | |- | ||
|0x3 | |0x3 || [[PKG_files#PackageType]] / [[PKG_files#PackageFlag]] / [[PKG_files#StorageType]] (PSVita) || 4 || Upgradeable, Patch, NonGame, HDDGamePatch, DiscGamePatch, RenameDirectory, ForcedInstallTo, Finalized | ||
|- | |- | ||
|0x4 | |0x4 || Package Size || 8 || 00 00 00 00 0E 77 40 00 | ||
|- | |- | ||
|0x5 | |0x5 || make_package_npdrm Revision (2 bytes) + Package Version (2 bytes) || 4 || 09 60 00 00 (960, 0.00), 12 03 00 00 (1203, 0.00), 12 12 00 00 (1212, 0.00), 12 73 01 01 (1273, 1.01), 19 53 01 00 (1953, 1.00), 19 63 01 00, 19 66 01 00, 19 72 01 02 (1972, 1.02) | ||
|- | |- | ||
|0x6 | |0x6 || Version + App Version / [[TitleID]] (on size 0xC) || 0xC || "NPEG00005\0\0\0" | ||
|- | |- | ||
|0x7 | |0x7 || QA Digest (described as "This is a digest of packaged files and attributes.")|| 0x18 || 00 00 00 00 00 00 00 00 B5 76 E1 D9 00 EE 9B BC 8E 24 17 91 5D BC 5A CB | ||
|- | |- | ||
|0x8 || | |0x8 || PS3/PSP/PSP2 System Version, Package Version, App Version || 8 || 00 00 00 00 00 00 00 00, 00 00 00 00 01 00 01 00, 44 01 70 00 01 01 00 00, 81 01 90 00 01 00 01 00, 81 04 75 00 01 02 01 00 | ||
|- | |- | ||
|0x9 | |0x9 || unk || 8 || either 00 00 00 00 00 00 00 00 or 00 00 00 00 00 24 00 00 | ||
|- | |- | ||
|0xA || | |0xA || unk || || | ||
|- | |- | ||
|0xB | |0xB || unk || || | ||
|- | |- | ||
|0xC | |0xC || unk || || | ||
|- | |- | ||
|0xD || | |0xD || ?ECDSA sig (or hash)? || 0x28 || always 6 zeroed chars at the beginning | ||
00 00 00 00 00 00 05 A0 18 8B B1 8A E5 E8 40 FD EE 71 E2 27 60 55 E6 39 06 94 5B 65 89 04 B2 88 61 DA BB A3 B2 55 C5 C1 | |||
|- | |- | ||
|0xE | |0xE || [[PKG_files#PARAM_SFO_info|PARAM.SFO Info]] || 0x38 || 00 00 0C 10 00 00 05 0C 00 00 00 14 01 67 00 00 00 00 00 00 00 00 00 00 FC 3D 1E 32 FA F7 A6 11 90 46 A6 34 BE 98 9A 78 65 A8 92 25 3C 49 D7 69 73 53 32 E7 8E 06 1E 60 | ||
|- | |- | ||
|0xF | |0xF || [[PKG_files#unknown_data0_info|unknown_data0_info]] || 0x48 || 00 00 05 60 00 00 03 20 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 0F 26 BD 5C 2F 13 95 EB 16 E6 62 07 8D 9A E3 DC 0B AC 25 11 1C 19 39 B9 40 06 4E 82 AF 1E C3 | ||
00 00 06 10 00 00 03 20 00 00 01 F4 00 00 01 F7 00 00 00 00 01 01 01 01 A5 74 D5 71 00 03 00 01 00 00 00 00 00 00 00 00 79 52 B2 3F 78 3B 9D F4 C0 BB 26 C0 EC 14 1B 37 8B 9B 69 71 1C 22 C3 49 57 97 B6 DE 78 0A D0 00 | 00 00 06 10 00 00 03 20 00 00 01 F4 00 00 01 F7 00 00 00 00 01 01 01 01 A5 74 D5 71 00 03 00 01 00 00 00 00 00 00 00 00 79 52 B2 3F 78 3B 9D F4 C0 BB 26 C0 EC 14 1B 37 8B 9B 69 71 1C 22 C3 49 57 97 B6 DE 78 0A D0 00 | ||
|- | |- | ||
|0x10 | |0x10 || [[PKG_files#entirety_info| Entirety Info]] || 0x38 || 00 00 0A 00 00 00 00 A0 D3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 4D AD EB 44 67 51 C1 2D 69 95 46 8C 82 A9 3D 74 AD F4 62 49 90 BD EE F0 75 97 A3 B6 5B 17 48 | ||
00 00 0A B0 00 00 01 60 FF D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 7F 9E EF 38 F7 61 6E C1 C5 CC B1 E1 83 12 0C 6F 38 4C 8C 22 84 8B A4 3B 7B 47 57 77 C9 F9 C9 | 00 00 0A B0 00 00 01 60 FF D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 7F 9E EF 38 F7 61 6E C1 C5 CC B1 E1 83 12 0C 6F 38 4C 8C 22 84 8B A4 3B 7B 47 57 77 C9 F9 C9 | ||
|- | |- | ||
|0x11 | |0x11 || PublishingTools version (4 Bytes) + PFSBuilder version (4 Bytes) + padding (0x20 Bytes) || 0x28 || 01 60 00 00 00 06 23 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
02 07 00 00 00 07 60 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 02 07 00 00 00 07 60 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
|- | |- | ||
|0x12 | |0x12 || [[PKG_files#unknown_data2_info|unknown_data2_info]] (points to a 0x10 bytes buffer)|| 0x38 || 00 00 11 20 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CF 74 D5 30 04 99 F0 57 E8 65 20 5C 3D 71 12 36 F1 E4 EF BC 98 EA 52 F1 F0 60 E8 7C 8A 53 B8 A4 | ||
|} | |} | ||
Line 323: | Line 167: | ||
{| class="wikitable" | {| class="wikitable" | ||
! | ! content type !! type name !! install path (on ps3) !! notes | ||
|- | |- | ||
| | |0x00000001 || || || | ||
|- | |- | ||
| | |0x00000002 || || || | ||
|- | |- | ||
| | |0x00000003 || || || | ||
|- | |- | ||
| | |0x00000004 || GameData (also patches) || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000005 || GameExec || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000006 || PS1Game || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000007 || PSP & PCEngine || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000008 || || || | ||
|- | |- | ||
| | |0x00000009 || Theme || /dev_hdd0/theme || | ||
|- | |- | ||
| | |0x0000000A || Widget || /dev_hdd0/widget || | ||
|- | |- | ||
| | |0x0000000B || License || /dev_hdd0/home/<current user>/exdata || | ||
|- | |- | ||
| | |0x0000000C || VSHModule || /dev_hdd0/vsh/modules/ || | ||
|- | |- | ||
| | |0x0000000D || PSN Avatar || /dev_hdd0/home/<current user>/psn_avatar || | ||
|- | |- | ||
| | |0x0000000E || PSPgo || /dev_hdd0/game/ || Displayed as Unknown Album: Corrupted Data | ||
|- | |- | ||
| | |0x0000000F || minis || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000010 || NEOGEO || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000011 || VMC || /dev_hdd0/tmp/vmc/ || | ||
|- | |- | ||
| | |0x00000012 || ?PS2Classic? Seen on PS2 classic || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000013 || || || | ||
|- | |- | ||
| | |0x00000014 || Seen on PSP remastered || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x00000015 || PSP2GD (PSVita Game Data) || || | ||
|- | |- | ||
| | |0x00000016 || PSP2AC (PSVita Additional Content) || || | ||
|- | |- | ||
| | |0x00000017 || PSP2LA (PSVita LiveArea) || || | ||
|- | |- | ||
| | |0x00000018 || ?PSM? (PSVita PSM) || || | ||
|- | |- | ||
| | |0x00000019 || WT (Web TV?) || /dev_hdd0/game/ || | ||
|- | |- | ||
| | |0x0000001D || ?PSM? (PSVita PSM) || || | ||
|- | |- | ||
| | |0x0000001F || PSP2Theme (PSVita Theme) || || | ||
|} | |} | ||
Line 385: | Line 229: | ||
! Identifier !! type name !! usage !! notes | ! Identifier !! type name !! usage !! notes | ||
|- | |- | ||
| | | unk || Patch || for PSP game updates, to use with CumulativePatch, IncrementalPatch, HybridPatch || | ||
|- | |- | ||
| | | unk || DiscGamePatch || for PS3 BD games || | ||
|- | |- | ||
| | | unk || HDDGamePatch || for PS3 HDD games (NPDRM) || | ||
|- | |- | ||
| | | unk || NoEBOOTBIN || || | ||
|- | |- | ||
| | | unk || Demo || || | ||
|- | |- | ||
| | | unk || Key || || | ||
|- | |- | ||
| | | unk || Upgradable || || | ||
|} | |} | ||
To class : DiscBinded, IncrementalPatch, HybridPatch, NonGame | |||
=== PackageFlag === | === PackageFlag === | ||
{| class="wikitable" | {| class="wikitable" | ||
! | ! Identifier !! type name !! usage !! notes | ||
|- | |||
| unk || RenameDirectory || || | |||
|- | |||
| unk || NoRenameDirectory || || | |||
|- | |||
| unk || Finalized || || | |||
|- | |- | ||
| | | unk || || || | ||
|- | |- | ||
| | | unk || || || | ||
|- | |- | ||
| | | unk || || || | ||
|} | |||
=== StorageType === | |||
Seams to be PSVita only. | |||
{| class="wikitable" | |||
! Identifier !! type name !! usage !! notes | |||
|- | |- | ||
| | | unk || VC-MC || || | ||
|- | |- | ||
| | | unk || ?VC? / ?MC? || || | ||
|} | |||
=== package.conf === | |||
{| class="wikitable" | |||
! Config name !! usage !! expected value !! example | |||
|- | |- | ||
| | | ContentID || needed || XXYYYY-XXXXYYYYY_00-XXXXXXXXXXXXXXXX || EP4153-NPEZ00314_00-0000111122223333 | ||
|- | |- | ||
| | | Klicensee || needed (can be set to 0x00000...) || 0x00000000000000000000000000000000 || 0x1234567899876543210123456789CE4D | ||
|- | |- | ||
| | | DRMType || needed || Network / Free / Local || Free | ||
|- | |- | ||
| | | ContentType || needed || See [[PKG_files#ContentType]] || minis | ||
|- | |- | ||
| | | PackageType || || See [[PKG_files#PackageType]] || DiscGamePatch | ||
|- | |- | ||
| | | PackageFlag || || See [[PKG_files#PackageFlag]] || RenameDirectory | ||
|- | |- | ||
| | | StorageType || needed for PSVita gamedata || See [[PKG_files#StorageType]] || VC-MC | ||
|- | |- | ||
| | | PackageVersion || || X.XX || 1.02 | ||
|- | |- | ||
| | | TitleID || used only for PSP and PS1 games || XXXXYYYYY || NPEZ00314 | ||
|- | |- | ||
| | | LimitedTimeStart || || YYYY-MM-DDThh:mmTZD || 2018-10-30T11:55T32 | ||
|- | |- | ||
| | | LimitedTimeEnd || || YYYY-MM-DDThh:mmTZD || 2019-10-30T11:55T32 | ||
|- | |- | ||
| | | InstallDirectory || || || | ||
|- | |- | ||
| | | ForcedInstallTo || Allows installing packages to any hdd directory (and even flash memory if it's mounted RW). || || | ||
|} | |} | ||
=== | === PARAM_SFO_info === | ||
typedef struct { // size is 0x38 | typedef struct { // size is 0x38 | ||
u32 param_offset; | u32 param_offset; | ||
u16 param_size; | u16 param_size; | ||
u32 unk_int; // | u32 unk_int; // ex: 0x2, 0x14, 0x4, 0x9 | ||
u32 | u32 PSP2_DISP_VER; // or may be PSP2_SYSTEM_VER | ||
u8 unk[0x8]; | u8 unk[0x8]; | ||
u8 param_digest[0x20]; // SHA256 of param_data. Called ParamDigest: This is sha256 digest of param.sfo. | u8 param_digest[0x20]; // SHA256 of param_data. Called ParamDigest: This is sha256 digest of param.sfo. | ||
} | } PARAM_SFO_info; | ||
=== | === unknown_data0_info === | ||
typedef struct { // size is 0x48 | typedef struct { // size is 0x48 | ||
Line 470: | Line 326: | ||
u8 unk[0x20]; | u8 unk[0x20]; | ||
u8 unknown_data_sha256[0x20]; | u8 unknown_data_sha256[0x20]; | ||
} | } unknown_data0_info; | ||
=== entirety_info === | === entirety_info === | ||
typedef struct { // size is 0x38 | typedef struct { // size is 0x38 | ||
u32 entirety_data_offset; // located just before SFO | u32 entirety_data_offset; // located just before SFO | ||
u32 entirety_data_size; // ex: | u32 entirety_data_size; // ex: 0x160, 0x100 in SDK | ||
u32 unk_int1; // ex: FE 10 00 00, FF D0 00 00, maybe ELF flag or PKG header size + 0xE | |||
u32 unk_int2; // ex: 1, 0 | |||
u32 | u8 unk[0x8]; | ||
u8 | u8 entirety_digest[0x20]; // SHA256 of entirety_data. Called EntiretyDigest: This is a digest of above digests. | ||
u8 entirety_digest[0x20]; | |||
} entirety_info; | } entirety_info; | ||
typedef struct { // size is 0x100 | typedef struct { // size is 0x100 | ||
u8 | u8 unk_digest[0x20]; // ???? | ||
u8 game_digest[0x20]; // ?SHA256? of ??. Called GameDigest: This is a digest of Header/Program/System/MajorParam Digests. | |||
u8 program_digest[0x20]; // ?SHA256? of ??. Called ProgramDigest: This is a digest of contents except sce_sys files. | |||
u8 system_digest[0x20]; // ?SHA256? of ??. Called SystemDigest: This is a digest of sce_sys files except param.sfo. | |||
u8 majorparam_digest[0x20]; // ?SHA256? of ??. Called MajorParamDigest: This is a digest of param.sfo that affect behavior. | |||
u8 param_digest[0x20]; // SHA256 of param.sfo. Called ParamDigest: This is sha256 digest of param.sfo. | |||
u8 header_digest[0x20]; // ?SHA256? of ??. Called HeaderDigest: This is a digest of package header. | |||
u8 others_digest[0x20]; // ?SHA256? of ??. Called OthersDigest: This is a digest of sce_sys files except above files. | |||
} entirety_data_100; | |||
u8 game_digest | |||
u8 program_digest | |||
u8 | |||
u8 | |||
u8 | |||
u8 header_digest | |||
u8 | |||
} | |||
typedef struct { // size is 0x160 | typedef struct { // size is 0x160 | ||
u8 | u8 unk_digest[0x20]; // ???? May be an encrypted form of the not found: # ContentDigest: This is a digest of content unique value. | ||
u8 game_digest[0x20]; | u8 game_digest[0x20]; // SHA256 of a buffer embedding Program/System/MajorParam/Header Digests in this order. Called GameDigest: This is a digest of Header/Program/System/MajorParam Digests. | ||
u8 program_digest[0x20]; | u8 program_digest[0x20]; // ?SHA256? of ??. Called ProgramDigest: This is a digest of contents except sce_sys files. | ||
u8 system_digest[0x20]; | u8 system_digest[0x20]; // ?SHA256? of ??. Called SystemDigest: This is a digest of sce_sys files except param.sfo. | ||
u8 | u8 majorparam_digest[0x20]; // ?SHA256? of ??. Called MajorParamDigest: This is a digest of param.sfo that affect behavior. | ||
u8 param_digest[0x20]; | u8 param_digest[0x20]; // SHA256 of param.sfo. Called ParamDigest: This is sha256 digest of param.sfo. | ||
u8 header_digest[0x20]; | u8 header_digest[0x20]; // ?SHA256? of ??. Called HeaderDigest: This is a digest of package header. | ||
u8 | u8 livearea_digest[0x20]; // ?SHA256? of ??. Called LiveareaDigest: This is a digest of sce_sys/livearea(&retail) files. | ||
u8 | u8 manual_digest[0x20]; // ?SHA256? of ??. Called ManualDigest: This is a digest of sce_sys/manual files. | ||
u8 | u8 trophy_digest[0x20]; // ?SHA256? of ??. Called TrophyDigest: This is a digest of sce_sys/trophy files. | ||
u8 | u8 others_digest[0x20]; // ?SHA256? of ??. Called OthersDigest: This is a digest of sce_sys files except above files. | ||
} | } entirety_data_160; | ||
=== unknown_data2_info === | |||
typedef struct { // size is 0x38 | typedef struct { // size is 0x38 | ||
u32 | u32 unknown_data_offset; | ||
u32 | u32 unknown_data_size; // usually 0x10 | ||
u8 unk[0x10]; | u8 unk[0x10]; | ||
u8 | u8 unknown_data_sha256[0x20]; | ||
} | } unknown_data2_info; | ||
=== | === File Entry === | ||
All values are in big endian format. | All values are in big endian format. | ||
Line 696: | Line 384: | ||
u32 flags; | u32 flags; | ||
u32 padding; | u32 padding; | ||
} | } PKG_FILE_HEADER; | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 709: | Line 397: | ||
| data_size || 0x10 || u64 || | | data_size || 0x10 || u64 || | ||
|- | |- | ||
| flags || 0x18 || u32 || The file type | | flags || 0x18 || u32 || The file type | ||
|- | |- | ||
| padding || 0x1C || u32 || zero | | padding || 0x1C || u32 || zero | ||
|} | |} | ||
=== Misc/Note === | |||
<s> | |||
From FW 4.00, install PKG from root device (but not as "bubble") for PS1 classic if not containing [[EDAT_files|.EDAT files]] license type Free will abort or install directly as bubble according to the cfw. | |||
</s> | |||
== File Footer == | == File Footer == | ||
Line 718: | Line 412: | ||
=== PackageDigest === | === PackageDigest === | ||
This is SHA1 digest of package without last 32 bytes. | |||
The last | The last 0x20 bytes of the package contains a hash (sha1sum) of the package (sha1 of the whole file minus the last 0x20 bytes). Or in other words... to verify the integrity of a package is needed to crop the 0x20 bytes at the end, then calculate the SHA1 of the resulting file, then compare with the SHA1 that was cropped. | ||
It is also used as part of the package identification info inside the '''TITLE_ID-ver.xml''' files in PSN servers that lists the available game patches for each game. See: [[Online_Connections#Game_Updating_Procedure|Game Updating Procedure]] page and the '''sha1sum''' in the .xml examples | It is also used as part of the package identification info inside the '''TITLE_ID-ver.xml''' files in PSN servers that lists the available game patches for each game. See: [[Online_Connections#Game_Updating_Procedure|Game Updating Procedure]] page and the '''sha1sum''' in the .xml examples | ||
*Notes | *Notes | ||
**This footer area is considered part of the package and is included when counting the '''total_size''' of the package (in the header at offset 0x18), and the header is hashed too by '''header_sha1_hash ''' (at offset 0xB8), this is important in the sequence of actions needed when building the package and updating/adding the | **This footer area is considered part of the package and is included when counting the '''total_size''' of the package (in the header at offset 0x18), and the header is hashed too by '''header_sha1_hash ''' (at offset 0xB8), this is important in the sequence of actions needed when building the package and updating/adding the sha1 footer at the end | ||
** | **Homebrew packages (at least some of them) doesnt includes this footer | ||
== Package Tools == | == Package Tools == | ||
Line 732: | Line 426: | ||
=== PKG builder / infos / extractor === | === PKG builder / infos / extractor === | ||
==== | ==== PSVita SDK official tool : make_pkg (2011-2015) ==== | ||
* latest version: rev 1972 from 3.55 PSVita SDK | |||
==== PS3 SDK official tool : make_package_npdrm (2006-2017) ==== | |||
* latest version: rev 1972 from 4.75 PS3 SDK | |||
* common version: rev 1732 from 3.40 PS3 SDK (also found under patched form) | |||
* latest version: rev | |||
* | |||
==== Make Package Npdrm Patcher (revision 1732) by SubZero Dezigns (2012) ==== | ==== Make Package Npdrm Patcher (revision 1732) by SubZero Dezigns (2012) ==== | ||
Line 1,012: | Line 517: | ||
=== PKG extractor === | === PKG extractor === | ||
==== ungpkg by failoverflow | ==== ungpkg by failoverflow (2010) ==== | ||
PS3/PSP .pkg | PS3/PSP .pkg | ||
Line 1,022: | Line 527: | ||
==== PkgDecrypt by St4rk (2017) ==== | ==== PkgDecrypt by St4rk (2017) ==== | ||
PSVita .pkg | |||
== Package links == | == Package links == | ||
* sqlite3 db of .pkg files (pkg links, file infos, signatures, etc): [https://mega.co.nz/#!f5QhWCTB!EzxEaMNKJ3zJ40c_qfGtZTVD3a1uis645Hffj_W3hpc pkg_harvester_db.7z 6.7 MB] (includes PS3, PSP) - uncompressed pkg_harvester.db: 24.5 MB | |||
several constants used in pkg_harvester.db: | |||
several constants used in pkg_harvester.db: | |||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
enum class ProductEnvironment | enum class ProductEnvironment | ||
Line 1,110: | Line 567: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{File Formats}}<noinclude>[[Category:Main]]</noinclude> | {{File Formats}}<noinclude>[[Category:Main]]</noinclude> |