Editing Playstation Update Package (PUP)

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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 5: Line 5:
== Location ==
== Location ==


=== PS Vita ===
=== PSVita ===


The PS Vita and PS Vita TV OS can install the update as /PSP2/UPDATE/PSP2UPDAT.PUP or as /PSVITA/UPDATE/PSVUPDAT.PUP.<br />
The PSVita and PSVita TV OS can install the update as /PSP2/UPDATE/PSP2UPDAT.PUP or as /PSVITA/UPDATE/PSVUPDAT.PUP.<br />


The update comes from:
The update comes from:
Line 29: Line 29:
To document.
To document.


=== PS Vita ===
=== PSVita ===


PUP contains updates for different partitions of the system. Most packages, once decrypted, decompressed and pieced together are a raw disk image for the partition to update. Sometimes, a TAR archive patch is also used along with the disk images but not as often. Sony usually releases three kinds of update files, each to update different components: release, systemdata and preinstall.
Each PUP contain updates for different partitions of the system. Most packages, once decrypted, decompressed and pieced together are a raw disk image for the partition to update. Sometimes a TAR archive patch is also used along with the disk images but not as often. Sony usually releases three kinds of update files, each to update different components: full, systemdata and preinst.


There are different types of PS Vita .PUP files:
There are different types of PSVita .PUP:


==== release - full - rel ====
==== full ====
 
This contains the actual system files. The main components are <code>os0</code>, <code>vs0</code>, and the [[Boot Sequence|bootloader partition]].
Release PUPs update most [[Partitions|partitions]]. This contains the actual system files. The main components are <code>os0</code>, <code>vs0</code>, and the [[Boot Sequence|bootloader partition]].
 
==== systemdata - sd ====


==== systemdata ====
Systemdata PUPs only update the <code>sa0</code> [[Partitions|partition]]. It is likely separated from the main update due to it not regularly needing updates and size concerns.
Systemdata PUPs only update the <code>sa0</code> [[Partitions|partition]]. It is likely separated from the main update due to it not regularly needing updates and size concerns.


==== preinstall - preinst ====
==== preinst ====
 
Preinst PUPs only update the <code>pd0</code> [[Partitions|partition]]. This is the [[Welcome Park]] application and the initial setup movie. It is likely separated from the main update because of the size.
Preinstall PUPs only update the <code>pd0</code> [[Partitions|partition]]. This is the [[Welcome Park]] application and the initial setup movie. It is likely separated from the main update due to it not regularly needing updates and size concerns.


==== com ====
==== com ====
 
Unknown. Maybe stands for Common.
Unknown. Maybe stands for Common or for Communication in the case it would target COM PS Vita i.e. PS Vita that have a 3G Modem.


==== modeldiff ====
==== modeldiff ====
Unknown. Maybe stands for Model Differences.


Unknown. Stands for Model Differences.
==== Debug ====
Debug updates for [[PTEL-XXXX]] and [[PDEL-XXXX]] do not separate into different PUPs. A single PUP will update all components. Additionally updates for PDEL units contains updates for the CP and probably other development unit specific components.


== Revisions ==
== Revisions ==


=== PS Vita ===
=== PSVita ===


See [https://psdevwiki.com/vita/index.php?title=Category:Firmware_revisions].
See [https://playstationdev.wiki/psvitadevwiki/index.php?title=Category:Firmware_revisions].


== Update List ==
== Update List ==
Line 65: Line 63:
=== PS3 ===
=== PS3 ===


There is no regioning in the .PUP files i.e. they are the same for all different regions (if you were looking for regioninfo, [[SKU_Regioning|see here]]). The PS3 however gets the [[ps3-updatelist.txt]] from different servers, depending on the region of that model (last 2 numbers in the CECHxxXX SKU name).
There is no regioning in the .PUP files, they are the same for all different regions (if you were looking for regioninfo, [http://www.ps3devwiki.com/index.php?title=SKU_Models#Regioning see here]).<br />
The PS3 however gets the [[ps3-updatelist.txt]] from different servers, depending on the region of that model (last 2 numbers in the CECHxxXX SKU name).


<ul>
<ul>
Line 82: Line 81:
<li> [http://fbr01.ps3.update.playstation.net/update/ps3/list/br/ps3-updatelist.txt Brasil, br] (11 > 0x8F)
<li> [http://fbr01.ps3.update.playstation.net/update/ps3/list/br/ps3-updatelist.txt Brasil, br] (11 > 0x8F)
</ul>
</ul>
 
for completeness see [[Target ID]]: Reference Tool/DECR : 0x81, Debug/DEX : 0x82, and Arcade : 0xA0
For completeness, see [[Product Code]]: Reference Tool/DECR : 0x81, Debug/DEX : 0x82, and Arcade : 0xA0


Retail basic structure of the update URL:
Retail basic structure of the update URL:
Line 94: Line 92:


Content:
Content:
<pre>
 
  # JP(shop)
  # JP(shop)
  Dest=83;CompatibleSystemSoftwareVersion=4.7600-;
  Dest=83;CompatibleSystemSoftwareVersion=4.7600-;
Line 130: Line 128:
  Dest=8F;CompatibleSystemSoftwareVersion=4.7600-;
  Dest=8F;CompatibleSystemSoftwareVersion=4.7600-;
  Dest=8F;ImageVersion=00010015;SystemSoftwareVersion=4.7600;CDN=http://dbr01.ps3.update.playstation.net/update/ps3/image/shop/2015_0903_6f462b5aaaed64263d72e1e989e4b336/PS3UPDAT.PUP;CDN_Timeout=30;
  Dest=8F;ImageVersion=00010015;SystemSoftwareVersion=4.7600;CDN=http://dbr01.ps3.update.playstation.net/update/ps3/image/shop/2015_0903_6f462b5aaaed64263d72e1e989e4b336/PS3UPDAT.PUP;CDN_Timeout=30;
</pre>
 


Shop basic structure of the update URL:
Shop basic structure of the update URL:
Line 136: Line 134:
  (TLD=2 letter abbreviation from above region, YYYY_MMDD is release date, MD5 is 22-digits long HASH)
  (TLD=2 letter abbreviation from above region, YYYY_MMDD is release date, MD5 is 22-digits long HASH)


=== PS Vita ===
=== PSVita ===
 
Contrarly to PS3, there is no regioning in the .PUP files: they are the same for all different regions.


Like on PS3, there is no regioning in the .PUP files: they are the same for all different regions. However, the PS Vita gets the psp2-updatelist.xml from different servers, depending on the region of that model.
However, the PSVita gets the psp2-updatelist.xml from different servers, depending on the region of that model.


On retail (CEX) consoles, when you check for updates via WiFi in settings the console will download an XML file based on the console's region code. For example on PS Vitas sold within the United States the URL for the XML file is <code>http://fus01.psp2.update.playstation.net/update/psp2/list/us/psp2-updatelist.xml</code>.
On retail (CEX) consoles, when you check for updates via WiFi in settings the console will download an XML file based on the console's region code. For example on PSVitas sold within the United States the URL for the XML file is <code>http://fus01.psp2.update.playstation.net/update/psp2/list/us/psp2-updatelist.xml</code>.


When this file is read by the system, the <code>region id</code> MUST match the system region.
When this file is read by the system, the <code>region id</code> MUST match the system region.
Line 148: Line 148:
The file must be no larger than 65535 bytes, and the URL's specifying where to download the .PUP from can be no longer than 1024 characters, it also must be a direct URL to the content *including "http://" protocol*.
The file must be no larger than 65535 bytes, and the URL's specifying where to download the .PUP from can be no longer than 1024 characters, it also must be a direct URL to the content *including "http://" protocol*.


When selecting "Update via connecting to PC", the console connects to Content Manager Assistant installed on a PC and then CMA downloads the psp2-updatelist.xml file and the PUP files from PC side and sends it back to the PS Vita. Because of this, by using a custom Content Manager Assistant such as QCMA, you can send whatever psp2-updatelist.xml you want to the PS Vita. This is also what happens with "Update via connecting to PS3".
When selecting "Update via connecting to PC" the console instead connected to Content Mannager Assistant and then CMA downloads the updatelist file and the PUP files from PC side and sends it back to the vita, because of this using a custom Content Mannager Assistant such as QCMA you can just send whatever psp2-updatelist you want to the vita. this is also what happens with "Update via connecting to PS3".


On PS Vita DevKit and TestKit, you can configure your own URL for the psp2-updatelist.xml file in <code>Debug Settings > System Update</code> and this setting can be overridden by placing a file at <code>ux0:/PSP2/UPDATE/SERVER_URL.TXT</code> or <code>host0:/PSP2/UPDATE/SERVER_URL.TXT</code>.
On devkit and testkit you can configure your own URL for the psp2-updatelist.xml file in <code>Debug Settings > System Update</code> and this setting can be overridden by placing a file at <code>ux0:/PSP2/UPDATE/SERVER_URL.TXT</code> or <code>host0:/PSP2/UPDATE/SERVER_URL.TXT</code>.


Retail:
Retail:
Line 254: Line 254:


Retail basic structure of the update URL:
Retail basic structure of the update URL:
<pre>
<pre>http://d<TLD>01.psp2.update.playstation.net/update/psp2/image/<YYYY_MMDD>/pre_<md5>/PSP2UPDAT.PUP?dest=<TLD>
http://d<TLD>01.psp2.update.playstation.net/update/psp2/image/<YYYY_MMDD>/pre_<md5>/PSP2UPDAT.PUP?dest=<TLD>
(TLD=2 letter abbreviation from above region, YYYY_MMDD is release date, md5 is 22-digits long HASH)</pre>
(TLD=2 letter abbreviation from above region, YYYY_MMDD is release date, md5 is 22-digits long HASH)
</pre>


  '''<?xml''' <span style="color: blue;">version</span><span style="color: red;">="1.0"</span> <span style="color: blue;">encoding</span><span style="color: red;">="UTF-8"</span>'''?>'''
  '''<?xml''' <span style="color: blue;">version</span><span style="color: red;">="1.0"</span> <span style="color: blue;">encoding</span><span style="color: red;">="UTF-8"</span>'''?>'''
Line 278: Line 276:
  '''</update_data_list>'''
  '''</update_data_list>'''


PS Vita PUP links use the same structure as PS3 PUP links:
PSVita PUP links use the same structure as the PS3:


<nowiki>http://d</nowiki><span style="color: red;">&lt;TLD&gt;</span>01.ps4.update.playstation.net/update/ps4/image/<span style="color: green;">&lt;YYYY_MMDD&gt;</span>/<span style="color: orange;">&lt;TYPE&gt;</span>_<span style="color: blue;">&lt;MD5&gt;</span>/PS4UPDATE.PUP?dest=<span style="color: red;">&lt;TLD&gt;</span>
<nowiki>http://d</nowiki><span style="color: red;">&lt;TLD&gt;</span>01.ps4.update.playstation.net/update/ps4/image/<span style="color: green;">&lt;YYYY_MMDD&gt;</span>/<span style="color: orange;">&lt;TYPE&gt;</span>_<span style="color: blue;">&lt;MD5&gt;</span>/PS4UPDATE.PUP?dest=<span style="color: red;">&lt;TLD&gt;</span>
Line 290: Line 288:
Note: this is untested, please report back!
Note: this is untested, please report back!


Using a webserver (apache, lighttpd, nginx, etc.) and proxy/firewall to catch http://f**01.psp2.update.playstation.net/update/psp2/list/**/psp2-updatelist.xml" and point it to your local server you could[1] have more control over the updates/bandwith. Of course you need to have every <code>PSP2UPDATE.PUP</code> file you reference to, otherwise it errors out.
Using a webserver (apache, lighttpd, nginx, etc. whatever your preference is) and proxy/firewall to catch http://f**01.psp2.update.playstation.net/update/psp2/list/**/psp2-updatelist.xml" and point it to your local server you could[1] have more control over the updates/bandwith. Of course you need to have every <code>PSP2UPDATE.PUP</code> file you reference to, otherwise it errors out.


In this example the webserver is configured at http://192.168.0.254, region is set to <code>eu</code>[2].
In this example the webserver is configured at http://192.168.0.254, region is set to <code>eu</code>[2]. Change it to your own need.


  '''<update_data_list>'''
  '''<update_data_list>'''
Line 448: Line 446:
  0x8002F2Ex - (Turning On/Off Recovery Mode Flag)
  0x8002F2Ex - (Turning On/Off Recovery Mode Flag)


= Structure =
= File structure =


== Verification ==
== Verification ==


The PUP Header is signed using HMAC, HMAC-SHA1 for PS3 and HMAC-SHA256 for PS Vita.
The HMAC key used to verify the packages has been released. Look around for "pup-hmac".


On PS Vita, the PUP Header Digest is signed using RSA2048. The PUP Header RSA signature is RSA-signed along with a message into SCEWM file, which is encrypted using AES128CBC.
== Decryption ==


The PUP Header embeds HMAC signatures for each PUP segment.
To decrypt the files that are unpacked using the tool, the keys are available under [[Keys]].
 
All the PUP keys are known except RSA private keys.


== Extraction ==
== Extraction ==


=== PS3 ===
The PSVita and PSVita TV update files can be extracted from .PUP using:
* "[http://www.vitadevwiki.com/index.php?title=Tools PS VITA Firmware xTractor]"
* pupunpack from [http://www.vitadevwiki.com/index.php?title=Tools#Vitatools vitatools].


=== PS Vita ===
== PS3 ==
 
The PS Vita and PS Vita TV update files can be extracted from .PUP using:
* "[http://www.psdevwiki.com/vita/index.php?title=Tools PS VITA Firmware xTractor]"
* pupunpack from [http://www.psdevwiki.com/vita/index.php?title=Tools#Vitatools vitatools].
 
== Decryption ==
 
Even though PUP is not encrypted, most files it embeds are.


== PS3 ==
<!--// PUP Extractor http://www.megaupload.com/?d=WILOJ5TC (outdated: incompatible output, tool not update since 27 may 2008 - autor:NDT @ ps3news) //-->


=== Header ===
=== Header ===


<source lang="C">
<source lang="C">
typedef struct ScePupHeader_v1 { // size is 0x30-bytes
typedef struct {
   uint8_t magic[7];
   uint64_t magic;
   uint8_t format_flag;
   uint8_t format_flag;
   uint64_t package_version;
   uint64_t package_version;
   uint64_t image_version;
   uint64_t image_version;
   uint64_t segment_num;
   uint64_t segment_num;
   uint64_t file_offset;
   uint64_t header_length;
   uint64_t file_size;
   uint64_t data_length;
} ScePupHeader_v1;
} PUPHeader;
</source>
</source>


Line 498: Line 488:
| 0x7 || 0x1 || uint8_t || Format Flag
| 0x7 || 0x1 || uint8_t || Format Flag
|-
|-
| 0x8 || 0x8 || unsigned long || Package Version. ?Might be Format version like on PS Vita?
| 0x8 || 0x8 || unsigned long || Package Version ?Might be Format version like on PSVita?
|-
|-
| 0x10 || 0x8 || unsigned long || Image Version. ?What is this?
| 0x10 || 0x8 || unsigned long || Image Version ?what is that?
|-
|-
| 0x18 || 0x8 || unsigned long || Segment Number
| 0x18 || 0x8 || unsigned long || Segment Num
|-
|-
| 0x20 || 0x8 || unsigned long || File Offset. It corresponds to Header Length.
| 0x20 || 0x8 || unsigned long || Header Length
|-
|-
| 0x28 || 0x8 || unsigned long || File Size. It corresponds to Data Length.
| 0x28 || 0x8 || unsigned long || Data Length
|-
|-
| 0x30 || 0x20 * '''segment_num''' || '''Segment Table''' || Segment Table
| 0x30 || 0x20 * '''segment_num''' || '''File Table''' || File Table
|-
|-
| 0x30 + (0x20 * '''segment_num''') || 0x20 * '''segment_num''' || '''Digest Table''' || Digest Table
| 0x30 + (0x20 * '''segment_num''') || 0x20 * '''segment_num''' || '''Hash Table''' || Hash Table
|-
|-
| 0x30 + (0x40 * '''segment_num''') || 0x14 || '''Header Digest''' || Header Digest
| 0x30 + (0x40 * '''segment_num''') || 0x14 || bytes || Header Hash
|-
|-
| 0x44 + (0x40 * '''segment_num''') || 0xC || uint8_t[0xC] || Padding
| 0x44 + (0x40 * '''segment_num''') || 0xC || bytes || Padding
|}
|}


=== Segment Table ===
=== File Table ===


The Segment Table consists of a number of Segment Entries determined by '''Segment Num'''.
The file table consists of a number of file entries determined by '''Segment Num''', with the format below:


<source lang="C">
<source lang="C">
typedef struct ScePupSegmentEntry { // size is 0x20-bytes
typedef struct {
   uint64_t id;
   uint64_t id;
   uint64_t offset;
   uint64_t offset;
   uint64_t size;
   uint64_t size;
   uint32_t sign_algorithm;
   uint8_t padding[8];
  uint32_t padding;
} PUPFileEntry;
} ScePupSegmentEntry;
</source>
</source>


{| class="wikitable"
{| class="wikitable"
|-
|-
! Offset !! Length !! Type !! Information
! Offset  
|-
! Length  
| 0x0 || 0x8 || unsigned long || ID
! Type  
! Information
|-
|-
| 0x8 || 0x8 || unsigned long || Offset
| 0x0
| 0x8  
| unsigned long
| ID
|-
|-
| 0x10 || 0x8 || unsigned long || Size
| 0x8
| 0x8
| unsigned long  
| Offset
|-
|-
| 0x18 || 0x4 || unsigned int || Signature Algorithm. 0 = HMAC-SHA1, 2 = HMAC-SHA256
| 0x10
| 0x8
| unsigned long
| Size
|-
|-
| 0x1C || 0x4 || char[4] || Padding
| 0x18
| 0x8
| unsigned long
| Unknown
|}
|}


=== Segment Entry IDs ===
=== Filename IDs ===


It is a mistake to try to connect a Segment Entry ID to any specific file. Nevertheless, there are certain Segment Entry IDs that have been linked with the same data throughout all observed PUPs.
PUPEntryID entries
<source lang="C">
static const PUPEntryID entries[] = {
  {0x100, "version.txt"},
  {0x101, "license.xml"},
  {0x102, "promo_flags.txt"},
  {0x103, "update_flags.txt"},
  {0x104, "patch_build.txt"},
  {0x200, "ps3swu.self"},
  {0x201, "vsh.tar"},
  {0x202, "dots.txt"},
  {0x203, "patch_data.pkg"},
  {0x300, "update_files.tar"},
  {0x501, "spkg_hdr.tar"},
  {0x601, "ps3swu2.self"},
  {0, NULL}
};
</source>


{| class="wikitable sortable"
{| class="wikitable"
! Segment Entry ID !! Console !! File name !! Notes
|-
| 0x100 || [[version.txt]] || PS3, PS Vita || Version string
|-
| 0x101 || [[license.xml]] || PS3, PS Vita || License XML. (?aka: resource.txt?)
|-
| 0x102 || [[promo_flags.txt]] || PS3 || (only on {{SHOP}}) (?aka: shop.txt?)
|-
|-
| 0x103 || [[update_flags.txt]] || PS3 ||
! Entry ID
! Filename
|-
|-
| 0x104 || [[patch_build.txt]] || PS3 ||
| 0x100
| [[version.txt]] (aka: ps3version.txt)
|-
|-
| 0x200 || [[ps3swu.self]], [[psp2swu.self]] || PS3, PS Vita || Main updater executable
| 0x101
| [[license.xml]] (aka: resource.txt? )
|-
|-
| 0x201 || [[vsh.tar]] / [[font_resource.tar]] || PS3 ||
| 0x102
| [[promo_flags.txt]] (only on {{shop}}) (aka: shop.txt?)
|-
|-
| 0x202 || [[dots.txt]] || PS3 ||
| 0x103
| [[update_flags.txt]]
|-
|-
| 0x203 || [[patch_data.pkg]] || PS3 ||
| 0x104
| [[patch_build.txt]]
|-
|-
| 0x204 || [[cui_setupper.self]] || PS Vita || Classical UI updater setupper executable
| 0x200
| [[ps3swu.self]]
|-
|-
| 0x221 || [[vs0_patch_tar_info.txt]] || PS Vita || vs0 patch tar archive access permission config
| 0x201
| [[vsh.tar]] / font_resource.tar
|-
|-
| 0x231 || [[vs0_patch_tar_2_info.txt]] || PS Vita || vs0 patch tar archive 2 access permission config
| 0x202
| [[dots.txt]]
|-
|-
| 0x300 || [[update_files.tar]] || PS3 ||
| 0x203
| [[patch_data.pkg]]
|-
|-
| 0x302 ||  || PS Vita || SLB2
| 0x300
| [[update_files.tar]]
|-
|-
| 0x303 ||  || PS Vita || os0
| 0x501
| [[spkg_hdr.tar]] (added since FW 3.56)
|-
|-
| 0x304 ||  || PS Vita || vs0
| 0x601
|-
| [[ps3swu2.self]] (added since FW 3.56)
| 0x305 ||  || PS Vita ||
|-
| 0x306 ||  || PS Vita ||
|-
| 0x307 ||  || PS Vita ||
|-
| 0x308 ||  || PS Vita ||
|-
| 0x309 ||  || PS Vita ||
|-
| 0x30A ||  || PS Vita ||
|-
| 0x30B ||  || PS Vita ||
|-
| 0x30C ||  || PS Vita ||
|-
| 0x30D ||  || PS Vita ||
|-
| 0x30E ||  || PS Vita ||
|-
| 0x30F ||  || PS Vita ||
|-
| 0x310 ||  || PS Vita ||
|-
| 0x311 ||  || PS Vita || vs0 patch tar archive
|-
| 0x312 ||  || PS Vita || vs0 patch tar archive 2
|-
| 0x313 ||  || PS Vita || Syscon update type 0: 00 24 10 00
|-
| 0x314 ||  || PS Vita || Syscon update type 1: 00 50 31 00, 00 50 40 00
|-
| 0x315 ||  || PS Vita || Syscon update type 2: 00 26 10 00, 00 52 40 00
|-
| 0x316 ||  || PS Vita || Syscon update type 3: 00 52 31 00
|-
| 0x317 ||  || PS Vita || Syscon update type 4:
|-
| 0x318 ||  || PS Vita || Syscon update type 5:
|-
| 0x319 ||  || PS Vita || Syscon update type 6:
|-
| 0x31A ||  || PS Vita || Syscon update type 7:
|-
| 0x31B ||  || PS Vita || Syscon update type 8:
|-
| 0x31C ||  || PS Vita || Syscon update type 9: 00 30 70 00
|-
| 0x400 || [[package_scewm.wm]] || PS Vita || SCEWM file
|-
| 0x401 || [[package_sceas.as]] || PS Vita || SCEAS file
|-
| 0x501 || [[spkg_hdr.tar]] || PS3 || (added since FW 3.56)
|-
| 0x601 || [[ps3swu2.self]] || PS3 || (added since FW 3.56)
|-
| 0x2005 ||  || PS Vita || CP ES1 firmware. In early Tool PUPs only.
|-
| 0x2006 ||  || PS Vita || CP ES2 firmware. In recent Tool PUPs only.
|}
|}


=== Digest Table ===
=== Hash Table ===


The Digest Table contains a Digest Entry for every segment inside the PUP.
The hash table contains a hash entry for every file inside the PUP.


<source lang="C">
<source lang="C">
typedef struct ScePupDigestEntry_v1 { // size is 0x20-bytes
typedef struct {
   uint64_t segment_index;
   uint64_t segment_index;
   uint8_t digest[0x14];
   uint8_t digest[0x14];
   uint32_t padding;
   uint32_t padding;
} ScePupDigestEntry_v1;
} PUPHashEntry;
</source>
</source>


Line 664: Line 629:
| 0x0 || 0x8 || uint64_t || Segment Index
| 0x0 || 0x8 || uint64_t || Segment Index
|-
|-
| 0x8 || 0x14 || uint8_t[0x14] || Digest (HMAC-SHA1)
| 0x8 || 0x14 || uint8_t[0x14] || Digest (HMAC-SHA1 hash)
|-
|-
| 0x1C || 0x4 || uint32_t || Padding
| 0x1C || 0x4 || uint32_t || Padding
|}
|}


=== Header Digest ===
=== Header Hash ===


<source lang="C">
<source lang="C">
typedef struct {
typedef struct {
   uint8_t digest[0x14]; // HMAC-SHA1
   uint8_t hash[0x14]; // HMAC-SHA1
} PUPHeaderDigest_v1;
} header_hash;
</source>
</source>


== PS Vita ==
== PSVita ==


=== Differences with PS3 PUPs ===
=== Differences with PS3 PUPs ===


The file structure of the PS Vita PUP is almost identical to the PS3 PUP, although there is a slight difference in the header, the hash algorithm and the signature.
The file structure of the PSVita PUP files is almost identical to the PS3's, although there is a slight difference in the header and the hash algorithm.


* PS Vita PUP is little-endian. PS3 PUP is big-endian.
* Whereas in PS3 the format is big-endian, for the PSVita it is little endian.
* PS Vita PUP '''Format Version''' is 2. PS3 PUP '''Format Version''' is 1.
* The '''Format Version''' field in PSVita PUP is set to 2 where in PS3 PUPs it was set to 1.
* There are 0x50 bytes of extra data in the PS Vita PUP Header compared to PS3 PUP.
* There is 0x50 bytes of extra data in the header.
* PS Vita PUP digests are longer than the ones in PS3 PUP: 0x20 bytes (SHA-256 length) in PS Vita PUP versus 0x14 bytes (SHA-1 length) in PS3 PUP.
* The digests used are of a longer length than in PS3 updates: 0x20 bytes (SHA-256 length) in PSVita versus 0x14 bytes (SHA-1 length) in PS3.
* PS Vita PUP Header Digest is signed using RSA2048 in the SCEWM file. ?PS3 PUP has a RSA signature?


=== Header ===
=== Header ===
<source lang="C">
typedef struct ScePupHeader_v2 { // size is 0x80-bytes
SceUInt8 magic[7];
SceUInt8 format_flag;
SceUInt64 format_version;
SceUInt32 version;
SceUInt32 buildno;
SceUInt64 segment_num;
SceUInt64 file_offset;
SceUInt64 file_size;
SceUInt32 sign_algorithm;
SceUInt32 sign_key_index;
SceUInt8 attribute[4];
SceUInt32 target;
SceUInt32 sub_target;
SceUInt32 support_list;
SceUInt32 base_version;
SceUInt32 base_buildno;
SceUInt8 unk_0x50[0x30];
} ScePupHeader_v2;
</source>


{| class="wikitable"
{| class="wikitable"
Line 724: Line 666:
| 0x10 || 0x4 || uint32_t || Version (ex: 0x01600000 on FW 1.60)
| 0x10 || 0x4 || uint32_t || Version (ex: 0x01600000 on FW 1.60)
|-
|-
| 0x14 || 0x4 || uint32_t || Build No
| 0x14 || 0x4 || uint32_t || Build No (ex: 0x1600 on FW 1.60)
|-
|-
| 0x18 || 0x8 || uint64_t || Segment Num (11 digits max)
| 0x18 || 0x8 || uint64_t || Segment Num (11 digits max)
|-
|-
| 0x20 || 0x8 || uint64_t || Header Length (ex: 0xC00, 0xE00, 0x1000, 0x1600)
| 0x20 || 0x8 || uint64_t || Header Length (ex: 0xE00, 0x1000)
|-
|-
| 0x28 || 0x8 || uint64_t || Data Length. Equals (PUP file size - PUP Header Length).
| 0x28 || 0x8 || uint64_t || Data Length. Equals (PUP file size - Header Length).
|-
|-
| 0x30 || 0x4 || uint32_t || Sign Algorithm. PS Vita only. (ex: 2)
| 0x30 || 0x4 || uint32_t || sign_algorithm. PSVita only. (ex: 2)
|-
|-
| 0x34 || 0x4 || uint32_t || Sign Key Index. PS Vita only. (ex: 1)
| 0x34 || 0x4 || uint32_t || sign_key_index. PSVita only. (ex: 1)
|-
|-
| 0x38 || 0x4 || uint8_t[4] || Attribute. PS Vita only. 0: default, 1: QAF required, 2: manufacturing mode required.
| 0x38 || 0x4 || uint8_t[4] || Attribute. PSVita only.
|-
|-
| 0x3C || 0x4 || uint32_t || Target. PS Vita only. 1: TOOL, 2: CEX, 4: DEX. cex_for_tool PUPs are set to 1.
| 0x3C || 0x4 || uint32_t || Target. PSVita only. Maybe matches Product Code target (to check).
|-
|-
| 0x40 || 0x4 || uint32_t || Sub Target. PS Vita only. (ex: 0)
| 0x40 || 0x4 || uint32_t || Sub Target. PSVita only. Maybe matches Product Sub Code target (to check).
|-
|-
| 0x44 || 0x4 || uint32_t || Support List. PS Vita only. (ex: 1, 7, 0xC, 0xF, 0x38, 0x78, 0x3F8, 0xFF8, 0xCFF8)
| 0x44 || 0x4 || uint32_t || Support List. PSVita only. (ex: 0xC, 0xF)
|-
|-
| 0x48 || 0x4 || uint32_t || Base Version. PS Vita only. (ex: 0)
| 0x48 || 0x4 || uint32_t || Base Version. PSVita only.
|-
|-
| 0x4C || 0x4 || uint32_t || Base Build No. PS Vita only. (ex: 0)
| 0x4C || 0x4 || uint32_t || Base Build No. PSVita only.
|-
|-
| 0x50 || 0x30 || char[0x30] || Unknown. PS Vita only. (ex: 0x2000)
| 0x50 || 0x30 || char[0x30] || Unknown. PSVita only.
|-
|-
| 0x80 || 0x20 * '''segment_num''' || '''Segment Table''' || Segment Table
| 0x80 || 0x20 * '''segment_num''' || '''File Table''' || File Table
|-
|-
| 0x80 + (0x20 * '''segment_num''') || 0x40 * '''segment_num''' || '''Digest Table''' || Digest Table
| 0x80 + (0x20 * '''segment_num''') || 0x40 * '''segment_num''' || '''Hash Table''' || Hash Table
|-
|-
| 0x80 + (0x60 * '''segment_num''') || 0x20 || '''Header Digest''' || Header Digest (HMAC-SHA256)
| 0x80 + (0x60 * '''segment_num''') || 0x20 || bytes || Header Hash (HMAC SHA-256, key unknown for now)
|}
|}


=== Segment Table ===
=== File Table ===


Same as in PS3 PUP.
The file table consists of a number of file entries determined by '''Segment Num''', with the format below (which is the same as the format in PS3 PUP1 files).


=== Digest Table ===
{| class="wikitable"
|-
! Offset !! Length !! Type !! Information
|-
| 0x0 || 0x8 || unsigned long || ID
|-
| 0x8 || 0x8 || unsigned long || Offset
|-
| 0x10 || 0x8 || unsigned long || Size
|-
| 0x18 || 0x8 || unsigned long || Sign algorithm. 2 = HMAC-SHA256
|}
 
=== Filename IDs ===
 
It is a mistake to try to connect a file entry ID to any specific file. A better way of organizing the update contents is through the extracted [[SCE]] encrypted file header. Nevertheless, there are certain file entry IDs that have been linked with the same data throughout all observed update packages.
 
{| class="wikitable sortable"
! File Entry ID !! Filename !! Notes
|-
| 0x100 || version.txt || Version string
|-
| 0x101 || license.xml || License XML
|-
| 0x200 || psp2swu.self || Main updater executable
|-
| 0x204 || cui_setupper.self || Classical UI updater initializer executable
|-
| 0x400 || package_scewm.wm || SCEWM file
|-
| 0x401 || package_sceas.as || SCEAS file
|-
| 0x2005 || || CP firmware. In early Tool PUPs only.
|-
| 0x2006 || || CP firmware. In Tool PUPs only.
|}


The Digest Table contains a Digest Entry for every segment inside the PUP.
=== Hash Table ===


<source lang="C">
The hash table contains a hash entry for every file inside the PUP.
typedef struct ScePupDigestEntry_v2 { // size is 0x40-bytes
SceUInt64 segment_index;
SceUInt8 digest[0x20];
SceUInt8 padding[0x18];
} ScePupDigestEntry_v2;
</source>


The hash entry format is:
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 779: Line 751:
| 0x0 || 0x8 || unsigned long || Segment Index
| 0x0 || 0x8 || unsigned long || Segment Index
|-
|-
| 0x8 || 0x20 || uint8_t[0x20] || Digest (HMAC-SHA256)
| 0x8 || 0x20 || char[0x20] || Digest (HMAC-SHA256 hash)
|-
|-
| 0x28 || 0x18 || uint8_t[0x18] || Padding
| 0x28 || 0x18 || char[0x18] || Padding
|}
|}


=== Header Digest ===
=== Header hash ===


<source lang="C">
After files hashes is a 0x20 bytes HMAC-SHA256 hash.
typedef struct {
  uint8_t digest[0x20]; // HMAC-SHA256
} PUPHeaderDigest_v2;
</source>


= Embedded files =
= Embedded files =
Line 1,068: Line 1,036:
</pre>
</pre>


== PS Vita ==
== PSVita ==


=== preinst - 01.000.000 ===
=== preinst - 01.000.000 ===
Please note that all contributions to PS3 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS3 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)