Editing SELF - SPRX

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 612: Line 612:
} supplemental_header_table;
} supplemental_header_table;
</source>
</source>
== Encryption Root Header ==
Temp name was Metadata Information. Official name is encryption_root_header.
This is not present in fCF (fSELF, fSPP, etc...).
The key and ivec fields are encrypted using AES256CBC.
=== Struct ===
<source lang="C">
typedef struct {
  uint8_t key[16];
  uint8_t key_pad[16];
  uint8_t iv[16];
  uint8_t iv_pad[16];
} __attribute__((packed)) encryption_root_header;
</source>
=== Comments ===
== Certification Header ==
Temp name was Metadata Header. Official name is certification_header.
It is only present if the Encryption Root Header is present.
It is decrypted using AES128 with the key and ivec entries from the Encryption Root Header.
It is located after the Encryption Root Header in the SELF file.
=== Struct ===
<source lang="C">
typedef struct {
  uint64_t footer_offset;
  uint32_t signature_type;            // 1 = ECDSA160, 5 = RSA2048
  uint32_t segment_count;
  uint32_t blocks_count; // was keyCount
  uint32_t optional_header_size;
  uint64_t unknown06;
} __attribute__((packed)) certification_header;
</source>
=== Comments ===
== Certification Body ==
*It is decrypted with the key and ivec entries from the Encryption Root Header.
=== Segment Certification Header ===
Temp name was Metadata Section Header. Official name is segment_certification_header.
It is only present if the Certification Header is present.
The number of sections is indicated by the segment_count entry in the Certification Header.
The Segment Certification Headers are located after the Certification Header in the SELF file.
==== Struct ====
<source lang="C">
typedef struct {
  uint64_t segment_offset;
  uint64_t segment_size;
  uint32_t segment_type;  // 1 = shdr, 2 = phdr, 3 = sceversion
  uint32_t program_idx;    // 0,1,2,3,etc for phdr, always 3 for shdrs, sceversion shdr number for sceversion
  uint32_t hash_algorithm; // ?1 = none?, 2 = sha1_hmac, 3 = sha1, 6 = sha256_hmac
  uint32_t hash_idx;
  uint32_t enc_algorithm;  // 1 = none, 2 = aes128cbccfb, 3 = aes128ctr
  uint32_t key_idx;        // -1 when enc_algorithm = none
  uint32_t iv_idx;        // -1 when enc_algorithm = none
  uint32_t comp_algorithm; // 1 = none, 2 = zlib
} __attribute__((packed)) segment_certification_header;
</source>
==== Comments ====
Notes:
*Segment data is decrypted using enc_algorithm with the key and ivec from the Segment Certification specified by key_idx and iv_idx.
*The segment_offset of the Segment Certification Header matches in general the offset from the Segment Extended Header.
=== Segment Certification ===
Temp name was Metadata Keys, Section Hash. Official name might be Segment Certification.
The number of Segment Certifications is indicated by the segment_count entry in the Certification Header.
The Segment Certifications are located after the Segment Certification Headers in the SELF file.
==== Struct ====
<source lang="C">
typedef struct {
  union { // size is 0x40 bytes
    uint8_t digest[0x20]; // hmac_sha1
    uint8_t hmac_key[0x20];
  } hash_type2;
  union { // size is 0x60 bytes
    uint8_t unk0[0x20]; // certinly hmax_sha256
    uint8_t unk1[0x40]; // certainly hmac_key
  } hash_type6;
  union { // size is 0x20 bytes
    uint8_t key[0x10];
    uint8_t iv[0x10];
  } encryption_params; // present for type 2 and 3
} __attribute__((packed)) segment_certification;
</source>
==== Comments ====
Notes:
*The HMAC-SHA1 is calculated on the decrypted data and before the decompression.
=== Optional Header Table ===
Temp name was Signature Info, Capabilities Info. Official name is optional_header_table.
The Optional Header Table is located after the Section Hash in the SELF file.
It is only present if optional_header_size in the Certification Header is not zero.
==== Struct ====
<source lang="C">
typedef struct {
uint32_t type; // 1=capability_header, 2=individual_seed_header, 3=attribute_header
uint32_t size;
uint64_t next; // 1 if another optional_header structure follows else 0
union {
// type 1
struct { // 0x20 bytes of data
uint8_t capability[0x20];
} capability_header;
// type 2
struct { // 0x100 bytes of data
uint8_t individual_seed[0x100];
} individual_seed_header;
// type 3
struct { // 0x20 bytes of data
uint8_t attribute[0x20];
} attribute_header;
};
} __attribute__((packed)) optional_header;
</source>
=== Comments ===
* Type 1 contains encrypted_capability. See [[Capability Flags]].
== Certification Footer ==
Temp name was Signature.
It is located at the Certification Header footer_offset in the SELF file.
It is decrypted with the key and ivec entries from the Encryption Root Header.
It can be ECDSA160 or RSA2048, according to the Certification Header.
=== Struct ===
<source lang="C">
typedef struct {
  union {
    uint8_t r[21];
    uint8_t s[21];
    uint8_t padding[6];
  } ECDSA160;
  union {
    uint8_t rsa[0x100];
  } RSA2048;
} __attribute__((packed)) certification_footer;
</source>
=== Comments ===
* footer_offset is the number of bytes which are used to generate the SHA-1 which is used to generate the ECDSA signature. The length should be eveything from the beginning until the signature itself. The decrypted version of the input data is used for signature.


= Extraction =
= Extraction =
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)