index.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!doctype html>
  2. <html lang="en-nz">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Locksmith — Astrologue Developer</title>
  7. <meta name="description" content="Locksmith is developer-friendly cryptography for Vala: sodium boxes, X.509, SSH, OpenPGP and WebPush over libsodium, GnuTLS, GPGME and libssh — it implements no cryptography itself. Free software, LGPL-3.0-or-later.">
  8. <meta name="color-scheme" content="light dark">
  9. <meta name="theme-color" content="#f2ebda" media="(prefers-color-scheme: light)">
  10. <meta name="theme-color" content="#0a0a12" media="(prefers-color-scheme: dark)">
  11. <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='27' fill='none' stroke='%23a8801f' stroke-width='4'/%3E%3Cpath d='M32 8l6 18 18 6-18 6-6 18-6-18-18-6 18-6z' fill='%23a8801f'/%3E%3Ccircle cx='32' cy='32' r='4' fill='%23003078'/%3E%3C/svg%3E">
  12. <meta property="og:title" content="Locksmith — Astrologue Developer">
  13. <meta property="og:description" content="Developer-friendly cryptography in objects, not byte arrays: sodium boxes, X.509, SSH, OpenPGP and WebPush over libsodium, GnuTLS, GPGME and libssh.">
  14. <meta property="og:type" content="website">
  15. <link rel="stylesheet" href="../../assets/css/style.css">
  16. </head>
  17. <body>
  18. <a class="skip-link" href="#main">Skip to content</a>
  19. <header class="masthead">
  20. <div class="container masthead__inner">
  21. <a class="brand" href="../../">
  22. <img class="brand__logo brand__logo--light" src="../../assets/img/astrologue-light.png" width="392" height="89" alt="Astrologue">
  23. <img class="brand__logo brand__logo--dark" src="../../assets/img/astrologue-dark.png" width="392" height="89" alt="Astrologue">
  24. </a>
  25. <nav class="site-nav" aria-label="Primary">
  26. <ul class="site-nav__list">
  27. <li><a href="../../">Home</a></li>
  28. <li><a href="../../#news">News</a></li>
  29. <li><a href="../../#download">Download</a></li>
  30. <li><a href="../" aria-current="page">Developer</a></li>
  31. <li><a class="nav-cta" href="../../#download">Get Astrologue</a></li>
  32. </ul>
  33. </nav>
  34. </div>
  35. </header>
  36. <main id="main">
  37. <nav class="breadcrumb" aria-label="Breadcrumb">
  38. <div class="container">
  39. <ol>
  40. <li><a href="../../">Astrologue</a></li>
  41. <li><a href="../">Developer</a></li>
  42. <li aria-current="page">Locksmith</li>
  43. </ol>
  44. </div>
  45. </nav>
  46. <section class="docs-header">
  47. <div class="container">
  48. <p class="kicker"><span>Security · Keys, seals and signatures</span></p>
  49. <h1>Locksmith</h1>
  50. <p class="lede">Developer-friendly cryptography for Vala, in objects rather than byte arrays. It wraps the battle-tested libraries you already have — libsodium, GnuTLS, GPGME and libssh — and implements no cryptography itself.</p>
  51. <dl class="docs-facts">
  52. <div><dt>Version</dt> <dd><code>0.1.0</code></dd></div>
  53. <div><dt>Licence</dt> <dd>LGPL-3.0-or-later</dd></div>
  54. <div><dt>Package</dt> <dd><code>usm&nbsp;install&nbsp;locksmith</code></dd></div>
  55. <div><dt>Language</dt> <dd>Vala</dd></div>
  56. </dl>
  57. </div>
  58. </section>
  59. <section class="band band--plain" id="docs">
  60. <div class="container docs-layout">
  61. <nav class="docs-toc" aria-label="On this page">
  62. <h2>On this page</h2>
  63. <ul>
  64. <li><a href="#overview">Overview</a></li>
  65. <li><a href="#features">Features</a></li>
  66. <li><a href="#installation">Installation</a></li>
  67. <li><a href="#usage">Usage &amp; documentation</a></li>
  68. <li><a href="#package">Package &amp; source</a></li>
  69. </ul>
  70. </nav>
  71. <div class="docs-prose">
  72. <header class="section-head" id="overview">
  73. <p class="kicker"><span>Overview</span></p>
  74. <h2>Why it exists</h2>
  75. </header>
  76. <p>Locksmith is an all-purpose cryptography library for Vala. It wraps the crypto libraries a machine already carries — libsodium, GnuTLS, GPGME and libssh — behind simple, object-oriented APIs, so an application gets secure cryptography without touching a byte array unless it wants to.</p>
  77. <p>The pledge is the design: <strong>Locksmith implements no cryptography itself.</strong> Every primitive comes from those four libraries; Locksmith contributes the object model, the wire formats and the defaults. Nothing new can be wrong in a way its underlying libraries are not, and an audit of the cryptography is an audit of software that has already been audited.</p>
  78. <p>Its wire formats are the ones the rest of the Astrologue stack already uses: Ed25519 attached signatures are <code>signature||message</code> (USM's format), seals use the X25519 ephemeral-header form, and keys are their raw bytes — so <a href="../usm/">USM</a> and <a href="../statum/">Statum</a> signed slots can move onto Locksmith without changing a byte on disk. A compatibility test suite proves both directions by compiling the original hand-rolled bindings alongside this library.</p>
  79. <header class="section-head" id="features">
  80. <p class="kicker"><span>Features</span></p>
  81. <h2>What it hands you</h2>
  82. </header>
  83. <ul class="docs-features">
  84. <li><strong>Signing.</strong> Ed25519 keypairs and public keys; attached (<code>signature||message</code>, the USM wire format) and detached signatures.</li>
  85. <li><strong>Sealing.</strong> X25519 anonymous seals and authenticated two-party boxes.</li>
  86. <li><strong>Symmetric.</strong> Secretbox keys and ciphers; the nonce travels inside the ciphertext, so it cannot be forgotten.</li>
  87. <li><strong>Hashing.</strong> One-call and streaming digests (SHA-1/2/3, SHAKE, MD5, BLAKE2b), HMAC, keyed BLAKE2b, PBKDF2, and argon2id password hashing — the only API pointed at passwords.</li>
  88. <li><strong>Certificates.</strong> X.509 via GnuTLS: RSA/ECDSA/Ed25519 keypairs, DistinguishedNames, certificates, PKCS#10 requests, and Authority objects that issue and verify.</li>
  89. <li><strong>Ssh.</strong> OpenSSH keys via libssh: generate, load <code>id_ed25519</code> files and <code>authorized_keys</code> lines, fingerprints, passphrase-protected saves, and SSHSIG sign/verify that interops with <code>ssh-keygen&nbsp;-Y</code>.</li>
  90. <li><strong>Pgp.</strong> OpenPGP via GPGME: hermetic keyrings, key generation, sign/verify, encrypt/decrypt, import/export, armored output.</li>
  91. <li><strong>WebPush.</strong> RFC 8291 message encryption and RFC 8292 VAPID headers via GnuTLS: browser subscription JSON in, POST-ready body and headers out.</li>
  92. </ul>
  93. <header class="section-head" id="installation">
  94. <p class="kicker"><span>Installation</span></p>
  95. <h2>Getting the library</h2>
  96. </header>
  97. <p>With USM on your machine, one command acquires, builds and installs the library with its header, Vala binding and introspection:</p>
  98. <figure class="code-plate">
  99. <pre><code>usm install locksmith</code></pre>
  100. <figcaption>USM resolves <code>invercargill-1</code> and <code>invercargill-json</code> itself.</figcaption>
  101. </figure>
  102. <p>Building by hand needs the four crypto libraries plus the stack's foundation — on Fedora:</p>
  103. <figure class="code-plate">
  104. <pre><code>sudo dnf install meson ninja-build vala libsodium-devel gnutls-devel \
  105. gpgme-devel libssh-devel libgpg-error-devel json-glib-devel \
  106. invercargill-devel
  107. git clone &lt;the Locksmith repository&gt;
  108. cd Locksmith
  109. meson setup build &amp;&amp; ninja -C build &amp;&amp; meson test -C build</code></pre>
  110. <figcaption>The Fedora line and the build commands are the README's own.</figcaption>
  111. </figure>
  112. <p>Then compile against it with Vala's usual package mechanism:</p>
  113. <figure class="code-plate">
  114. <pre><code>valac --pkg locksmith-1 my-program.vala</code></pre>
  115. <figcaption>The package ships its five internal bindings alongside, so <code>--pkg locksmith-1</code> resolves everything.</figcaption>
  116. </figure>
  117. <header class="section-head" id="usage">
  118. <p class="kicker"><span>Usage &amp; documentation</span></p>
  119. <h2>Quick start, from the README</h2>
  120. </header>
  121. <p>Signing, the way USM signs a package listing — but with objects:</p>
  122. <figure class="code-plate">
  123. <pre><code>var pair = new Locksmith.Signing.KeyPair.generate();
  124. var signed = pair.sign(new ByteBuffer.from_byte_array(listing.data));
  125. var recovered = pair.public_key.verify(signed); // null when invalid</code></pre>
  126. <figcaption>Verbatim from the README's Quickstart. Verification returns null rather than throwing — invalid input is a normal outcome.</figcaption>
  127. </figure>
  128. <p>Sealing (anonymous: only the recipient can open) and symmetric encryption (the nonce travels inside):</p>
  129. <figure class="code-plate">
  130. <pre><code>var recipient = new Locksmith.Sealing.KeyPair.generate();
  131. var sealed = recipient.public_key.seal(message);
  132. var opened = recipient.unseal(sealed);
  133. var key = new Locksmith.Symmetric.Key.generate();
  134. var cipher = new Locksmith.Symmetric.Cipher();
  135. var stored = cipher.encrypt(key, secret);
  136. var back = cipher.decrypt(key, stored); // throws CIPHER when tampered</code></pre>
  137. <figcaption>From the README. Tamper detection is proven by the test suite, not just round-trips.</figcaption>
  138. </figure>
  139. <p>A password is never hashed with a digest — it goes to argon2id, and verification is a method on the same object:</p>
  140. <figure class="code-plate">
  141. <pre><code>var phc = new Locksmith.Hashing.PasswordHash().hash(password);
  142. // verify later: hasher.verify(phc, attempt)</code></pre>
  143. <figcaption>Digested data is labelled integrity-only, never password-safe.</figcaption>
  144. </figure>
  145. <h3>Certificates and SSH keys</h3>
  146. <p>An Authority issues and verifies leaves; an SSH key saves and signs in OpenSSH's own formats:</p>
  147. <figure class="code-plate">
  148. <pre><code>var root = Locksmith.Certificates.Authority.generate(
  149. Locksmith.Certificates.KeyType.ED25519, subject, 3650);
  150. var leaf = root.issue_for_public_key(leaf_subject, server.public_key,
  151. 365, sans);
  152. string reason;
  153. leaf.verify(root.certificate, out reason);
  154. var key = new Locksmith.Ssh.Key.generate(Locksmith.Ssh.KeyType.ED25519,
  155. "me@host");
  156. print("%s\n", key.public_string); // authorized_keys line
  157. var signature = key.sign(file_contents); // SSHSIG</code></pre>
  158. <figcaption>From the README's Quickstart — the SSHSIG output verifies with <code>ssh-keygen -Y</code>.</figcaption>
  159. </figure>
  160. <h3>OpenPGP and WebPush</h3>
  161. <figure class="code-plate">
  162. <pre><code>var ctx = new Locksmith.Pgp.Context.create();
  163. ctx.home_directory = keyring_dir;
  164. var key = ctx.generate_key("Alice &lt;alice@example.org&gt;");
  165. var signed = ctx.sign(document);
  166. var subscription = new Locksmith.WebPush.Subscription.from_json(json);
  167. var vapid = new Locksmith.WebPush.ApplicationServerKeys.generate();
  168. var message = Locksmith.WebPush.encrypt(subscription, payload);
  169. var headers = Locksmith.WebPush.Vapid.headers(vapid,
  170. "https://push.example.net", "mailto:admin@example.org");</code></pre>
  171. <figcaption>A hermetic GPGME keyring for the first; the application-server half of RFC 8291 + 8292 for the second — POST-ready output.</figcaption>
  172. </figure>
  173. <h3>The API philosophy</h3>
  174. <p>Every key, nonce, signature, digest and ciphertext is an <code>Invercargill.BinaryData</code> (concretely <code>ByteBuffer</code>), so <code>to_base64()</code>, <code>to_hex()</code> and equality come free. What a constructor accepts, a method gives back: <code>from_base64</code>/<code>from_hex</code>/<code>from_bytes</code> against <code>to_base64</code>/<code>to_hex</code>/<code>to_der</code>/<code>to_pem</code>. Malformed input throws a <code>Locksmith.Error</code> code; verification — where invalid input is a normal outcome — returns <code>bool</code> or <code>null</code>, so control flow reads like intent.</p>
  175. <p>Runnable versions of every snippet above live in <code>examples/</code> — one standalone program per subsystem (<code>signing_example.vala</code>, <code>sealing_example.vala</code>, <code>symmetric_example.vala</code>, <code>hashing_example.vala</code>, <code>certificates_example.vala</code>, <code>ssh_example.vala</code>, <code>pgp_example.vala</code>, <code>webpush_example.vala</code>), each smoke-tested by <code>meson test</code>. The library suite itself runs round-trips, tamper detection and RFC vectors through both <code>meson test</code> and USM's <code>test</code> exec, so what is documented here is what is exercised.</p>
  176. <header class="section-head" id="package">
  177. <p class="kicker"><span>Package &amp; source</span></p>
  178. <h2>The ledger</h2>
  179. </header>
  180. <dl class="docs-package">
  181. <div><dt>Version</dt><dd><code>0.1.0</code> (from <code>MANIFEST.usm</code>)</dd></div>
  182. <div><dt>Licence</dt><dd>LGPL-3.0-or-later — free to run, study, share and improve; the LGPL keeps it free to link from any program. The <code>vapi/</code> libsodium binding is derived from Billy Barrow's ISC-licensed binding, credited in-file.</dd></div>
  183. <div><dt>Package</dt><dd><code>usm install locksmith</code></dd></div>
  184. <div><dt>Provides</dt><dd><code>liblocksmith-1.so</code>, <code>locksmith.h</code>, <code>locksmith-1.vapi</code> + <code>.deps</code> plus the five internal bindings (<code>libsodium</code>, <code>gnutls-supplement</code>, <code>gnutls-x509</code>, <code>gpgme</code>, <code>libssh</code>) in <code>share/vala/vapi</code>, <code>locksmith-1.gir</code>, <code>locksmith-1.typelib</code>, <code>locksmith-1.pc</code></dd></div>
  185. <div><dt>Needs at runtime</dt><dd>GLib, GObject, GIO, <code>libinvercargill-1.so</code>, <code>libinvercargill-json.so</code>, <code>libsodium.so&nbsp;&gt;=26</code>, <code>libgnutls.so&nbsp;&gt;=30</code>, <code>libgpgme.so&nbsp;&gt;=45</code>, <code>libssh.so&nbsp;&gt;=4</code> and the <code>gpg</code> binary.</dd></div>
  186. <div><dt>Source</dt><dd>The repository <code>clanker/Locksmith</code> on the Astrologue forge (git over ssh, port 222). Free software: the licence guarantees your right to the source.</dd></div>
  187. </dl>
  188. <nav class="docs-siblings" aria-label="Related in the catalogue">
  189. <p>Its neighbours:</p>
  190. <ul>
  191. <li><a href="../statum/">Statum</a></li>
  192. <li><a href="../spry/">Spry</a></li>
  193. <li><a href="../usm/">USM</a></li>
  194. </ul>
  195. </nav>
  196. <nav class="docs-pager" aria-label="Project pages">
  197. <a class="docs-pager__link docs-pager__link--prev" href="../spry/">
  198. <span>Previous</span>
  199. <strong>Spry</strong>
  200. </a>
  201. <p class="docs-pager__up"><a href="../">All eleven</a></p>
  202. <a class="docs-pager__link docs-pager__link--next" href="../vallama/">
  203. <span>Next in the catalogue</span>
  204. <strong>Vallama</strong>
  205. </a>
  206. </nav>
  207. </div>
  208. </div>
  209. </section>
  210. </main>
  211. <footer class="site-footer">
  212. <div class="container">
  213. <div class="footer-grid">
  214. <div class="foot-brand">
  215. <img class="brand__logo brand__logo--dark" src="../../assets/img/astrologue-dark.png" width="392" height="89" alt="Astrologue">
  216. <p>An operating system for change — kept for self sufficiency, resilience, and software freedom, so regular people can hold the power of general purpose computers in their own hands.</p>
  217. </div>
  218. <nav aria-label="The four freedoms">
  219. <p class="foot-title">The Four Freedoms</p>
  220. <ol class="freedoms">
  221. <li><strong>Run</strong> the software as you wish, for any purpose.</li>
  222. <li><strong>Study</strong> the source and change it to do your computing as you wish.</li>
  223. <li><strong>Share</strong> copies so you can help others.</li>
  224. <li><strong>Modify</strong> and publish your versions so everyone benefits.</li>
  225. </ol>
  226. </nav>
  227. <nav aria-label="Site">
  228. <p class="foot-title">Site</p>
  229. <ul class="foot-list">
  230. <li><a href="../../">Home</a></li>
  231. <li><a href="../../#news">News</a></li>
  232. <li><a href="../../#download">Download</a></li>
  233. <li><a href="../">Developer</a></li>
  234. </ul>
  235. </nav>
  236. </div>
  237. <p class="colophon">Set in Cinzel and EB Garamond (SIL Open Font License). Astrologue is free software, licensed GPL-3.0-or-later: take it, tend it, pass it on. The libraries are LGPL-3.0-or-later, so they remain free to link.</p>
  238. </div>
  239. </footer>
  240. </body>
  241. </html>