Compare commits

...

3 Commits

Author SHA1 Message Date
brent saner
a369b9b5b7 fix rsa v1 plain example 2025-09-02 21:33:25 -04:00
brent saner
84838ce0c6 clean up the CRT notes 2025-09-02 00:23:38 -04:00
brent saner
ce2081c811 provide full name for Chinese Remainder Theorem 2025-09-01 23:58:23 -04:00
3 changed files with 32 additions and 24 deletions

View File

@@ -6,3 +6,4 @@ set -e
cd "${PWD}/_ref" cd "${PWD}/_ref"
asciidoctor -o ./KEY_GUIDE.html ./KEY_GUIDE.adoc asciidoctor -o ./KEY_GUIDE.html ./KEY_GUIDE.adoc
git add KEY_GUIDE.html git add KEY_GUIDE.html
echo "Generated KEY_GUIDE.html"

View File

@@ -635,7 +635,7 @@ pre.rouge .gs {
<h1>OpenSSH Key Structure Guide</h1> <h1>OpenSSH Key Structure Guide</h1>
<div class="details"> <div class="details">
<span id="author" class="author">brent saner &lt;bts@square-r00t.net&gt;, https://r00t2.io</span><br> <span id="author" class="author">brent saner &lt;bts@square-r00t.net&gt;, https://r00t2.io</span><br>
<span id="revdate">Last updated 2025-09-01 13:47:06 -0400</span> <span id="revdate">Last updated 2025-09-02 21:33:25 -0400</span>
</div> </div>
<div id="toc" class="toc2"> <div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div> <div id="toctitle">Table of Contents</div>
@@ -1264,7 +1264,7 @@ ftSfkGNUzTzPFbF5iEukTvKm42a7F/I/ExMVgpN/eQxJ7+m5TOgja0KC1h5fCN4L
4.0.1.5 uint32 allocator for 4.0.1.5.0 (4 bytes) 4.0.1.5 uint32 allocator for 4.0.1.5.0 (4 bytes)
4.0.1.5.0 private exponent ('d') 4.0.1.5.0 private exponent ('d')
4.0.1.6 uint32 allocator for 4.0.1.6.0 (4 bytes) 4.0.1.6 uint32 allocator for 4.0.1.6.0 (4 bytes)
4.0.1.6.0 CRT helper value ('q^(-1) % p') 4.0.1.6.0 CRT
4.0.1.7 uint32 allocator for 4.0.1.7.0 (4 bytes) 4.0.1.7 uint32 allocator for 4.0.1.7.0 (4 bytes)
4.0.1.7.0 prime #1 ('p') 4.0.1.7.0 prime #1 ('p')
4.0.1.8 uint32 allocator for 4.0.1.8.0 (4 bytes) 4.0.1.8 uint32 allocator for 4.0.1.8.0 (4 bytes)
@@ -1289,9 +1289,16 @@ ftSfkGNUzTzPFbF5iEukTvKm42a7F/I/ExMVgpN/eQxJ7+m5TOgja0KC1h5fCN4L
<p><strong>Chunk 4.0:</strong> This is technically currently unused; upstream hardcodes to 1 (left zero-padded 0x01).</p> <p><strong>Chunk 4.0:</strong> This is technically currently unused; upstream hardcodes to 1 (left zero-padded 0x01).</p>
</div> </div>
<div class="paragraph"> <div class="paragraph">
<p><strong>Chunk 4.0.0.1.0, 4.0.1.4.0:</strong> This is almost always <code>65537</code> for a couple reasons. It&#8217;s the <a href="https://en.wikipedia.org/wiki/Fermat_number" target="_blank" rel="noopener">"Fermat Prime"</a> <em>F<sub>4</sub></em>.</p>
</div>
<div class="paragraph">
<p><strong>Chunk 4.0.0.1.0, 4.0.0.2.0, 4.0.1.3.0, 4.0.1.4.0:</strong> Note that the ordering of <code>e</code>/<code>n</code> in <strong>4.0.0</strong> is changed to <code>n</code>/<code>e</code> in <strong>4.0.1</strong>.</p> <p><strong>Chunk 4.0.0.1.0, 4.0.0.2.0, 4.0.1.3.0, 4.0.1.4.0:</strong> Note that the ordering of <code>e</code>/<code>n</code> in <strong>4.0.0</strong> is changed to <code>n</code>/<code>e</code> in <strong>4.0.1</strong>.</p>
</div> </div>
<div class="paragraph"> <div class="paragraph">
<p><strong>Chunk 4.0.1.6.0:</strong> The CRT coefficient, or <a href="https://en.wikipedia.org/wiki/Chinese_remainder_theorem" target="_blank" rel="noopener">Chinese Remainder Theorem</a>, is a helper used during decryption and signing. It&#8217;s commonly referred to as <code>qnlv</code> or <em>inverse coefficient</em>.
The value for this chunk is the result of <code>q^(-1) % p</code>.</p>
</div>
<div class="paragraph">
<p><strong>Chunk 4.0.1.10:</strong> The padding used aligns the private key (<strong>4.0.1.0</strong> to <strong>4.0.1.9.0</strong>) to the cipher blocksize. For plaintext keys, a blocksize of 8 is used.</p> <p><strong>Chunk 4.0.1.10:</strong> The padding used aligns the private key (<strong>4.0.1.0</strong> to <strong>4.0.1.9.0</strong>) to the cipher blocksize. For plaintext keys, a blocksize of 8 is used.</p>
</div> </div>
</td> </td>
@@ -1301,9 +1308,6 @@ ftSfkGNUzTzPFbF5iEukTvKm42a7F/I/ExMVgpN/eQxJ7+m5TOgja0KC1h5fCN4L
</div> </div>
<div class="sect5"> <div class="sect5">
<h6 id="bkdn_rsa_priv_v1_plain_ex"><a class="link" href="#bkdn_rsa_priv_v1_plain_ex">3.1.2.3.2. Example</a></h6> <h6 id="bkdn_rsa_priv_v1_plain_ex"><a class="link" href="#bkdn_rsa_priv_v1_plain_ex">3.1.2.3.2. Example</a></h6>
<div class="paragraph">
<p>The following example, being encrypted, is protected with a passphrase. The passphrase used in this example key is <strong><code>test</code></strong>.</p>
</div>
<div class="listingblock"> <div class="listingblock">
<div class="title"><code>id_rsa</code> Format</div> <div class="title"><code>id_rsa</code> Format</div>
<div class="content"> <div class="content">
@@ -1368,7 +1372,7 @@ CnIIHn+l1HLBQosH6uXRW2TqHip1CFEv6atlX4ajE0htPMod2OkKzFyfuk1udnUH+6ufOn
oAiRAxnBFtR72SSzmUJUO4ig9hJ5UrLY4SkPMCn1Qq6+nAyONs8yloZc1mQ8iSTVZuv0lx oAiRAxnBFtR72SSzmUJUO4ig9hJ5UrLY4SkPMCn1Qq6+nAyONs8yloZc1mQ8iSTVZuv0lx
gJOZoawJb+Htw7X4cb9e8LTUTg6idiDSBRQuC/z2d7TbAlUyEho/B0WqTQWGMxczJXhVpc gJOZoawJb+Htw7X4cb9e8LTUTg6idiDSBRQuC/z2d7TbAlUyEho/B0WqTQWGMxczJXhVpc
7L46xEA9BP8MwMWLfASQS0AhJcK8KmOiDrswnMbz5l2zAaBYuNrOB+cbOPPzWVQz9psZjw 7L46xEA9BP8MwMWLfASQS0AhJcK8KmOiDrswnMbz5l2zAaBYuNrOB+cbOPPzWVQz9psZjw
cAAAdQU4NHElODRxIAAAAHc3NoLXJzYQAAAgEAt87ARgHOKhLwySTLmjDrmQBmgSyxQ2kZ cAAAdQobGx2KGxsdgAAAAHc3NoLXJzYQAAAgEAt87ARgHOKhLwySTLmjDrmQBmgSyxQ2kZ
PzCyuf3Ur8swDJGPKnfWRBDzYXrnyMoxjCV9PE304sQQi7vpOoaJS6FLNXXy9yFQvDgdy/ PzCyuf3Ur8swDJGPKnfWRBDzYXrnyMoxjCV9PE304sQQi7vpOoaJS6FLNXXy9yFQvDgdy/
t0LHoZaGb9MYSs6WdhrdoPwpkvbIZtdWmRn8ItnEvw3kBajHbVGaoqUyncaCV3ciml0LdT t0LHoZaGb9MYSs6WdhrdoPwpkvbIZtdWmRn8ItnEvw3kBajHbVGaoqUyncaCV3ciml0LdT
p4JaiblSdfnAJeIVNDxsiM1mkKIh+K6e9nXuRk3H0RjaQQUH6l1rZIndYK/YpmRkkts+J5 p4JaiblSdfnAJeIVNDxsiM1mkKIh+K6e9nXuRk3H0RjaQQUH6l1rZIndYK/YpmRkkts+J5
@@ -1516,10 +1520,10 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
103 103
104 104
</pre></td><td class="code"><pre>0.0 6f70656e7373682d6b65792d763100 ("openssh-key-v1" + 0x00) </pre></td><td class="code"><pre>0.0 6f70656e7373682d6b65792d763100 ("openssh-key-v1" + 0x00)
1.0 0000000a (10) 1.0 00000004 (4)
1.0.0 6165733235362d637472 ("none") 1.0.0 6e6f6e65 ("none")
2.0 00000006 (6) 2.0 00000004 (4)
2.0.0 626372797074 ("none") 2.0.0 6e6f6e65 ("none")
3.0 00000000 (0) 3.0 00000000 (0)
4.0 00000001 (1) 4.0 00000001 (1)
4.0.0 00000217 (535) 4.0.0 00000217 (535)
@@ -1546,8 +1550,8 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
bc2a63a20ebb309cc6f3e65db301a058b8dace07e71b38f3f3595433f69b198f bc2a63a20ebb309cc6f3e65db301a058b8dace07e71b38f3f3595433f69b198f
07 (bytes) 07 (bytes)
4.0.1 00000750 (1872) 4.0.1 00000750 (1872)
4.0.1.0 53834712 (1401112338) 4.0.1.0 a1b1b1d8 (2712777176)
4.0.1.1 53834712 (1401112338) 4.0.1.1 a1b1b1d8 (2712777176)
4.0.1.2 00000007 (7) 4.0.1.2 00000007 (7)
4.0.1.2.0 7373682d727361 ("ssh-rsa") 4.0.1.2.0 7373682d727361 ("ssh-rsa")
4.0.1.3 00000201 (513) 4.0.1.3 00000201 (513)
@@ -1597,7 +1601,7 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
2a52312abee4c6155acfee9384a16348c715346ebe693895fe6d2348d4dedb0a 2a52312abee4c6155acfee9384a16348c715346ebe693895fe6d2348d4dedb0a
137c487185ff949c209115b9c8a106329991f049e8430c7ba60dd5408d72ac98 (bytes) 137c487185ff949c209115b9c8a106329991f049e8430c7ba60dd5408d72ac98 (bytes)
4.0.1.7 00000101 (257) 4.0.1.7 00000101 (257)
4.0.1.7.0 00e50b65ba6ae4cb29ae66129c3e41ffeba36cd6ecbaa7045ff90cea71d09bc0 00e50b65ba6ae4cb29ae66129c3e41ffeba36cd6ecbaa7045ff90cea71d09bc0
56b0b9134dc5754c49da1fe8ab169cd149eedaeccf4913d915f4f241c5fd86c7 56b0b9134dc5754c49da1fe8ab169cd149eedaeccf4913d915f4f241c5fd86c7
7511e0c261c344600a84cce78e8cf493e492844cb82c42ab6d1246a53e5cf50a 7511e0c261c344600a84cce78e8cf493e492844cb82c42ab6d1246a53e5cf50a
d4759c2a5c09d53b1c5c3b449328eea01434d6e537b3a513928dfaddf0a72728 d4759c2a5c09d53b1c5c3b449328eea01434d6e537b3a513928dfaddf0a72728

View File

@@ -43,7 +43,7 @@ Since plaintext/unencrypted keys do not have a cipher or KDF (as there's no encr
4.0.1.5 uint32 allocator for 4.0.1.5.0 (4 bytes) 4.0.1.5 uint32 allocator for 4.0.1.5.0 (4 bytes)
4.0.1.5.0 private exponent ('d') 4.0.1.5.0 private exponent ('d')
4.0.1.6 uint32 allocator for 4.0.1.6.0 (4 bytes) 4.0.1.6 uint32 allocator for 4.0.1.6.0 (4 bytes)
4.0.1.6.0 CRT helper value ('q^(-1) % p') 4.0.1.6.0 CRT
4.0.1.7 uint32 allocator for 4.0.1.7.0 (4 bytes) 4.0.1.7 uint32 allocator for 4.0.1.7.0 (4 bytes)
4.0.1.7.0 prime #1 ('p') 4.0.1.7.0 prime #1 ('p')
4.0.1.8 uint32 allocator for 4.0.1.8.0 (4 bytes) 4.0.1.8 uint32 allocator for 4.0.1.8.0 (4 bytes)
@@ -59,16 +59,19 @@ Since plaintext/unencrypted keys do not have a cipher or KDF (as there's no encr
*Chunk 4.0:* This is technically currently unused; upstream hardcodes to 1 (left zero-padded 0x01). *Chunk 4.0:* This is technically currently unused; upstream hardcodes to 1 (left zero-padded 0x01).
*Chunk 4.0.0.1.0, 4.0.1.4.0:* This is almost always `65537` for a couple reasons. It's the https://en.wikipedia.org/wiki/Fermat_number["Fermat Prime"^] __F~4~__.
*Chunk 4.0.0.1.0, 4.0.0.2.0, 4.0.1.3.0, 4.0.1.4.0:* Note that the ordering of `e`/`n` in *4.0.0* is changed to `n`/`e` in *4.0.1*. *Chunk 4.0.0.1.0, 4.0.0.2.0, 4.0.1.3.0, 4.0.1.4.0:* Note that the ordering of `e`/`n` in *4.0.0* is changed to `n`/`e` in *4.0.1*.
*Chunk 4.0.1.6.0:* The CRT coefficient, or https://en.wikipedia.org/wiki/Chinese_remainder_theorem[Chinese Remainder Theorem^], is a helper used during decryption and signing. It's commonly referred to as `qnlv` or _inverse coefficient_.
The value for this chunk is the result of `q^(-1) % p`.
*Chunk 4.0.1.10:* The padding used aligns the private key (*4.0.1.0* to *4.0.1.9.0*) to the cipher blocksize. For plaintext keys, a blocksize of 8 is used. *Chunk 4.0.1.10:* The padding used aligns the private key (*4.0.1.0* to *4.0.1.9.0*) to the cipher blocksize. For plaintext keys, a blocksize of 8 is used.
==== ====
[id="bkdn_rsa_priv_v1_plain_ex"] [id="bkdn_rsa_priv_v1_plain_ex"]
====== Example ====== Example
The following example, being encrypted, is protected with a passphrase. The passphrase used in this example key is *`test`*.
.`id_rsa` Format .`id_rsa` Format
[source,text,linenums] [source,text,linenums]
---- ----
@@ -84,7 +87,7 @@ CnIIHn+l1HLBQosH6uXRW2TqHip1CFEv6atlX4ajE0htPMod2OkKzFyfuk1udnUH+6ufOn
oAiRAxnBFtR72SSzmUJUO4ig9hJ5UrLY4SkPMCn1Qq6+nAyONs8yloZc1mQ8iSTVZuv0lx oAiRAxnBFtR72SSzmUJUO4ig9hJ5UrLY4SkPMCn1Qq6+nAyONs8yloZc1mQ8iSTVZuv0lx
gJOZoawJb+Htw7X4cb9e8LTUTg6idiDSBRQuC/z2d7TbAlUyEho/B0WqTQWGMxczJXhVpc gJOZoawJb+Htw7X4cb9e8LTUTg6idiDSBRQuC/z2d7TbAlUyEho/B0WqTQWGMxczJXhVpc
7L46xEA9BP8MwMWLfASQS0AhJcK8KmOiDrswnMbz5l2zAaBYuNrOB+cbOPPzWVQz9psZjw 7L46xEA9BP8MwMWLfASQS0AhJcK8KmOiDrswnMbz5l2zAaBYuNrOB+cbOPPzWVQz9psZjw
cAAAdQU4NHElODRxIAAAAHc3NoLXJzYQAAAgEAt87ARgHOKhLwySTLmjDrmQBmgSyxQ2kZ cAAAdQobGx2KGxsdgAAAAHc3NoLXJzYQAAAgEAt87ARgHOKhLwySTLmjDrmQBmgSyxQ2kZ
PzCyuf3Ur8swDJGPKnfWRBDzYXrnyMoxjCV9PE304sQQi7vpOoaJS6FLNXXy9yFQvDgdy/ PzCyuf3Ur8swDJGPKnfWRBDzYXrnyMoxjCV9PE304sQQi7vpOoaJS6FLNXXy9yFQvDgdy/
t0LHoZaGb9MYSs6WdhrdoPwpkvbIZtdWmRn8ItnEvw3kBajHbVGaoqUyncaCV3ciml0LdT t0LHoZaGb9MYSs6WdhrdoPwpkvbIZtdWmRn8ItnEvw3kBajHbVGaoqUyncaCV3ciml0LdT
p4JaiblSdfnAJeIVNDxsiM1mkKIh+K6e9nXuRk3H0RjaQQUH6l1rZIndYK/YpmRkkts+J5 p4JaiblSdfnAJeIVNDxsiM1mkKIh+K6e9nXuRk3H0RjaQQUH6l1rZIndYK/YpmRkkts+J5
@@ -127,10 +130,10 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
[source,text,linenums] [source,text,linenums]
---- ----
0.0 6f70656e7373682d6b65792d763100 ("openssh-key-v1" + 0x00) 0.0 6f70656e7373682d6b65792d763100 ("openssh-key-v1" + 0x00)
1.0 0000000a (10) 1.0 00000004 (4)
1.0.0 6165733235362d637472 ("none") 1.0.0 6e6f6e65 ("none")
2.0 00000006 (6) 2.0 00000004 (4)
2.0.0 626372797074 ("none") 2.0.0 6e6f6e65 ("none")
3.0 00000000 (0) 3.0 00000000 (0)
4.0 00000001 (1) 4.0 00000001 (1)
4.0.0 00000217 (535) 4.0.0 00000217 (535)
@@ -157,8 +160,8 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
bc2a63a20ebb309cc6f3e65db301a058b8dace07e71b38f3f3595433f69b198f bc2a63a20ebb309cc6f3e65db301a058b8dace07e71b38f3f3595433f69b198f
07 (bytes) 07 (bytes)
4.0.1 00000750 (1872) 4.0.1 00000750 (1872)
4.0.1.0 53834712 (1401112338) 4.0.1.0 a1b1b1d8 (2712777176)
4.0.1.1 53834712 (1401112338) 4.0.1.1 a1b1b1d8 (2712777176)
4.0.1.2 00000007 (7) 4.0.1.2 00000007 (7)
4.0.1.2.0 7373682d727361 ("ssh-rsa") 4.0.1.2.0 7373682d727361 ("ssh-rsa")
4.0.1.3 00000201 (513) 4.0.1.3 00000201 (513)
@@ -208,7 +211,7 @@ hau1VzZBnp8AAAAYVGhpcyBpcyBhIGNvbW1lbnQgc3RyaW5nAQID
2a52312abee4c6155acfee9384a16348c715346ebe693895fe6d2348d4dedb0a 2a52312abee4c6155acfee9384a16348c715346ebe693895fe6d2348d4dedb0a
137c487185ff949c209115b9c8a106329991f049e8430c7ba60dd5408d72ac98 (bytes) 137c487185ff949c209115b9c8a106329991f049e8430c7ba60dd5408d72ac98 (bytes)
4.0.1.7 00000101 (257) 4.0.1.7 00000101 (257)
4.0.1.7.0 00e50b65ba6ae4cb29ae66129c3e41ffeba36cd6ecbaa7045ff90cea71d09bc0 00e50b65ba6ae4cb29ae66129c3e41ffeba36cd6ecbaa7045ff90cea71d09bc0
56b0b9134dc5754c49da1fe8ab169cd149eedaeccf4913d915f4f241c5fd86c7 56b0b9134dc5754c49da1fe8ab169cd149eedaeccf4913d915f4f241c5fd86c7
7511e0c261c344600a84cce78e8cf493e492844cb82c42ab6d1246a53e5cf50a 7511e0c261c344600a84cce78e8cf493e492844cb82c42ab6d1246a53e5cf50a
d4759c2a5c09d53b1c5c3b449328eea01434d6e537b3a513928dfaddf0a72728 d4759c2a5c09d53b1c5c3b449328eea01434d6e537b3a513928dfaddf0a72728