NPD: Difference between revisions

From PS3 Developer wiki
Jump to navigation Jump to search
No edit summary
(→‎Structure: antiwrapping names)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
NPD is a packet format used on PS3 in [[NPDRM]] contents. It corresponds to 2 sort of packets: the ones in SDAT/[[EDAT files]] and the ones in [[SELF_-_SPRX#Supplemental_Header_Table|SELF/SPRX NPDRM header]] in [[NPDRM]] SELF/SPRX files only. NPD likely stands for Network Playstation Data or Network Playstation Drm. PS Vita equivalent is "DRM".
NPD is a packet format used on PS3 in [[NPDRM]] contents. It corresponds to 2 sort of packets: the ones in SDAT/[[EDAT files]] and the ones in [[SELF_-_SPRX#Supplemental_Header_Table|SELF/SPRX NPDRM header]] in [[NPDRM]] SELF/SPRX files. NPD stands for Network Playstation Drm. The PS Vita equivalent of PS3 "NPD" packets are "DRM" packets.


= Location =
= Location =
Line 15: Line 15:
| 0x04 || Version || 4 || uint32_t || ex: 1, 2, 3, 4. See [[EDAT_files#Footer]] for the precise NPD packager version.
| 0x04 || Version || 4 || uint32_t || ex: 1, 2, 3, 4. See [[EDAT_files#Footer]] for the precise NPD packager version.
|-
|-
| 0x08 || [[NPDRM#DRM Type|DRM Type]] || 4 || uint32_t || For PS2 EDAT, PS3 FW requires it to be with activation (i.e. Local DRM). For [[PKG_files#Misc.2FNote|PS1 PKG]], PS3 FW 4.00 introduced some changes for installing them with regard to the EDAT DRM type.
| 0x08 || [[NPDRM#DRM Type|DRM Type]] || 4 || uint32_t || For PS2 EDAT, PS3 OS requires it to be with activation (i.e. Local DRM). For [[PKG_files#Misc.2FNote|PS1 PKG]], PS3 System Software version 4.00 introduced some changes for installing them with regard to the EDAT DRM type.
|-
|-
| 0x0C || [[App Types|Application Type]] || 4 || uint32_t ||
| 0x0C || [[App Types|Application Type]] || 4 || uint32_t ||
|-
|-
| 0x10 || [[PARAM.SFO#CONTENT_ID|CONTENT ID]] || 0x30 || uint8_t[0x30] || Content ID (with padding to fit 48 bytes)
| 0x10 || [[PARAM.SFO#CONTENT_ID|Content ID]] || 0x30 || uint8_t[0x30] || Content ID (with padding to fit 48 bytes)
|-
|-
| 0x40 || Digest || 0x10 || uint8[0x10] || QA digest. It seems to be a SHA-1 hash of the non-finalized file (debug self/sprx created with make_fself_npdrm) or of the original EDAT data. Original data are unknown until the whole file is read, so it cannot be used as a check, however it can be used as watermark or zeroed on forged file.
| 0x40 || Digest || 0x10 || uint8[0x10] || QA digest. It seems to be a SHA-1 hash of the non-finalized file (debug SELF/SPRX created with make_fself_npdrm) or of the original EDAT data. Original data are unknown until the whole file is read, so it cannot be used as a check, however it can be used as watermark or zeroed on forged file.
|-
|-
| 0x50 || NPD CID-FN Hash || 0x10 || uint8_t[0x10] || CID-FN hash. AES-CMAC hash of concatenation of Content ID (48 bytes) and EDAT/SELF filename (eg "MINIS.EDAT", "EBOOT.BIN") using the [[Keys#NPDRM_Keys|CID-FN hash AES-CMAC key]]. Example: aes_cmac(55 50 30 35 37 36 2D 4E 50 55 5A 30 30 31 34 39 5F 30 30 2D 56 41 4E 47 55 41 52 44 32 30 30 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00 00 4D 49 4E 49 53 2E 45 44 41 54, npd_cid_fn_hash_aes_cmac_key).
| 0x50 || CID-FN Hash || 0x10 || uint8_t[0x10] || CID-FN hash. AES-CMAC hash of concatenation of Content ID (48 bytes) and EDAT/SELF filename (eg "MINIS.EDAT", "EBOOT.BIN") using the [[Keys#NPD_CID-FN_Hash_AES-CMAC_Key|npd_cid_fn_hash_aes_cmac_key]]. Example: aes_cmac(55 50 30 35 37 36 2D 4E 50 55 5A 30 30 31 34 39 5F 30 30 2D 56 41 4E 47 55 41 52 44 32 30 30 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00 00 4D 49 4E 49 53 2E 45 44 41 54, npd_cid_fn_hash_aes_cmac_key).
|-
|-
| 0x60 || NPD Header hash || 0x10 || uint8_t[0x10] || Header hash. AES CMAC hash of the 0x60 bytes from the beginning of the file using (klicensee XOR [[Keys#NPDRM_Keys|wor_key]]) as AES-CMAC key.
| 0x60 || Header Hash || 0x10 || uint8_t[0x10] || Header hash. AES CMAC hash of the 0x60 bytes from the beginning of the file using (klicensee XOR [[Keys#NPD_Header_Hash_XOR_Key|npd_header_hash_xor_key]]) as AES-CMAC key.
|-
|-
| 0x70 || Activation time || 8 || ?64-bit time or with 32-bit padding? || Start of the validity period, filled with 00 if not used.
| 0x70 || Limited Time Start || 8 || ?64-bit time or with 32-bit padding? || Start of the validity period, filled with 00 if not used.
|-
|-
| 0x78 || Expiration time || 8 || ?64-bit time or with 32-bit padding? || End of the validity period, filled with 00 if not used.
| 0x78 || Limited Time End || 8 || ?64-bit time or with 32-bit padding? || End of the validity period, filled with 00 if not used.
|}
|}


<source lang="C">
<syntaxhighlight lang="C">
typedef struct PS3_NPD { //size is 0x80 bytes
typedef struct PS3_NPD { //size is 0x80 bytes
   uint32_t magic; // 4E 50 44 00 ("NPD.")
   uint32_t magic; // 4E 50 44 00 ("NPD.")
Line 42: Line 42:
   uint8_t cid_fn_hash[0x10];
   uint8_t cid_fn_hash[0x10];
   uint8_t header_hash[0x10];
   uint8_t header_hash[0x10];
   uint64_t activation_time;
   uint64_t limited_time_start;
   uint64_t expiration_time;
   uint64_t limited_time_end;
} PS3_NPD;
} PS3_NPD;
</source>
</syntaxhighlight>


= Tools =
= Tools =


* The official tool to generate NPD packets is make_package_npdrm. See [[PKG_files#Package_Tools]].
* The main tool to deal with NPD packets is [https://github.com/ErikPshat/make_npdata-hykem/ make_npdata by Hykem].
* The main tool to deal with NPD packets is [https://github.com/ErikPshat/make_npdata-hykem/ make_npdata by Hykem].

Latest revision as of 19:33, 13 June 2023

NPD is a packet format used on PS3 in NPDRM contents. It corresponds to 2 sort of packets: the ones in SDAT/EDAT files and the ones in SELF/SPRX NPDRM header in NPDRM SELF/SPRX files. NPD stands for Network Playstation Drm. The PS Vita equivalent of PS3 "NPD" packets are "DRM" packets.

Location[edit | edit source]

NPD packets are stored in EDAT files and in NPDRM SELF - SPRX files.

Structure[edit | edit source]

Offset Name Size Type Notes
0x00 Magic 4 char[4] "NPD\0" (4E 50 44 00)
0x04 Version 4 uint32_t ex: 1, 2, 3, 4. See EDAT_files#Footer for the precise NPD packager version.
0x08 DRM Type 4 uint32_t For PS2 EDAT, PS3 OS requires it to be with activation (i.e. Local DRM). For PS1 PKG, PS3 System Software version 4.00 introduced some changes for installing them with regard to the EDAT DRM type.
0x0C Application Type 4 uint32_t
0x10 Content ID 0x30 uint8_t[0x30] Content ID (with padding to fit 48 bytes)
0x40 Digest 0x10 uint8[0x10] QA digest. It seems to be a SHA-1 hash of the non-finalized file (debug SELF/SPRX created with make_fself_npdrm) or of the original EDAT data. Original data are unknown until the whole file is read, so it cannot be used as a check, however it can be used as watermark or zeroed on forged file.
0x50 CID-FN Hash 0x10 uint8_t[0x10] CID-FN hash. AES-CMAC hash of concatenation of Content ID (48 bytes) and EDAT/SELF filename (eg "MINIS.EDAT", "EBOOT.BIN") using the npd_cid_fn_hash_aes_cmac_key. Example: aes_cmac(55 50 30 35 37 36 2D 4E 50 55 5A 30 30 31 34 39 5F 30 30 2D 56 41 4E 47 55 41 52 44 32 30 30 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00 00 4D 49 4E 49 53 2E 45 44 41 54, npd_cid_fn_hash_aes_cmac_key).
0x60 Header Hash 0x10 uint8_t[0x10] Header hash. AES CMAC hash of the 0x60 bytes from the beginning of the file using (klicensee XOR npd_header_hash_xor_key) as AES-CMAC key.
0x70 Limited Time Start 8 ?64-bit time or with 32-bit padding? Start of the validity period, filled with 00 if not used.
0x78 Limited Time End 8 ?64-bit time or with 32-bit padding? End of the validity period, filled with 00 if not used.
typedef struct PS3_NPD { //size is 0x80 bytes
  uint32_t magic; // 4E 50 44 00 ("NPD.")
  uint32_t version;
  uint32_t drm_type;
  uint32_t app_type;
  uint8_t content_id[0x30];
  uint8_t digest[0x10];
  uint8_t cid_fn_hash[0x10];
  uint8_t header_hash[0x10];
  uint64_t limited_time_start;
  uint64_t limited_time_end;
} PS3_NPD;

Tools[edit | edit source]