Start keychip proto docs

This commit is contained in:
Bottersnike 2023-02-18 23:11:56 +00:00
parent f0ee40b08c
commit fed0270c34

View File

@ -0,0 +1,441 @@
{% extends "sega.html" %} {% block title %}Ring Keychip{% endblock %} {% block body %}
<h1>Ring Keychip</h1>
<p>
The Ring keychip is arguably simultaniously one of the most overkill while least utilised parts of the system.
On-board is a PIC microcontroller, a dedicated cryptography chip, a hardware SHA engine for authentication, and
flash storage.
</p>
<h2>Protocol</h2>
<p>
The PIC communicates with the system using a parallel bus. This bus is exposed physically on the keychip connector,
and in software can be accessed using <code>\\.\mxparallel</code>. All bus communication is encrypted using AES 128
ECB, using a different key for each data direction. Send/receive is defined from the perspective of the Ring system.
That is, the "Send" key handles data from the Ring to the keychip, and the "Receive" key handles data from the
keychip to the Ring. The initial key values are:
</p>
<h3>Initial receive key:</h3>
<pre><code>75 6f 72 61 74 6e 65 6b 61 6d 69 68 73 75 6b 75</code></pre>
<h3>Initial send key:</h3>
<pre><code>66 6E 65 6B 65 72 61 77 64 72 61 68 61 67 65 73</code></pre>
<p>
All packets are first prefixed by a command ordinal (see below), then command-specific information. The base unit of
transfer is 16 bytes due to AES 128. Unused bytes can contain anything, however mxkeychip chooses to pad using
random bytes derrived from the current system time.
</p>
<h3>Command Ordinals</h3>
<table>
<thead>
<tr>
<td>Ordinal</td>
<td>Command</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0</code></td>
<td>SetKeyS</td>
</tr>
<tr>
<td><code>1</code></td>
<td>SetKeyR</td>
</tr>
<tr>
<td><code>2</code></td>
<td>SetIv</td>
</tr>
<tr>
<td><code>3</code></td>
<td>Decrypt</td>
</tr>
<tr>
<td><code>4</code></td>
<td>Encrypt</td>
</tr>
<tr>
<td><code>5</code></td>
<td>GetAppBootInfo</td>
</tr>
<tr>
<td><code>6</code></td>
<td>EepromWrite</td>
</tr>
<tr>
<td><code>7</code></td>
<td>EepromRead</td>
</tr>
<tr>
<td><code>8</code></td>
<td>NvramWrite</td>
</tr>
<tr>
<td><code>9</code></td>
<td>NvramRead</td>
</tr>
<tr>
<td><code>10</code></td>
<td>AddPlayCount</td>
</tr>
<tr>
<td><code>11</code></td>
<td>FlashRead</td>
</tr>
<tr>
<td><code>12</code></td>
<td>FlashErase</td>
</tr>
<tr>
<td><code>13</code></td>
<td></td>
</tr>
<tr>
<td><code>14</code></td>
<td>FlashWrite</td>
</tr>
<tr>
<td><code>15</code></td>
<td></td>
</tr>
<tr>
<td><code>16</code></td>
<td></td>
</tr>
<tr>
<td><code>17</code></td>
<td></td>
</tr>
<tr>
<td><code>18</code></td>
<td></td>
</tr>
<tr>
<td><code>19</code></td>
<td></td>
</tr>
<tr>
<td><code>20</code></td>
<td>KcGetVersion</td>
</tr>
<tr>
<td><code>21</code></td>
<td>SetMainId</td>
</tr>
<tr>
<td><code>22</code></td>
<td>GetMainId</td>
</tr>
<tr>
<td><code>23</code></td>
<td>SetKeyId</td>
</tr>
<tr>
<td><code>24</code></td>
<td>GetKeyId</td>
</tr>
<tr>
<td><code>25</code></td>
<td>GetPlayCounter</td>
</tr>
</tbody>
</table>
<h3>SetKeyS</h3>
<p>Sets the "send" encryption key. The key is changed before communication of the reply.</p>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>0</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">"send" encryption key</td>
</tr>
</table>
<h4>Response</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>0</td>
<td colspan="15"><i>unused</i></td>
</tr>
</table>
<h3>SetKeyR</h3>
<p>Sets the "receive" encryption key. The key is changed before communication of the reply.</p>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>1</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">"receive" encryption key</td>
</tr>
</table>
<h4>Response</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>1</td>
<td colspan="15"><i>unused</i></td>
</tr>
</table>
<h3>SetIv</h3>
<p>Reset the game key IV to its initial value</p>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>2</td>
<td colspan="15"><i>unused</i></td>
</tr>
</table>
<h4>Response</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>2</td>
<td colspan="15"><i>unused</i></td>
</tr>
</table>
<h3>Decrypt</h3>
<p>Decrypt a block of data using the game key</p>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>3</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">ciphertext to decrypt</td>
</tr>
</table>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>3</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">decrypted plaintext</td>
</tr>
</table>
<h3>Encrypt</h3>
<p>Encrypt a block of data using the game key</p>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>4</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">plaintext to encrypt</td>
</tr>
</table>
<h4>Request</h4>
<table>
<thead>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</thead>
<tr>
<td>4</td>
<td colspan="15"><i>unused</i></td>
</tr>
<tr>
<td colspan="16">encrypted ciphertext</td>
</tr>
</table>
{% endblock %}