As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com.

Changes

Jump to: navigation, search

Installing ChipWhisperer

12,113 bytes removed, 12:07, 2 July 2020
no edit summary
This page describes how to install the ChipWhisperer software. <span class="expandall"></span>
{{Warningbox|These installation instructions are out of date! The new installation instructions can be found at https://chipwhisperer.readthedocs.io/en/latest/, along with our software documentation.}} This page describes how to install the ChipWhisperer software before release 5.1.  There are four five ways to set up ChipWhisperer:
* '''VMWare Virtual Machine:''' Get a pre-prepared virtual machine image with all of the required tools already installed. ''Recommended for beginners.''
* '''Windows Installer''' Get a Windows binary that installs the ChipWhisperer repository to your computer. Does not include WinAVR compiler.
* '''ChipWhisperer Releases:''' Get a zip file with the latest stable ChipWhisperer code and run it on your own environment.
* '''PyPi Package:''' <code>pip install chipwhisperer</code>. Only includes the software - doesn't come with the hardware source files, drivers, or example firmware.
* '''Git Repository:''' Get the latest, bleeding-edge features and bugs. Recommended if you're an experienced developer and you want to contribute to ChipWhisperer.
'''NOTE TO USERS WITH AN ARM TARGET:''' To build firmware, you'll need the GNU Embedded Toolchain For ARM. This is included with the VM. Otherwise please see '''Installing ARM Toolchain''' at the bottom of the page.
<br>
{{Warningbox|If you are installing 64-bit Python rather than 32-bit, and the ChipWhisperer software's graph widget's axis disappear, the fix is this: ''pip uninstall pyside'' and then ''pip install https://download.qt.io/official_releases/pyside/PySide-1.2.2-cp27-none-win_amd64.whl''. This uninstalls the current pyside package and installs the official QT Pyside package.}}
 
<br>
{{Warningbox|You may need to add ''--trusted-host pypi.python.org'' to the ''pip install'' command to allow HTTP connections. This is done as follows for example: ''sudo pip install --trusted-host pypi.python.org pyusb''}}
 
<br>
{{TOC|limit=3}}
{{CollapsibleSection
|intro = == = Using VMWare Virtual Machine ===
|content= Installing ChipWhisperer/Using VMWare Virtual Machine}}
{{CollapsibleSection|intro = === Automatic Windows (XP or later) Installer ===|content= Installing ChipWhisperer/Windows Installer}}
This section describes how to install the {{CollapsibleSection|intro= === Manual Install - Windows ===|content= Installing ChipWhisperer software for /Required Tools - Windows. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!}}
{{CollapsibleSection|intro== Python Setup ==Manual Install - Linux ===|content= Installing ChipWhisperer/Required Tools - Linux}}
The first step is to install Python 2. If you already a recent version of Python installed (2.7.x), you can skip this step. Note that Python 3.x will not work with this codebase.{{CollapsibleSection|intro= === Manual Install - Mac OS X ===|content= Installing ChipWhisperer/Required Tools - Mac OS X}}
The recommend method of installing Python is to use a distribution called [http:{{CollapsibleSection|intro= === Installing ChipWhisperer from Releases ===|content= Installing ChipWhisperer//winpython.github.io/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.Installing ChipWhisperer from Releases}}
<ol style{{CollapsibleSection|intro="list-style-type: decimal;"><li>Install WinPython 2.7.x. Download the latest release in the 2.7.x branch === Installing ChipWhisperer from the [http://winpython.github.io/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as <code>c:\WinPython32bit-2.7.10.3</code>, or into your local directory such as <code>c:\Users\yourname\WinPython-32bit-2.7.10.3</code>.</li><li>Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.</li><li><p>Run the following commands to get needed packages:</p><pre>pip install pyqtgraphpip install configobj</pre><p>Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:</p><pre>pip install pyusb</pre><p>If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:</p><pre>pip install pyusbPyPi ===1.0.0b1</pre></li><li><p>Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.<|content= Installing ChipWhisperer/p><p>If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) Installing ChipWhisperer from that command prompt.</p></li><li>Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.</li></ol>PyPi}}
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:{{CollapsibleSection|intro= === Installing ChipWhisperer from Git ===|content= Installing ChipWhisperer/Installing ChipWhisperer from Git}}
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it: <pre>python setup.py install</pre>This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp; install that. '''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]: <pre>pip install umysql</pre>'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard]. {{CollapsibleSection|intro== Getting &amp; Installing ChipWhisperer == Assuming you've got a working Python installation, the next step is to install &amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository <code>git://git.assembla.com/chipwhisperer.git</code> instead, but this '''may be broken''' so you should start with the latest release instead. Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen <code>C:\chipwhisperer</code> as your working directory. Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed: <pre>cd c:\chipwhisperer\openadc\controlsw\pythonpython setup.py developcd c:\chipwhisperer\softwarepython setup.py develop</pre>If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal: <pre>cd c:\chipwhisperer\software\chipwhisperer\python CWAnalyzer.pyw</pre>Alternatively you can just double-click on <code>CWAnalyzer.py</code> from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''. You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&hd=1 Video] of the Installation Procedure: [[File:Youtube-win7-install.png|YouTubeWin7Install]]_ == Installing Hardware Drivers == Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section. == Getting AVR Compiler ARM Toolchain == The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however! To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already). Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps: <ol style="list-style-type: decimal;"><li><p><code>cd</code> to the directory with the avr-serial example, and run <code>make</code>:</p><pre>cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aesmake</pre><p>If this is successful, you'll see an output like the following:</p><p>[[File:Avr-build-ok.png|image]]</p><p>If instead you get an error something like <code>make: *** No rule to make target `simpleserial.elf', needed by `elf'. Stop.</code>, this means a required file was missing.</p></li><li>Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external "AVR Studio" program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].</li></ol> content= Linux = == Python Setup == On Linux, installing Python &amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type: <pre>$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb$ sudo pip install pyqtgraph</pre>On Ubuntu or similar: <pre>$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip$ sudo pip install pyusb$ sudo pip install pyqtgraph</pre> == Getting Installing ChipWhisperer == As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux: <syntaxhighlight lang="bash">$ git clone git://git.assembla.com/chipwhisperer.git$ cd chipwhisperer$ git clone git://git.assembla.com/openadc.git</syntaxhighlight >Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:<syntaxhighlight lang="bash">$ cd software$ sudo python setup.py develop$ cd ../openadc/controlsw/python$ sudo python setup.py develop</syntaxhighlight > '''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this. == Hardware Drivers == The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called <code>/etc/udev/rules.d/99-newae.rules</code> . The contents of this file should be: <pre># CW-LiteSUBSYSTEM=="usb", ATTRS{idVendorInstalling_ARM_Toolchain}=="2b3e", ATTRS{idProduct}=="ace2", MODE="0664", GROUP="plugdev" # CW-1200SUBSYSTEM=="usb", ATTRS{idVendor}=="2b3e", ATTRS{idProduct}=="ace3", MODE="0664", GROUP="plugdev" # CW-305 (Artix Target)SUBSYSTEM=="usb", ATTRS{idVendor}=="2b3e", ATTRS{idProduct}=="c305", MODE="0664", GROUP="plugdev" # CW-CR2SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", MODE="0664", GROUP="plugdev"SUBSYSTEM=="usb", ATTRS{idVendor}=="221a", ATTRS{idProduct}=="0100", MODE="0664", GROUP="plugdev"</pre>Then add your username to the plugdev group: <pre>$ sudo usermod -a -G plugdev YOUR-USERNAME</pre>And reset the udev system: <pre>$ sudo udevadm control --reload-rules</pre>Finally log out &amp; in again for the group change to take effect. You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].  == FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) == '''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2. First, you need to install the D2XX drivers &amp; python module. See the section [[#Optional_Packages]]. Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file <code>/etc/udev/rules.d/99-libftdi.rules</code> . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be: <pre>SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0664", GROUP="plugdev"ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", RUN+="/bin/sh -c 'echo $kernel &gt; /sys/bus/usb/drivers/ftdi_sio/unbind'"</pre>Then add your username to the plugdev group (if not already done): <pre>$ sudo usermod -a -G plugdev YOUR-USERNAME</pre>And reset the udev system: <pre>$ sudo udevadm control --reload-rules</pre>Finally log out &amp; in again for the group change to take effect. == Getting the AVR Toolchain ==Many of the tutorials use the AVR XMEGA microcontrollers as a target. In order to compile code for these targets, you'll need the AVR toolchain. This is easy to set up:<pre>sudo apt-get install avr-libc gcc-avr</pre> = MAC OS X = The following have been tested on Mac OS X Yosemite (10.10) - earlier versions may not have a recent enough Python installation (recommended 2.7.6 or later). It's possible to install other Python versions on your Mac OS X via the 'homebrew' system, we will use this for installing a few additional required tools. == Python Setup == <ol style="list-style-type: decimal;"><li>Ensure your user account has a password. In order for the 'sudo' command to work it requires you to type your password, so if you don't have one enabled be sure to set a temporary password now.</li><li><p>Install the 'homebrew' system, see [http://brew.sh brew.sh] for details. Briefly, you can install it by pasting the following in a terminal:</p><pre>$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</pre></li><li><p>Install PySide using homebrew:</p><pre>$ brew install pyside</pre><p>The install will probably print a message like this:</p><blockquote><p>[[File:Install_macosx_brewpath.png|image]]</p></blockquote><p>Note you must run that command in order to successfully import the modules, in this example it would be:</p><pre>$ mkdir -p /Users/macmini/Library/Python/2.7/lib/python/site-packages$ echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/macmini/Library/Python/2.7/lib/python/site-packages/homebrew.pth</pre></li></ol> == Working SciPy Distribution == You may need to upgrade your scipy from the base install, if you wish to do template attacks. This is not needed for other attacks, so please only proceed with the following if you receive an error that your version of scipy is too old. The easiest method is to use brew again:  brew install scipy You will also need to follow the instructions as above (inserting the link to the brew site-packages location). You will finally need to run the following:  brew link --overwrite numpy == AVR-GCC Install == You can easily use brew to install avr-gcc, as decribed at [https://github.com/osx-cross/homebrew-avr/ OSX-Cross Project]:
$ brew tap osx<!-cross/avr- {{CollapsibleSection |intro= === Quick Tests === $ brew install avr|content= Installing ChipWhisperer/Quick Tests}}--libc>
= Making sure that everything works =Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example[[Category: $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py  $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.py $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.pyThey should all work out of the box with the Chipwhisper Lite hardware.Introduction]]
Approved_users, administrator
366
edits

Navigation menu