<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Cryptech Project - Releases</title><link href="https://wiki.cryptech.is/" rel="alternate"></link><link href="https://wiki.cryptech.is/feeds/releases.atom.xml" rel="self"></link><id>https://wiki.cryptech.is/</id><updated>2021-10-10T23:43:00+00:00</updated><entry><title>Release Notes</title><link href="https://wiki.cryptech.is/ReleaseNotes" rel="alternate"></link><published>2017-05-13T19:06:00+00:00</published><updated>2017-05-13T19:18:00+00:00</updated><author><name>Rob Austein</name></author><id>tag:wiki.cryptech.is,2017-05-13:/ReleaseNotes</id><summary type="html">&lt;h2&gt;3.0, May 2017&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;New keystore implementation.  Basically a very small flash filesystem, including basic wear leveling.  Maximum number of keys varies depending on key size and how many options are attached, but for any reasonable use it should hold on the order of 2,000 keys at least.&lt;/li&gt;
&lt;li&gt;In-memory …&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;h2&gt;3.0, May 2017&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;New keystore implementation.  Basically a very small flash filesystem, including basic wear leveling.  Maximum number of keys varies depending on key size and how many options are attached, but for any reasonable use it should hold on the order of 2,000 keys at least.&lt;/li&gt;
&lt;li&gt;In-memory keystore moved to HSM (previously was in memory of the client library), uses same API as flash keystore.&lt;/li&gt;
&lt;li&gt;RPC mechanism extended to support the new keystores (&lt;code&gt;hal_rpc_pkey_match()&lt;/code&gt;, &lt;code&gt;hal_rpc_pkey_set_attributes()&lt;/code&gt;, etc).&lt;/li&gt;
&lt;li&gt;PKCS #11 code rewritten to use libhal attribute mechanism, sqlite3 database gone.&lt;/li&gt;
&lt;li&gt;Verilog implementations of ECDSA base point multipliers for P-256 and P-384 curves, key generation and signing significantly faster than with software ECDSA implementation.&lt;/li&gt;
&lt;li&gt;Key backup mechanism: two more RPC functions, and a Python script &lt;code&gt;cryptech_backup&lt;/code&gt; to drive the process.&lt;/li&gt;
&lt;li&gt;Private key representation changed to PKCS #8 format (a self-identifying uniform format with optional encryption, supported by many other tools).  Key backup uses encrypted form of PKCS #8.&lt;/li&gt;
&lt;li&gt;Default build of client software now uses a multiplexer daemon &lt;code&gt;cryptech_muxd&lt;/code&gt; which allows multiple clients to talk to the HSM at once (packages such as OpenDNSSEC which uses multiple daemons talking to the same HSM need this).  Software can still be built for direct connection to HSM but it is no longer the default.&lt;/li&gt;
&lt;li&gt;New trivial script &lt;code&gt;cryptech_console&lt;/code&gt; to talk to the HSM's management port via the multiplexer daemon; &lt;code&gt;cryptech_upload&lt;/code&gt; now supports both direct connection and connection via the multiplexer daemon.&lt;/li&gt;
&lt;li&gt;Python client implementations of libhal RPC mechanism and PKCS #11 now installed as &lt;code&gt;cryptech.libhal&lt;/code&gt; and &lt;code&gt;cryptech.py11&lt;/code&gt;, respectively.&lt;/li&gt;
&lt;li&gt;Python PKCS #11 client hacked to play nicely with &lt;code&gt;pkcs11-spy&lt;/code&gt; debugging tool.&lt;/li&gt;
&lt;li&gt;RTOS replaced by simple non-preemptive (voluntary yield) tasking system, eliminating a huge morass of potential race conditions, debugging nightmares, priority inversions, and similar horrors.  Lack of preemption means that console acess may have to wait for something else to yield the ARM CPU, but it's more than worth it to get rid of all the stability problems the RTOS was causing.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://git.cryptech.is/user/sra/openssl-engine/about"&gt;Sample code for using the HSM as an OpenSSL engine&lt;/a&gt; is available.  This only works with RSA for the moment, due to apparent limitations of the engine implementation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Getting started with 3.0:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wiki.cryptech.is/BinaryPackages"&gt;Install the software&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.cryptech.is/Upgrading"&gt;Upgrade the firmware&lt;/a&gt;.  &lt;strong&gt;Please note the warnings about bricking your HSM&lt;/strong&gt;, how to avoid that, and what to do if you failed to avoid it.&lt;/li&gt;
&lt;li&gt;Set the usual environment variables, perhaps using &lt;code&gt;cryptech_probe&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Start the multiplexer daemon &lt;code&gt;cryptech_muxd&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At this point, you should be able to use the PKCS #11 library, the &lt;code&gt;cryptech_backup&lt;/code&gt; script, and so forth.&lt;/p&gt;</content><category term="Releases"></category></entry><entry><title>Building Cryptech Software/Firmware/Bitstream From Source</title><link href="https://wiki.cryptech.is/BuildingFromSource" rel="alternate"></link><published>2017-05-13T17:47:00+00:00</published><updated>2021-10-10T23:43:00+00:00</updated><author><name>Rob Austein</name></author><id>tag:wiki.cryptech.is,2017-05-13:/BuildingFromSource</id><summary type="html">&lt;p&gt;Everything you need to build our software, firmware, and FPGA
bitstreams from source yourself is publicly available, but the process
is a bit complicated.  Overall, there are two methods, one of which
our developers use while writing this stuff, the other of which we use
for the automated reproducible builds …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Everything you need to build our software, firmware, and FPGA
bitstreams from source yourself is publicly available, but the process
is a bit complicated.  Overall, there are two methods, one of which
our developers use while writing this stuff, the other of which we use
for the automated reproducible builds which go into our binary
distributions.  Both methods eventually boil down to "get the source
code then run make", but the details differ.&lt;/p&gt;
&lt;h2&gt;What developers do&lt;/h2&gt;
&lt;p&gt;We check out copies of all the several dozen separate repositories and
carefully arrange them in a tree structure which matches the official
naming scheme.  Yes, really.  It's tedious, but we have
&lt;a href="https://git.cryptech.is/user/sra/build-tools/tree/https-sync-repos.py"&gt;a script to automate this&lt;/a&gt;.
This works by parsing the &lt;code&gt;.gitmodules&lt;/code&gt; file in the &lt;code&gt;releng/alpha&lt;/code&gt;
repository (see "reproducible builds", below).&lt;/p&gt;
&lt;p&gt;Once you have this tree, you can hop around within it, building
whichever bits are of interest to you.  So if you want to rebuild just
the HSM firmware (the C code that runs on the ARM), you would go to
&lt;code&gt;sw/stm32&lt;/code&gt; and run &lt;code&gt;make&lt;/code&gt; there.&lt;/p&gt;
&lt;h2&gt;What we do for reproducible builds&lt;/h2&gt;
&lt;p&gt;Reproducible builds use the same tree structure (as they must for the
various Makefiles to work properly), but the entire tree is embedded
in a git "superrepository" which also contains the release engineering
goo necessary to make the whole thing work.  Do &lt;code&gt;git help submodule&lt;/code&gt;
for an introduction to git's submodule mechanism.&lt;/p&gt;
&lt;p&gt;With this model, one just checks out a copy of
&lt;a href="https://git.cryptech.is/releng/alpha/about"&gt;the superrepository&lt;/a&gt;,
runs &lt;code&gt;make&lt;/code&gt; in its top directory, and eventually
the complete package pops out the other side.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git clone https://git.cryptech.is/releng/alpha.git
cd alpha
make
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That's the good news.  The bad news is that this process has higher
demands on its build environment: it expects to find the a complete
tool set, including the XiLinx synthesis tools, the several different
cross compilers for the firmware, and the &lt;code&gt;pbuilder&lt;/code&gt; system for
building clean room packages for Ubuntu and Debian.&lt;/p&gt;
&lt;p&gt;As a compromise, one can use this source tree as if it were the
development source tree described above: just use the supermodule to
pull down everything else, but then ignore the supermodule and build
individual pieces as if you'd checked out all the repositories by
hand.&lt;/p&gt;
&lt;h2&gt;Skip all this git mess and just download a tarball&lt;/h2&gt;
&lt;p&gt;There's another alternative, which is simpler than any of the above:
just download the source tarball.  Since the only build environments
we support at the moment are Debian Jessie and Ubuntu Xenial, which
also happen to be environments for which we build binary packages, you
can just use APT:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get source cryptech-alpha
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Which will give you the same tree structure, but without all the git fun.&lt;/p&gt;
&lt;h2&gt;Build environment&lt;/h2&gt;
&lt;p&gt;Our software and firmware developers use the Debian and Ubuntu Linux
distributions.  Our current build box for binary packages runs Debian
Jessie.&lt;/p&gt;
&lt;p&gt;Our Verilog developers use various environments and have been known to
use graphical tools, but synthesis of the bitstreams that go in our
binary packages is done via the XiLinx command line tools on the same
Debian Jessie machine as the software and firmware builds.&lt;/p&gt;
&lt;p&gt;Which tools you need will of course depend on exactly what you're
trying to do.&lt;/p&gt;
&lt;p&gt;Most of the tools work on either 32-bit or 64-bit machines, but if you
intend to run the full binary package build script, you'll need a
64-bit machine (or VM) because the tools won't build 64-bit binaries
on a 32-bit machine.&lt;/p&gt;
&lt;p&gt;Basic tool set (not all required for every purpose, but they're all
supported Debian packages so it's usually easier just to install them
all and not worry about it):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pbuilder&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ubuntu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rsync&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sudo&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;yaml&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;serial&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ecdsa&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gcc&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;arm&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eabi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gdb&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;arm&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eabi&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gcc&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;avr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;binutils&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;avr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;avr&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;libc&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jessie&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;backports&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;debootstrap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;distro&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;apt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;reprepro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ubuntu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;archive&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;keyring&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is not an exhaustive list, because some of the other packages we
use are pulled in by these as dependencies.&lt;/p&gt;
&lt;p&gt;You will also need a copy of the XiLinx tools, which is tedious enough
that it's described in a separate section, below.&lt;/p&gt;
&lt;p&gt;Once you have all the tools installed, you'll need a copy of the
source tree, as explained in the preceeding sections.&lt;/p&gt;
&lt;p&gt;pbuilder requires a bit of setup (you can skip this if you're not
trying to do the full binary package build):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;for code in jessie xenial; do for arch in i386 amd64; do pbuilder-dist $code $arch create; done; done
ln -s jessie_result ~/pbuilder/jessie-amd64_result
ln -s xenial_result ~/pbuilder/xenial-amd64_result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Installing the XiLinx tools&lt;/h2&gt;
&lt;p&gt;XiLinx tools setup is a bit involved.  You can skip this section if
you don't intend to build FPGA bitstreams.&lt;/p&gt;
&lt;p&gt;We use the command line versions of the XiLinx tools, but installing
them requires a graphical environment, because the XiLinx installer
and license manager are GUI tools.  If you're running this on a server
and don't already have a graphical environment installed, you can get
away with something fairly minimal.  For example, if you have a VNC
viewer such as "Chicken of the VNC" on your laptop, you can get away
with a fairly minimal X11 toolset:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install tightvncserver xterm icewm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you're already running X11 on your laptop and are comfortable with
extruding that to the build machine, eg, via &lt;code&gt;ssh -Y&lt;/code&gt;, you can just
use that (not recommended for long-haul use, eg, if the laptop is in
Boston and the server is in Reykjavik).&lt;/p&gt;
&lt;p&gt;You'll need to start by using a web browser to download the
&lt;a href="http://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/design-tools.html"&gt;Xilinx ​ISE Design Suite&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;XiLinx only supports specific versions of Red Hat and Suse Linux, but
their tools do run on Debian and Ubuntu.  A few  caveats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Debian and Ubuntu symlink &lt;code&gt;/bin/sh&lt;/code&gt; to &lt;code&gt;/bin/dash&lt;/code&gt;, which can't handle
  some of the syntax used in XiLinx's shell scripts, so you'll need to
  change that symlink to point to &lt;code&gt;/bin/bash&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Although the XiLinx software can be installed as user or root, by
  default it wants to install into /opt/Xilinx, so you need to install
  as root if you want to do that.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The XiLinx tools are disk hogs, so if you're building a VM for this,
  you'll probably want to give it at least 30-40 GB of disk space.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step-by-step installation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Unpack &lt;code&gt;Xilinx_ISE_DS_Lin_14.7_1015_1.tar&lt;/code&gt; (or whatever version you have).&lt;/li&gt;
&lt;li&gt;In an X11 environment, cd to &lt;code&gt;Xilinx_ISE_DS_Lin_14.7_1015_1&lt;/code&gt;, and run &lt;code&gt;sudo ./xsetup&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click through two screens of license agreements.&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;ISE WebPACK&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Unselect (or leave unselected) Install Cable Drivers.&lt;/li&gt;
&lt;li&gt;Go!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Well, not quite.  You'll need to convince the ISE tools that you have
a valid license to use the ISE tools.  Go to
http://www.xilinx.com/products/design-tools/ise-design-suite/ise-webpack.htm,
click the &lt;code&gt;Licensing Solutions&lt;/code&gt; link.  On the page to which that takes
you, expand the section &lt;code&gt;Obtain a license for Free or Evaluation
product&lt;/code&gt;.  To download the ISE Webpack, you should have created an
account, so now you can go to the Licensing Site and use that account
to create a Certificate Based License.&lt;/p&gt;
&lt;p&gt;You do not need to go through the HostID dance, just say Do It. You
will then receive a certificate in email (not an X.509 certificate)
which you will be able to use. Then start the ISE Webpack by issuing
the command &lt;code&gt;ise&lt;/code&gt;.  Go to the Help menu and Manage Licenses. Use the
resulting new License Manager window to install the &lt;code&gt;.lic&lt;/code&gt; file.  This
process is complex and flakey.&lt;/p&gt;
&lt;p&gt;Here's
&lt;a href="http://www.armadeus.com/wiki/index.php?title=ISE_WebPack_installation_on_Linux"&gt;another description of installing ISE on Ubuntu&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;ise&lt;/code&gt; binary referred to above is in &lt;code&gt;/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ise&lt;/code&gt;
(or in &lt;code&gt;.../lin/ise&lt;/code&gt;, but the pbuilder setup requires a 64-bit build machine).&lt;/p&gt;
&lt;p&gt;When running this remotely under tightvncserver, setup looks something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;vncserver&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;geometry&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1280&lt;/span&gt;&lt;span class="n"&gt;x768&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;depth&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;localhost&lt;/span&gt;
&lt;span class="n"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;DISPLAY&lt;/span&gt;&lt;span class="o"&gt;=:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;XAUTHORITY&lt;/span&gt;&lt;span class="o"&gt;=~/.&lt;/span&gt;&lt;span class="n"&gt;Xauthority&lt;/span&gt;
&lt;span class="n"&gt;icewm&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then, either in the same shell as the above or in an xterm in the new display&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd Xilinx_ISE_DS_Lin_14.7_1015_1
sudo ./xsetup

cd
/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ise
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It turns out you don't really need to run the whole &lt;code&gt;ise&lt;/code&gt; tool to
get to the license manager, you can just run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xlcm -manage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;But you do have to source the appropriate settings file first, none of
the XiLinx tools work properly without that:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;. /opt/Xilinx/14.7/ISE_DS/settings64.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Releases"></category></entry><entry><title>Upgrading the Cryptech Alpha HSM</title><link href="https://wiki.cryptech.is/Upgrading" rel="alternate"></link><published>2017-05-12T23:15:00+00:00</published><updated>2018-04-07T23:03:00+00:00</updated><author><name>Cryptech Core Team</name></author><id>tag:wiki.cryptech.is,2017-05-12:/Upgrading</id><summary type="html">&lt;p&gt;This page explains how to upgrade the Cryptech Alpha firmware, bootloader,
and FPGA bitstream (as needed).&lt;/p&gt;
&lt;p&gt;All of the operations here use the Alpha's "management" (MGMT) port,
so that cable must be connected to your Linux or OSX host machine.&lt;/p&gt;
&lt;h2&gt;Upgrading from the stock firmware (Berlin workshop or CrowdSupply)&lt;/h2&gt;
&lt;p&gt;The …&lt;/p&gt;</summary><content type="html">&lt;p&gt;This page explains how to upgrade the Cryptech Alpha firmware, bootloader,
and FPGA bitstream (as needed).&lt;/p&gt;
&lt;p&gt;All of the operations here use the Alpha's "management" (MGMT) port,
so that cable must be connected to your Linux or OSX host machine.&lt;/p&gt;
&lt;h2&gt;Upgrading from the stock firmware (Berlin workshop or CrowdSupply)&lt;/h2&gt;
&lt;p&gt;The main feature of the 3.0 firmware release is a completely new HSM
keystore implementation, which makes better use of the Alpha's keystore
flash, allows a much larger number of keys, and removes the need for an
SQL database on the host. (See ReleaseNotes.)&lt;/p&gt;
&lt;p&gt;We did not attempt to provide any sort of backwards compatability to the
original minimalistic keystore implementation, so this upgrade process
will wipe your keystore. Sorry. More importantly (from the limited
viewpoint of the upgrade process), it will change how the HSM stores its
PINs, which complicates the upgrade process.&lt;/p&gt;
&lt;p&gt;Because we use the bootloader to upgrade the firmware, and the firmware to
upgrade the bootloader, both use the PINs stored in the keystore to login,
so both need to understand the new keystore, so both need to be upgraded.&lt;/p&gt;
&lt;p&gt;Because of the tricky nature of this particular upgrade, you must
perform these steps, in the specified order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install the new host software package using APT or Homebrew.&lt;/li&gt;
&lt;li&gt;Wipe the HSM keystore to reset PINs back to the "factory" state.&lt;/li&gt;
&lt;li&gt;Upgrade the main HSM firmware.&lt;/li&gt;
&lt;li&gt;Upgrade the HSM bootloader.&lt;/li&gt;
&lt;li&gt;Log in to upgraded HSM to set PINs, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Upgrading the bootloader before the main firmware will brick your
Alpha.&lt;/strong&gt;  So don't do that.&lt;/p&gt;
&lt;p&gt;If something goes horribly wrong and you do somehow manage to brick
your Alpha, see DisasterRecovery.&lt;/p&gt;
&lt;h2&gt;Upgrading from 'ksng'&lt;/h2&gt;
&lt;p&gt;A few intrepid users are already testing the 'ksng' development branch,
using the instructions at &lt;a href="https://wiki.cryptech.is/UpgradeToKSNG"&gt;UpgradeToKSNG&lt;/a&gt;. In this case, and with future
upgrades, it it not necessary to either wipe the keystore or upgrade the
bootloader.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install the new host software package using APT or Homebrew.&lt;/li&gt;
&lt;li&gt;Upgrade the main HSM firmware.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Install the cryptech-alpha package&lt;/h2&gt;
&lt;h3&gt;using apt-get on Debian or Ubuntu Linux&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;update
$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Yes, you have to install it even if you already had it installed, because
APT wants permission before accepting the new package dependencies.&lt;/p&gt;
&lt;p&gt;Or you could instead run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;upgrade&lt;span class="w"&gt; &lt;/span&gt;--with-new-pkgs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;but that might upgrade unrelated stuff.&lt;/p&gt;
&lt;p&gt;If you had the '-ksng' package installed, you might then want to run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;remove&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha-ksng
$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;autoclean
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;but nothing terrible is likely to happen if you omit those steps.&lt;/p&gt;
&lt;p&gt;If you're running on Debian Jessie, you may need to enable &lt;a href="https://backports.debian.org/Instructions/"&gt;&lt;code&gt;jessie-backports&lt;/code&gt;&lt;/a&gt; and make sure you're getting the &lt;code&gt;python-serial&lt;/code&gt; and &lt;code&gt;python-tornado&lt;/code&gt; dependencies from the backports (the versions of those packages in the base Debian Jessie distribution are too old).&lt;/p&gt;
&lt;h3&gt;using Homebrew on OSX&lt;/h3&gt;
&lt;p&gt;If you're upgrading from the original firmware (have not installed the &lt;code&gt;-ksng&lt;/code&gt; package), a normal Homebrew upgrade cycle
should suffice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;update
$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you have the &lt;code&gt;-ksng&lt;/code&gt; package installed, you need to tell Homebrew that you want to switch back:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;update
$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;migrate&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha-ksng
$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In either case, you might then want to do something like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;cleanup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;but nothing terrible is likely to happen if you omit that step.&lt;/p&gt;
&lt;p&gt;If you've tried doing this and nothing happens, you might be hitting a known old bug in Homebrew itself.  Make sure your copy of Homebrew is up to date, and if that still doesn't work, try deinstalling whichever &lt;code&gt;cryptech-alpha*&lt;/code&gt; package you have installed and reinstalling &lt;code&gt;cryptech-alpha&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Set usual CRYPTECH_* environment variables&lt;/h2&gt;
&lt;p&gt;The upgrade process uses the &lt;code&gt;CRYPTECH_CTY_CLIENT_SERIAL_DEVICE&lt;/code&gt;
environment variable.  The easiest way to set it is by using the
&lt;code&gt;cryptech_probe&lt;/code&gt; script, just as you would for other usage of the
Alpha.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`cryptech_probe`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;(Note: you can use the new &lt;code&gt;cryptech_muxd&lt;/code&gt; and &lt;code&gt;cryptech_console&lt;/code&gt;, but
these instructions assume you are familiar with &lt;code&gt;cryptech_miniterm&lt;/code&gt;. Or
you could be using &lt;code&gt;picocom&lt;/code&gt; or &lt;code&gt;kermit&lt;/code&gt; or something else. Doesn't matter
to us.)&lt;/p&gt;
&lt;h2&gt;Clear the keystore flash&lt;/h2&gt;
&lt;p&gt;If you are upgrading from the original firmware, you will need to wipe the
keystore, to avoid confusing the new keystore code.&lt;/p&gt;
&lt;p&gt;The good news is that we have a utility to back up and restore the new
keystore. The bad news is that we don't have a way to back up the old
keystore.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;cryptech_miniterm

Username:&lt;span class="w"&gt; &lt;/span&gt;wheel
Password:&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;your-wheel-pin-goes-here&amp;gt;

cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;erase&lt;span class="w"&gt; &lt;/span&gt;YesIAmSure

^&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Upgrade the main HSM firmware&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cryptech_upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;firmware&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wheel&lt;/span&gt;
&lt;span class="n"&gt;PIN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Upgrade the bootloader&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cryptech_upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;bootloader&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wheel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;simon&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;says&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;whack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bootloader&lt;/span&gt;
&lt;span class="n"&gt;PIN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;(Optional) Upgrade the FPGA bitstream&lt;/h2&gt;
&lt;p&gt;This upgrade includes an experimental ECDSA point multiplier in hardware,
which the firmware will use if present.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cryptech_upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;fpga&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wheel&lt;/span&gt;
&lt;span class="n"&gt;PIN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Log in and set PINs, masterkey, etcetera&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;cryptech_miniterm

Username:&lt;span class="w"&gt; &lt;/span&gt;wheel
PIN:&lt;span class="w"&gt; &lt;/span&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding

cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;wheel&lt;span class="w"&gt; &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;so&lt;span class="w"&gt;    &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;user&lt;span class="w"&gt;  &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;masterkey&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;

^&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Releases"></category></entry><entry><title>Upgrading Cryptech Alpha HSM to "ksng" development package</title><link href="https://wiki.cryptech.is/UpgradeToKSNG" rel="alternate"></link><published>2016-12-22T22:33:00+00:00</published><updated>2016-12-22T22:53:00+00:00</updated><author><name>Rob Austein</name></author><id>tag:wiki.cryptech.is,2016-12-22:/UpgradeToKSNG</id><summary type="html">&lt;p&gt;This page attempts to explain the upgrade procedure for testing out
the new "ksng" development branch of the Cryptech Alpha firmware.&lt;/p&gt;
&lt;h2&gt;Cavats&lt;/h2&gt;
&lt;p&gt;This particular upgrade is more complicated than we would have
preferred, due to the interaction of two unrelated factors:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;As the name (obscurely) implies, the main feature in …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;This page attempts to explain the upgrade procedure for testing out
the new "ksng" development branch of the Cryptech Alpha firmware.&lt;/p&gt;
&lt;h2&gt;Cavats&lt;/h2&gt;
&lt;p&gt;This particular upgrade is more complicated than we would have
preferred, due to the interaction of two unrelated factors:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;As the name (obscurely) implies, the main feature in the ksng
   branch is a completely new HSM keystore implementation, which makes
   better use of the Alpha's keystore flash, allows a much larger
   number of keys, removes the need for an SQL database on the host,
   gets your laundry 25% brighter, and leaves your breath alone.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We did not attempt to provide any sort of backwards compatability
   to the old minimalistic keystore implementation, so this upgrade
   process will wipe your keystore.  Sorry.  More importantly (from
   the limited viewpoint of the upgrade process), it will change how
   the HSM stores its PINs, which complicates the upgrade process.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The "Device Field Upgrade" (DFU) capability in the Alpha's firmware
   was a last-minute addition before the Berlin workshop in July 2016,
   and, as last minute additions often do, it turned out to be buggy.
   There are three distinct pieces of software involved in the upgrade
   process, and they were all slightly buggy, in different ways.
   Because of this, one must perform the upgrade steps in a particular
   order to avoid bricking the HSM.  The upgrade includes fixes for
   all the (known) bugs in the DFU process, so we hope that this will
   be a one-time annoyance (famous last words).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If something goes horribly wrong and you do somehow manage to brick
your Alpha, don't give up, recovery is still possible, it just
requires an ST-LINK debugger and cable (more on this below).&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;Because of the tricky nature of this particular upgrade, you must
perform these steps, in the specified order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install the new host software package using APT or Homebrew.&lt;/li&gt;
&lt;li&gt;Wipe the HSM keystore to reset PINs back to the "factory" state.&lt;/li&gt;
&lt;li&gt;Upgrade the main HSM firmware.&lt;/li&gt;
&lt;li&gt;Upgrade the HSM bootloader.&lt;/li&gt;
&lt;li&gt;Log in to upgraded HSM to set PINs, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Upgrading the bootloader before the main firmware will brick your
Alpha.&lt;/strong&gt;  So don't do that.&lt;/p&gt;
&lt;p&gt;All of the operations here use the Alpha's "management" (MGMT) port,
so that cable must be connected to your Linux or OSX host machine.&lt;/p&gt;
&lt;p&gt;This upgrade procedure was tested on Debian Jessie, with an Alpha
whose firmware had been rolled back to the version from the Berlin
workshop (APT/Homebrew package version 2.0.1468584175, commit
cd445b69b2caa7205f4e1c368aa2c6bf8c2d7692 in repository
https://git.cryptech.is/releng/alpha.git).&lt;/p&gt;
&lt;h2&gt;Install cryptech-alpha-ksng package using apt-get or Homebrew&lt;/h2&gt;
&lt;p&gt;Binaries for the "ksng" branch are available as a separate set of
"cryptech-alpha-ksng" packages, which replace the "cryptech-alpha"
packages for the master branch.  This seemed the simplest way of
letting people experiment with the new code while falling back to the
old if necessary.  The "cryptech-alpha-ksng" packages are declared to
conflict with the "cryptech-alpha" packages, because they install
programs by the same name in the same places and you need the version
of the host software which goes with the HSM firmware your running.&lt;/p&gt;
&lt;p&gt;APT handles package conflicts differently from the way that Homebrew
does.  If you have "cryptech-alpha" installed and try to install
"cryptech-alpha-ksng", APT assumes you meant what you said and will
just replace the old package with the new one.  Homebrew, on the other
hand, reports the conflict and refuses to proceed until you sort it out.&lt;/p&gt;
&lt;p&gt;The following assumes that you already had the Cryptech APT repository
or Homebrew tap configured; if not, see  &lt;a href="https://wiki.cryptech.is/BinaryPackages"&gt;BinaryPackages&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Installing cryptech-alpha-ksng package using apt-get on Debian or Ubuntu Linux&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;update
$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha-ksng
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Installing cryptech-alpha-ksng package using Homebrew on OSX&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;update
$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;uninstall&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha
$&lt;span class="w"&gt; &lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;cryptech-alpha-ksng
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Set usual CRYPTECH_* environment variables&lt;/h2&gt;
&lt;p&gt;The upgrade process uses the &lt;code&gt;CRYPTECH_CTY_CLIENT_SERIAL_DEVICE&lt;/code&gt;
environment variable.  The easiest way to set it is by using the
&lt;code&gt;cryptech_probe&lt;/code&gt; script, just as you would for other usage of the
Alpha.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;cryptech_probe&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Clear the keystore flash&lt;/h2&gt;
&lt;p&gt;Sorry about this.  Yes, we know we need backup and restore, we'll get
there.  But for this upgrade, it's safest to wipe the keystore.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;cryptech_miniterm

Username:&lt;span class="w"&gt; &lt;/span&gt;wheel
Password:&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;your-wheel-pin-goes-here&amp;gt;

cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;erase&lt;span class="w"&gt; &lt;/span&gt;YesIAmSure

^&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Upgrade the main HSM firmware&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cryptech_upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;firmware&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wheel&lt;/span&gt;
&lt;span class="n"&gt;PIN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Upgrade the bootloader&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cryptech_upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;bootloader&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wheel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;simon&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;says&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;whack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bootloader&lt;/span&gt;
&lt;span class="n"&gt;PIN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Log in and set PINs, masterkey, etcetera&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;cryptech_miniterm

Username:&lt;span class="w"&gt; &lt;/span&gt;wheel
PIN:&lt;span class="w"&gt; &lt;/span&gt;YouReallyNeedToChangeThisPINRightNowWeAreNotKidding

cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;wheel&lt;span class="w"&gt; &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;so&lt;span class="w"&gt;    &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;keystore&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pin&lt;span class="w"&gt; &lt;/span&gt;user&lt;span class="w"&gt;  &lt;/span&gt;fnord
cryptech&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;masterkey&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;

^&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;What to do if you manage to brick your Alpha&lt;/h2&gt;
&lt;p&gt;If the above procedure somehow goes horribly wrong and bricks your
alpha, you can still recover, but you'll need an ST-LINK programmer.
There's some discussion of this at &lt;a href="https://git.cryptech.is/sw/stm32.md"&gt;sw/stm32&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Possible sources for the ST-LINK programmer and a suitable cable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;http://www.mouser.com/search/ProductDetail.aspx?R=0virtualkey0virtualkeyNUCLEO-F411RE&lt;/li&gt;
&lt;li&gt;https://www.sparkfun.com/products/10376&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are relatively cheap, you'll probably pay as much for the
postage as for the parts themselves.  If you have a better source, go
for it.&lt;/p&gt;
&lt;p&gt;The programmer is the important part, you can use any sort of cabling
you like so long as it connects the right pins of the programmer to
the corresponding pins on the Alpha; the SparkFun cable just happens
to be a tidy package which matches the relevant SWD headers.&lt;/p&gt;
&lt;p&gt;We'll include a more detailed description of the recovery process here
if anybody needs it, but the short version is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install OpenOCD on your host machine.&lt;/li&gt;
&lt;li&gt;Open up the Alpha's case, take the board out.&lt;/li&gt;
&lt;li&gt;Connect the programmer and power the board back up.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;flash-target&lt;/code&gt; script from the &lt;code&gt;sw/stm32&lt;/code&gt; repository to
  stuff the &lt;code&gt;hsm.elf&lt;/code&gt; and &lt;code&gt;bootloader.elf&lt;/code&gt; files from the binary
  firmware tarball into the HSM.&lt;/li&gt;
&lt;li&gt;Power down, disconnect the programmer, put the Alpha back in its
  case, done.&lt;/li&gt;
&lt;/ul&gt;</content><category term="Releases"></category></entry><entry><title>Binary Packages for Cryptech Software and Firmware</title><link href="https://wiki.cryptech.is/BinaryPackages" rel="alternate"></link><published>2016-12-15T22:44:00+00:00</published><updated>2019-09-03T15:23:00+00:00</updated><author><name>Rob Austein</name></author><id>tag:wiki.cryptech.is,2016-12-15:/BinaryPackages</id><summary type="html">&lt;p&gt;The Cryptech Project maintains APT and Homebrew repositories
containing packaged software for the Cryptech Alpha board for Debian
and Ubuntu Linux and for Mac OS X.  The binary packages also include
pre-compiled images for the Alpha Board's Artix-7 FPGA, Cortex M4 ARM
CPU, and AVR ATtiny828 MCU.&lt;/p&gt;
&lt;h2&gt;How to get …&lt;/h2&gt;</summary><content type="html">&lt;p&gt;The Cryptech Project maintains APT and Homebrew repositories
containing packaged software for the Cryptech Alpha board for Debian
and Ubuntu Linux and for Mac OS X.  The binary packages also include
pre-compiled images for the Alpha Board's Artix-7 FPGA, Cortex M4 ARM
CPU, and AVR ATtiny828 MCU.&lt;/p&gt;
&lt;h2&gt;How to get APT packages for Debian Stretch, Debian Buster, Ubuntu Xenial, or Ubuntu Bionic&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Fetch and validate the repository key.  Presumably you're security
    concious (otherwise, why are you installing this stuff?), so you may
    want to pay attention to what &lt;code&gt;gpg --check-sig&lt;/code&gt; says here.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;id=37A8E93F5D7E7B9A
wget https://apt.cryptech.is/apt-gpg-key.gpg
gpg --recv-key $id
gpg --check-sig $id
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the repository key.  We used to use &lt;code&gt;apt-key(8)&lt;/code&gt; for this,
    these days the cool kids use the &lt;code&gt;/etc/apt/trusted.gpg.d/&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo chown root:root apt-gpg-key.gpg
sudo mv apt-gpg-key.gpg /etc/apt/trusted.gpg.d/cryptech.gpg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure apt to use the repository.  You need to add a couple of
    entries to &lt;code&gt;/etc/apt/source.list.d/&lt;/code&gt;; which entries you need to add
    depends on which distribution you're running.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For Debian Stretch, do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo wget -q -O /etc/apt/sources.list.d/cryptech.list https://apt.cryptech.is/sources.stretch.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For Debian Buster, do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo wget -q -O /etc/apt/sources.list.d/cryptech.list https://apt.cryptech.is/sources.buster.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For Ubuntu Xenial, do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo wget -q -O /etc/apt/sources.list.d/cryptech.list https://apt.cryptech.is/sources.xenial.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For Ubuntu Bionic, do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo wget -q -O /etc/apt/sources.list.d/cryptech.list https://apt.cryptech.is/sources.bionic.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the package index.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;code&gt;cryptech-alpha&lt;/code&gt; package.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get install cryptech-alpha
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Updating APT packages&lt;/h2&gt;
&lt;p&gt;Once you've performed the steps above you should be able to upgrade to newer
version of the code using the normal APT upgrade process:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get update
sudo apt-get upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;How to get Homebrew packages for Mac OS X&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Fetch and validate the repository key.  Presumably you're security
    concious (otherwise, why are you installing this stuff?), so you may
    want to pay attention to what &lt;code&gt;gpg --check-sig&lt;/code&gt; says here.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;id=37A8E93F5D7E7B9A
gpg --recv-key $id
gpg --check-sig $id
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure Homebrew to use the repository.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;brew tap cryptech/sw https://brew.cryptech.is/tap
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the package index.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;brew update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check the commit signature on the cryptech-alpha package formula.
    This is optional (Homebrew doesn't care whether you do this), but if
    you want to know whether the formula was signed by the Cryptech
    project, this is how to check.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;brew&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nv"&gt;max&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="k"&gt;show&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;signature&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;cryptech&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;alpha&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;code&gt;cryptech-alpha&lt;/code&gt; package.  At the moment, this is only
    available as a Homebrew source package due to licensing issues in
    the MacOS Xcode SDK, so the installation will probably take several
    minutes, as some of the libraries are a bit slow to compile (sorry...).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;brew install cryptech-alpha
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Updating Homebrew packages&lt;/h2&gt;
&lt;p&gt;Once you've performed the steps above you should be able to upgrade to newer
version of the code using the normal Homebrew upgrade process:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;brew update
brew upgrade
brew cleanup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Releases"></category></entry></feed>