title: RSA Public Key format
body: <p>Where can i find some documentation on the format of an RSA public key?</p>
  <p>An RSA public key formatted by <code>OpenSSH</code>:</p>
  <blockquote>
  <p>ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQB/nAmOjTmezNUDKYvEeIRf2YnwM9/uUG1d0BYsc8/tRtx+RGi7N2lUbp728MXGwdnL9od4cItzky/zVdLZE2cycOa18xBK9cOWmcKS0A8FYBxEQWJ/q9YVUgZbFKfYGaGQxsER+A0w/fX8ALuk78ktP31K69LcQgxIsl7rNzxsoOQKJ/CIxOGMMxczYTiEoLvQhapFQMs3FL96didKr/QbrfB1WT6s3838SEaXfgZvLef1YB2xmfhbT9OXFE3FXvh2UPBfN+ffE7iiayQf/2XR+8j4N4bW30DiPtOQLGUrH1y5X/rpNZNlWW2+jGIxqZtgWg7lTy3mXy5x836Sj/6L</p>
  </blockquote>
  <p>The same public key formatted for use in Secure Shell <a href="https://www.rfc-editor.org/rfc/rfc4716" rel="noreferrer">(RFC 4716 - The Secure Shell (SSH) Public Key File Format)</a>:</p>
  <pre><code>---- BEGIN SSH2 PUBLIC KEY ----
  AAAAB3NzaC1yc2EAAAABJQAAAQB/nAmOjTmezNUDKYvEeIRf2YnwM9/uUG1d0BYs
  c8/tRtx+RGi7N2lUbp728MXGwdnL9od4cItzky/zVdLZE2cycOa18xBK9cOWmcKS
  0A8FYBxEQWJ/q9YVUgZbFKfYGaGQxsER+A0w/fX8ALuk78ktP31K69LcQgxIsl7r
  NzxsoOQKJ/CIxOGMMxczYTiEoLvQhapFQMs3FL96didKr/QbrfB1WT6s3838SEaX
  fgZvLef1YB2xmfhbT9OXFE3FXvh2UPBfN+ffE7iiayQf/2XR+8j4N4bW30DiPtOQ
  LGUrH1y5X/rpNZNlWW2+jGIxqZtgWg7lTy3mXy5x836Sj/6L
  ---- END SSH2 PUBLIC KEY ----
  </code></pre>
  <p>The same public key formatted as an RSA public key (note the <em>five</em> <strong><code>-</code></strong>, and no space):</p>
  <pre><code>-----BEGIN RSA PUBLIC KEY-----
  MIIBCgKCAQEA+xGZ/wcz9ugFpP07Nspo6U17l0YhFiFpxxU4pTk3Lifz9R3zsIsu
  ERwta7+fWIfxOo208ett/jhskiVodSEt3QBGh4XBipyWopKwZ93HHaDVZAALi/2A
  +xTBtWdEo7XGUujKDvC2/aZKukfjpOiUI8AhLAfjmlcD/UZ1QPh0mHsglRNCmpCw
  mwSXA9VNmhz+PiB+Dml4WWnKW/VHo2ujTXxq7+efMU4H2fny3Se3KYOsFPFGZ1TN
  QSYlFuShWrHPtiLmUdPoP6CV2mML1tk+l7DIIqXrQhLUKDACeM5roMx0kLhUWB8P
  +0uj1CNlNN4JRZlC7xFfqiMbFRU9Z4N6YwIDAQAB
  -----END RSA PUBLIC KEY-----
  </code></pre>
  <p>The hex dump of the base-64 encoded data:</p>
  <pre><code>00 00 00 07 73 73 68 2d 72 73 61 00 00 00 01 25 00 00 01 00 7f 9c 09
  8e 8d 39 9e cc d5 03 29 8b c4 78 84 5f d9 89 f0 33 df ee 50 6d 5d d0 
  16 2c 73 cf ed 46 dc 7e 44 68 bb 37 69 54 6e 9e f6 f0 c5 c6 c1 d9 cb
  f6 87 78 70 8b 73 93 2f f3 55 d2 d9 13 67 32 70 e6 b5 f3 10 4a f5 c3 
  96 99 c2 92 d0 0f 05 60 1c 44 41 62 7f ab d6 15 52 06 5b 14 a7 d8 19 
  a1 90 c6 c1 11 f8 0d 30 fd f5 fc 00 bb a4 ef c9 2d 3f 7d 4a eb d2 dc 
  42 0c 48 b2 5e eb 37 3c 6c a0 e4 0a 27 f0 88 c4 e1 8c 33 17 33 61 38 
  84 a0 bb d0 85 aa 45 40 cb 37 14 bf 7a 76 27 4a af f4 1b ad f0 75 59 
  3e ac df cd fc 48 46 97 7e 06 6f 2d e7 f5 60 1d b1 99 f8 5b 4f d3 97 
  14 4d c5 5e f8 76 50 f0 5f 37 e7 df 13 b8 a2 6b 24 1f ff 65 d1 fb c8 
  f8 37 86 d6 df 40 e2 3e d3 90 2c 65 2b 1f 5c b9 5f fa e9 35 93 65 59 
  6d be 8c 62 31 a9 9b 60 5a 0e e5 4f 2d e6 5f 2e 71 f3 7e 92 8f fe 8b
  </code></pre>
  <p>i've <a href="http://www.cryptosys.net/pki/rsakeyformats.html" rel="noreferrer">read that there are a couple of formats</a><sup><a href="https://archive.fo/AnIlM" rel="noreferrer"></a></sup>:</p>
  <blockquote>
  <p>Key data may be encoded in three general ways:</p>
  <ul>
  <li>Binary DER-encoded format. This is sometimes called ASN.1 BER-encoded</li>
  <li>PEM or base64 format. This is the same data as the DER-encoded file but it is encoded in base64 with additional header and footer lines</li>
  <li>XML format.</li>
  </ul>
  </blockquote>
  <p>If it's <a href="http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One" rel="noreferrer">ASN.1</a>, the hex certainly doesn't look like it.</p>
  <p>What's the format of an RSA public key?</p>
  <hr />
  <h2>See also</h2>
  <ul>
  <li><a href="http://www.cryptosys.net/pki/rsakeyformats.html" rel="noreferrer">RSA Key Formats</a></li>
  <li><a href="http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One" rel="noreferrer">Abstract Syntax Notation One</a></li>
  <li><a href="http://tools.ailon.org/tools/XmlKey" rel="noreferrer">Convert Base64 Public Key to XML Signature</a> <sup><a href="https://archive.fo/mAYWx" rel="noreferrer"></a></sup></li>
  <li><a href="https://lapo.it/asn1js/" rel="noreferrer">Decode PEM formats</a></li>
  </ul>