Changes

Jump to navigation Jump to search
1,025 bytes added ,  00:39, 25 May 2020
Line 1,763: Line 1,763:  
== mgkm_sm.self ==
 
== mgkm_sm.self ==
   −
MagicGate Key Manager secure module.
+
Magic Gate Key Manager secure module.
These commands seem to be used to set keys (on FW 0.990 and 1.50). There are debug strings referencing these F00D commands as "set_key_command") on [[Dmac5|Dmac5]]. This key seems to be used to do stuff with TripleDES and another unknown encrypt algorithm.
     −
=== 0x1 ===
+
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]].
   −
=== 0x2 ===
+
On FW 0.940, commands 1 and 2 are only called by SceSblMgKeyMgrForDriver_1C5388D0 which consists of:
 +
<source lang="C">
 +
int SceSblMgKeyMgrForDriver_1C5388D0(void *in, void *out) {
 +
  int ret;
 +
  uint8_t tmp_buffer[16];
 +
  ret = call_cmd_1();
 +
  if ((ret == 0) && (ret = call_cmd_2(), ret == 0)) {
 +
    aesECBDec16B(in, tmp_buffer, 0x1E);
 +
    aesECBEnc16B(tmp_buffer, out, 0x1F);
 +
  }
 +
  return ret;
 +
}
 +
</source>
 +
 
 +
=== 0x1 - set_key_1 ===
 +
 
 +
<source lang="C">
 +
memset(buffer, 0, 0x20);
 +
memcpy(buffer, KEY_1, 0x10);
 +
bigmac_memcpy(0xE04E0000 + 0x1F * 0x20, buffer, 0x20);
 +
</source>
 +
 
 +
=== 0x2 - set_key_2 ===
 +
 
 +
<source lang="C">
 +
memset(buffer, 0, 0x20);
 +
memcpy(buffer, openpsid, 0x10);
 +
memcpy(buffer + 0x10, KEY_2, 0x10);
 +
bigmac_sha256(buffer, buffer, 0x20);
 +
bigmac_memcpy(0xE04E0000 + 0x1E * 0x20, buffer, 0x20);
 +
</source>
 +
 
 +
=== 0x3 - unset_key_1 ===
 +
 
 +
<source lang="C">
 +
memset(buffer, 0, 0x20);
 +
bigmac_memcpy(0xE04E0000 + 0x1F * 0x20, buffer, 0x20);
 +
</source>
 +
 
 +
=== 0x4 - unset_key_2 ===
 +
 
 +
<source lang="C">
 +
memset(buffer, 0, 0x20);
 +
bigmac_memcpy(0xE04E0000 + 0x1E * 0x20, buffer, 0x20);
 +
</source>
       
[[Category:Kernel]]
 
[[Category:Kernel]]
5,761

edits

Navigation menu