Content License: Difference between revisions
CelesteBlue (talk | contribs) (Created page with "The PS4 content license files are like on PSP, PS3 and PS4 the .rif files.<br /> But for the first time, the format has been a lot changed: * There is only 1 .rif file (and .i...") |
(→Secret) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
The PS4 content license files are like on PSP, PS3 and | The PS4 content license files are like on PSP, PS3 and PSVita the .rif files. | ||
But for the first time, the format has been a lot | |||
* There is only | But for the first time, the format has been changed a lot: | ||
* There is only one .rif file (and .idx) per game/app. On PSP, PS3 and PSVita, there were 1 .rif per content (1 for the game + 1 for each DLC) | |||
* This is handled by adding each DLC license to the game .rif. To know where the license is in the .rif, PS4 generates a .idx file (RIF index). | * This is handled by adding each DLC license to the game .rif. To know where the license is in the .rif, PS4 generates a .idx file (RIF index). | ||
* When the .rif is downloaded from PSN by SceShellcore, it is added to the current .rif file of the game (if existing).<br />Then the .idx is generated. ShellCore calls npdrm_ioctl to get a 0x10 bytes HMAC-SHA256 per console key from SAMU.<br />The HMAC is computed over the RIF data and is written to the .idx entry.<br />The aim is both to ensure .rif integrity and to make sure the .rif and .idx can't be copied to another PS4 console. | * When the .rif is downloaded from PSN by SceShellcore, it is added to the current .rif file of the game (if existing).<br />Then the .idx is generated. ShellCore calls npdrm_ioctl to get a 0x10 bytes HMAC-SHA256 per console key from SAMU.<br />The HMAC is computed over the RIF data and is written to the .idx entry.<br />The aim is both to ensure .rif integrity and to make sure the .rif and .idx can't be copied to another PS4 console. | ||
Line 17: | Line 18: | ||
The .rif file embeds one or more [[RIF Entry|RIF entry]]. | The .rif file embeds one or more [[RIF Entry|RIF entry]]. | ||
[[Rif/samples|Sample disc rif files]]. | |||
=== RIF Entry === | === RIF Entry === | ||
Line 33: | Line 36: | ||
| Version || <code>0x004</code> || 2 || <code>00 01</code>, <code>00 02</code> || See [[#RIF Type|RIF Type]] | | Version || <code>0x004</code> || 2 || <code>00 01</code>, <code>00 02</code> || See [[#RIF Type|RIF Type]] | ||
|- | |- | ||
| | | ?DRM Type? || <code>0x006</code> || 2 || <code>00 02</code> for KDS, <code>FF FF</code> for disc || | ||
|- | |- | ||
| PSN Account ID || <code>0x008</code> || 8 || <code>AB CD EF 01 02 34 78 91</code> || zeroed if not KDS RIF | | PSN Account ID || <code>0x008</code> || 8 || <code>AB CD EF 01 02 34 78 91</code> || zeroed if not KDS RIF | ||
Line 170: | Line 173: | ||
| Unknown || <code>0x00</code> || 0x10 || - || | | Unknown || <code>0x00</code> || 0x10 || - || | ||
|- | |- | ||
| | | Zeroes? || <code>0x10</code> || 0x10 || - || | ||
|- | |- | ||
| | | Zeroes? || <code>0x20</code> || 0x10 || - || | ||
|- | |- | ||
| Content Key Seed || <code>0x30</code> || 0x10 || - || Used to generate PFS key | | Content Key Seed || <code>0x30</code> || 0x10 || - || Used to generate PFS key | ||
Line 182: | Line 185: | ||
| Unknown || <code>0x60</code> || 0x10 || - || | | Unknown || <code>0x60</code> || 0x10 || - || | ||
|- | |- | ||
| Entitlement Key || <code>0x70</code> || 0x10 || - || | | Entitlement Key || <code>0x70</code> || 0x10 || - || Usually zeroes | ||
|- | |- | ||
| | | Zeroes? || <code>0x80</code> || 0x10 || - || | ||
|} | |} | ||
Line 191: | Line 194: | ||
This RIF form is paired with a .idx file. | This RIF form is paired with a .idx file. | ||
When in this form, contrarly to [[RIF File|RIF files]] a [[#RIFA Header|RIFA header]] is present, followed by sequential [[#RIF Entry|RIF entries]]. | When in this form, contrarly to [[#RIF File|RIF files]] a [[#RIFA Header|RIFA header]] is present, followed by sequential [[#RIF Entry|RIF entries]]. | ||
See also [[#RIF IDX|IDX structure]] for the paired .idx file. | See also [[#RIF IDX|IDX structure]] for the paired .idx file. |
Latest revision as of 14:31, 24 November 2022
The PS4 content license files are like on PSP, PS3 and PSVita the .rif files.
But for the first time, the format has been changed a lot:
- There is only one .rif file (and .idx) per game/app. On PSP, PS3 and PSVita, there were 1 .rif per content (1 for the game + 1 for each DLC)
- This is handled by adding each DLC license to the game .rif. To know where the license is in the .rif, PS4 generates a .idx file (RIF index).
- When the .rif is downloaded from PSN by SceShellcore, it is added to the current .rif file of the game (if existing).
Then the .idx is generated. ShellCore calls npdrm_ioctl to get a 0x10 bytes HMAC-SHA256 per console key from SAMU.
The HMAC is computed over the RIF data and is written to the .idx entry.
The aim is both to ensure .rif integrity and to make sure the .rif and .idx can't be copied to another PS4 console.
The files an be found in:
- For disc licenses:
/mnt/disc/license/rif
(on the BluRay) and/preinst2/app/CUSA00001/app.rif
(on the HDD) - For digital content licenses:
/user/license/*.rif
,/user/license/*.idx
- For another type of digital content licenses:
/user/home/*/license/*.rif
,/user/home/*/license/*.idx
RIF File[edit | edit source]
This is a .rif that is not paired with a .idx file.
For a rif file that is paired with a .idx file, see RIFA file.
The .rif file embeds one or more RIF entry.
RIF Entry[edit | edit source]
Fields are big-endian. Each RIF entry is 0x400 bytes sized.
Name | Offset | Size | Example | Remark |
---|---|---|---|---|
Magic | 0x000 |
4 | 52 49 46 00 ('RIF\0') |
|
Version | 0x004 |
2 | 00 01 , 00 02 |
See RIF Type |
?DRM Type? | 0x006 |
2 | 00 02 for KDS, FF FF for disc |
|
PSN Account ID | 0x008 |
8 | AB CD EF 01 02 34 78 91 |
zeroed if not KDS RIF |
Start Timestamp | 0x010 |
8 | 00 00 00 00 52 85 64 00 |
Start timestamp (unix/epoch) |
End Timestamp | 0x018 |
8 | 7F FF FF FF FF FF FF FF |
End timestamp (unix/epoch), typically INT64_MAX |
Content ID | 0x020 |
0x30 | IP9100-CUSA00001_00-PLAYROOM00000000 |
|
RIF Type | 0x050 |
2 | 01 01 |
See RIF Type |
Unknown | 0x052 |
2 | 00 0F |
|
Unknown | 0x054 |
2 | 00 1A |
|
SKU Flag | 0x056 |
2 | 00 01 |
|
Extra Flags | 0x058 |
4 | 00 00 00 00 |
|
Unknown | 0x060 |
4 | 00 02 00 00 |
|
Unknown | 0x064 |
4 | 00 00 00 01 |
|
?RIF format revision? | 0x068 |
4 | 00 00 00 02 , 00 00 00 03 |
2 on old rifs (3.55), 3 on new rifs (5.00) |
Unknown | 0x06C |
2 | 00 02 |
|
Unknown | 0x06E |
0x1D2 | - | |
Disc Key | 0x240 |
0x20 | - | Not present in KDS RIFs |
Secret Encryption IV | 0x260 |
0x10 | - | |
Encrypted Secret | 0x270 |
0x90 | - | See Secret for when decrypted |
RSA Signature | 0x300 |
0x100 | - | Verified using public key depending on type |
RIF Type[edit | edit source]
Type | FW Type | Min Ver | Max Ver | Name | Description | Remarks |
---|---|---|---|---|---|---|
0x000
|
All | 1 | 1 | KDS | Used for digital content | Revoked in at least 4.05 |
0x001
|
All | 2 | 2 | |||
0x002
|
All | 3 | 3 | |||
0x101
|
All | 1 | 1 | Isolated | Used for truly free content (Playroom, Vue, Spotify) | |
0x302
| ||||||
0x102
|
All | 1 | 1 | Disc | Used for Blu-ray content | |
0x200
|
DEX/TEST | 1 | 1 | Fake/Debug | Used for testing/debugging | |
0x201
| ||||||
0x202
| ||||||
0x303
|
CEX | 1 | 1 | ? | ||
0x304
|
? (not CEX) | 1 | 1 | ? | ||
0x305
|
DEX/TEST | 1 | 1 | ? |
Secret[edit | edit source]
This structure corresponds to the decrypted form. Size is 0x90 bytes.
Name | Offset | Size | Example | Remark |
---|---|---|---|---|
Unknown | 0x00 |
0x10 | - | |
Zeroes? | 0x10 |
0x10 | - | |
Zeroes? | 0x20 |
0x10 | - | |
Content Key Seed | 0x30 |
0x10 | - | Used to generate PFS key |
SELF Key Seed | 0x40 |
0x10 | - | Used to generate SELF key |
Unknown | 0x50 |
0x10 | - | |
Unknown | 0x60 |
0x10 | - | |
Entitlement Key | 0x70 |
0x10 | - | Usually zeroes |
Zeroes? | 0x80 |
0x10 | - |
RIFA File[edit | edit source]
This RIF form is paired with a .idx file.
When in this form, contrarly to RIF files a RIFA header is present, followed by sequential RIF entries.
See also IDX structure for the paired .idx file.
RIFA Header[edit | edit source]
Fields are big-endian. Size is 0x400 bytes.
Name | Offset | Size | Example | Remark |
---|---|---|---|---|
Magic | 0x000 |
4 | 72 69 66 61 ("rifa") |
|
Service ID | 0x004 |
0x14 | IP9100-CUSA00001_00\0 |
Size assumed |
Unknown | 0x018 |
0x3D8 | full of zeroes |
IDX File[edit | edit source]
This is the RIF index file. It is used in pair with RIFA files.
RIF IDX[edit | edit source]
Fields are little-endian. Size is 0x20 bytes (header) + entries_count * 0x30 bytes (entry_size).
Name | Offset | Size | Example | Remark |
---|---|---|---|---|
Magic | 0x00 |
4 | 72 69 64 78 ("ridx") |
|
Entries count | 0x04 |
4 | 01 00 00 00 , 03 00 00 00 |
|
Version | 0x08 |
1 | 01 |
1 (current) |
Service ID | 0x09 |
19 | IP9100-CUSA00001_00 |
|
Unknown | 0x1C |
4 | 01 00 00 00 , 00 00 00 00 |
|
Entries | 0x20 |
0x30 * Entries Count | See RIF IDX entry |
RIF IDX Entry[edit | edit source]
Fields are little-endian. Size is 0x30 bytes.
Name | Offset | Size | Example | Remark |
---|---|---|---|---|
Entitlement label | 0x00 |
16 | PLAYROOM00000000 |
|
RIF Offset | 0x10 |
8 | 00 04 00 00 00 00 00 00 |
Offset into RIFA file |
RIF Size | 0x18 |
8 | 00 04 00 00 00 00 00 00 |
|
Unknown | 0x20 |
1 | 01 |
|
Unknown | 0x21 |
1 | 00 |
|
RIF data HMAC-SHA256 | 0x22 |
8 | - | First 8 bytes of HMAC-SHA256 of RIF data using per-console data as key |
Unknown | 0x2A |
6 | - |