Changes

Jump to navigation Jump to search
no edit summary
Line 1: Line 1: −
Depending on the F00D SELF that is currently loaded, different commands are handled.
+
Depending on the [[SM]] that is currently loaded, different commands are handled.
    
== Request Buffer ==
 
== Request Buffer ==
   −
Each request that is made sends a page aligned buffer that has a max size of a page. After as 64 byte header common to all commands, the data afterwards is specific to each command. The documentation for each command below specifies the data that goes after the header. The special command id of -1 (<code>0xFFFFFFFF</code>) is used to shut down the currently loaded F00D SELF.
+
Each request that is made sends a page aligned buffer that has a max size of a page. After as 64 byte header common to all commands, the data afterwards is specific to each command. The documentation for each command below specifies the data that goes after the header. The special command id of -1 (<code>0xFFFFFFFF</code>) is used to stop the current loaded [[SM]].
   −
{| class="wikitable"
+
Command buffer structure (as seen on FWs 3.60-3.73):
 +
 
 +
{| class='wikitable'
 
|-
 
|-
! Offset !! Size !! Description
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0x0 || 0x4 || Size of buffer
+
| 0x0
 +
| 0x4
 +
| Size of the structure (header + data)
 
|-
 
|-
| 0x4 || 0x4 || Command ID
+
| 0x4
 +
| 0x4
 +
| Command ID
 
|-
 
|-
| 0x8 || 0x4 || Return value (output)
+
| 0x8
 +
| 0x4
 +
| Command return value is written here by the SM
 
|-
 
|-
| 0xC || 0x34 || Unknown/Unused
+
| 0xC
 +
| 0x4
 +
| unk2
 
|-
 
|-
| 0x40 || Variable (max 0xFC0) || Command specific buffer
+
| 0x10
 +
| 0x30
 +
| padding
 
|-
 
|-
 +
| 0x40
 +
| variable, chosen by NS Kernel, max=0x1000-0x40
 +
| data buffer
 
|}
 
|}
   −
=== Physical Address List ===
+
On FW 0.931, and maybe in later prototype FWs, the data buffer is located at offset 0x10 instead of 0x40. Thus we can ask why they added the 0x30 bytes padding.
 +
 
 +
=== Physical Address Range ===
    
A common format used in these requests is a list of physical address and size. This simple structure is defined below. See [[SceSysmem#sceKernelVARangeToPARangeForDriver|sceKernelVARangeToPARangeForDriver]] for information on creating this list.
 
A common format used in these requests is a list of physical address and size. This simple structure is defined below. See [[SceSysmem#sceKernelVARangeToPARangeForDriver|sceKernelVARangeToPARangeForDriver]] for information on creating this list.
Line 32: Line 51:  
|-
 
|-
 
| 0x4 || 0x4 || Size
 
| 0x4 || 0x4 || Size
|-
   
|}
 
|}
   −
This data format is used when passing large buffers of data to F00D. This is because the memory manager in kernel could allocate contiguous virtual addresses that corresponds to varying physical addresses.
+
This data format is used when passing large buffers of data to [[CMeP]]. This is because the memory manager in kernel could allocate contiguous virtual addresses that corresponds to varying physical addresses.
    
== kprx_auth_sm.self ==
 
== kprx_auth_sm.self ==
   −
This is a special SELF that is found in the boot [[SLB2]] partition. The raw (encrypted) SELF is found in secure world memory (placed there by an early bootloader). It is used to decrypt SELFs for ARM. The SELF header is passed into a page aligned buffer and a [[F00D Commands#Physical Address List|paddr list]] is generated from it.
+
This is a special SM found in the [[SLB2]] partition. The raw (encrypted) SELF is stored in [[Secure World]] memory. It is placed there by an early bootloader.
 +
 
 +
kprx_auth_sm is used to decrypt SELF and SPSFO files for ARM. The CF header is passed into a page aligned buffer and a [[F00D Commands#Physical Address Range|PA range]] is generated from it.
    
=== 0x10001 - sceSblAuthMgrAuthHeader ===
 
=== 0x10001 - sceSblAuthMgrAuthHeader ===
Line 45: Line 65:  
Used by [[SceSblAuthMgr#sceSblAuthMgrAuthHeaderForKernel|sceSblAuthMgrAuthHeaderForKernel]].
 
Used by [[SceSblAuthMgr#sceSblAuthMgrAuthHeaderForKernel|sceSblAuthMgrAuthHeaderForKernel]].
   −
Checks the SELF header for decryption. The header is copied to the F00D private memory region first (on 1.69 with 0x1000 sized header, it is at <code>0x00811CC0</code> in F00D memory space.
+
Checks the SELF header for decryption. The header is copied to the cmep private memory region first (on 1.69 with 0x1000 sized header, it is at <code>0x00811CC0</code> in cmep memory space.
    
{| class="wikitable"
 
{| class="wikitable"
Line 52: Line 72:  
| 0x40 || 0x130 || [[SceSblSsSmComm#Types|SceSblSmCommContext130]]
 
| 0x40 || 0x130 || [[SceSblSsSmComm#Types|SceSblSmCommContext130]]
 
|-
 
|-
| 0x170 || 0x4 || Number of paddr list entries for buffer
+
| 0x170 || 0x4 || Number of physical address list entries for buffer
 
|-
 
|-
| 0x174 || 0x4 || Physical address of paddr list
+
| 0x174 || 0x4 || Physical address of physical address list
 
|}
 
|}
   Line 79: Line 99:  
Used by [[SceSblAuthMgr#sceSblAuthMgrAuthSegmentForKernel|sceSblAuthMgrAuthSegmentForKernel]].
 
Used by [[SceSblAuthMgr#sceSblAuthMgrAuthSegmentForKernel|sceSblAuthMgrAuthSegmentForKernel]].
   −
Decrypt a buffer from the SELF corresponding to the program segment number passed in above. The segment is read in <code>0x10000</code> bytes chunks and is decrypted in place (the input buffer will contain the decrypted data). A [[F00D Commands#Physical Address List|paddr list]] is generated from the buffer. The input buffer and output buffer can be the same.
+
Decrypt a buffer from the SELF corresponding to the program segment number passed in above. The segment is read in <code>0x10000</code> bytes chunks and is decrypted in place (the input buffer will contain the decrypted data). A [[F00D Commands#Physical Address List|physical address list]] is generated from the buffer. The input buffer and output buffer can be the same.
    
{| class="wikitable"
 
{| class="wikitable"
Line 85: Line 105:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Number of entries in input paddr list
+
| 0x40 || 0x4 || Number of entries in input physical address list
 
|-
 
|-
| 0x44 || 0x4 || Physical address of the input paddr list
+
| 0x44 || 0x4 || Physical address of the input physical address list
 
|-
 
|-
| 0x48 || 0x4 || Number of entries in output paddr list
+
| 0x48 || 0x4 || Number of entries in output physical address list
 
|-
 
|-
| 0x4C || 0x4 || Physical address of the output paddr list
+
| 0x4C || 0x4 || Physical address of the output physical address list
 
|}
 
|}
   Line 132: Line 152:  
| 0x144 || 0x4 || Key ID
 
| 0x144 || 0x4 || Key ID
 
|-
 
|-
| 0x148 || 0x4 || Slot ID
+
| 0x148 || 0x4 || Dst Slot ID. 0~0x1F.
 
|-
 
|-
 
| 0x14C || 0x4 || Key size & 0xF (Should be 0)
 
| 0x14C || 0x4 || Key size & 0xF (Should be 0)
Line 144: Line 164:  
This function writes zeroes into dmac5 keyring.
 
This function writes zeroes into dmac5 keyring.
   −
=== 0x70001 - sceSblAuthMgrDecBindDataForDriver ===
+
=== 0x70001 - sceSblAuthMgrDecBindData ===
    
Used by [[SceSblAuthMgr#sceSblAuthMgrDecBindDataForDriver|sceSblAuthMgrDecBindDataForDriver]] and [[SceNpDrm]] for gamecard binding data used in conjunction with the RIF license file on the gamecard for deriving the klicensee.
 
Used by [[SceSblAuthMgr#sceSblAuthMgrDecBindDataForDriver|sceSblAuthMgrDecBindDataForDriver]] and [[SceNpDrm]] for gamecard binding data used in conjunction with the RIF license file on the gamecard for deriving the klicensee.
Line 158: Line 178:  
Removed on FW 2.10.
 
Removed on FW 2.10.
   −
Verify SceKitActivationData derived from AFV.
+
Verify SceKitActivationData read from sd0:/act.dat.
 +
 
 +
Uses different keys (AES256CBC and AES256CMAC) than check_activation_code_2.
   −
Use "internal" keys (?internal kits maybe? Not used on PDEL kernel).
+
Used only on TOOL rev 3.
    
{| class="wikitable"
 
{| class="wikitable"
Line 166: Line 188:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x80 || [[SceSblSsMgr#SceKitActivationData|SceKitActivationData]]
+
| 0x0 || 0x80 || Input: [[SceSblSsMgr|SceKitActivationData]]
 
|}
 
|}
   Line 173: Line 195:  
Removed on FW 2.10.
 
Removed on FW 2.10.
   −
Verify SceKitActivationData derived from AFV.
+
Verify SceKitActivationData read from sd0:VITA.ACT.
 +
 
 +
Uses different keys (AES256CBC and AES256CMAC) than check_activation_code_1.
   −
Use PDEL/PTEL keys. (maybe also latest DEM)
+
Used on any Kit other than TOOL rev 3 (uses command 1), TEST, TOOL rev 4, Manufacturing Mode and QA flagged (bypasses activation).
    
{| class="wikitable"
 
{| class="wikitable"
Line 181: Line 205:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x80 || [[SceSblSsMgr#SceKitActivationData|SceKitActivationData]]
+
| 0x0 || 0x80 || Input: [[SceSblSsMgr|SceKitActivationData]]
 
|}
 
|}
    
=== 0x4 - check_nvs_cmac ===
 
=== 0x4 - check_nvs_cmac ===
   −
Verify NVS activation data authenticity by comparing with stored CMAC.
+
Not present on FW 0.931.
 +
 
 +
Verify NVS activation data authenticity using CMAC.
    
{| class="wikitable"
 
{| class="wikitable"
Line 192: Line 218:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x20? to check || input: [[SceSblSsMgr|SceNVSKitActivationData]]
+
| 0x0 || 0x20 || Input: [[SceSblSsMgr|SceNVSKitActivationData]]
 
|}
 
|}
   Line 205: Line 231:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Magic "act\0"
+
| 0x0 || 0x4 || Magic "act\0"
 
|-
 
|-
| 0x44 || 0x4 || Issue number
+
| 0x4 || 0x4 || Issue number
 
|-
 
|-
| 0x48 || 0x4 || Start validity time unix timestamp
+
| 0x8 || 0x4 || Start validity time unix timestamp
 
|-
 
|-
| 0x4C || 0x4 || End validity time unix timestamp
+
| 0xC || 0x4 || End validity time unix timestamp
 
|-
 
|-
| 0x50 || 0x10 || output: CMAC of the 0x10 input bytes
+
| 0x10 || 0x10 || Output: CMAC of the 0x10 input bytes
 
|}
 
|}
   Line 226: Line 252:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x10 || SceKitNVSActivationData without CMAC
+
| 0x0 || 0x10 || [[SceSblSsMgr|SceNVSKitActivationData]] without CMAC
 
|-
 
|-
| 0x50 || 0x20 || SceKitNVSActivationData
+
| 0x10 || 0x20 || [[SceSblSsMgr|SceNVSKitActivationData]]
 
|}
 
|}
   Line 241: Line 267:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x80 || [[SceSblSsMgr#SceKitActivationData|SceKitActivationData]] (new activation data)
+
| 0x0 || 0x80 || Input: [[SceSblSsMgr#|SceKitActivationData]] (new activation data)
 
|-
 
|-
| 0xC0 || 0x100 || RSA signature over new activation data
+
| 0x80 || 0x100 || Input: RSA signature over new activation data
 
|-
 
|-
| 0x1C0 || 0x80 ||[[SceSblSsMgr#SceKitActivationData|SceKitActivationData]] (previous activation data)
+
| 0x180 || 0x80 || Input: [[SceSblSsMgr|SceKitActivationData]] (previous activation data)
 
|-
 
|-
| 0x240 || 0x100 || RSA signature over previous activation data
+
| 0x200 || 0x100 || Input: RSA signature over previous activation data
 
|-
 
|-
| 0x340 || 0x20 || Output: SceKitNVSActivationData (same as act_sm command 4)
+
| 0x300 || 0x20 || Output: [[SceSblSsMgr|SceNVSKitActivationData]]
 
|}
 
|}
   Line 262: Line 288:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || input: Previous return value
+
| 0x0 || 0x4 || Input: Previous return value
 
|-
 
|-
| 0x44 || 0x4 || input: Current time
+
| 0x4 || 0x4 || Input: Current time
 
|-
 
|-
| 0x48 || 0x4 || output: License Status
+
| 0x8 || 0x4 || Output: License Status
 
|-
 
|-
| 0x4C || 0x4 || output: Expire Date
+
| 0xC || 0x4 || Output: Expire Date
 
|-
 
|-
| 0x50 || 0x8 || Reserved
+
| 0x10 || 0x8 || Reserved
 
|-
 
|-
| 0x58 || 0x20 || input: SceKitNVSActivationData (read from NVS offset 0x520)
+
| 0x18 || 0x20 || Input: [[SceSblSsMgr|SceNVSKitActivationData]] (read from NVS offset 0x520)
 
|-
 
|-
| 0x78 || 0x80 || input: SceKitActivationData (read from tm0:activate/act.dat)
+
| 0x38 || 0x80 || Input: [[SceSblSsMgr|SceKitActivationData]] (read from tm0:activate/act.dat)
 
|-
 
|-
| 0xF8 || 0x100 || input: RSA signature over activation data (read from tm0:activate/actsig.dat)
+
| 0xB8 || 0x100 || Input: RSA signature over activation data (read from tm0:activate/actsig.dat)
 
|}
 
|}
   Line 306: Line 332:     
=== 0x5 - CreatePassPhrase ===
 
=== 0x5 - CreatePassPhrase ===
 +
 +
Creates NP passphrase (per-console and per NP account).
    
Used in [[SceSblSsMgr#sceSblSsCreatePassPhraseForDriver|sceSblSsCreatePassPhraseForDriver]].
 
Used in [[SceSblSsMgr#sceSblSsCreatePassPhraseForDriver|sceSblSsCreatePassPhraseForDriver]].
   −
== compat_sm.self ==
+
Input size is 0x220 bytes.
 
  −
Compat SM functions only works on DEX and CEX units, or on units in Manufacturing Mode or with a certain QA Flag. This is why most DevKit units don't have access to PSPEmu.
  −
 
  −
=== 0x10006 - sceCompatSecLoadSCBootCode ===
  −
 
  −
Load Secure CPU Boot Code. PSP main CPU (Tachyon codename) is an Allegrex 32-bit little-endian RISC CPU with FPU and VFPU, 1 ~ 333MHz, MIPS III-based.
  −
 
  −
Called on init and before resume of PSP.
      
{| class="wikitable"
 
{| class="wikitable"
Line 323: Line 343:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Boot/resume cookie. Pass 0 when cold booting, <code>resume_handler ^ magic</code> when resuming
+
| 0x40 || 0x8 || Secure Tick
 +
|-
 +
| 0x48 || 0x4 || Unknown. Maybe version or reserved. ex: 0.
 +
|-
 +
| 0x4C || 0x4 || Arguments size in usermode (0x18 bytes)
 +
|-
 +
| 0x50 || 0x10 || NP Account ID in ASCII
 
|-
 
|-
| 0x44 || 0x4 || Set to 0 (unused)
+
| 0x60 || 0x200 || IdStorage leaf 0x44 (contains PS Vita IDPS Certificate)
 
|}
 
|}
   −
On FW 3.73 (simplified):
+
Output size is 0x220 bytes.
   −
<source lang="C">
+
{| class="wikitable"
 +
|-
 +
! Offset !! Size !! Description
 +
|-
 +
| 0x40 || 0x8 || Secure Tick
 +
|-
 +
| 0x48 || 0x4 || Unknown. Maybe version or reserved. ex: 0.
 +
|-
 +
| 0x4C || 0x4 || Arguments size in usermode (0x18 bytes)
 +
|-
 +
| 0x50 || 0x10 || NP Account ID in ASCII
 +
|-
 +
| 0x60 || 0x200 || NP PassPhrase
 +
|}
 +
 
 +
== compat_sm.self ==
 +
 
 +
Compat SM functions only works on DEX and CEX units, or on units in Manufacturing Mode or with a certain QA Flag. This is why most DevKit units don't have access to PSPEmu.
 +
 
 +
=== 0x10006 - sceCompatSecLoadSCBootCode ===
 +
 
 +
Load Secure CPU Boot Code. PSP main CPU (Tachyon codename) is an Allegrex 32-bit little-endian RISC CPU with FPU and VFPU, 1 ~ 333MHz, MIPS III-based.
 +
 
 +
Called on init and before resume of PSP.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Offset !! Size !! Description
 +
|-
 +
| 0x40 || 0x4 || Boot/resume cookie. Pass 0 when cold booting, <code>resume_handler ^ magic</code> when resuming
 +
|-
 +
| 0x44 || 0x4 || Set to 0 (unused)
 +
|}
 +
 
 +
On FW 3.73 (simplified):
 +
 
 +
<source lang="C">
 
*(u32 *)SceSonyRegbus_e8000004 = 4;
 
*(u32 *)SceSonyRegbus_e8000004 = 4;
 
syncm();
 
syncm();
Line 447: Line 509:     
=== 0x1000B ===
 
=== 0x1000B ===
 +
 +
Execute kirk commands.
    
This is one of the variable sized buffers that can be placed inside [[F00D_Commands#Request_Buffer|Request_Buffer]].
 
This is one of the variable sized buffers that can be placed inside [[F00D_Commands#Request_Buffer|Request_Buffer]].
Line 483: Line 547:  
Following are the supported "KIRK" commands.
 
Following are the supported "KIRK" commands.
   −
==== 0x4 - kirk_encrypt ====
+
==== 0x4 - encrypt_with_portability ====
    
Original PSP Kirk 4 service for encrypting data.
 
Original PSP Kirk 4 service for encrypting data.
Line 493: Line 557:  
Uses one set of keys.
 
Uses one set of keys.
   −
Available <code>Key ID</code> values are (key is encrypted with key from keyslot 0x345 and put into keyslot 0x21): 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x38, 0x39, 0x3A, 0x80, 0x81, 0x82, 0x83
+
Available <code>Key ID</code> values are (key is encrypted with key from keyslot 0x345 and put into keyslot 0x21): 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x38, 0x39, 0x3A, 0x80, 0x81, 0x82, 0x83.
    
Special <code>Key ID</code> 0x100 is available. Uses keys from keyslots 0x601 and 0x602.
 
Special <code>Key ID</code> 0x100 is available. Uses keys from keyslots 0x601 and 0x602.
Line 503: Line 567:  
seed is aes cbc encrypted with key to produce resulting key.
 
seed is aes cbc encrypted with key to produce resulting key.
   −
==== 0x7 - kirk_decrypt ====
+
==== 0x7 - decrypt_with_portability ====
   −
Original PSP Kirk 7 service for decrypting data
+
Original PSP Kirk 7 service for decrypting data.
    
Does not use any specific data structure in <code>Data Buffer</code>.
 
Does not use any specific data structure in <code>Data Buffer</code>.
Line 513: Line 577:  
Uses two sets of keys.
 
Uses two sets of keys.
   −
Available key ids are (key is encrypted with key from keyslot 0x345 and put into keyslot 0x21): 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x38, 0x39, 0x3A, 0x80, 0x81, 0x82, 0x83
+
Available key ids are (key is encrypted with key from keyslot 0x345 and put into keyslot 0x21): 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x38, 0x39, 0x3A, 0x80, 0x81, 0x82, 0x83.
   −
Available <code>Key ID</code> values are (key is encrypted with key from keyslot 0x340 and put into keyslot 0x10): 0x44, 0x53, 0x57, 0x63, 0x64, 0x68, 0xC0, 0xC1, 0xC2, 0xC3
+
Available <code>Key ID</code> values are (key is encrypted with key from keyslot 0x340 and put into keyslot 0x10): 0x44, 0x53, 0x57, 0x63, 0x64, 0x68, 0xC0, 0xC1, 0xC2, 0xC3.
    
Special <code>Key ID</code> 0x100 is available. Uses keys from keyslots 0x601 and 0x602 (will be documented later).
 
Special <code>Key ID</code> 0x100 is available. Uses keys from keyslots 0x601 and 0x602 (will be documented later).
Line 525: Line 589:  
seed is aes cbc encrypted with key to produce resulting key.
 
seed is aes cbc encrypted with key to produce resulting key.
   −
==== 0xC - kirk_ecc160_generate_keys ====
+
==== 0xC - ecc160_generate_keys ====
    
Original PSP Kirk 0xC service for Generating a 160bit ECC private/public keypair. Call with an empty buffer of length 0x3C. The structure below is the return structure.
 
Original PSP Kirk 0xC service for Generating a 160bit ECC private/public keypair. Call with an empty buffer of length 0x3C. The structure below is the return structure.
Line 552: Line 616:  
|}
 
|}
   −
==== 0xD - kirk_ecc160_multiply ====
+
==== 0xD - ecc160_multiply ====
    
Original PSP Kirk 0xD service for multiplying a 160bit ECC curve point with a value. Call with a multiplier, x and y point value.
 
Original PSP Kirk 0xD service for multiplying a 160bit ECC curve point with a value. Call with a multiplier, x and y point value.
Line 580: Line 644:  
|}
 
|}
   −
==== 0xE - kirk_ecc160_generate_random ====
+
==== 0xE - ecc160_prngen ====
   −
Original PSP Kirk 0xE service for 160bit Random number generation. Call with an empty buffer, the result structure is below.
+
Original PSP Kirk 0xE service for 160bit Random number generation. Call with an empty buffer.
   −
Output:
   
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0x14 || Cryptographic Random Number
+
| 0x0|| 0x14 || Output: Pseudo Random Number
 
|-
 
|-
 
|}
 
|}
   −
==== 0x10 - kirk_ecc160_sign ====
+
==== 0x10 - ecc160_sig_gen ====
    
Original PSP Kirk 0x10 service for 160bit ECC signing.
 
Original PSP Kirk 0x10 service for 160bit ECC signing.
Line 612: Line 675:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0x20 || Encrypted private key (see kirk-engine implementation for fuse_id process for encryption)
+
| 0x0|| 0x20 || Encrypted private key
 
|-
 
|-
| 0x20|| 0x14 || SHA1 hash of the content you want signed
+
| 0x20|| 0x14 || SHA1 hash of the content to sign
 
|-
 
|-
 
|}
 
|}
Line 629: Line 692:  
|}
 
|}
   −
==== 0x11 - kirk_ecc160_verify ====
+
==== 0x11 - ecc160_sig_verify ====
    
Original PSP Kirk 0x11 service for 160bit ECC signature verification. Call with the below structure, then function will return pass or fail.
 
Original PSP Kirk 0x11 service for 160bit ECC signature verification. Call with the below structure, then function will return pass or fail.
Line 644: Line 707:  
| 0x14|| 0x14 || Public Key Y component
 
| 0x14|| 0x14 || Public Key Y component
 
|-
 
|-
| 0x28|| 0x14 || SHA1 hash of the content that is signed
+
| 0x28|| 0x14 || SHA1 hash of the signed content
 
|-
 
|-
 
| 0x3C|| 0x14 || ECC Signature R component
 
| 0x3C|| 0x14 || ECC Signature R component
Line 653: Line 716:  
No output.
 
No output.
   −
==== 0x12 - verify_cmac_signature ====
+
==== 0x12 - cert_verify ====
    
This function checks that CMAC of <code>Message</code> equals <code>Encrypted CMAC value</code>.
 
This function checks that CMAC of <code>Message</code> equals <code>Encrypted CMAC value</code>.
Line 674: Line 737:  
|}
 
|}
   −
==== 0x14 - kirk_ecc224_generate_keys ====
+
==== 0x14 - ecc224_generate_keys ====
   −
New Vita Kirk 0x14 service for Generating a 224bit ECC private/public keypair. Call with an empty buffer of length 0x54. The structure below is the return structure.
+
New Vita Kirk 0x14 service for generating a 224bit ECC private/public keypair. Call with an empty buffer of length 0x54. The structure below is the return structure.
    
Private key <code>dA</code> is obtained by:
 
Private key <code>dA</code> is obtained by:
Line 701: Line 764:  
|}
 
|}
   −
==== 0x15 - kirk_ecc224_multiply ====
+
==== 0x15 - ecc224_multiply ====
    
New Vita Kirk 0x15 service for multiplying a 224bit ECC curve point with a value. Call with a multiplier, x and y point value.
 
New Vita Kirk 0x15 service for multiplying a 224bit ECC curve point with a value. Call with a multiplier, x and y point value.
Line 729: Line 792:  
|}
 
|}
   −
==== 0x16 - kirk_ecc224_generate_random ====
+
==== 0x16 - ecc224_prngen ====
   −
New Vita Kirk 0x16 service for 224bit Random number generation. Call with an empty buffer, the result structure is below.
+
New Vita Kirk 0x16 service for 224bit Random number generation. Call with an empty buffer.
   −
Output:
   
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0x1C || Cryptographic Random Number
+
| 0x0|| 0x1C || Output: Pseudo Random Number
 
|-
 
|-
 
|}
 
|}
   −
==== 0x17 - kirk_ecc224_sign ====
+
==== 0x17 - ecc224_sig_gen ====
    
New Vita Kirk 0x17 service for 224bit ECC signing.
 
New Vita Kirk 0x17 service for 224bit ECC signing.
Line 778: Line 840:  
|}
 
|}
   −
==== 0x18 - kirk_ecc224_verify ====
+
==== 0x18 - ecc224_sig_verify ====
    
New Vita Kirk 0x18 service for 224bit ECDSA signature verification. Call with the below structure, then function will return pass or fail.
 
New Vita Kirk 0x18 service for 224bit ECDSA signature verification. Call with the below structure, then function will return pass or fail.
Line 799: Line 861:  
|}
 
|}
   −
==== 0x19 - verify_cmac_signature ====
+
==== 0x19 - cert_verify_new ====
    
This function checks that CMAC of <code>Message</code> equals <code>Encrypted CMAC value</code>.
 
This function checks that CMAC of <code>Message</code> equals <code>Encrypted CMAC value</code>.
Line 809: Line 871:  
Key in keyslot 0x0 is derived using key from keyslot 0x204 with static seed value.
 
Key in keyslot 0x0 is derived using key from keyslot 0x204 with static seed value.
   −
This function is related to IdStorage somehow.
+
This function is used to verify PSVita new IdStorage Certificates.
    
Input:
 
Input:
Line 816: Line 878:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0xD8 || Message
+
| 0x0|| 0xE8 || Input: Certificate
|-
  −
| 0xD8|| 0x10 || Encrypted CMAC value
  −
|-
   
|}
 
|}
   Line 838: Line 897:  
- this way we know that card knows how to properly encrypt.
 
- this way we know that card knows how to properly encrypt.
   −
- kirk service 1B will decrypt packet 8 with key_id and master_key
+
- Kirk service 1B will decrypt packet 8 with key_id and master_key
    
- then it will verify challenge0
 
- then it will verify challenge0
Line 1,062: Line 1,121:  
|}
 
|}
   −
==== 0x21 - kirk_ecc160_sign ====
+
==== 0x21 - ecc160_hmac_sha256_sig_gen ====
    
New Vita Kirk 0x21 service for 160bit ECC signing.  
 
New Vita Kirk 0x21 service for 160bit ECC signing.  
Line 1,083: Line 1,142:  
| 0x0|| 0x20 || unknown, must be zeroes
 
| 0x0|| 0x20 || unknown, must be zeroes
 
|-
 
|-
| 0x20|| 0x14 || message hash
+
| 0x20|| 0x14 || Message hash
 
|-
 
|-
 
|}
 
|}
Line 1,098: Line 1,157:  
|}
 
|}
   −
==== 0x22 - kirk_ecc224_sign_sceebootpbp ====
+
==== 0x22 - ecc224_sceebootpbp_sig_gen ====
    
New Vita Kirk 0x22 service for 224bit ECC signing.  
 
New Vita Kirk 0x22 service for 224bit ECC signing.  
Line 1,139: Line 1,198:     
New Vita Kirk 0x23 service.
 
New Vita Kirk 0x23 service.
 +
 +
It encrypts the plain message with AES128CBC, static key and null IV, then calculates the AES128CMAC of the encrypted message with another static key.
    
Input:
 
Input:
Line 1,145: Line 1,206:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0x10 || Message
+
| 0x0|| 0x10 || Plain message
 
|-
 
|-
 
|}
 
|}
Line 1,154: Line 1,215:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x0|| 0x10 || Encrypted Message
+
| 0x0|| 0x10 || Encrypted message
 
|-
 
|-
| 0x10|| 0x10 || Encrypted Message CMAC
+
| 0x10|| 0x10 || Encrypted message CMAC
 
|-
 
|-
 
|}
 
|}
Line 1,164: Line 1,225:  
[[SceSblPostSsMgr#sceSblPmMgrAuthEtoIForDriver|sceSblPmMgrAuthEtoIForDriver]] uses "sd0:sm/pm_sm_sd.self" whilst other PmSm functions use "os0:sm/pm_sm.self".
 
[[SceSblPostSsMgr#sceSblPmMgrAuthEtoIForDriver|sceSblPmMgrAuthEtoIForDriver]] uses "sd0:sm/pm_sm_sd.self" whilst other PmSm functions use "os0:sm/pm_sm.self".
   −
Services 9 and 0xA appeared on 1.03 (maybe 1.00). They are not present on 0.990 and earlier.
+
Services 8, 9 and 0xA appeared on FW 1.03 (maybe 1.00). They are not present on FW 0.990 and earlier.
 +
 
 +
Keyset must be between 0-0xC on FW 0.931.
    
=== 0x1 - get_product_mode ===
 
=== 0x1 - get_product_mode ===
Line 1,170: Line 1,233:  
Used by sceSblPmMgrGetProductModeFromNVS.
 
Used by sceSblPmMgrGetProductModeFromNVS.
   −
Data size is 0x28 bytes. (0x20 bytes used)
+
Data size is 0x28 bytes.
    
Input: 0x20 buffer read from NVS at offset 0.
 
Input: 0x20 buffer read from NVS at offset 0.
Line 1,177: Line 1,240:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Output: product mode
+
| 0x40 || 0x4 || Output: Product Mode
 
|-
 
|-
| 0x44 || 0x4 || zeroed
+
| 0x44 || 0x4 || Reserved
 
|-
 
|-
| 0x48 || 0x20 || input only: NVS data read at offset 0
+
| 0x48 || 0x20 || Input: NVS block read at offset 0
 
|}
 
|}
   Line 1,188: Line 1,251:  
Used by sceSblPmMgrSetProductMode.
 
Used by sceSblPmMgrSetProductMode.
   −
Data size is 0x28 bytes. (0x20 bytes used)
+
Data size is 0x28 bytes.
    
Input: 0x20 bytes buffer read from NVS at offset 0, to which is written the new product mode to set.
 
Input: 0x20 bytes buffer read from NVS at offset 0, to which is written the new product mode to set.
Line 1,197: Line 1,260:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || new product mode
+
| 0x40 || 0x4 || Input: Product Mode
 
|-
 
|-
| 0x44 || 0x1C || output only
+
| 0x44 || 0x4 || Reserved
 +
|-
 +
| 0x48 || 0x20 || Input and output: NVS block read/written at offset 0
 
|}
 
|}
    
=== 0x3 - gen_req_hello ===
 
=== 0x3 - gen_req_hello ===
   −
Input: 0x30 bytes buffer.
+
This command gets the Ernie secure packet for the first JIG auth command.
   −
This is the first JIG auth command. The 0x28 buffer content is for the first time set by this service.
+
Data size is 0x30 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1 (6 or 14)
+
| 0x40 || 0x4 || Input: keyset (6, 14)
 
|-
 
|-
| 0x44 || 0x4 || arg2 (1 when arg1 in [4, 6, 12]; 2 when arg1 in [14]; otherwise undefined)
+
| 0x44 || 0x4 || Input: keyset_rev (1 when keyset in [4, 6, 12]; 2 when keyset in [14]; otherwise undefined)
 
|-
 
|-
| 0x48 || 0x28 || output only
+
| 0x48 || 0x28 || Output: Ernie secure packet
 
|}
 
|}
    
=== 0x4 - gen_challenge ===
 
=== 0x4 - gen_challenge ===
   −
Input: 0x30 bytes buffer.
+
Data size is 0x30 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1 (6 or 14)
+
| 0x40 || 0x4 || Input: keyset (6, 14)
 
|-
 
|-
| 0x44 || 0x4 || arg2 (1 when arg1 in [4, 6, 12]; 2 when arg1 in [14]; otherwise undefined)
+
| 0x44 || 0x4 || Input: keyset_rev (1 when keyset in [4, 6, 12]; 2 when keyset in [14]; otherwise undefined)
 
|-
 
|-
| 0x48 || 0x28 || input and output
+
| 0x48 || 0x28 || Input and output: Ernie secure packet
 
|}
 
|}
    
=== 0x5 - check_response ===
 
=== 0x5 - check_response ===
   −
Input: 0x30 bytes buffer.
+
Returns 0 on success.
   −
Returns 0 on success, doesn't modify the input buffer.
+
Data size is 0x30 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1 (6 or 14)
+
| 0x40 || 0x4 || input: keyset (6, 14)
 
|-
 
|-
| 0x44 || 0x4 || arg2 (1 when arg1 in [4, 6, 12]; 2 when arg1 in [14]; otherwise undefined)
+
| 0x44 || 0x4 || input: keyset_rev (1 when keyset in [4, 6, 12]; 2 when arg1 in [14]; otherwise undefined)
 
|-
 
|-
| 0x48 || 0x28 || input only
+
| 0x48 || 0x28 || input: Ernie secure packet
 
|}
 
|}
    
=== 0x6 - gen_req_result ===
 
=== 0x6 - gen_req_result ===
   −
Input: 0x30 bytes buffer.
+
Encrypts Ernie secure packet for step 4 with the chosen keyset.
 +
 
 +
Data size is 0x30 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1 (6 or 14)
+
| 0x40 || 0x4 || Input: keyset (4, 6 on FW 0.931-3.60)
 
|-
 
|-
| 0x44 || 0x4 || arg2 (1 when arg1 in [4, 6, 12]; 2 when arg1 in [14]; otherwise undefined)
+
| 0x44 || 0x4 || Input: keyset_rev (1 when keyset in [4, 6, 12]; 2 when keyset in [14]; otherwise undefined)
 
|-
 
|-
| 0x48 || 0x28 || input and output
+
| 0x48 || 0x28 || Input and output: Ernie secure packet
 
|}
 
|}
    
=== 0x7 - check_result ===
 
=== 0x7 - check_result ===
   −
Input: 0x30 bytes buffer.
+
Returns 0 on success.
   −
Returns 0 on success, doesn't modify the input buffer.
+
Data size is 0x30 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1 (6 or 14)
+
| 0x40 || 0x4 || Input: keyset (4, 6, 14)
 
|-
 
|-
| 0x44 || 0x4 || arg2 (1 when arg1 in [4, 6, 12]; 2 when arg in [14]; otherwise undefined)
+
| 0x44 || 0x4 || Input: keyset_rev (1 when keyset in [4, 6, 12]; 2 when keyset in [14]; otherwise undefined)
 
|-
 
|-
| 0x48 || 0x28 || input only
+
| 0x48 || 0x28 || Input: Ernie secure packet
 
|}
 
|}
   −
=== 0x8 ===
+
=== 0x8 - run_pm_command ===
   −
Used on 1.03+ by sceSblPmMgrGetProductModeFromNVS.
+
Not present in old FWs.
   −
Input: 0x70 bytes buffer.
+
Used on FW 1.03+ by sceSblPmMgrGetProductModeFromNVS.
 +
 
 +
Data size is 0x70 bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || new product mode
+
| 0x40 || 0x4 || Input: Command (0: gen_get_mgmt_data_req, 1: get_mgmt_data, 3: decrypt_response, 4: set_product_mode, 5: set_product_mode_off, 7: set_sd_mode_off)
 +
|-
 +
| 0x44 || 0x4 || Reserved
 
|-
 
|-
| 0x44 || 0x4 || 0
+
| 0x48 || 0x4 || Input and output: product mode
 
|-
 
|-
| 0x48 || 0x4 || out1: current product mode
+
| 0x4C || 0x4 || Input and output: unknown Mgmt Data
 
|-
 
|-
| 0x4C || 0x4 || out2
+
| 0x50 || 0x30 || Input and output: Ernie secure packet for setting Product Mode
 
|-
 
|-
| 0x50 || 0x60 || unk
+
| 0x80 || 0x30 || Input and output: Ernie secure packet for getting Product mode
 
|}
 
|}
    
=== 0x9 - gen_jig_message ===
 
=== 0x9 - gen_jig_message ===
   −
Only on 1.03+.
+
Only on FW 1.03+.
   −
Input: 0x10C bytes buffer.
+
Data size is 0x10C bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1: flag.
+
| 0x40 || 0x4 || Input: keyset_flag (0x48 for keyset 4, 0x49 for keyset 12)
 
|-
 
|-
| 0x44 || 0x4 || arg2
+
| 0x44 || 0x4 || Reserved
 
|-
 
|-
| 0x48 || 0x104 || output
+
| 0x48 || 0x104 || Output: jig_message
 
|}
 
|}
    
=== 0xA - check_jig_response ===
 
=== 0xA - check_jig_response ===
   −
Only on 1.03+.
+
Only on FW 1.03+.
   −
Input: 0x10C bytes buffer.
+
Returns 0 on success.
 +
 
 +
Data size is 0x10C bytes.
    
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || arg1: flag.
+
| 0x40 || 0x4 || Input: keyset_flag (0x48 for keyset 4, 0x49 for keyset 12)
 
|-
 
|-
| 0x44 || 0x4 || arg2
+
| 0x44 || 0x4 || Reserved
 
|-
 
|-
| 0x48 || 0x104 || input
+
| 0x48 || 0x104 || Input: jig_response
 
|}
 
|}
   Line 1,336: Line 1,409:  
Decrypt or check QAF Token. Used on 1.03 PDEL.
 
Decrypt or check QAF Token. Used on 1.03 PDEL.
   −
=== 0x1 ===
+
=== 0x1 - Some syscon secure packet stuff ===
   −
=== 0x2 ===
+
=== 0x2 - Some syscon secure packet stuff ===
    
=== 0x3 ===
 
=== 0x3 ===
Line 1,446: Line 1,519:  
== update_service_sm.self ==
 
== update_service_sm.self ==
   −
This is used by [[SceSblUpdateMgr]] to decrypt update packages extracted from [[PUP]] files. Both 0x40002 and 0x50002 reference buffers in the following way: an inner paddr list is generated for the buffer containing the data to encrypt/decrypt, then an outer paddr list is generated for the inner list. That means there's two levels of indirection in the paddr list.
+
This is used by [[SceSblUpdateMgr]] to decrypt update packages extracted from [[PUP]] files.
 +
 
 +
<s>Both 0x40002 and 0x50002 reference buffers in the following way: an inner physical address list is generated for the buffer containing the data to encrypt/decrypt, then an outer physical address list is generated for the inner list. That means there's two levels of indirection in the physical address list.</s>
 +
 
 +
Services with PA Vectors to pass data to cmep decide whether to use normal vectors or deep vectors depending on the flag of the argument.
    
=== 0x10002 - sceSblUsSmAuthPupHeader ===
 
=== 0x10002 - sceSblUsSmAuthPupHeader ===
Line 1,452: Line 1,529:  
SCE_SBL_SM_COMM_FID_SM_AUTH_PUP_HEADER.
 
SCE_SBL_SM_COMM_FID_SM_AUTH_PUP_HEADER.
   −
Verify PUP header.
+
Verify PUP header (with hash check).
   −
Input data size: 0xFF0.
+
Input data size: 0xFC0.
   −
Input: PA vector of the PUP header including the PUP Hash (size: 0x80 + segment_num * 0x60 + 0x20)
+
Input: PA vector of the PUP header including the PUP Hash (size: 0x80 + segment_num * 0x20 + segment_num * 0x40 + 0x20)
    
=== 0x20002 - sceSblUsSmAuthPupSegment ===
 
=== 0x20002 - sceSblUsSmAuthPupSegment ===
Line 1,464: Line 1,541:  
Verify PUP segment.
 
Verify PUP segment.
   −
Input data size: 0xFF0.
+
Input data size: 0xFC0.
    
=== 0x30002 - sceSblUsSmAuthPupWatermark ===
 
=== 0x30002 - sceSblUsSmAuthPupWatermark ===
Line 1,472: Line 1,549:  
Verify PUP watermark.
 
Verify PUP watermark.
   −
Input data size: 0xFF0.
+
Input data size: 0xFC0.
   −
Input data: a packet embedding at least two paddr (or PA vectors): PUP Watermark (0x1000 bytes) and PUP Hash (0x20 bytes).
+
Input data: a packet embedding at least two physical addresses (or PA vectors): PUP Watermark (0x1000 bytes) and PUP Hash (0x20 bytes).
    
=== 0x40002 - sceSblUsSmAuthSpkg ===
 
=== 0x40002 - sceSblUsSmAuthSpkg ===
Line 1,490: Line 1,567:  
| 0x48 || 0x8 || Set to 0x1
 
| 0x48 || 0x8 || Set to 0x1
 
|-
 
|-
| 0x50 || 0x14 || <code>struct paddr_list_req</code> for Paddr list below
+
| 0x50 || 0x14 || <code>struct paddr_list_req</code> for physical address list below
 
|-
 
|-
 
| 0x64 || 0x14 || <code>struct paddr_list_req</code> for pkg buffer
 
| 0x64 || 0x14 || <code>struct paddr_list_req</code> for pkg buffer
 
|-
 
|-
| 0x78 || Variable (max 0xF88(0x1F1 entry)) || Copy of paddr list for pkg buffer (contents described at 0x50)
+
| 0x78 || Variable (max 0xF88(0x1F1 entry)) || Copy of physical address list for pkg buffer (contents described at 0x50)
 
|}
 
|}
   Line 1,511: Line 1,588:  
| 0x48 || 0x8 || Set to 1
 
| 0x48 || 0x8 || Set to 1
 
|-
 
|-
| 0x50 || 0x14 || <code>struct paddr_list_req</code> for paddr list copied to 0x78. Only count field is used.
+
| 0x50 || 0x14 || <code>struct paddr_list_req</code> for physical address list copied to 0x78. Only count field is used.
 
|-
 
|-
| 0x64 || 0x14 || <code>struct paddr_list_req</code> for inner paddr list. Not used.
+
| 0x64 || 0x14 || <code>struct paddr_list_req</code> for inner physical address list. Not used.
 
|-
 
|-
| 0x78 || Variable (max 0xF88(0x1F1 entry)) || outer paddr list / paddr list to paddr list to encrypt
+
| 0x78 || Variable (max 0xF88(0x1F1 entry)) || outer physical address list / physical address list to physical address list to encrypt
 
|}
 
|}
   −
Each inner paddr list is first copied to temporary f00d memory, then they all are checked for validity at once. Maximum size of inner list is 0xff7 (so probably 0xff7 / 8 * 8 = 0xff0). Any lengths higher than that result in <code>SCE_SBL_ERROR_SL_ENOMEM = 0x800f020c</code>.
+
Each inner physical address list is first copied to temporary cmep memory, then they all are checked for validity at once. Maximum size of inner list is 0xff7 (so probably 0xff7 / 8 * 8 = 0xff0). Any lengths higher than that result in <code>SCE_SBL_ERROR_SL_ENOMEM = 0x800f020c</code>.
    
How it works:
 
How it works:
Line 1,524: Line 1,601:  
* first, all inner entries are checked for validity, if something's invalid, bail out <code>SCE_SBL_ERROR_SL_EINVAL 0x800f0216</code>
 
* first, all inner entries are checked for validity, if something's invalid, bail out <code>SCE_SBL_ERROR_SL_EINVAL 0x800f0216</code>
 
* start at last outer entry and move towards the first
 
* start at last outer entry and move towards the first
* if current entry looks valid (length >= 8), proceed to inner paddr encryption
+
* if current entry looks valid (length >= 8), proceed to inner physical address encryption
 
* if no valid entries found, error=<code>SCE_SBL_ERROR_SL_EINVAL 0x800f0216</code>
 
* if no valid entries found, error=<code>SCE_SBL_ERROR_SL_EINVAL 0x800f0216</code>
 
* if multiple valid entries found, error=<code>SCE_SBL_ERROR_SL_EIO 0x800f0205</code> (???) (but the first one found is always encrypted)
 
* if multiple valid entries found, error=<code>SCE_SBL_ERROR_SL_EIO 0x800f0205</code> (???) (but the first one found is always encrypted)
Line 1,531: Line 1,608:  
Bugs(?):
 
Bugs(?):
   −
* encrypting same paddr twice or more times within a single inner paddr list always results in same output, no matter what input was, reproducible with length=0x10 or less
+
* encrypting same physical address twice or more times within a single inner physical address list always results in same output, no matter what input was, reproducible with length=0x10 or less
* sum(inner list sizes) must be <= 0xFF0, but there's no overflow check, a large inner list causes f00d to overwrite memory with data like:
+
* sum(inner list sizes) must be <= 0xFF0, but there's no overflow check, a large inner list causes cmep to overwrite memory with data like:
 
<pre>
 
<pre>
00:00:26 0 // this is paddr 0x1F000000
+
00:00:26 0 // this is physical address 0x1F000000
 
00:00:26 0
 
00:00:26 0
 
00:00:26 0
 
00:00:26 0
Line 1,541: Line 1,618:  
00:00:26 812d40
 
00:00:26 812d40
 
00:00:26 0
 
00:00:26 0
00:00:26 1f000020 // this is paddr 0x1F00001C
+
00:00:26 1f000020 // this is physical address 0x1F00001C
 
00:00:26 0
 
00:00:26 0
 
00:00:26 0
 
00:00:26 0
Line 1,574: Line 1,651:  
The input is plain SNVS sectors read from NVS.
 
The input is plain SNVS sectors read from NVS.
   −
Calculates a XTS Encrypt using the per console keys in keyring slot 0x502, and 0x503 for the tweak and decryption keys. Appears to be intended for up to 0x3E0 bytes in size, but the size in F00D packet +4 derives the XTS size and memcpy.
+
Calculates a XTS Encrypt using the per console keys in keyring slot 0x502, and 0x503 for the tweak and decryption keys. Appears to be intended for up to 0x3E0 bytes in size, but the size in cmep packet +4 derives the XTS size and memcpy.
    
The result is XTS encrypted SNVS sectors.
 
The result is XTS encrypted SNVS sectors.
Line 1,594: Line 1,671:  
The input is XTS encrypted sectors.
 
The input is XTS encrypted sectors.
   −
Calculates a XTS Decrypt using the per console keys in keyring slot 0x502, and 0x503 for the tweak and decryption keys. Appears to be intended for up to 0x3E0 in size, but the size in F00D packet +4 derives the XTS size and memcpy.
+
Calculates a XTS Decrypt using the per console keys in keyring slot 0x502, and 0x503 for the tweak and decryption keys. Appears to be intended for up to 0x3E0 in size, but the size in cmep packet +4 derives the XTS size and memcpy.
    
The result is plain sectors.
 
The result is plain sectors.
Line 1,687: Line 1,764:     
Usage:
 
Usage:
* 1) sceSblSmCommCallFunc(id, 0xB0002, &f00d_resp, data, 0x88);
+
* 1) sceSblSmCommCallFunc(id, 0xB0002, &cmep_resp, data, 0x88);
 
For read:
 
For read:
 
* 2) nvs_read_special(data + 0x28, 0x10, data + 0x58, 0x30)
 
* 2) nvs_read_special(data + 0x28, 0x10, data + 0x58, 0x30)
 
For write:
 
For write:
 
* 2) nvs_write_special(data + 0x28, 0x30, data + 0x58, 0x10);
 
* 2) nvs_write_special(data + 0x28, 0x30, data + 0x58, 0x10);
* 3) sceSblSmCommCallFunc(id, 0xB0002, &f00d_resp, data, 0x88);
+
* 3) sceSblSmCommCallFunc(id, 0xB0002, &cmep_resp, data, 0x88);
    
=== 0xC0002 - sceSblUsSmSnvsEncryptDecryptMgmtData ===
 
=== 0xC0002 - sceSblUsSmSnvsEncryptDecryptMgmtData ===
Line 1,712: Line 1,789:     
Usage:
 
Usage:
* 1) sceSblSmCommCallFunc(id, 0xC0002, &f00d_resp, data, 0x70);
+
* 1) sceSblSmCommCallFunc(id, 0xC0002, &cmep_resp, data, 0x70);
 
For write:
 
For write:
 
* 2) nvs_write_special(data + 0x10, 0x30, data + 0x40, 0x10);
 
* 2) nvs_write_special(data + 0x10, 0x30, data + 0x40, 0x10);
 
For read:
 
For read:
 
* 2) nvs_read_special(data + 0x10, 0x10, data + 0x40, 0x30);
 
* 2) nvs_read_special(data + 0x10, 0x10, data + 0x40, 0x30);
* 3) sceSblSmCommCallFunc(id, 0xC0002, &f00d_resp, data, 0x70);
+
* 3) sceSblSmCommCallFunc(id, 0xC0002, &cmep_resp, data, 0x70);
    
=== 0xD0002 ===
 
=== 0xD0002 ===
   −
Syscon update related. Usage is to proxy encrypted data F00D <=> Syscon.
+
Syscon update related. Usage is to proxy encrypted data Cmep <=> Syscon.
    
Data size is 0x58 bytes.
 
Data size is 0x58 bytes.
Line 1,735: Line 1,812:     
Usage:
 
Usage:
* 1) sceSblSmCommCallFunc(id, 0xD0002, &f00d_resp, data, 0x58);
+
* 1) sceSblSmCommCallFunc(id, 0xD0002, &cmep_resp, data, 0x58);
 
For modes 0, 1 and 3:
 
For modes 0, 1 and 3:
 
* 2) memcpy(data + 8, data + 0x30, 0x28); SceSysconForDriver_4D03754A(data + 8, 0x28, data + 0x30, 0x28);
 
* 2) memcpy(data + 8, data + 0x30, 0x28); SceSysconForDriver_4D03754A(data + 8, 0x28, data + 0x30, 0x28);
* 3) sceSblSmCommCallFunc(id, 0xD0002, &f00d_resp, data, 0x58);
+
* 3) sceSblSmCommCallFunc(id, 0xD0002, &cmep_resp, data, 0x58);
 +
 
 +
 
 +
Mode
 +
 
 +
0 - Do init 0x28 buffer.
 +
 
 +
1 - Do bigmac unknown crypto with some blob.
 +
 
 +
2 - Do bigmac unknown crypto with some blob.
 +
 
 +
3 - Do bigmac unknown crypto with some blob.
 +
 
 +
4 - Do some working. And reset syscon ticket count with Bigmac PRNG (Keyslot 0x512).
    
== utoken_sm.self ==
 
== utoken_sm.self ==
Line 1,749: Line 1,839:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Paddr of [[SceSblPostSsMgr#Types|SceUtoken]] buffer
+
| 0x40 || 0x4 || Physical address of [[SceSblPostSsMgr#Types|SceUtoken]] buffer
 
|-
 
|-
 
| 0x44 || 0x4 || Size of [[SceSblPostSsMgr#Types|SceUtoken]] buffer (usually 0x800)
 
| 0x44 || 0x4 || Size of [[SceSblPostSsMgr#Types|SceUtoken]] buffer (usually 0x800)
Line 1,765: Line 1,855:  
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x40 || 0x4 || Paddr of [[SceSblPostSsMgr#Types|SceUtoken]] buffer
+
| 0x40 || 0x4 || Physical address of [[SceSblPostSsMgr#Types|SceUtoken]] buffer
 
|-
 
|-
 
| 0x44 || 0x4 || Size of [[SceSblPostSsMgr#Types|SceUtoken]] buffer (usually 0x800)
 
| 0x44 || 0x4 || Size of [[SceSblPostSsMgr#Types|SceUtoken]] buffer (usually 0x800)
Line 1,778: Line 1,868:  
Magic Gate Key Manager secure module.
 
Magic Gate Key Manager secure module.
    +
Present on 0.931-3.73. Commands are almost the same on any FW, only KEY_31 varies.
 +
0
 
These commands are used to set keys (as seen on FWs from 0.940 to 3.60) to [[Dmac5|DMAC5]] registers in NS memory. These keys are used in to do encryption stuff with AES-ECB and TripleDES-ECB algorithms through [[Dmac5|DMAC5]].
 
These commands are used to set keys (as seen on FWs from 0.940 to 3.60) to [[Dmac5|DMAC5]] registers in NS memory. These keys are used in to do encryption stuff with AES-ECB and TripleDES-ECB algorithms through [[Dmac5|DMAC5]].
   Line 1,798: Line 1,890:  
<source lang="C">
 
<source lang="C">
 
memset(buffer, 0, 0x20);
 
memset(buffer, 0, 0x20);
memcpy(buffer, KEY_1, 0x10);
+
memcpy(buffer, KEY_31, 0x10);
 
bigmac_memcpy(0xE04E0000 + 0x1F * 0x20, buffer, 0x20);
 
bigmac_memcpy(0xE04E0000 + 0x1F * 0x20, buffer, 0x20);
 
</source>
 
</source>
Line 1,807: Line 1,899:  
memset(buffer, 0, 0x20);
 
memset(buffer, 0, 0x20);
 
memcpy(buffer, pOpenPsId, 0x10);
 
memcpy(buffer, pOpenPsId, 0x10);
memcpy(buffer + 0x10, KEY_2, 0x10);
+
memcpy(buffer + 0x10, KEY_30_SEED, 0x10);
 
bigmac_sha256(buffer, buffer, 0x20);
 
bigmac_sha256(buffer, buffer, 0x20);
 
bigmac_memcpy(0xE04E0000 + 0x1E * 0x20, buffer, 0x20);
 
bigmac_memcpy(0xE04E0000 + 0x1E * 0x20, buffer, 0x20);
6,295

edits

Navigation menu