<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.newae.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DavidRysk</id>
		<title>ChipWhisperer Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.newae.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DavidRysk"/>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/Special:Contributions/DavidRysk"/>
		<updated>2026-04-24T11:57:43Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.newae.com/index.php?title=V3:Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=3068</id>
		<title>V3:Tutorial B5-2 Breaking DES (Straightforward)</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=V3:Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=3068"/>
				<updated>2017-12-04T22:54:04Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox tutorial&lt;br /&gt;
|name                   = B5-2: Breaking DES (Straightforward)&lt;br /&gt;
|image                  = &lt;br /&gt;
|caption                = &lt;br /&gt;
|software versions      =&lt;br /&gt;
|capture hardware       = CW-Lite, CW-Lite 2-Part, CW-Pro&lt;br /&gt;
|Target Device          = &lt;br /&gt;
|Target Architecture    = XMEGA&lt;br /&gt;
|Hardware Crypto        = No&lt;br /&gt;
|Purchase Hardware      = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (e.g. chipwhisperer/hardware/victims/firmware/simpleserial-des/simpleserial-des-xmega.hex), instead;&lt;br /&gt;
&lt;br /&gt;
and:&lt;br /&gt;
* Setting an appropriate 'Total Samples' (e.g. 3500) and 'Offset' (e.g. 15500) in the ''Scope Settings'';&lt;br /&gt;
* Setting the 'Key Length (Bytes)', 'Input Length (Bytes)' and 'Output Length (Bytes)' to 8 bytes in the ''Target Settings'';&lt;br /&gt;
* Setting an appropriate 8 bytes Key in the ''Generic Settings (e.g. 2B 7E 15 16 28 AE D2 A6)''.&lt;br /&gt;
&lt;br /&gt;
* Or, alternatively, execute the script &amp;quot;ChipWhisperer-Lite: DES SimpleSerial on XMEGA&amp;quot; to do the above steps automatically in this platform.&lt;br /&gt;
&lt;br /&gt;
In the Analyzer, the only difference is to set the 'Crypto Algorithm' to DES in the ''Attack Settings''.&lt;br /&gt;
&lt;br /&gt;
[[File:breaking_des.png|896x896px]]&lt;br /&gt;
&lt;br /&gt;
Note that the attack attemps to recover the [[wikipedia:File:DES-key-schedule.png|first round key]], which only has 48bits ([[wikipedia:File:DES-f-function.png|8 s-boxes x 6 bits each]]), while the original key has 56 significative bits (64 if we count the parity bits that are irrelevant). So, if we map the first round key, obtained after the attack, to the original key (you can use the provided  DES Key Schedule Tool to do it), there will still be 8 bits missing (256 combinations).&lt;br /&gt;
&lt;br /&gt;
[[File:deskeyschedulecalc.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, it matches the original key that was:&lt;br /&gt;
&lt;br /&gt;
[[File:key_des.png|801x801px]]&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=3067</id>
		<title>Tutorial B5-2 Breaking DES (Straightforward)</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=3067"/>
				<updated>2017-12-04T22:53:51Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warningbox|This tutorial has been updated for ChipWhisperer 4.0.0 release. If you are using 3.x.x see the &amp;quot;V3&amp;quot; link in the sidebar.}}&lt;br /&gt;
&lt;br /&gt;
{{Infobox tutorial&lt;br /&gt;
|name                   = B5-2: Breaking DES (Straightforward)&lt;br /&gt;
|image                  = &lt;br /&gt;
|caption                = &lt;br /&gt;
|software versions      =&lt;br /&gt;
|capture hardware       = CW-Lite, CW-Lite 2-Part, CW-Pro&lt;br /&gt;
|Target Device          = &lt;br /&gt;
|Target Architecture    = XMEGA&lt;br /&gt;
|Hardware Crypto        = No&lt;br /&gt;
|Purchase Hardware      = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
# Flashing the DES firmware to the target device (e.g. chipwhisperer/hardware/victims/firmware/simpleserial-des/simpleserial-des-xmega.hex), instead;&lt;br /&gt;
# Setting an appropriate 'Total Samples' (e.g. 3500) and 'Offset' (e.g. 15500) in the ''Scope Settings'';&lt;br /&gt;
# Setting the 'Key Length (Bytes)', 'Input Length (Bytes)' and 'Output Length (Bytes)' to 8 bytes in the ''Target Settings'';&lt;br /&gt;
# Setting an appropriate 8 bytes Key in the ''Generic Settings (e.g. 2B 7E 15 16 28 AE D2 A6)''.&lt;br /&gt;
&lt;br /&gt;
* Or, alternatively, execute the script &amp;quot;setup_cwlite_xmega_des.py&amp;quot; to perform steps 2-4 (you still need to perform step 1 yourself).&lt;br /&gt;
&lt;br /&gt;
In the Analyzer, you'll need to modify the script to call the DES model instead of the AES model. This will mean:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.analyzer.attacks.models.DES import DES, SBox_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And setting:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
leak_model = DES(SBox_output)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the example analyzer script for a complete listing of the required commands.&lt;br /&gt;
&lt;br /&gt;
Note that the attack attemps to recover the [[wikipedia:File:DES-key-schedule.png|first round key]], which only has 48bits ([[wikipedia:File:DES-f-function.png|8 s-boxes x 6 bits each]]), while the original key has 56 significative bits (64 if we count the parity bits that are irrelevant). So, if we map the first round key, obtained after the attack, to the original key (you can use the provided  DES Key Schedule Tool to do it), there will still be 8 bits missing (256 combinations).&lt;br /&gt;
&lt;br /&gt;
[[File:deskeyschedulecalc.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, it matches the original key that was:&lt;br /&gt;
&lt;br /&gt;
[[File:key_des.png|801x801px]]&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=3066</id>
		<title>Installing ChipWhisperer/Required Tools - Mac OS X</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=3066"/>
				<updated>2017-11-23T03:32:17Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: add libusb to requirements&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Python &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install the 'homebrew' system, see [http://brew.sh brew.sh] for details. Briefly, you can install it by pasting the following in a terminal:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;As PySide is based on Qt 4, which is not officially supported by Homebrew, you will need to load the [https://github.com/cartr/homebrew-qt4 homebrew-qt4 tap]:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew tap cartr/qt4&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install PySide using homebrew:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew install pyside&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The install will probably print a message like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Install_macosx_brewpath.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note you must run that command in order to successfully import the modules, in this example it would be:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ mkdir -p /Users/macmini/Library/Python/2.7/lib/python/site-packages&lt;br /&gt;
$ echo 'import site; site.addsitedir(&amp;quot;/usr/local/lib/python2.7/site-packages&amp;quot;)' &amp;gt;&amp;gt; /Users/macmini/Library/Python/2.7/lib/python/site-packages/homebrew.pth&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; SciPy &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The easiest method is to use brew again:&lt;br /&gt;
&lt;br /&gt;
 brew install scipy&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 brew link --overwrite numpy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; libusb &amp;lt;/h2&amp;gt;&lt;br /&gt;
libusb is needed for the ChipWhisperer software to communicate with the board.&lt;br /&gt;
&lt;br /&gt;
Again, use brew:&lt;br /&gt;
&lt;br /&gt;
 brew install libusb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; AVR-GCC &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can easily use brew to install avr-gcc, as decribed at [https://github.com/osx-cross/homebrew-avr/ OSX-Cross Project]:&lt;br /&gt;
&lt;br /&gt;
 $ brew tap osx-cross/avr&lt;br /&gt;
 &lt;br /&gt;
 $ brew install avr-gcc&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=3001</id>
		<title>Installing ChipWhisperer/Required Tools - Mac OS X</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=3001"/>
				<updated>2017-10-26T01:17:58Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: avr-libc formula no longer exists, one can just install avr-gcc directly.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Python &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install the 'homebrew' system, see [http://brew.sh brew.sh] for details. Briefly, you can install it by pasting the following in a terminal:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;As PySide is based on Qt 4, which is not officially supported by Homebrew, you will need to load the [https://github.com/cartr/homebrew-qt4 homebrew-qt4 tap]:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew tap cartr/qt4&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install PySide using homebrew:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew install pyside&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The install will probably print a message like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Install_macosx_brewpath.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note you must run that command in order to successfully import the modules, in this example it would be:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ mkdir -p /Users/macmini/Library/Python/2.7/lib/python/site-packages&lt;br /&gt;
$ echo 'import site; site.addsitedir(&amp;quot;/usr/local/lib/python2.7/site-packages&amp;quot;)' &amp;gt;&amp;gt; /Users/macmini/Library/Python/2.7/lib/python/site-packages/homebrew.pth&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; SciPy &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The easiest method is to use brew again:&lt;br /&gt;
&lt;br /&gt;
 brew install scipy&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 brew link --overwrite numpy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; AVR-GCC &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can easily use brew to install avr-gcc, as decribed at [https://github.com/osx-cross/homebrew-avr/ OSX-Cross Project]:&lt;br /&gt;
&lt;br /&gt;
 $ brew tap osx-cross/avr&lt;br /&gt;
 &lt;br /&gt;
 $ brew install avr-gcc&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=2793</id>
		<title>Installing ChipWhisperer/Required Tools - Mac OS X</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer/Required_Tools_-_Mac_OS_X&amp;diff=2793"/>
				<updated>2017-08-01T01:31:55Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Add homebrew-qt4 tap step&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Python &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install the 'homebrew' system, see [http://brew.sh brew.sh] for details. Briefly, you can install it by pasting the following in a terminal:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;As PySide is based on Qt 4, which is not officially supported by Homebrew, you will need to load the [https://github.com/cartr/homebrew-qt4 homebrew-qt4 tap]:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew tap cartr/qt4&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Install PySide using homebrew:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ brew install pyside&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The install will probably print a message like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Install_macosx_brewpath.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note you must run that command in order to successfully import the modules, in this example it would be:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;$ mkdir -p /Users/macmini/Library/Python/2.7/lib/python/site-packages&lt;br /&gt;
$ echo 'import site; site.addsitedir(&amp;quot;/usr/local/lib/python2.7/site-packages&amp;quot;)' &amp;gt;&amp;gt; /Users/macmini/Library/Python/2.7/lib/python/site-packages/homebrew.pth&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; SciPy &amp;lt;/h2&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The easiest method is to use brew again:&lt;br /&gt;
&lt;br /&gt;
 brew install scipy&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 brew link --overwrite numpy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; AVR-GCC &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can easily use brew to install avr-gcc, as decribed at [https://github.com/osx-cross/homebrew-avr/ OSX-Cross Project]:&lt;br /&gt;
&lt;br /&gt;
 $ brew tap osx-cross/avr&lt;br /&gt;
 &lt;br /&gt;
 $ brew install avr-libc&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=2792</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=2792"/>
				<updated>2017-08-01T01:24:36Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Remove duplicate section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span class=&amp;quot;expandall&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page describes how to install the ChipWhisperer software. &lt;br /&gt;
&lt;br /&gt;
There are five ways to set up ChipWhisperer:&lt;br /&gt;
* '''VMWare Virtual Machine:''' Get a pre-prepared virtual machine image with all of the required tools already installed. ''Recommended for beginners.''&lt;br /&gt;
* '''Windows Installer''' Get a Windows binary that installs the ChipWhisperer repository to your computer. Does not include WinAVR compiler.&lt;br /&gt;
* '''ChipWhisperer Releases:''' Get a zip file with the latest stable ChipWhisperer code and run it on your own environment. &lt;br /&gt;
* '''PyPi Package:''' &amp;lt;code&amp;gt;pip install chipwhisperer&amp;lt;/code&amp;gt;. Only includes the software - doesn't come with the hardware source files, drivers, or example firmware.&lt;br /&gt;
* '''Git Repository:''' Get the latest, bleeding-edge features and bugs. Recommended if you're an experienced developer and you want to contribute to ChipWhisperer.&lt;br /&gt;
&lt;br /&gt;
{{TOC|limit=3}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Using VMWare Virtual Machine =&lt;br /&gt;
|content= Installing ChipWhisperer/Using VMWare Virtual Machine}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Automatic Windows Installer =&lt;br /&gt;
|content= Installing ChipWhisperer/Windows Installer}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Manual Install - Windows =&lt;br /&gt;
|content= Installing ChipWhisperer/Required Tools - Windows}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Manual Install - Linux =&lt;br /&gt;
|content= Installing ChipWhisperer/Required Tools - Linux}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Manual Install - Mac OS X =&lt;br /&gt;
|content= Installing ChipWhisperer/Required Tools - Mac OS X}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Installing ChipWhisperer from Releases =&lt;br /&gt;
|content= Installing ChipWhisperer/Installing ChipWhisperer from Releases}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Installing ChipWhisperer from PyPi =&lt;br /&gt;
|content= Installing ChipWhisperer/Installing ChipWhisperer from PyPi}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Installing ChipWhisperer from Git =&lt;br /&gt;
|content= Installing ChipWhisperer/Installing ChipWhisperer from Git}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro= = Quick Tests =&lt;br /&gt;
|content= Installing ChipWhisperer/Quick Tests}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Introduction]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2779</id>
		<title>Tutorial B3-1 Timing Analysis with Power for Password Bypass</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2779"/>
				<updated>2017-07-22T00:02:33Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Note output of print&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to breaking devices by determining when a device is performing certain operations. It will use a simple password check, and demonstrate how to perform a basic power analysis.&lt;br /&gt;
&lt;br /&gt;
In addition this example shows you how to drive the ChipWhisperer software with a script, rather than using the GUI. This will be required when attacking new devices which you have not yet added to the core ChipWhisperer software.&lt;br /&gt;
&lt;br /&gt;
Note this is not a prerequisite to the tutorial on breaking AES. You can skip this tutorial if you wish to go ahead with the AES tutorial.&lt;br /&gt;
&lt;br /&gt;
You can also view a 53-min [https://www.youtube.com/watch?v=h4eAU6vEONs&amp;amp;hd=1 Video Version on YouTube]:&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
&lt;br /&gt;
You should have already completed [[Tutorial B2 Viewing Instruction Power Differences]] to gain a better understanding of the ChipWhisperer interface.&lt;br /&gt;
&lt;br /&gt;
= Building the Target Firmware =&lt;br /&gt;
&lt;br /&gt;
The target firmware is located in the directory &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\basic-passwdcheck&amp;lt;/code&amp;gt;. Build the firmware using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;, once again being careful to ensure you are using the correct &amp;lt;code&amp;gt;PLATFORM=&amp;lt;/code&amp;gt; command. You should end up with something like this being printed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Creating Symbol Table: basic-passwdcheck.sym&lt;br /&gt;
avr-nm -n basic-passwdcheck.elf &amp;amp;gt; basic-passwdcheck.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    5400 bytes (3.9% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        524 bytes (6.4% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Manual Communications with the Target =&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to configure the target as in the previous tutorials. Rather than tediously going through the setup process again, we'll simply use one of the scripts built into the ChipWhisperer-Capture software. This will demonstrate how we can use a script as a starting point to simplify our setup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect your target hardware (ChipWhisperer-Lite/Pro or ChipWhisperer-Capture Rev 2 with target board).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the ChipWhisperer-Capture software.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Example Scripts'', select one which most closely matches your hardware. For example here I'm using a ChipWhisperer-Lite with the XMEGA target, so will select the &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot; script. Note I'm ''NOT'' attacking AES, so will need to make some adjustments later. (The &amp;quot;Timing Attack on CW-Lite (XMEGA)&amp;quot; script already does most of this for us, so using it would defeat the purpose of this tutorial.)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system should connect to your hardware. Remember you have not yet reprogrammed the target so won't be communicating with the target program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using the programming tool (such as XMEGA programming dialog), program the file &amp;lt;code&amp;gt;basic-passwdcheck.hex&amp;lt;/code&amp;gt; into the target device. This file is located where you ran &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Select ''Tools --&amp;gt; Terminal'', and press ''Connect''. You should see a window such as this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Termconn.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point we need to reset the target device. The easiest way to do this is use the programmer interface, and press the ''Check Signature'' or ''Read Signature'' button. This will reset the target device as part of the signature read operation. You should see some messages come across the terminal emulator window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Checksig_print.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Note a few warnings about the terminal emulator:&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The on-board buffer is fairly small, and can be easily overflowed. You may notice a few longer lines become trunicated if printing is too fast!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can uncheck the &amp;amp;quot;Show non-ASCII as hex&amp;amp;quot; to avoid having the &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; printed in red. The &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; is the hex character for a newline. Many protocols use non-ASCII characters, so to help with debugging it is left enabled by default.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/dd&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We've now got some super-secure system! Let's begin with some exploratory tests - in this case I happened to know the correct password is &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''tip'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In real systems, you may often know ''one'' of the passwords, which is sufficient to investigate the password checking routines as we will do. You also normally have an ability to reset passwords to default. While the reset procedure would erase any data you care about, the attacker will be able to use this 'sacrificial' device to learn about possible vulnerabilites. So the assumption that we have access to the password is really just saying we have access to ''a'' password, and will use that knowledge to break the system in general.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the terminal emulator, write the correct password in, and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt;. You should be greeted by a welcome message, and if using the CW-Lite XMEGA target the green LED will illuminate:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Passok.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system enters an infinite loop for any password entry. Thus you must reset the system, use the ''Programmer Window'' to again perform a ''Check Signature'' or ''Read Signature'' operation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter an incorrect password - notice a different message is printed, and if using the CW-Lite XMEGA target the red LED will come on.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Recording Power Traces =&lt;br /&gt;
Now that we can communicate with our super-secure system, our next goal is to get a power trace while the target is running. To do this, we'll get the power measurements to trigger after we send our password to the target. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We'll make some changes to the trigger setup of the ChipWhisperer (on the ''Scope Settings'' tab). In particular, ensure you set the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Offset = 0&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Timeout set to 5 seconds or greater (to give yourself time when manually testing)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Timeout_offset.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change to the ''Target Settings'' tab, and delete the ''Command'' strings. Those strings are used in the AES attack to send a specific command to the target device. For now we will be manually sending data:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Text_targetsettings.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the ''Target Settings'' tab, under ''Protocol Version'', change ''Version'' from ''Auto'' to ''1.0''&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter the password &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt; in the terminal window, but ''do not'' yet hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button, and immediately switch to the terminal emulator window and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt; to send the password.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You must send the password before the timeout occurs -- you can increase the length of the timeout if needed to give yourself more time! If this works you should see the power consumption displayed in the GUI:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Trace_manual_pass.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rather than using the manual terminal, let's now use the GUI to automatically send a password try. Switching back to the ''Target Settings'' tab, write &amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt; into the ''Go Command'' option:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Gocorrect.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Go Command'' is sent right after the scope is armed. In this example it means we can capture the power consumption during the password entry phase.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Now perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Hopefully this resulted in the same waveform as before! Note the device takes around 1 second to 'boot', so if you are too lightning fast after resetting the device it won't actually be ready to accept the password. You can keep the terminal emulator window open to view the output data.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Play around with the password entered on the ''Go Command'' - try all of the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px4\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0paa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;haaaa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;a\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You should notice a distinct change in the password depending how many characters were correct. For example the following shows the difference between passwords of &amp;lt;code&amp;gt;h0px4&amp;lt;/code&amp;gt; (which has 4 correct characters) and &amp;lt;code&amp;gt;h0paa&amp;lt;/code&amp;gt; (which has 3 correct characters):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:3vs4.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Automatic Resets =&lt;br /&gt;
The last step before scripting an entire attack is to figure out how to automatically reset the target device before (or after) each capture. There are two ways to do this, and the following steps take you through two examples of how to accomplish this goal.&lt;br /&gt;
&lt;br /&gt;
== Reset via Spare IO Lines ==&lt;br /&gt;
&lt;br /&gt;
TODO - see reset via programming interface for now&lt;br /&gt;
&lt;br /&gt;
== Reset via Auxiliary Module ==&lt;br /&gt;
&lt;br /&gt;
Auxiliary modules are small pieces of code that can perform some extra functions during the capture process. The functions inside these Python modules are run before a capture, before the power measurement is armed, before the measurement is triggered, after a single trace is completed, and after an entire capture is finished. We will use an existing auxiliary module to reset the target chip before arming the measurement so that we don't have to manually reset the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; We're going to use the ''Reset AVR/XMEGA via CW-Lite'' auxiliary module. Let's get an idea of how this module works: &lt;br /&gt;
* Navigate to the auxiliary modules folder (&amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\auxiliary\&amp;lt;/code&amp;gt;) and open &amp;lt;code&amp;gt;ResetCW1183Read.py&amp;lt;/code&amp;gt; in your choice of text editor.&lt;br /&gt;
* Find the function definition for &amp;lt;code&amp;gt;resetDevice()&amp;lt;/code&amp;gt;. It contains a line that looks like: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CWCoreAPI.getInstance().getScope().scopetype.cwliteXMEGA.readSignature()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Look for the lines where this function gets called. You'll find that the function &amp;lt;code&amp;gt;traceArm()&amp;lt;/code&amp;gt; uses it like:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resettiming = self.findParam('resettiming').value()&lt;br /&gt;
if resettiming == 'Pre-Arm':&lt;br /&gt;
    self.resetDevice()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Effectively, this code will read the target's signature before we arm the power measurement. This means that the target will automatically be reset before capturing a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Go back to the ChipWhisperer Capture software. In the ''Generic Settings'' tab, switch the Auxiliary Module to ''Reset AVR/XMEGA via CW-Lite''.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Now, in the ''Aux Settings'' tab, we can configure our automatic reset. Make sure the settings are:&lt;br /&gt;
* Pre-arm delay: roughly 1200 ms&lt;br /&gt;
* Post-arm delay: the default (0 ms) is fine&lt;br /&gt;
* Reset timing: Pre-arm (reset the device before we arm the scope)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Press ''Capture 1''. The target will automatically reset, with the Safe-o-matic 3000 boot sequence appearing in the console. Then, 1 second later, the program will send the password to the target and record a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, confirm that you can try different passwords (in ''Target Settings'') and see how the power trace changes when your password has 0, 1, 2... correct characters.&lt;br /&gt;
&lt;br /&gt;
= Performing the Timing Attack =&lt;br /&gt;
So far, we've set up our ChipWhisperer to automatically reset the target, send it a password attempt of our choice, and record a power trace while the target processes the password. Now, we'll write a Python script to automatically try different passwords and use these power traces to discover the password stored on the target.&lt;br /&gt;
&lt;br /&gt;
== Scripting the Setup ==&lt;br /&gt;
Our first step will be to write a script that automatically sets up the ChipWhisperer Capture software with all of the settings we've tested above. We'll do this by modifying an existing script with our own settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a copy of an existing ChipWhisperer script. The example scripts are located at &amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\scripts&amp;lt;/code&amp;gt;; for example, the default one for the XMEGA device is called &amp;lt;code&amp;gt;cwlite-simpleserialxmega.py&amp;lt;/code&amp;gt;. Make a copy of this script and put it somewhere memorable.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rename the script something else - for example, &amp;lt;code&amp;gt;cwlite-passwordcrack.py&amp;lt;/code&amp;gt; - and open it for editing. You'll notice that a large chunk of the code is used to set the parameters:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Total Samples', 3000],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Offset', 1500],&lt;br /&gt;
              ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Those parameters come from the ''Scripting Parameters'' tab. Switch over to it and notice this tab logs all of the parameter changes, showing you how to change the parameters through the API:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Scriptcommands.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note that commands run via the script are also printed, so you can see where the values being set are coming from too. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point, close the ''ChipWhisperer-Capture'' window so we can confirm the script still works. Run the new script (which doesn't have any changes yet) from the command line. You may have to open a console with Python in the path:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you installed WinPython, run the ''WinPython Console'' from your WinPython installation directory.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If using the VMWare image of a Linux machine, this should just be a regular console&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Run the script with &amp;lt;code&amp;gt;python cwlite-passwordcrack.py&amp;lt;/code&amp;gt;. If the script errors out, it might be that the location of the FPGA bitstream is stored in relative terms. To fix this perform the following:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open ChipWhisperer-Capture regularly.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run the ChipWhisperer script that you used previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Select ''Tools--&amp;amp;gt;Config CW Firmware''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the &amp;amp;quot;FPGA .zip (Release)&amp;amp;quot;, hit the &amp;amp;quot;Find&amp;amp;quot; button. Point the system to the file &amp;lt;code&amp;gt;chipwhisperer/hardware/capture/chipwhisperer-lite/cwlite_firmware.zip&amp;lt;/code&amp;gt; on your filesystem. Note by default there is a relative path.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Once again on the ''Target Settings'' tab, delete the various commands. Make a note of the resulting ''Script Commands'' which you will need to enter to achieve this same goal. Close ChipWhisperer-Capture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Continue editing your script. First, find the line setting the Trigger Offset:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 1500],&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;And set this to 0, which we were using previously:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 0],&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Next, append the required commands to clear the simpleserial commands and to enable the automatic resets:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ...BUNCH MORE COMMANDS HERE HAVE BEEN REMOVED...&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
&lt;br /&gt;
              #Append your commands here&lt;br /&gt;
              ['Simple Serial', 'Load Key Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Go Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Output Format', u''],   &lt;br /&gt;
&lt;br /&gt;
              ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
              ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],                   &lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will set the password. You can enter the password in the Capture ''Target Settings'' tab, and see the following sort of call would set the appropriate password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;self.api.setParameter(['Simple Serial', 'Go Command', u'h0px3\\n'])&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note the newline is actually escaped, to set the text equivalent of what will be printed. This will result in an actual newline going out across the serial port. Set that command at some point in your script.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Close any open ChipWhisperer-Capture windows, and run the script as before. You should connect to the target, and be able to press ''Capture 1'' and see the correct waveform.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running a Single Capture ==&lt;br /&gt;
With our settings prepared, the next step is to use our script to record and analyze a power trace. We need to be able to get the trace data into our Python script so we can analyze it for the timing attack.&lt;br /&gt;
&lt;br /&gt;
The API allows us to ''press the Capture 1'' button and ''view the power trace'' without using the GUI. There are two relevant commands here:&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.capture1()&amp;lt;/code&amp;gt; acts as if we've just pressed the ''Capture 1'' button;&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.getScope().channels[0].getTrace()&amp;lt;/code&amp;gt; returns a list of datapoints that were recorded in the previous capture.&lt;br /&gt;
We want to test these two commands. After the setup portion of your script, add some code similar to the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self.api.capture1()&lt;br /&gt;
data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Run your script. The ChipWhisperer should automatically capture one trace and print out the several thousand datapoints. (Note that output of &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt; statements may go to the ''Debug Logging'' tab in the GUI.) This is all we need to continue.&lt;br /&gt;
&lt;br /&gt;
== Attacking a Single Letter ==&lt;br /&gt;
Now that we can record one power trace, we can start the timing attack. Our goal here is to automatically find the first letter of the Super Secret (tm) password.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Look at this example of the power traces when 0 and 1 bytes are correct. We can see a clear point that appears to shift forward in time:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Passwordcrackerpts.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When we guess the first byte incorrectly, there is a distinct power spike at sample number 153. However, when we guess correctly, the target spends more time processing the password, and this spike moves 72 samples forward. This means that we can check if our first byte is correct by checking this data point: if we're right, it will have an amplitude greater than -0.2. Note the specific point will change for different hardware, and may also change if you use different versions of avr-gcc to compile the target code. The example code here was compiled with WinAVR 20100110, which has avr-gcc 4.3.3. If you view the video version of this tutorial the point numbers are different for example, so be sure to check what they are for your specific system.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Add a loop to your script that does the following:&lt;br /&gt;
* Sets the ''Go Command'' to the next character we want to try&lt;br /&gt;
* Captures a power trace&lt;br /&gt;
* Checks if sample 153 is above -0.2 (fill in the appropriate numbers here)&lt;br /&gt;
* Repeats for all characters we want to try&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
&lt;br /&gt;
for c in trylist:&lt;br /&gt;
    # Test this password and record a power trace&lt;br /&gt;
    self.api.setParameter(['Simple Serial', 'Go Command', c + '\n'])&lt;br /&gt;
    self.api.capture1()&lt;br /&gt;
    &lt;br /&gt;
    # Get the data and check data[153]&lt;br /&gt;
    data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
    if data[153] &amp;gt; -0.2:&lt;br /&gt;
        print &amp;quot;Success: &amp;quot; + c          &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This script will eventually stop, but you can use Ctrl+C on the command line to kill it. Make sure your script prints &amp;quot;Success: h&amp;quot;!&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Attacking the Full Password ==&lt;br /&gt;
The last step is to attack the entire password, one letter at a time. The procedure to do this is:&lt;br /&gt;
* Start with a blank password string&lt;br /&gt;
* Loop through all of the characters we want to try:&lt;br /&gt;
** Add the next character to the end of the password&lt;br /&gt;
** Test this new candidate password using code similar to the above&lt;br /&gt;
** If the new password is correct up to character (1, 2, ..., 5), add it to the end of the password&lt;br /&gt;
* Repeat until we've cracked all 5 characters.&lt;br /&gt;
&lt;br /&gt;
Note that the point of interest is no longer at sample 153. We noticed earlier that this key point moves 72 samples forward for every correct character, so we'll have to check location &amp;lt;code&amp;gt;153&amp;lt;/code&amp;gt; for character 0, &amp;lt;code&amp;gt;153 + 72&amp;lt;/code&amp;gt; for character 1, and &amp;lt;code&amp;gt;153 + i*72&amp;lt;/code&amp;gt; for character &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
password = ''&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
  &lt;br /&gt;
for i in range(5):&lt;br /&gt;
    for c in trylist:&lt;br /&gt;
        # Get a power trace using our next attempt&lt;br /&gt;
        nextPass = password + '{}'.format(c)&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        &lt;br /&gt;
        # Grab the trace&lt;br /&gt;
        nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        &lt;br /&gt;
        # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
        if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
            continue&lt;br /&gt;
            &lt;br /&gt;
        # If we got here, we've found the right letter&lt;br /&gt;
        password += c&lt;br /&gt;
        print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
        break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After some time, this prints &amp;lt;code&amp;gt;5 characters: h0px3&amp;lt;/code&amp;gt; -- it automatically finds the correct password.&lt;br /&gt;
&lt;br /&gt;
That's it! You should have successfully cracked a password using the timing attack. Some notes on this method:&lt;br /&gt;
&lt;br /&gt;
* The target device has a finite start-up time, which slows down the attack. If you wish, remove some of the printf()'s from the target code, recompile and reprogram, and see how quickly you can do this attack.&lt;br /&gt;
* The current script doesn't look for the &amp;amp;quot;WELCOME&amp;amp;quot; message when the password is OK. That is an extension that allows it to crack any size password.&lt;br /&gt;
* If there was a lock-out on a wrong password, the system would ignore it, as it resets the target after every attempt.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
This tutorial has demonstrated the use of the power side-channel for performing timing attacks. A target with a simple password-based security system is broken. In addition you have learned about the scripting support in the ChipWhisperer-Capture software.&lt;br /&gt;
&lt;br /&gt;
= Appendix: Completed Timing Attack Script =&lt;br /&gt;
The &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt; function at the end of the tutorial might look something like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # This is the function that gets called when our script starts&lt;br /&gt;
        &lt;br /&gt;
        # First: set up the basics and connect to the CW-Lite&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Scope Module', 'ChipWhisperer/OpenADC'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Target Module', 'Simple Serial'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Trace Format', 'ChipWhisperer/Native'])&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.setParameter(['ChipWhisperer/OpenADC', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Next: set up everything we need to connect to the target&lt;br /&gt;
        # Put all of our commands in a list and execute them at the end&lt;br /&gt;
        lstexample = [&lt;br /&gt;
                      # Gain&lt;br /&gt;
                      ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
                      # Trigger&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Offset', 0],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Total Samples', 2000],&lt;br /&gt;
                      # Clock&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
                      # Pins&lt;br /&gt;
                      ['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
                      ['CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
                      # Automatic commands&lt;br /&gt;
                      ['Simple Serial', 'Load Key Command', ''],&lt;br /&gt;
                      ['Simple Serial', 'Go Command', 'h0px3\n'],&lt;br /&gt;
                      ['Simple Serial', 'Output Format', ''],&lt;br /&gt;
                      # Auto-reset&lt;br /&gt;
                      ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
                      ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],&lt;br /&gt;
                      ]&lt;br /&gt;
        &lt;br /&gt;
        #Download all hardware setup parameters&lt;br /&gt;
        for cmd in lstexample: &lt;br /&gt;
            self.api.setParameter(cmd)&lt;br /&gt;
                       &lt;br /&gt;
        # Get one capture for fun&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        print data&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Crack the first letter&lt;br /&gt;
        password = ''&lt;br /&gt;
        trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
          &lt;br /&gt;
        for i in range(5):&lt;br /&gt;
            for c in trylist:&lt;br /&gt;
                # Get a power trace using our next attempt&lt;br /&gt;
                nextPass = password + '{}'.format(c)&lt;br /&gt;
                self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
                self.api.capture1()&lt;br /&gt;
                &lt;br /&gt;
                # Grab the trace&lt;br /&gt;
                nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
                &lt;br /&gt;
                # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
                if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
                    continue&lt;br /&gt;
                    &lt;br /&gt;
                # If we got here, we've found the right letter&lt;br /&gt;
                password += c&lt;br /&gt;
                print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
                break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2778</id>
		<title>Tutorial B3-1 Timing Analysis with Power for Password Bypass</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2778"/>
				<updated>2017-07-21T23:20:18Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: minor grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to breaking devices by determining when a device is performing certain operations. It will use a simple password check, and demonstrate how to perform a basic power analysis.&lt;br /&gt;
&lt;br /&gt;
In addition this example shows you how to drive the ChipWhisperer software with a script, rather than using the GUI. This will be required when attacking new devices which you have not yet added to the core ChipWhisperer software.&lt;br /&gt;
&lt;br /&gt;
Note this is not a prerequisite to the tutorial on breaking AES. You can skip this tutorial if you wish to go ahead with the AES tutorial.&lt;br /&gt;
&lt;br /&gt;
You can also view a 53-min [https://www.youtube.com/watch?v=h4eAU6vEONs&amp;amp;hd=1 Video Version on YouTube]:&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
&lt;br /&gt;
You should have already completed [[Tutorial B2 Viewing Instruction Power Differences]] to gain a better understanding of the ChipWhisperer interface.&lt;br /&gt;
&lt;br /&gt;
= Building the Target Firmware =&lt;br /&gt;
&lt;br /&gt;
The target firmware is located in the directory &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\basic-passwdcheck&amp;lt;/code&amp;gt;. Build the firmware using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;, once again being careful to ensure you are using the correct &amp;lt;code&amp;gt;PLATFORM=&amp;lt;/code&amp;gt; command. You should end up with something like this being printed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Creating Symbol Table: basic-passwdcheck.sym&lt;br /&gt;
avr-nm -n basic-passwdcheck.elf &amp;amp;gt; basic-passwdcheck.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    5400 bytes (3.9% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        524 bytes (6.4% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Manual Communications with the Target =&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to configure the target as in the previous tutorials. Rather than tediously going through the setup process again, we'll simply use one of the scripts built into the ChipWhisperer-Capture software. This will demonstrate how we can use a script as a starting point to simplify our setup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect your target hardware (ChipWhisperer-Lite/Pro or ChipWhisperer-Capture Rev 2 with target board).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the ChipWhisperer-Capture software.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Example Scripts'', select one which most closely matches your hardware. For example here I'm using a ChipWhisperer-Lite with the XMEGA target, so will select the &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot; script. Note I'm ''NOT'' attacking AES, so will need to make some adjustments later. (The &amp;quot;Timing Attack on CW-Lite (XMEGA)&amp;quot; script already does most of this for us, so using it would defeat the purpose of this tutorial.)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system should connect to your hardware. Remember you have not yet reprogrammed the target so won't be communicating with the target program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using the programming tool (such as XMEGA programming dialog), program the file &amp;lt;code&amp;gt;basic-passwdcheck.hex&amp;lt;/code&amp;gt; into the target device. This file is located where you ran &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Select ''Tools --&amp;gt; Terminal'', and press ''Connect''. You should see a window such as this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Termconn.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point we need to reset the target device. The easiest way to do this is use the programmer interface, and press the ''Check Signature'' or ''Read Signature'' button. This will reset the target device as part of the signature read operation. You should see some messages come across the terminal emulator window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Checksig_print.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Note a few warnings about the terminal emulator:&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The on-board buffer is fairly small, and can be easily overflowed. You may notice a few longer lines become trunicated if printing is too fast!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can uncheck the &amp;amp;quot;Show non-ASCII as hex&amp;amp;quot; to avoid having the &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; printed in red. The &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; is the hex character for a newline. Many protocols use non-ASCII characters, so to help with debugging it is left enabled by default.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/dd&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We've now got some super-secure system! Let's begin with some exploratory tests - in this case I happened to know the correct password is &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''tip'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In real systems, you may often know ''one'' of the passwords, which is sufficient to investigate the password checking routines as we will do. You also normally have an ability to reset passwords to default. While the reset procedure would erase any data you care about, the attacker will be able to use this 'sacrificial' device to learn about possible vulnerabilites. So the assumption that we have access to the password is really just saying we have access to ''a'' password, and will use that knowledge to break the system in general.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the terminal emulator, write the correct password in, and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt;. You should be greeted by a welcome message, and if using the CW-Lite XMEGA target the green LED will illuminate:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Passok.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system enters an infinite loop for any password entry. Thus you must reset the system, use the ''Programmer Window'' to again perform a ''Check Signature'' or ''Read Signature'' operation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter an incorrect password - notice a different message is printed, and if using the CW-Lite XMEGA target the red LED will come on.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Recording Power Traces =&lt;br /&gt;
Now that we can communicate with our super-secure system, our next goal is to get a power trace while the target is running. To do this, we'll get the power measurements to trigger after we send our password to the target. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We'll make some changes to the trigger setup of the ChipWhisperer (on the ''Scope Settings'' tab). In particular, ensure you set the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Offset = 0&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Timeout set to 5 seconds or greater (to give yourself time when manually testing)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Timeout_offset.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change to the ''Target Settings'' tab, and delete the ''Command'' strings. Those strings are used in the AES attack to send a specific command to the target device. For now we will be manually sending data:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Text_targetsettings.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the ''Target Settings'' tab, under ''Protocol Version'', change ''Version'' from ''Auto'' to ''1.0''&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter the password &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt; in the terminal window, but ''do not'' yet hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button, and immediately switch to the terminal emulator window and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt; to send the password.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You must send the password before the timeout occurs -- you can increase the length of the timeout if needed to give yourself more time! If this works you should see the power consumption displayed in the GUI:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Trace_manual_pass.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rather than using the manual terminal, let's now use the GUI to automatically send a password try. Switching back to the ''Target Settings'' tab, write &amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt; into the ''Go Command'' option:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Gocorrect.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Go Command'' is sent right after the scope is armed. In this example it means we can capture the power consumption during the password entry phase.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Now perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Hopefully this resulted in the same waveform as before! Note the device takes around 1 second to 'boot', so if you are too lightning fast after resetting the device it won't actually be ready to accept the password. You can keep the terminal emulator window open to view the output data.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Play around with the password entered on the ''Go Command'' - try all of the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px4\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0paa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;haaaa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;a\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You should notice a distinct change in the password depending how many characters were correct. For example the following shows the difference between passwords of &amp;lt;code&amp;gt;h0px4&amp;lt;/code&amp;gt; (which has 4 correct characters) and &amp;lt;code&amp;gt;h0paa&amp;lt;/code&amp;gt; (which has 3 correct characters):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:3vs4.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Automatic Resets =&lt;br /&gt;
The last step before scripting an entire attack is to figure out how to automatically reset the target device before (or after) each capture. There are two ways to do this, and the following steps take you through two examples of how to accomplish this goal.&lt;br /&gt;
&lt;br /&gt;
== Reset via Spare IO Lines ==&lt;br /&gt;
&lt;br /&gt;
TODO - see reset via programming interface for now&lt;br /&gt;
&lt;br /&gt;
== Reset via Auxiliary Module ==&lt;br /&gt;
&lt;br /&gt;
Auxiliary modules are small pieces of code that can perform some extra functions during the capture process. The functions inside these Python modules are run before a capture, before the power measurement is armed, before the measurement is triggered, after a single trace is completed, and after an entire capture is finished. We will use an existing auxiliary module to reset the target chip before arming the measurement so that we don't have to manually reset the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; We're going to use the ''Reset AVR/XMEGA via CW-Lite'' auxiliary module. Let's get an idea of how this module works: &lt;br /&gt;
* Navigate to the auxiliary modules folder (&amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\auxiliary\&amp;lt;/code&amp;gt;) and open &amp;lt;code&amp;gt;ResetCW1183Read.py&amp;lt;/code&amp;gt; in your choice of text editor.&lt;br /&gt;
* Find the function definition for &amp;lt;code&amp;gt;resetDevice()&amp;lt;/code&amp;gt;. It contains a line that looks like: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CWCoreAPI.getInstance().getScope().scopetype.cwliteXMEGA.readSignature()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Look for the lines where this function gets called. You'll find that the function &amp;lt;code&amp;gt;traceArm()&amp;lt;/code&amp;gt; uses it like:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resettiming = self.findParam('resettiming').value()&lt;br /&gt;
if resettiming == 'Pre-Arm':&lt;br /&gt;
    self.resetDevice()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Effectively, this code will read the target's signature before we arm the power measurement. This means that the target will automatically be reset before capturing a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Go back to the ChipWhisperer Capture software. In the ''Generic Settings'' tab, switch the Auxiliary Module to ''Reset AVR/XMEGA via CW-Lite''.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Now, in the ''Aux Settings'' tab, we can configure our automatic reset. Make sure the settings are:&lt;br /&gt;
* Pre-arm delay: roughly 1200 ms&lt;br /&gt;
* Post-arm delay: the default (0 ms) is fine&lt;br /&gt;
* Reset timing: Pre-arm (reset the device before we arm the scope)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Press ''Capture 1''. The target will automatically reset, with the Safe-o-matic 3000 boot sequence appearing in the console. Then, 1 second later, the program will send the password to the target and record a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, confirm that you can try different passwords (in ''Target Settings'') and see how the power trace changes when your password has 0, 1, 2... correct characters.&lt;br /&gt;
&lt;br /&gt;
= Performing the Timing Attack =&lt;br /&gt;
So far, we've set up our ChipWhisperer to automatically reset the target, send it a password attempt of our choice, and record a power trace while the target processes the password. Now, we'll write a Python script to automatically try different passwords and use these power traces to discover the password stored on the target.&lt;br /&gt;
&lt;br /&gt;
== Scripting the Setup ==&lt;br /&gt;
Our first step will be to write a script that automatically sets up the ChipWhisperer Capture software with all of the settings we've tested above. We'll do this by modifying an existing script with our own settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a copy of an existing ChipWhisperer script. The example scripts are located at &amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\scripts&amp;lt;/code&amp;gt;; for example, the default one for the XMEGA device is called &amp;lt;code&amp;gt;cwlite-simpleserialxmega.py&amp;lt;/code&amp;gt;. Make a copy of this script and put it somewhere memorable.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rename the script something else - for example, &amp;lt;code&amp;gt;cwlite-passwordcrack.py&amp;lt;/code&amp;gt; - and open it for editing. You'll notice that a large chunk of the code is used to set the parameters:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Total Samples', 3000],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Offset', 1500],&lt;br /&gt;
              ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Those parameters come from the ''Scripting Parameters'' tab. Switch over to it and notice this tab logs all of the parameter changes, showing you how to change the parameters through the API:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Scriptcommands.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note that commands run via the script are also printed, so you can see where the values being set are coming from too. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point, close the ''ChipWhisperer-Capture'' window so we can confirm the script still works. Run the new script (which doesn't have any changes yet) from the command line. You may have to open a console with Python in the path:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you installed WinPython, run the ''WinPython Console'' from your WinPython installation directory.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If using the VMWare image of a Linux machine, this should just be a regular console&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Run the script with &amp;lt;code&amp;gt;python cwlite-passwordcrack.py&amp;lt;/code&amp;gt;. If the script errors out, it might be that the location of the FPGA bitstream is stored in relative terms. To fix this perform the following:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open ChipWhisperer-Capture regularly.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run the ChipWhisperer script that you used previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Select ''Tools--&amp;amp;gt;Config CW Firmware''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the &amp;amp;quot;FPGA .zip (Release)&amp;amp;quot;, hit the &amp;amp;quot;Find&amp;amp;quot; button. Point the system to the file &amp;lt;code&amp;gt;chipwhisperer/hardware/capture/chipwhisperer-lite/cwlite_firmware.zip&amp;lt;/code&amp;gt; on your filesystem. Note by default there is a relative path.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Once again on the ''Target Settings'' tab, delete the various commands. Make a note of the resulting ''Script Commands'' which you will need to enter to achieve this same goal. Close ChipWhisperer-Capture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Continue editing your script. First, find the line setting the Trigger Offset:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 1500],&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;And set this to 0, which we were using previously:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 0],&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Next, append the required commands to clear the simpleserial commands and to enable the automatic resets:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ...BUNCH MORE COMMANDS HERE HAVE BEEN REMOVED...&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
&lt;br /&gt;
              #Append your commands here&lt;br /&gt;
              ['Simple Serial', 'Load Key Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Go Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Output Format', u''],   &lt;br /&gt;
&lt;br /&gt;
              ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
              ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],                   &lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will set the password. You can enter the password in the Capture ''Target Settings'' tab, and see the following sort of call would set the appropriate password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;self.api.setParameter(['Simple Serial', 'Go Command', u'h0px3\\n'])&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note the newline is actually escaped, to set the text equivalent of what will be printed. This will result in an actual newline going out across the serial port. Set that command at some point in your script.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Close any open ChipWhisperer-Capture windows, and run the script as before. You should connect to the target, and be able to press ''Capture 1'' and see the correct waveform.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running a Single Capture ==&lt;br /&gt;
With our settings prepared, the next step is to use our script to record and analyze a power trace. We need to be able to get the trace data into our Python script so we can analyze it for the timing attack.&lt;br /&gt;
&lt;br /&gt;
The API allows us to ''press the Capture 1'' button and ''view the power trace'' without using the GUI. There are two relevant commands here:&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.capture1()&amp;lt;/code&amp;gt; acts as if we've just pressed the ''Capture 1'' button;&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.getScope().channels[0].getTrace()&amp;lt;/code&amp;gt; returns a list of datapoints that were recorded in the previous capture.&lt;br /&gt;
We want to test these two commands. After the setup portion of your script, add some code similar to the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self.api.capture1()&lt;br /&gt;
data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Run your script. The ChipWhisperer should automatically capture one trace and print out the several thousand datapoints. This is all we need to continue.&lt;br /&gt;
&lt;br /&gt;
== Attacking a Single Letter ==&lt;br /&gt;
Now that we can record one power trace, we can start the timing attack. Our goal here is to automatically find the first letter of the Super Secret (tm) password.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Look at this example of the power traces when 0 and 1 bytes are correct. We can see a clear point that appears to shift forward in time:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Passwordcrackerpts.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When we guess the first byte incorrectly, there is a distinct power spike at sample number 153. However, when we guess correctly, the target spends more time processing the password, and this spike moves 72 samples forward. This means that we can check if our first byte is correct by checking this data point: if we're right, it will have an amplitude greater than -0.2. Note the specific point will change for different hardware, and may also change if you use different versions of avr-gcc to compile the target code. The example code here was compiled with WinAVR 20100110, which has avr-gcc 4.3.3. If you view the video version of this tutorial the point numbers are different for example, so be sure to check what they are for your specific system.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Add a loop to your script that does the following:&lt;br /&gt;
* Sets the ''Go Command'' to the next character we want to try&lt;br /&gt;
* Captures a power trace&lt;br /&gt;
* Checks if sample 153 is above -0.2 (fill in the appropriate numbers here)&lt;br /&gt;
* Repeats for all characters we want to try&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
&lt;br /&gt;
for c in trylist:&lt;br /&gt;
    # Test this password and record a power trace&lt;br /&gt;
    self.api.setParameter(['Simple Serial', 'Go Command', c + '\n'])&lt;br /&gt;
    self.api.capture1()&lt;br /&gt;
    &lt;br /&gt;
    # Get the data and check data[153]&lt;br /&gt;
    data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
    if data[153] &amp;gt; -0.2:&lt;br /&gt;
        print &amp;quot;Success: &amp;quot; + c          &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This script will eventually stop, but you can use Ctrl+C on the command line to kill it. Make sure your script prints &amp;quot;Success: h&amp;quot;!&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Attacking the Full Password ==&lt;br /&gt;
The last step is to attack the entire password, one letter at a time. The procedure to do this is:&lt;br /&gt;
* Start with a blank password string&lt;br /&gt;
* Loop through all of the characters we want to try:&lt;br /&gt;
** Add the next character to the end of the password&lt;br /&gt;
** Test this new candidate password using code similar to the above&lt;br /&gt;
** If the new password is correct up to character (1, 2, ..., 5), add it to the end of the password&lt;br /&gt;
* Repeat until we've cracked all 5 characters.&lt;br /&gt;
&lt;br /&gt;
Note that the point of interest is no longer at sample 153. We noticed earlier that this key point moves 72 samples forward for every correct character, so we'll have to check location &amp;lt;code&amp;gt;153&amp;lt;/code&amp;gt; for character 0, &amp;lt;code&amp;gt;153 + 72&amp;lt;/code&amp;gt; for character 1, and &amp;lt;code&amp;gt;153 + i*72&amp;lt;/code&amp;gt; for character &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
password = ''&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
  &lt;br /&gt;
for i in range(5):&lt;br /&gt;
    for c in trylist:&lt;br /&gt;
        # Get a power trace using our next attempt&lt;br /&gt;
        nextPass = password + '{}'.format(c)&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        &lt;br /&gt;
        # Grab the trace&lt;br /&gt;
        nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        &lt;br /&gt;
        # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
        if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
            continue&lt;br /&gt;
            &lt;br /&gt;
        # If we got here, we've found the right letter&lt;br /&gt;
        password += c&lt;br /&gt;
        print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
        break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After some time, this prints &amp;lt;code&amp;gt;5 characters: h0px3&amp;lt;/code&amp;gt; -- it automatically finds the correct password.&lt;br /&gt;
&lt;br /&gt;
That's it! You should have successfully cracked a password using the timing attack. Some notes on this method:&lt;br /&gt;
&lt;br /&gt;
* The target device has a finite start-up time, which slows down the attack. If you wish, remove some of the printf()'s from the target code, recompile and reprogram, and see how quickly you can do this attack.&lt;br /&gt;
* The current script doesn't look for the &amp;amp;quot;WELCOME&amp;amp;quot; message when the password is OK. That is an extension that allows it to crack any size password.&lt;br /&gt;
* If there was a lock-out on a wrong password, the system would ignore it, as it resets the target after every attempt.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
This tutorial has demonstrated the use of the power side-channel for performing timing attacks. A target with a simple password-based security system is broken. In addition you have learned about the scripting support in the ChipWhisperer-Capture software.&lt;br /&gt;
&lt;br /&gt;
= Appendix: Completed Timing Attack Script =&lt;br /&gt;
The &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt; function at the end of the tutorial might look something like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # This is the function that gets called when our script starts&lt;br /&gt;
        &lt;br /&gt;
        # First: set up the basics and connect to the CW-Lite&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Scope Module', 'ChipWhisperer/OpenADC'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Target Module', 'Simple Serial'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Trace Format', 'ChipWhisperer/Native'])&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.setParameter(['ChipWhisperer/OpenADC', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Next: set up everything we need to connect to the target&lt;br /&gt;
        # Put all of our commands in a list and execute them at the end&lt;br /&gt;
        lstexample = [&lt;br /&gt;
                      # Gain&lt;br /&gt;
                      ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
                      # Trigger&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Offset', 0],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Total Samples', 2000],&lt;br /&gt;
                      # Clock&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
                      # Pins&lt;br /&gt;
                      ['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
                      ['CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
                      # Automatic commands&lt;br /&gt;
                      ['Simple Serial', 'Load Key Command', ''],&lt;br /&gt;
                      ['Simple Serial', 'Go Command', 'h0px3\n'],&lt;br /&gt;
                      ['Simple Serial', 'Output Format', ''],&lt;br /&gt;
                      # Auto-reset&lt;br /&gt;
                      ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
                      ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],&lt;br /&gt;
                      ]&lt;br /&gt;
        &lt;br /&gt;
        #Download all hardware setup parameters&lt;br /&gt;
        for cmd in lstexample: &lt;br /&gt;
            self.api.setParameter(cmd)&lt;br /&gt;
                       &lt;br /&gt;
        # Get one capture for fun&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        print data&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Crack the first letter&lt;br /&gt;
        password = ''&lt;br /&gt;
        trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
          &lt;br /&gt;
        for i in range(5):&lt;br /&gt;
            for c in trylist:&lt;br /&gt;
                # Get a power trace using our next attempt&lt;br /&gt;
                nextPass = password + '{}'.format(c)&lt;br /&gt;
                self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
                self.api.capture1()&lt;br /&gt;
                &lt;br /&gt;
                # Grab the trace&lt;br /&gt;
                nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
                &lt;br /&gt;
                # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
                if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
                    continue&lt;br /&gt;
                    &lt;br /&gt;
                # If we got here, we've found the right letter&lt;br /&gt;
                password += c&lt;br /&gt;
                print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
                break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2777</id>
		<title>Tutorial B3-1 Timing Analysis with Power for Password Bypass</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2777"/>
				<updated>2017-07-21T23:19:20Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Italics for consistency&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to breaking devices by determining when a device is performing certain operations. It will use a simple password check, and demonstrate how to perform a basic power analysis.&lt;br /&gt;
&lt;br /&gt;
In addition this example shows you how to drive the ChipWhisperer software with a script, rather than using the GUI. This will be required when attacking new devices which you have not yet added to the core ChipWhisperer software.&lt;br /&gt;
&lt;br /&gt;
Note this is not a prerequisite to the tutorial on breaking AES. You can skip this tutorial if you wish to go ahead with the AES tutorial.&lt;br /&gt;
&lt;br /&gt;
You can also view a 53-min [https://www.youtube.com/watch?v=h4eAU6vEONs&amp;amp;hd=1 Video Version on YouTube]:&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
&lt;br /&gt;
You should have already completed [[Tutorial B2 Viewing Instruction Power Differences]] to gain a better understanding of the ChipWhisperer interface.&lt;br /&gt;
&lt;br /&gt;
= Building the Target Firmware =&lt;br /&gt;
&lt;br /&gt;
The target firmware is located in the directory &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\basic-passwdcheck&amp;lt;/code&amp;gt;. Build the firmware using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;, once again being careful to ensure you are using the correct &amp;lt;code&amp;gt;PLATFORM=&amp;lt;/code&amp;gt; command. You should end up with something like this being printed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Creating Symbol Table: basic-passwdcheck.sym&lt;br /&gt;
avr-nm -n basic-passwdcheck.elf &amp;amp;gt; basic-passwdcheck.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    5400 bytes (3.9% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        524 bytes (6.4% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Manual Communications with the Target =&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to configure the target as in the previous tutorials. Rather than tediously going through the setup process again, we'll simply use one of the scripts built into the ChipWhisperer-Capture software. This will demonstrate how we can use a script as a starting point to simplify our setup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect your target hardware (ChipWhisperer-Lite/Pro or ChipWhisperer-Capture Rev 2 with target board).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the ChipWhisperer-Capture software.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Example Scripts'', select one which most closely matches your hardware. For example here I'm using a ChipWhisperer-Lite with the XMEGA target, so will select the &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot; script. Note I'm ''NOT'' attacking AES, so will need to make some adjustments later. (The &amp;quot;Timing Attack on CW-Lite (XMEGA)&amp;quot; script already does most of this for us, so using it would defeat the purpose of this tutorial.)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system should connect to your hardware. Remember you have not yet reprogrammed the target so won't be communicating with the target program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using the programming tool (such as XMEGA programming dialog), program the file &amp;lt;code&amp;gt;basic-passwdcheck.hex&amp;lt;/code&amp;gt; into the target device. This file is located where you ran &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Select ''Tools --&amp;gt; Terminal'', and press ''Connect''. You should see a window such as this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Termconn.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point we need to reset the target device. The easiest way to do this is use the programmer interface, and press the ''Check Signature'' or ''Read Signature'' button. This will reset the target device as part of the signature read operation. You should see some messages come across the terminal emulator window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Checksig_print.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Note a few warnings about the terminal emulator:&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The on-board buffer is fairly small, and can be easily overflowed. You may notice a few longer lines become trunicated if printing is too fast!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can uncheck the &amp;amp;quot;Show non-ASCII as hex&amp;amp;quot; to avoid having the &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; printed in red. The &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; is the hex character for a newline. Many protocols use non-ASCII characters, so to help with debugging it is left enabled by default.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/dd&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We've now got some super-secure system! Let's begin with some exploratory tests - in this case I happened to know the correct password is &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''tip'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In real systems, you may often know ''one'' of the passwords, which is sufficient to investigate the password checking routines as we will do. You also normally have an ability to reset passwords to default. While the reset procedure would erase any data you care about, the attacker will be able to use this 'sacrificial' device to learn about possible vulnerabilites. So the assumption that we have access to the password is really just saying we have access to ''a'' password, and will use that knowledge to break the system in general.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the terminal emulator, write the correct password in, and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt;. You should be greeted by a welcome message, and if using the CW-Lite XMEGA target the green LED will illuminate:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Passok.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system enters an infinite loop for any password entry. Thus you must reset the system, use the ''Programmer Window'' to again perform a ''Check Signature'' or ''Read Signature'' operation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter an incorrect password - notice a different message is printed, and if using the CW-Lite XMEGA target the red LED will come on.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Recording Power Traces =&lt;br /&gt;
Now that we can communicate with our super-secure system, our next goal is to get a power trace while the target is running. To do this, we'll get the power measurements to trigger after we send our password to the target. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We'll make some changes to the trigger setup of the ChipWhisperer (on the ''Scope Settings'' tab). In particular, ensure you set the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Offset = 0&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Timeout set to 5 seconds or greater (to give yourself time when manually testing)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Timeout_offset.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change to the ''Target Settings'' tab, and delete the ''Command'' strings. Those strings are used in the AES attack to send a specific command to the target device, for now we will be manually sending data:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Text_targetsettings.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the ''Target Settings'' tab, under ''Protocol Version'', change ''Version'' from ''Auto'' to ''1.0''&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter the password &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt; in the terminal window, but ''do not'' yet hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button, and immediately switch to the terminal emulator window and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt; to send the password.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You must send the password before the timeout occurs -- you can increase the length of the timeout if needed to give yourself more time! If this works you should see the power consumption displayed in the GUI:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Trace_manual_pass.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rather than using the manual terminal, let's now use the GUI to automatically send a password try. Switching back to the ''Target Settings'' tab, write &amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt; into the ''Go Command'' option:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Gocorrect.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Go Command'' is sent right after the scope is armed. In this example it means we can capture the power consumption during the password entry phase.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Now perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Hopefully this resulted in the same waveform as before! Note the device takes around 1 second to 'boot', so if you are too lightning fast after resetting the device it won't actually be ready to accept the password. You can keep the terminal emulator window open to view the output data.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Play around with the password entered on the ''Go Command'' - try all of the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px4\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0paa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;haaaa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;a\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You should notice a distinct change in the password depending how many characters were correct. For example the following shows the difference between passwords of &amp;lt;code&amp;gt;h0px4&amp;lt;/code&amp;gt; (which has 4 correct characters) and &amp;lt;code&amp;gt;h0paa&amp;lt;/code&amp;gt; (which has 3 correct characters):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:3vs4.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Automatic Resets =&lt;br /&gt;
The last step before scripting an entire attack is to figure out how to automatically reset the target device before (or after) each capture. There are two ways to do this, and the following steps take you through two examples of how to accomplish this goal.&lt;br /&gt;
&lt;br /&gt;
== Reset via Spare IO Lines ==&lt;br /&gt;
&lt;br /&gt;
TODO - see reset via programming interface for now&lt;br /&gt;
&lt;br /&gt;
== Reset via Auxiliary Module ==&lt;br /&gt;
&lt;br /&gt;
Auxiliary modules are small pieces of code that can perform some extra functions during the capture process. The functions inside these Python modules are run before a capture, before the power measurement is armed, before the measurement is triggered, after a single trace is completed, and after an entire capture is finished. We will use an existing auxiliary module to reset the target chip before arming the measurement so that we don't have to manually reset the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; We're going to use the ''Reset AVR/XMEGA via CW-Lite'' auxiliary module. Let's get an idea of how this module works: &lt;br /&gt;
* Navigate to the auxiliary modules folder (&amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\auxiliary\&amp;lt;/code&amp;gt;) and open &amp;lt;code&amp;gt;ResetCW1183Read.py&amp;lt;/code&amp;gt; in your choice of text editor.&lt;br /&gt;
* Find the function definition for &amp;lt;code&amp;gt;resetDevice()&amp;lt;/code&amp;gt;. It contains a line that looks like: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CWCoreAPI.getInstance().getScope().scopetype.cwliteXMEGA.readSignature()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Look for the lines where this function gets called. You'll find that the function &amp;lt;code&amp;gt;traceArm()&amp;lt;/code&amp;gt; uses it like:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resettiming = self.findParam('resettiming').value()&lt;br /&gt;
if resettiming == 'Pre-Arm':&lt;br /&gt;
    self.resetDevice()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Effectively, this code will read the target's signature before we arm the power measurement. This means that the target will automatically be reset before capturing a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Go back to the ChipWhisperer Capture software. In the ''Generic Settings'' tab, switch the Auxiliary Module to ''Reset AVR/XMEGA via CW-Lite''.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Now, in the ''Aux Settings'' tab, we can configure our automatic reset. Make sure the settings are:&lt;br /&gt;
* Pre-arm delay: roughly 1200 ms&lt;br /&gt;
* Post-arm delay: the default (0 ms) is fine&lt;br /&gt;
* Reset timing: Pre-arm (reset the device before we arm the scope)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Press ''Capture 1''. The target will automatically reset, with the Safe-o-matic 3000 boot sequence appearing in the console. Then, 1 second later, the program will send the password to the target and record a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, confirm that you can try different passwords (in ''Target Settings'') and see how the power trace changes when your password has 0, 1, 2... correct characters.&lt;br /&gt;
&lt;br /&gt;
= Performing the Timing Attack =&lt;br /&gt;
So far, we've set up our ChipWhisperer to automatically reset the target, send it a password attempt of our choice, and record a power trace while the target processes the password. Now, we'll write a Python script to automatically try different passwords and use these power traces to discover the password stored on the target.&lt;br /&gt;
&lt;br /&gt;
== Scripting the Setup ==&lt;br /&gt;
Our first step will be to write a script that automatically sets up the ChipWhisperer Capture software with all of the settings we've tested above. We'll do this by modifying an existing script with our own settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a copy of an existing ChipWhisperer script. The example scripts are located at &amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\scripts&amp;lt;/code&amp;gt;; for example, the default one for the XMEGA device is called &amp;lt;code&amp;gt;cwlite-simpleserialxmega.py&amp;lt;/code&amp;gt;. Make a copy of this script and put it somewhere memorable.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rename the script something else - for example, &amp;lt;code&amp;gt;cwlite-passwordcrack.py&amp;lt;/code&amp;gt; - and open it for editing. You'll notice that a large chunk of the code is used to set the parameters:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Total Samples', 3000],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Offset', 1500],&lt;br /&gt;
              ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Those parameters come from the ''Scripting Parameters'' tab. Switch over to it and notice this tab logs all of the parameter changes, showing you how to change the parameters through the API:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Scriptcommands.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note that commands run via the script are also printed, so you can see where the values being set are coming from too. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point, close the ''ChipWhisperer-Capture'' window so we can confirm the script still works. Run the new script (which doesn't have any changes yet) from the command line. You may have to open a console with Python in the path:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you installed WinPython, run the ''WinPython Console'' from your WinPython installation directory.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If using the VMWare image of a Linux machine, this should just be a regular console&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Run the script with &amp;lt;code&amp;gt;python cwlite-passwordcrack.py&amp;lt;/code&amp;gt;. If the script errors out, it might be that the location of the FPGA bitstream is stored in relative terms. To fix this perform the following:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open ChipWhisperer-Capture regularly.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run the ChipWhisperer script that you used previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Select ''Tools--&amp;amp;gt;Config CW Firmware''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the &amp;amp;quot;FPGA .zip (Release)&amp;amp;quot;, hit the &amp;amp;quot;Find&amp;amp;quot; button. Point the system to the file &amp;lt;code&amp;gt;chipwhisperer/hardware/capture/chipwhisperer-lite/cwlite_firmware.zip&amp;lt;/code&amp;gt; on your filesystem. Note by default there is a relative path.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Once again on the ''Target Settings'' tab, delete the various commands. Make a note of the resulting ''Script Commands'' which you will need to enter to achieve this same goal. Close ChipWhisperer-Capture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Continue editing your script. First, find the line setting the Trigger Offset:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 1500],&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;And set this to 0, which we were using previously:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 0],&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Next, append the required commands to clear the simpleserial commands and to enable the automatic resets:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ...BUNCH MORE COMMANDS HERE HAVE BEEN REMOVED...&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
&lt;br /&gt;
              #Append your commands here&lt;br /&gt;
              ['Simple Serial', 'Load Key Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Go Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Output Format', u''],   &lt;br /&gt;
&lt;br /&gt;
              ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
              ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],                   &lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will set the password. You can enter the password in the Capture ''Target Settings'' tab, and see the following sort of call would set the appropriate password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;self.api.setParameter(['Simple Serial', 'Go Command', u'h0px3\\n'])&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note the newline is actually escaped, to set the text equivalent of what will be printed. This will result in an actual newline going out across the serial port. Set that command at some point in your script.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Close any open ChipWhisperer-Capture windows, and run the script as before. You should connect to the target, and be able to press ''Capture 1'' and see the correct waveform.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running a Single Capture ==&lt;br /&gt;
With our settings prepared, the next step is to use our script to record and analyze a power trace. We need to be able to get the trace data into our Python script so we can analyze it for the timing attack.&lt;br /&gt;
&lt;br /&gt;
The API allows us to ''press the Capture 1'' button and ''view the power trace'' without using the GUI. There are two relevant commands here:&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.capture1()&amp;lt;/code&amp;gt; acts as if we've just pressed the ''Capture 1'' button;&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.getScope().channels[0].getTrace()&amp;lt;/code&amp;gt; returns a list of datapoints that were recorded in the previous capture.&lt;br /&gt;
We want to test these two commands. After the setup portion of your script, add some code similar to the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self.api.capture1()&lt;br /&gt;
data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Run your script. The ChipWhisperer should automatically capture one trace and print out the several thousand datapoints. This is all we need to continue.&lt;br /&gt;
&lt;br /&gt;
== Attacking a Single Letter ==&lt;br /&gt;
Now that we can record one power trace, we can start the timing attack. Our goal here is to automatically find the first letter of the Super Secret (tm) password.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Look at this example of the power traces when 0 and 1 bytes are correct. We can see a clear point that appears to shift forward in time:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Passwordcrackerpts.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When we guess the first byte incorrectly, there is a distinct power spike at sample number 153. However, when we guess correctly, the target spends more time processing the password, and this spike moves 72 samples forward. This means that we can check if our first byte is correct by checking this data point: if we're right, it will have an amplitude greater than -0.2. Note the specific point will change for different hardware, and may also change if you use different versions of avr-gcc to compile the target code. The example code here was compiled with WinAVR 20100110, which has avr-gcc 4.3.3. If you view the video version of this tutorial the point numbers are different for example, so be sure to check what they are for your specific system.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Add a loop to your script that does the following:&lt;br /&gt;
* Sets the ''Go Command'' to the next character we want to try&lt;br /&gt;
* Captures a power trace&lt;br /&gt;
* Checks if sample 153 is above -0.2 (fill in the appropriate numbers here)&lt;br /&gt;
* Repeats for all characters we want to try&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
&lt;br /&gt;
for c in trylist:&lt;br /&gt;
    # Test this password and record a power trace&lt;br /&gt;
    self.api.setParameter(['Simple Serial', 'Go Command', c + '\n'])&lt;br /&gt;
    self.api.capture1()&lt;br /&gt;
    &lt;br /&gt;
    # Get the data and check data[153]&lt;br /&gt;
    data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
    if data[153] &amp;gt; -0.2:&lt;br /&gt;
        print &amp;quot;Success: &amp;quot; + c          &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This script will eventually stop, but you can use Ctrl+C on the command line to kill it. Make sure your script prints &amp;quot;Success: h&amp;quot;!&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Attacking the Full Password ==&lt;br /&gt;
The last step is to attack the entire password, one letter at a time. The procedure to do this is:&lt;br /&gt;
* Start with a blank password string&lt;br /&gt;
* Loop through all of the characters we want to try:&lt;br /&gt;
** Add the next character to the end of the password&lt;br /&gt;
** Test this new candidate password using code similar to the above&lt;br /&gt;
** If the new password is correct up to character (1, 2, ..., 5), add it to the end of the password&lt;br /&gt;
* Repeat until we've cracked all 5 characters.&lt;br /&gt;
&lt;br /&gt;
Note that the point of interest is no longer at sample 153. We noticed earlier that this key point moves 72 samples forward for every correct character, so we'll have to check location &amp;lt;code&amp;gt;153&amp;lt;/code&amp;gt; for character 0, &amp;lt;code&amp;gt;153 + 72&amp;lt;/code&amp;gt; for character 1, and &amp;lt;code&amp;gt;153 + i*72&amp;lt;/code&amp;gt; for character &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
password = ''&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
  &lt;br /&gt;
for i in range(5):&lt;br /&gt;
    for c in trylist:&lt;br /&gt;
        # Get a power trace using our next attempt&lt;br /&gt;
        nextPass = password + '{}'.format(c)&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        &lt;br /&gt;
        # Grab the trace&lt;br /&gt;
        nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        &lt;br /&gt;
        # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
        if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
            continue&lt;br /&gt;
            &lt;br /&gt;
        # If we got here, we've found the right letter&lt;br /&gt;
        password += c&lt;br /&gt;
        print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
        break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After some time, this prints &amp;lt;code&amp;gt;5 characters: h0px3&amp;lt;/code&amp;gt; -- it automatically finds the correct password.&lt;br /&gt;
&lt;br /&gt;
That's it! You should have successfully cracked a password using the timing attack. Some notes on this method:&lt;br /&gt;
&lt;br /&gt;
* The target device has a finite start-up time, which slows down the attack. If you wish, remove some of the printf()'s from the target code, recompile and reprogram, and see how quickly you can do this attack.&lt;br /&gt;
* The current script doesn't look for the &amp;amp;quot;WELCOME&amp;amp;quot; message when the password is OK. That is an extension that allows it to crack any size password.&lt;br /&gt;
* If there was a lock-out on a wrong password, the system would ignore it, as it resets the target after every attempt.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
This tutorial has demonstrated the use of the power side-channel for performing timing attacks. A target with a simple password-based security system is broken. In addition you have learned about the scripting support in the ChipWhisperer-Capture software.&lt;br /&gt;
&lt;br /&gt;
= Appendix: Completed Timing Attack Script =&lt;br /&gt;
The &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt; function at the end of the tutorial might look something like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # This is the function that gets called when our script starts&lt;br /&gt;
        &lt;br /&gt;
        # First: set up the basics and connect to the CW-Lite&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Scope Module', 'ChipWhisperer/OpenADC'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Target Module', 'Simple Serial'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Trace Format', 'ChipWhisperer/Native'])&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.setParameter(['ChipWhisperer/OpenADC', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Next: set up everything we need to connect to the target&lt;br /&gt;
        # Put all of our commands in a list and execute them at the end&lt;br /&gt;
        lstexample = [&lt;br /&gt;
                      # Gain&lt;br /&gt;
                      ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
                      # Trigger&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Offset', 0],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Total Samples', 2000],&lt;br /&gt;
                      # Clock&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
                      # Pins&lt;br /&gt;
                      ['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
                      ['CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
                      # Automatic commands&lt;br /&gt;
                      ['Simple Serial', 'Load Key Command', ''],&lt;br /&gt;
                      ['Simple Serial', 'Go Command', 'h0px3\n'],&lt;br /&gt;
                      ['Simple Serial', 'Output Format', ''],&lt;br /&gt;
                      # Auto-reset&lt;br /&gt;
                      ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
                      ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],&lt;br /&gt;
                      ]&lt;br /&gt;
        &lt;br /&gt;
        #Download all hardware setup parameters&lt;br /&gt;
        for cmd in lstexample: &lt;br /&gt;
            self.api.setParameter(cmd)&lt;br /&gt;
                       &lt;br /&gt;
        # Get one capture for fun&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        print data&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Crack the first letter&lt;br /&gt;
        password = ''&lt;br /&gt;
        trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
          &lt;br /&gt;
        for i in range(5):&lt;br /&gt;
            for c in trylist:&lt;br /&gt;
                # Get a power trace using our next attempt&lt;br /&gt;
                nextPass = password + '{}'.format(c)&lt;br /&gt;
                self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
                self.api.capture1()&lt;br /&gt;
                &lt;br /&gt;
                # Grab the trace&lt;br /&gt;
                nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
                &lt;br /&gt;
                # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
                if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
                    continue&lt;br /&gt;
                    &lt;br /&gt;
                # If we got here, we've found the right letter&lt;br /&gt;
                password += c&lt;br /&gt;
                print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
                break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2776</id>
		<title>Tutorial B3-1 Timing Analysis with Power for Password Bypass</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B3-1_Timing_Analysis_with_Power_for_Password_Bypass&amp;diff=2776"/>
				<updated>2017-07-21T23:16:25Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Some updates for current code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to breaking devices by determining when a device is performing certain operations. It will use a simple password check, and demonstrate how to perform a basic power analysis.&lt;br /&gt;
&lt;br /&gt;
In addition this example shows you how to drive the ChipWhisperer software with a script, rather than using the GUI. This will be required when attacking new devices which you have not yet added to the core ChipWhisperer software.&lt;br /&gt;
&lt;br /&gt;
Note this is not a prerequisite to the tutorial on breaking AES. You can skip this tutorial if you wish to go ahead with the AES tutorial.&lt;br /&gt;
&lt;br /&gt;
You can also view a 53-min [https://www.youtube.com/watch?v=h4eAU6vEONs&amp;amp;hd=1 Video Version on YouTube]:&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
&lt;br /&gt;
You should have already completed [[Tutorial B2 Viewing Instruction Power Differences]] to gain a better understanding of the ChipWhisperer interface.&lt;br /&gt;
&lt;br /&gt;
= Building the Target Firmware =&lt;br /&gt;
&lt;br /&gt;
The target firmware is located in the directory &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\basic-passwdcheck&amp;lt;/code&amp;gt;. Build the firmware using &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;, once again being careful to ensure you are using the correct &amp;lt;code&amp;gt;PLATFORM=&amp;lt;/code&amp;gt; command. You should end up with something like this being printed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Creating Symbol Table: basic-passwdcheck.sym&lt;br /&gt;
avr-nm -n basic-passwdcheck.elf &amp;amp;gt; basic-passwdcheck.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    5400 bytes (3.9% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        524 bytes (6.4% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Manual Communications with the Target =&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to configure the target as in the previous tutorials. Rather than tediously going through the setup process again, we'll simply use one of the scripts built into the ChipWhisperer-Capture software. This will demonstrate how we can use a script as a starting point to simplify our setup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect your target hardware (ChipWhisperer-Lite/Pro or ChipWhisperer-Capture Rev 2 with target board).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the ChipWhisperer-Capture software.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Example Scripts'', select one which most closely matches your hardware. For example here I'm using a ChipWhisperer-Lite with the XMEGA target, so will select the &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot; script. Note I'm ''NOT'' attacking AES, so will need to make some adjustments later. (The &amp;quot;Timing Attack on CW-Lite (XMEGA)&amp;quot; script already does most of this for us, so using it would defeat the purpose of this tutorial.)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system should connect to your hardware. Remember you have not yet reprogrammed the target so won't be communicating with the target program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using the programming tool (such as XMEGA programming dialog), program the file &amp;lt;code&amp;gt;basic-passwdcheck.hex&amp;lt;/code&amp;gt; into the target device. This file is located where you ran &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Select ''Tools --&amp;gt; Terminal'', and press ''Connect''. You should see a window such as this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Termconn.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point we need to reset the target device. The easiest way to do this is use the programmer interface, and press the ''Check Signature'' or ''Read Signature'' button. This will reset the target device as part of the signature read operation. You should see some messages come across the terminal emulator window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Checksig_print.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Note a few warnings about the terminal emulator:&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The on-board buffer is fairly small, and can be easily overflowed. You may notice a few longer lines become trunicated if printing is too fast!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can uncheck the &amp;amp;quot;Show non-ASCII as hex&amp;amp;quot; to avoid having the &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; printed in red. The &amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt; is the hex character for a newline. Many protocols use non-ASCII characters, so to help with debugging it is left enabled by default.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/dd&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We've now got some super-secure system! Let's begin with some exploratory tests - in this case I happened to know the correct password is &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''tip'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In real systems, you may often know ''one'' of the passwords, which is sufficient to investigate the password checking routines as we will do. You also normally have an ability to reset passwords to default. While the reset procedure would erase any data you care about, the attacker will be able to use this 'sacrificial' device to learn about possible vulnerabilites. So the assumption that we have access to the password is really just saying we have access to ''a'' password, and will use that knowledge to break the system in general.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the terminal emulator, write the correct password in, and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt;. You should be greeted by a welcome message, and if using the CW-Lite XMEGA target the green LED will illuminate:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Passok.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The system enters an infinite loop for any password entry. Thus you must reset the system, use the ''Programmer Window'' to again perform a ''Check Signature'' or ''Read Signature'' operation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter an incorrect password - notice a different message is printed, and if using the CW-Lite XMEGA target the red LED will come on.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Recording Power Traces =&lt;br /&gt;
Now that we can communicate with our super-secure system, our next goal is to get a power trace while the target is running. To do this, we'll get the power measurements to trigger after we send our password to the target. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We'll make some changes to the trigger setup of the ChipWhisperer (on the Scope Settings tab). In particular, ensure you set the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Offset = 0&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Timeout set to 5 seconds or greater (to give yourself time when manually testing)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Timeout_offset.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change to the ''Target Settings'' tab, and delete the ''Command'' strings. Those strings are used in the AES attack to send a specific command to the target device, for now we will be manually sending data:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Text_targetsettings.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the ''Target Settings'' tab, under ''Protocol Version'', change ''Version'' from ''Auto'' to ''1.0''&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter the password &amp;lt;code&amp;gt;h0px3&amp;lt;/code&amp;gt; in the terminal window, but ''do not'' yet hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button, and immediately switch to the terminal emulator window and press &amp;lt;code&amp;gt;&amp;amp;lt;enter&amp;amp;gt;&amp;lt;/code&amp;gt; to send the password.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You must send the password before the timeout occurs -- you can increase the length of the timeout if needed to give yourself more time! If this works you should see the power consumption displayed in the GUI:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Trace_manual_pass.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rather than using the manual terminal, let's now use the GUI to automatically send a password try. Switching back to the ''Target Settings'' tab, write &amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt; into the ''Go Command'' option:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Gocorrect.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Go Command'' is sent right after the scope is armed. In this example it means we can capture the power consumption during the password entry phase.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Now perform the following actions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reset the target device (e.g. by performing the signature check).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Hopefully this resulted in the same waveform as before! Note the device takes around 1 second to 'boot', so if you are too lightning fast after resetting the device it won't actually be ready to accept the password. You can keep the terminal emulator window open to view the output data.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Play around with the password entered on the ''Go Command'' - try all of the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px3\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0px4\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;h0paa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;haaaa\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;a\n&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You should notice a distinct change in the password depending how many characters were correct. For example the following shows the difference between passwords of &amp;lt;code&amp;gt;h0px4&amp;lt;/code&amp;gt; (which has 4 correct characters) and &amp;lt;code&amp;gt;h0paa&amp;lt;/code&amp;gt; (which has 3 correct characters):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:3vs4.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Automatic Resets =&lt;br /&gt;
The last step before scripting an entire attack is to figure out how to automatically reset the target device before (or after) each capture. There are two ways to do this, and the following steps take you through two examples of how to accomplish this goal.&lt;br /&gt;
&lt;br /&gt;
== Reset via Spare IO Lines ==&lt;br /&gt;
&lt;br /&gt;
TODO - see reset via programming interface for now&lt;br /&gt;
&lt;br /&gt;
== Reset via Auxiliary Module ==&lt;br /&gt;
&lt;br /&gt;
Auxiliary modules are small pieces of code that can perform some extra functions during the capture process. The functions inside these Python modules are run before a capture, before the power measurement is armed, before the measurement is triggered, after a single trace is completed, and after an entire capture is finished. We will use an existing auxiliary module to reset the target chip before arming the measurement so that we don't have to manually reset the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; We're going to use the ''Reset AVR/XMEGA via CW-Lite'' auxiliary module. Let's get an idea of how this module works: &lt;br /&gt;
* Navigate to the auxiliary modules folder (&amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\auxiliary\&amp;lt;/code&amp;gt;) and open &amp;lt;code&amp;gt;ResetCW1183Read.py&amp;lt;/code&amp;gt; in your choice of text editor.&lt;br /&gt;
* Find the function definition for &amp;lt;code&amp;gt;resetDevice()&amp;lt;/code&amp;gt;. It contains a line that looks like: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CWCoreAPI.getInstance().getScope().scopetype.cwliteXMEGA.readSignature()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Look for the lines where this function gets called. You'll find that the function &amp;lt;code&amp;gt;traceArm()&amp;lt;/code&amp;gt; uses it like:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resettiming = self.findParam('resettiming').value()&lt;br /&gt;
if resettiming == 'Pre-Arm':&lt;br /&gt;
    self.resetDevice()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Effectively, this code will read the target's signature before we arm the power measurement. This means that the target will automatically be reset before capturing a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Go back to the ChipWhisperer Capture software. In the ''Generic Settings'' tab, switch the Auxiliary Module to ''Reset AVR/XMEGA via CW-Lite''.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Now, in the ''Aux Settings'' tab, we can configure our automatic reset. Make sure the settings are:&lt;br /&gt;
* Pre-arm delay: roughly 1200 ms&lt;br /&gt;
* Post-arm delay: the default (0 ms) is fine&lt;br /&gt;
* Reset timing: Pre-arm (reset the device before we arm the scope)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Press ''Capture 1''. The target will automatically reset, with the Safe-o-matic 3000 boot sequence appearing in the console. Then, 1 second later, the program will send the password to the target and record a power trace.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, confirm that you can try different passwords (in ''Target Settings'') and see how the power trace changes when your password has 0, 1, 2... correct characters.&lt;br /&gt;
&lt;br /&gt;
= Performing the Timing Attack =&lt;br /&gt;
So far, we've set up our ChipWhisperer to automatically reset the target, send it a password attempt of our choice, and record a power trace while the target processes the password. Now, we'll write a Python script to automatically try different passwords and use these power traces to discover the password stored on the target.&lt;br /&gt;
&lt;br /&gt;
== Scripting the Setup ==&lt;br /&gt;
Our first step will be to write a script that automatically sets up the ChipWhisperer Capture software with all of the settings we've tested above. We'll do this by modifying an existing script with our own settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a copy of an existing ChipWhisperer script. The example scripts are located at &amp;lt;code&amp;gt;chipwhisperer\software\chipwhisperer\capture\scripts&amp;lt;/code&amp;gt;; for example, the default one for the XMEGA device is called &amp;lt;code&amp;gt;cwlite-simpleserialxmega.py&amp;lt;/code&amp;gt;. Make a copy of this script and put it somewhere memorable.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Rename the script something else - for example, &amp;lt;code&amp;gt;cwlite-passwordcrack.py&amp;lt;/code&amp;gt; - and open it for editing. You'll notice that a large chunk of the code is used to set the parameters:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
              ['CW Extra', 'CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Total Samples', 3000],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Offset', 1500],&lt;br /&gt;
              ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
              ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Those parameters come from the ''Scripting Parameters'' tab. Switch over to it and notice this tab logs all of the parameter changes, showing you how to change the parameters through the API:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Scriptcommands.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note that commands run via the script are also printed, so you can see where the values being set are coming from too. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point, close the ''ChipWhisperer-Capture'' window so we can confirm the script still works. Run the new script (which doesn't have any changes yet) from the command line. You may have to open a console with Python in the path:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you installed WinPython, run the ''WinPython Console'' from your WinPython installation directory.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If using the VMWare image of a Linux machine, this should just be a regular console&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Run the script with &amp;lt;code&amp;gt;python cwlite-passwordcrack.py&amp;lt;/code&amp;gt;. If the script errors out, it might be that the location of the FPGA bitstream is stored in relative terms. To fix this perform the following:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-roman;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open ChipWhisperer-Capture regularly.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run the ChipWhisperer script that you used previously.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Select ''Tools--&amp;amp;gt;Config CW Firmware''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the &amp;amp;quot;FPGA .zip (Release)&amp;amp;quot;, hit the &amp;amp;quot;Find&amp;amp;quot; button. Point the system to the file &amp;lt;code&amp;gt;chipwhisperer/hardware/capture/chipwhisperer-lite/cwlite_firmware.zip&amp;lt;/code&amp;gt; on your filesystem. Note by default there is a relative path.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Once again on the ''Target Settings'' tab, delete the various commands. Make a note of the resulting ''Script Commands'' which you will need to enter to achieve this same goal. Close ChipWhisperer-Capture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Continue editing your script. First, find the line setting the Trigger Offset:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 1500],&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;And set this to 0, which we were using previously:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;['OpenADC', 'Trigger Setup', 'Offset', 0],&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Next, append the required commands to clear the simpleserial commands and to enable the automatic resets:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;#Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
lstexample = [['CW Extra', 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
              ...BUNCH MORE COMMANDS HERE HAVE BEEN REMOVED...&lt;br /&gt;
              #Final step: make DCMs relock in case they are lost&lt;br /&gt;
              ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
&lt;br /&gt;
              #Append your commands here&lt;br /&gt;
              ['Simple Serial', 'Load Key Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Go Command', u''],&lt;br /&gt;
              ['Simple Serial', 'Output Format', u''],   &lt;br /&gt;
&lt;br /&gt;
              ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
              ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],                   &lt;br /&gt;
              ]&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will set the password. You can enter the password in the Capture ''Target Settings'' tab, and see the following sort of call would set the appropriate password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;self.api.setParameter(['Simple Serial', 'Go Command', u'h0px3\\n'])&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Note the newline is actually escaped, to set the text equivalent of what will be printed. This will result in an actual newline going out across the serial port. Set that command at some point in your script.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Close any open ChipWhisperer-Capture windows, and run the script as before. You should connect to the target, and be able to press ''Capture 1'' and see the correct waveform.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running a Single Capture ==&lt;br /&gt;
With our settings prepared, the next step is to use our script to record and analyze a power trace. We need to be able to get the trace data into our Python script so we can analyze it for the timing attack.&lt;br /&gt;
&lt;br /&gt;
The API allows us to ''press the Capture 1'' button and ''view the power trace'' without using the GUI. There are two relevant commands here:&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.capture1()&amp;lt;/code&amp;gt; acts as if we've just pressed the ''Capture 1'' button;&lt;br /&gt;
* &amp;lt;code&amp;gt; self.api.getScope().channels[0].getTrace()&amp;lt;/code&amp;gt; returns a list of datapoints that were recorded in the previous capture.&lt;br /&gt;
We want to test these two commands. After the setup portion of your script, add some code similar to the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self.api.capture1()&lt;br /&gt;
data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Run your script. The ChipWhisperer should automatically capture one trace and print out the several thousand datapoints. This is all we need to continue.&lt;br /&gt;
&lt;br /&gt;
== Attacking a Single Letter ==&lt;br /&gt;
Now that we can record one power trace, we can start the timing attack. Our goal here is to automatically find the first letter of the Super Secret (tm) password.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Look at this example of the power traces when 0 and 1 bytes are correct. We can see a clear point that appears to shift forward in time:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:Passwordcrackerpts.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When we guess the first byte incorrectly, there is a distinct power spike at sample number 153. However, when we guess correctly, the target spends more time processing the password, and this spike moves 72 samples forward. This means that we can check if our first byte is correct by checking this data point: if we're right, it will have an amplitude greater than -0.2. Note the specific point will change for different hardware, and may also change if you use different versions of avr-gcc to compile the target code. The example code here was compiled with WinAVR 20100110, which has avr-gcc 4.3.3. If you view the video version of this tutorial the point numbers are different for example, so be sure to check what they are for your specific system.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Add a loop to your script that does the following:&lt;br /&gt;
* Sets the ''Go Command'' to the next character we want to try&lt;br /&gt;
* Captures a power trace&lt;br /&gt;
* Checks if sample 153 is above -0.2 (fill in the appropriate numbers here)&lt;br /&gt;
* Repeats for all characters we want to try&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
&lt;br /&gt;
for c in trylist:&lt;br /&gt;
    # Test this password and record a power trace&lt;br /&gt;
    self.api.setParameter(['Simple Serial', 'Go Command', c + '\n'])&lt;br /&gt;
    self.api.capture1()&lt;br /&gt;
    &lt;br /&gt;
    # Get the data and check data[153]&lt;br /&gt;
    data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
    if data[153] &amp;gt; -0.2:&lt;br /&gt;
        print &amp;quot;Success: &amp;quot; + c          &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This script will eventually stop, but you can use Ctrl+C on the command line to kill it. Make sure your script prints &amp;quot;Success: h&amp;quot;!&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Attacking the Full Password ==&lt;br /&gt;
The last step is to attack the entire password, one letter at a time. The procedure to do this is:&lt;br /&gt;
* Start with a blank password string&lt;br /&gt;
* Loop through all of the characters we want to try:&lt;br /&gt;
** Add the next character to the end of the password&lt;br /&gt;
** Test this new candidate password using code similar to the above&lt;br /&gt;
** If the new password is correct up to character (1, 2, ..., 5), add it to the end of the password&lt;br /&gt;
* Repeat until we've cracked all 5 characters.&lt;br /&gt;
&lt;br /&gt;
Note that the point of interest is no longer at sample 153. We noticed earlier that this key point moves 72 samples forward for every correct character, so we'll have to check location &amp;lt;code&amp;gt;153&amp;lt;/code&amp;gt; for character 0, &amp;lt;code&amp;gt;153 + 72&amp;lt;/code&amp;gt; for character 1, and &amp;lt;code&amp;gt;153 + i*72&amp;lt;/code&amp;gt; for character &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An example of this loop is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
password = ''&lt;br /&gt;
trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
  &lt;br /&gt;
for i in range(5):&lt;br /&gt;
    for c in trylist:&lt;br /&gt;
        # Get a power trace using our next attempt&lt;br /&gt;
        nextPass = password + '{}'.format(c)&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        &lt;br /&gt;
        # Grab the trace&lt;br /&gt;
        nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        &lt;br /&gt;
        # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
        if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
            continue&lt;br /&gt;
            &lt;br /&gt;
        # If we got here, we've found the right letter&lt;br /&gt;
        password += c&lt;br /&gt;
        print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
        break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After some time, this prints &amp;lt;code&amp;gt;5 characters: h0px3&amp;lt;/code&amp;gt; -- it automatically finds the correct password.&lt;br /&gt;
&lt;br /&gt;
That's it! You should have successfully cracked a password using the timing attack. Some notes on this method:&lt;br /&gt;
&lt;br /&gt;
* The target device has a finite start-up time, which slows down the attack. If you wish, remove some of the printf()'s from the target code, recompile and reprogram, and see how quickly you can do this attack.&lt;br /&gt;
* The current script doesn't look for the &amp;amp;quot;WELCOME&amp;amp;quot; message when the password is OK. That is an extension that allows it to crack any size password.&lt;br /&gt;
* If there was a lock-out on a wrong password, the system would ignore it, as it resets the target after every attempt.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
This tutorial has demonstrated the use of the power side-channel for performing timing attacks. A target with a simple password-based security system is broken. In addition you have learned about the scripting support in the ChipWhisperer-Capture software.&lt;br /&gt;
&lt;br /&gt;
= Appendix: Completed Timing Attack Script =&lt;br /&gt;
The &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt; function at the end of the tutorial might look something like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # This is the function that gets called when our script starts&lt;br /&gt;
        &lt;br /&gt;
        # First: set up the basics and connect to the CW-Lite&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Scope Module', 'ChipWhisperer/OpenADC'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Target Module', 'Simple Serial'])&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Trace Format', 'ChipWhisperer/Native'])&lt;br /&gt;
        self.api.setParameter(['Simple Serial', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.setParameter(['ChipWhisperer/OpenADC', 'Connection', 'ChipWhisperer-Lite'])&lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Next: set up everything we need to connect to the target&lt;br /&gt;
        # Put all of our commands in a list and execute them at the end&lt;br /&gt;
        lstexample = [&lt;br /&gt;
                      # Gain&lt;br /&gt;
                      ['OpenADC', 'Gain Setting', 'Setting', 45],&lt;br /&gt;
                      # Trigger&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Offset', 0],&lt;br /&gt;
                      ['OpenADC', 'Trigger Setup', 'Total Samples', 2000],&lt;br /&gt;
                      # Clock&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'],&lt;br /&gt;
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],&lt;br /&gt;
                      # Pins&lt;br /&gt;
                      ['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&lt;br /&gt;
                      ['CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'],&lt;br /&gt;
                      ['CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'],&lt;br /&gt;
                      # Automatic commands&lt;br /&gt;
                      ['Simple Serial', 'Load Key Command', ''],&lt;br /&gt;
                      ['Simple Serial', 'Go Command', 'h0px3\n'],&lt;br /&gt;
                      ['Simple Serial', 'Output Format', ''],&lt;br /&gt;
                      # Auto-reset&lt;br /&gt;
                      ['Generic Settings', 'Auxiliary Module', 'Reset AVR/XMEGA via CW-Lite'],&lt;br /&gt;
                      ['Aux Settings', 'Reset AVR/XMEGA via CW-Lite', 'Delay (Post-Arm)', 1200],&lt;br /&gt;
                      ]&lt;br /&gt;
        &lt;br /&gt;
        #Download all hardware setup parameters&lt;br /&gt;
        for cmd in lstexample: &lt;br /&gt;
            self.api.setParameter(cmd)&lt;br /&gt;
                       &lt;br /&gt;
        # Get one capture for fun&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
        data = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
        print data&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        # Crack the first letter&lt;br /&gt;
        password = ''&lt;br /&gt;
        trylist = 'abcdefghijklmnopqrstuvwxyz0123456789'&lt;br /&gt;
          &lt;br /&gt;
        for i in range(5):&lt;br /&gt;
            for c in trylist:&lt;br /&gt;
                # Get a power trace using our next attempt&lt;br /&gt;
                nextPass = password + '{}'.format(c)&lt;br /&gt;
                self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])&lt;br /&gt;
                self.api.capture1()&lt;br /&gt;
                &lt;br /&gt;
                # Grab the trace&lt;br /&gt;
                nextTrace = self.api.getScope().channels[0].getTrace()&lt;br /&gt;
                &lt;br /&gt;
                # Check location 153, 225, etc. If it's too low, we've failed&lt;br /&gt;
                if nextTrace[153 + 72*i] &amp;lt; -0.2:&lt;br /&gt;
                    continue&lt;br /&gt;
                    &lt;br /&gt;
                # If we got here, we've found the right letter&lt;br /&gt;
                password += c&lt;br /&gt;
                print '{} characters: {}'.format(i+1, password)&lt;br /&gt;
                break&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B2_Viewing_Instruction_Power_Differences&amp;diff=2775</id>
		<title>Tutorial B2 Viewing Instruction Power Differences</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B2_Viewing_Instruction_Power_Differences&amp;diff=2775"/>
				<updated>2017-07-19T00:07:49Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: fix line break&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to measuring the power consumption of a device under attack. It will demonstrate how you can view the difference between a 'add' instruction and a 'mul' instruction.&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
&lt;br /&gt;
You should have already completed [[Tutorial_B1_Building_a_SimpleSerial_Project]]. This tutorial assumes you are capable of building a new AVR/XMEGA code, programming the code, and connecting to the ChipWhisperer.&lt;br /&gt;
&lt;br /&gt;
= Setting Up the Example =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Copy the directory &amp;lt;code&amp;gt;simpleserial-base&amp;lt;/code&amp;gt; which is found at &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\&amp;lt;/code&amp;gt; of the chipwhisperer release to a new directory called &amp;lt;code&amp;gt;simpleserial-base-lab2&amp;lt;/code&amp;gt;. You must keep it in the same directory, as it will reference other files within that directory for the build process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you just completed [[Tutorial_B1_Building_a_SimpleSerial_Project]], you can simply reuse that code (this builds upon it).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;At this point we want to modify the system to perform a number of operations. We won't actually use the input data. To do so, open the file &amp;lt;code&amp;gt;simpleserial-base.c&amp;lt;/code&amp;gt; with a text editor such as Programmer's Notepad (which ships with WinAVR).&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Find the following code block towards the end of the file, which may look different if you just completed [[Tutorial_B1_Building_a_SimpleSerial_Project]].&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Modify it to do some work with no-ops and multiplication instructions:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;          &lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change the terminal to the directory with your source, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to build the system. Remember you can press the up arrow on the keyboard to get recently typed commands in most OSes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Which should have the following output, you will '''want to check the build platform is what you expect''':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;...Bunch of lines removed...&lt;br /&gt;
Creating Extended Listing: simpleserial-base.lss&lt;br /&gt;
avr-objdump -h -S -z simpleserial-base.elf &amp;amp;gt; simpleserial-base.lss&lt;br /&gt;
&lt;br /&gt;
Creating Symbol Table: simpleserial-base.sym&lt;br /&gt;
avr-nm -n simpleserial-base.elf &amp;amp;gt; simpleserial-base.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    1568 bytes (1.1% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        224 bytes (2.7% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Following the instructions given in [[Tutorial_B1_Building_a_SimpleSerial_Project]], program the AVR or XMEGA with your new code. Note you __do not__ need to close the programming window. If you will be doing frequent modifications to the source code, this can simplify your life since you only need to hit the '''Program''' button in AVRStudio to download new code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Ensure the hardware is setup as in [[Tutorial_B1_Building_a_SimpleSerial_Project]]. If using the CW1002, ensure the SMA cable is also connected as described in the previous tutorial.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Capturing Power Traces =&lt;br /&gt;
&lt;br /&gt;
The basic steps to connect to the ChipWhisperer device are described in [[Tutorial_B1_Building_a_SimpleSerial_Project]]. They are repeated here as well, however see [[Tutorial_B1_Building_a_SimpleSerial_Project]] for pictures &amp;amp;amp; mode details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start ChipWhisperer-Capture&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under ''Generic Settings'' tab, as the ''Scope Module'', select the ''ChipWhisperer/OpenADC'' option.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under ''Generic Settings'' tab, as the ''Target Module'', select the ''Simple Serial'' option.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Target Settings'' tab, and as the ''connection'', select the ''ChipWhisperer'' (for CW1002) or ''NewAE USB (CWLite/CW1200)'' (for ChipWhisperer Lite/Pro).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Scope Settings'' tab, and ensure the ''connection'' is set to either ''ChipWhisperer'' (for CW1002) or ''NewAE USB (CWLite/CW1200)'' (for ChipWhisperer Lite/Pro).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run the master connect (click the button labeled ''Master: DIS''). Both the Target &amp;amp;amp; Scope should switch to ''CON'' and be green circles.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;For the CW1173/CW1180/Cw1200 (ChipWhisperer-Lite/Pro based systems), perform the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''CLKGEN'' frequency to ''7.37 MHz''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Target HS-IO Out'' as ''CLKGEN''&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If targetting an XMEGA board (either the ChipWhisperer-Lite XMEGA default target, or the XMEGA on the multi-target board), perform the following:&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set ''Target IO1'' as ''Serial RXD''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set ''Target IO2'' as ''Serial TXD''&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the status monitor (&amp;lt;i&amp;gt;Tools &amp;gt; Encryption Status Monitor&amp;lt;/i&amp;gt;).&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 10. Hit the ''Run 1'' [[File:Capture One Button.PNG|image]] button. You may have to hit it a few times, as the very first serial data is often lost. You should see data populate in the ''Text Out'' field of the monitor window. The ''Text In'' and ''Text Out'' aren't actually used in this example, so you can close the ''Monitor'' dialog.&lt;br /&gt;
&lt;br /&gt;
At this point you've completed the same amount of information as the previous tutorial. The following section describes how to setup the analog capture hardware, which is new (to you). The following is entirely done in the ''Scope Settings'' tab:&lt;br /&gt;
&lt;br /&gt;
[[File:01_trigger_setupxcf.PNG|image]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;11&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under ''Trigger Setup'' set the ''Mode'' to ''rising edge''. This means the system will trigger on a rising edge logic level:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:02_CW_Extra.PNG|image]]&lt;br /&gt;
&lt;br /&gt;
{{Warningbox|Beginning of a hardware specific section for CW1002}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol start=&amp;quot;12&amp;quot; style=&amp;quot;list-style-type: decimal&amp;quot;&amp;gt;&amp;lt;li&amp;gt;For the CW1002 (ChipWhisperer Capture Rev 2) hardware only, perform the following:&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the ''Trigger Pins'' unselect the ''Front Panel A'' as an option, and select ''Target IO4 (Trigger Line)''. This will mean only the trigger pin coming from the AVR target is used to trigger the capture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;In the same area, select the ''Clock Source'' as being from ''Target IO-IN''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:03_ADC_Clock.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can monitor the ''Freq Counter'' option, which measures the frequency being used on the ''EXTCLK'' input. This should be 7.37 MHz, which is the oscillator on the multi-target board.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Change the ''ADC Clock'' ''source'' as being ''EXTCLK x4 via DCM''. This routes the external clock through a 4x multiplier, and routes it to the ADC.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warningbox|End of CW1002 (ChipWhisperer Capture Rev 2) specific section}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;12&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;For the CW1173/CW1180/Cw1200 (ChipWhisperer-Lite/Pro based hardware), perform the following:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Change the ''ADC Clock'' ''source'' as being ''CLKGEN x4 via DCM''. This routes the device clock through a 4x multiplier, and routes it to the ADC.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;13&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the '''Reset ADC DCM''' button.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:04_ADC_Clock_2_1.png|image]]&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;14&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;The ''ADC Freq'' should show 29.5 MHz (which is 4x 7.37 MHz), and the ''DCM Locked'' checkbox __MUST__ be checked. If the ''DCM Locked'' checkbox is NOT checked, try hitting the ''Reset ADC DCM'' button again.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;At this point you can hit the ''Capture 1'' button, and see if the system works! You should end up with a window looking like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:05_Low_Gain.PNG|image|1250px]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Whilst there is a waveform, you need to adjust the capture settings. There are two main settings of importance, the analog gain and number of samples to capture.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:06_high_gain.PNG|image|1250px]]&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;16&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under ''Gain Setting'' set the ''Mode'' to ''high''. Increase the ''Gain Setting'' to about 25. You'll be able to adjust this further during experimentations, you may need to increase this depending on your hardware and target device. For the multi-target board with the CW1002 you will probably need to set this around 40.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under ''Trigger Setup'' set the ''Total Samples'' to ''500''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Try a few more ''Capture 1'' traces, and you should see a 'zoomed-in' waveform.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Modifying the Target =&lt;br /&gt;
&lt;br /&gt;
== Background on Setup ==&lt;br /&gt;
&lt;br /&gt;
This tutorial is using either an AtMega328p which is an Atmel AVR device, or AtXMEGA128D4 which is an Atmel XMEGA device. We are comparing the power consumption of two different instructions, the &amp;lt;code&amp;gt;MUL&amp;lt;/code&amp;gt; (multiply) instruction and the &amp;lt;code&amp;gt;NOP&amp;lt;/code&amp;gt; (no operation) instruction. Some information on these two instructions:&lt;br /&gt;
&lt;br /&gt;
; mul&lt;br /&gt;
* Multiples two 8-bit numbers together.&lt;br /&gt;
* Takes 2 clock cycles to complete&lt;br /&gt;
* Intuitively expect fairly large power consumption due to complexity of operation required&lt;br /&gt;
; nop&lt;br /&gt;
* Does nothing&lt;br /&gt;
* Takes 1 clock cycle to complete&lt;br /&gt;
* Intuitively expect low power consumption due to core doing nothing&lt;br /&gt;
&lt;br /&gt;
Note that the capture clock is running at 4x the device clock. Thus a single &amp;lt;code&amp;gt;mul&amp;lt;/code&amp;gt; instruction should span 8 samples on our output graph, since it takes 4 samples to cover a complete clock cycle.&lt;br /&gt;
&lt;br /&gt;
== Initial Code ==&lt;br /&gt;
&lt;br /&gt;
The initial code has a power signature something like this (yours will vary based on various physical considerations, and depending if you are using an XMEGA or AVR device):&lt;br /&gt;
&lt;br /&gt;
[[File:cap_nop_mul.png|image]]&lt;br /&gt;
&lt;br /&gt;
Note that the 10 &amp;lt;code&amp;gt;mul&amp;lt;/code&amp;gt; instructions would be expected to take 80 samples to complete, and the 10 &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt; instructions should take 40 samples to complete. By modifying the code we can determine exactly which portion of the trace is corresponding to which operations.&lt;br /&gt;
&lt;br /&gt;
== Increase number of NOPs ==&lt;br /&gt;
&lt;br /&gt;
We will then modify the code to have twenty NOP operations in a row instead of ten. The modified code looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;          &lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/source&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;mul&amp;lt;/code&amp;gt; operation takes 2 clock cycles on the AVR, and the &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt; operation takes 1 clock cycles. Thus we expect to now see two areas of the power trace which appear to take approximately the same time. The resulting power trace looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:cap_doublenop_mul.png|image]]&lt;br /&gt;
&lt;br /&gt;
Pay particular attention to the section between sample number 0 &amp;amp;amp; sample number 180. It is in this section we can compare the two power graphs to see the modified code. We can actually 'see' the change in operation of the device! It would appear the &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt; is occuring from approximately 10-90, and the &amp;lt;code&amp;gt;mul&amp;lt;/code&amp;gt; occuring from 90-170.&lt;br /&gt;
&lt;br /&gt;
== Add NOP loop after MUL ==&lt;br /&gt;
&lt;br /&gt;
Finally, we will add 10 more NOPs after the 10 MULs. The code should look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;          &lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;mul r0,r1&amp;quot; &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
asm volatile(&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
&amp;quot;nop&amp;quot;       &amp;quot;\n\t&amp;quot;&lt;br /&gt;
::&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/source&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
With an output graph that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:cap_doublenop_mul_nop.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
== Comparison of All Three ==&lt;br /&gt;
&lt;br /&gt;
The following graph lines the three options up. One can see where adding loops of different operations shows up in the power consumption.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:nop_mul_comparison.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
= Clock Phase Adjustment =&lt;br /&gt;
&lt;br /&gt;
A final area of interest is the clock phase adjustment. The clock phase adjustment is used to shift the ADC sample clock from the actual device clock by small amounts. This will affect the appearance of the captured waveform, and in more advanced methods is used to improve the measurement.&lt;br /&gt;
&lt;br /&gt;
The phase adjustment is found under the ''Phase Adjust'' option of the ''ADC Clock'' setting:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:phasesetting.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
To see the effect this has, first consider an image of the power measured by a regular oscilloscope (at 1.25GS/s):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:scope_real.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
And the resulting waveforms for a variety of different phase shift settings:&lt;br /&gt;
&lt;br /&gt;
[[File:phase_differences.png|image]]&lt;br /&gt;
&lt;br /&gt;
The specifics of the capture are highly dependent on each ChipWhisperer board &amp;amp;amp; target platform. The phase shift allows customization of the capture waveform for optimum performance, however what constitutes 'optimum performance' is highly dependent on the specifics of your algorithm.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
In this tutorial you have learned how power analysis can tell you the operations being performed on a microcontroller. In future work we will move towards using this for breaking various forms of security on devices.&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B1_Building_a_SimpleSerial_Project&amp;diff=2774</id>
		<title>Tutorial B1 Building a SimpleSerial Project</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B1_Building_a_SimpleSerial_Project&amp;diff=2774"/>
				<updated>2017-07-18T23:34:59Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Fix tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to the 'simpleserial' communications system. It will show you how to perform different operations on data based on input from the ChipWhisperer software. This can be used for building your own system which you wish to 'break'.&lt;br /&gt;
&lt;br /&gt;
{{TOC|limit=3}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; What is SimpleSerial &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[SimpleSerial]] is the communications protocol used for almost all of the ChipWhisperer demo project. It's a very basic serial protocol which can be easily implemented on most systems. This system communicates using a standard asyncronous serial protocol, 38400 baud, 8-N-1.&lt;br /&gt;
&lt;br /&gt;
All messages are sent in ASCII-text, and are normally terminated with a line-feed ('\n'). This allows you to interact with the simpleserial system over a standard terminal emulator.&lt;br /&gt;
&lt;br /&gt;
The following message types are defined:&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;&lt;br /&gt;
: Sending a 'x' resets the buffers. This does not require a line-feed termination. It is suggested to always send a stream of x's to initilize the system in case the device was already in some other mode due to noise/corruption.&lt;br /&gt;
; &amp;lt;code&amp;gt;k00112233445566778899AABBCCDDEEFF\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: Loads the encryption key &amp;lt;code&amp;gt;00112233445566778899AABBCCDDEEFF&amp;lt;/code&amp;gt; into the system. If not called the system may use some default key.&lt;br /&gt;
; &amp;lt;code&amp;gt;pAABBCCDDEEFF00112233445566778899\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: Encrypts the data &amp;lt;code&amp;gt;AABBCCDDEEFF00112233445566778899&amp;lt;/code&amp;gt; with the key loaded with the 'k' command. The system will respond with a string starting with r, as shown next.&lt;br /&gt;
; &amp;lt;code&amp;gt;rCBBD4A2B34F2571758FF6A797E09859D\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: This is the response from the system. If data has been encrypted with a 'p' for example, the system will respond with the 'r' sequence automatically. So sending the earlier example means the result of the encryption was &amp;lt;code&amp;gt;cbbd4a2b34f2571758ff6a797e09859d&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Building the Basic Example &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll need to have installed avr-gcc and avr-libc. You may have already done this by following the installation guide, or if using the ChipWhisperer-VM it comes prepared with avr-gcc already setup. See the [[Installing_ChipWhisperer]] guide for details.&lt;br /&gt;
&lt;br /&gt;
Once you have a working compiler (check by typing 'avr-gcc' at the command line - if using Windows you may need to setup a special batch file to provide you with a avr-gcc command prompt).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;We want to use the existing SimpleSerial firmware as a base for our project, but we don't want to edit the existing firmware. Instead, we'll make a new project with a copy of this firmware. Copy the directory &amp;lt;code&amp;gt;simpleserial-base&amp;lt;/code&amp;gt; which is found at &amp;lt;code&amp;gt;chipwhisperer/hardware/victims/firmware/&amp;lt;/code&amp;gt; of the chipwhisperer release to a new directory called &amp;lt;code&amp;gt;simpleserial-base-lab1&amp;lt;/code&amp;gt;. You must keep it in the same directory, as it will reference other files within that directory for the build process.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Open a terminal with avr-gcc in the path. If using Windows the sidebar on the [[Installing_ChipWhisperer]] page - you can either add WinAVR to your system path, or you can run the 'winavr.bat' file suggested.&amp;lt;/dt&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change the terminal to the newly copied directory. For example:&amp;lt;/p&amp;gt;&lt;br /&gt;
Windows:&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-base-lab1&amp;lt;/pre&amp;gt;&lt;br /&gt;
Linux/macOS:&amp;lt;pre&amp;gt;cd chipwhisperer/hardware/victims/firmware/simpleserial-base-lab1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then, run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to build the system. Make sure you specify which platform you're using as your target. For example, for the ChipWhisperer Lite target, run&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;make PLATFORM=CW303&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Which should have the following output:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;...Bunch of lines removed...&lt;br /&gt;
Creating Extended Listing: simpleserial-base.lss&lt;br /&gt;
avr-objdump -h -S -z simpleserial-base.elf &amp;amp;gt; simpleserial-base.lss&lt;br /&gt;
&lt;br /&gt;
Creating Symbol Table: simpleserial-base.sym&lt;br /&gt;
avr-nm -n simpleserial-base.elf &amp;amp;gt; simpleserial-base.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    1524 bytes (1.1% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        224 bytes (2.7% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
Ensure that the &amp;quot;Built for platform ___&amp;quot; matches your target device.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Modifying the Basic Example &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point we want to modify the system to perform 'something' with the data, such that we can confirm the system is working. To do so, open the file &amp;lt;code&amp;gt;simpleserial-base.c&amp;lt;/code&amp;gt; with a code editor such as ''Programmer's Notepad'' (which ships with WinAVR).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Find the following code block towards the end of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Modify it to increment the value of each sent data byte:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
for(int i = 0; i &amp;lt; 16; i++){&lt;br /&gt;
    pt[i]++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Rebuild the example using the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command. Remember you can press the up arrow on the keyboard to get recently typed commands in most OSes.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1173 (Lite) =&lt;br /&gt;
|content= Completing Tutorial with CW1173}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1200 (Pro) =&lt;br /&gt;
|content= Completing Tutorial with CW1200}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1002 (ChipWhisperer Capture Rev2) =&lt;br /&gt;
|content= Completing Tutorial with CW1002 (ChipWhisperer Capture Rev2)}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Conclusion &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this tutorial you have learned how to build a custom program for the microcontroller on the ChipWhisperer target board. You have programmed the built .hex file into the microcontroller, and confirmed communications with the ChipWhisperer device.&lt;br /&gt;
&lt;br /&gt;
In future labs you will build on this knowledge to attack specific instructions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Troubleshooting &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Issues with compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;You may have to generate the .dep and objdir directories manually before make will work:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;mkdir .dep&lt;br /&gt;
mkdir objdir&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On Windows 8, you may get an error like fork: resyntaxhighlight temporarily unavailable. This requires you to install an updated mysys.dll. Download from http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip, unzip file, and copy the .dll to &amp;lt;code&amp;gt;C:\WinAVR-20100110\utils\bin&amp;lt;/code&amp;gt;, replacing the existing file.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For the AVR Studio USB Drivers, you'll need to download a [https://gallery.atmel.com/Products/Details/004ccabd-e18e-431a-8557-83deaea23341 Special Update] from Atmel.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You may wish to use the &amp;amp;quot;ChipWhisperer Virtual Machine&amp;amp;quot; on newer Windows systems, which does not require any of the above setup.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B1_Building_a_SimpleSerial_Project&amp;diff=2773</id>
		<title>Tutorial B1 Building a SimpleSerial Project</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B1_Building_a_SimpleSerial_Project&amp;diff=2773"/>
				<updated>2017-07-18T23:18:44Z</updated>
		
		<summary type="html">&lt;p&gt;DavidRysk: Add command lines for Linux/macOS&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will introduce you to the 'simpleserial' communications system. It will show you how to perform different operations on data based on input from the ChipWhisperer software. This can be used for building your own system which you wish to 'break'.&lt;br /&gt;
&lt;br /&gt;
{{TOC|limit=3}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; What is SimpleSerial &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[SimpleSerial]] is the communications protocol used for almost all of the ChipWhisperer demo project. It's a very basic serial protocol which can be easily implemented on most systems. This system communicates using a standard asyncronous serial protocol, 38400 baud, 8-N-1.&lt;br /&gt;
&lt;br /&gt;
All messages are sent in ASCII-text, and are normally terminated with a line-feed ('\n'). This allows you to interact with the simpleserial system over a standard terminal emulator.&lt;br /&gt;
&lt;br /&gt;
The following message types are defined:&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;&lt;br /&gt;
: Sending a 'x' resets the buffers. This does not require a line-feed termination. It is suggested to always send a stream of x's to initilize the system in case the device was already in some other mode due to noise/corruption.&lt;br /&gt;
; &amp;lt;code&amp;gt;k00112233445566778899AABBCCDDEEFF\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: Loads the encryption key &amp;lt;code&amp;gt;00112233445566778899AABBCCDDEEFF&amp;lt;/code&amp;gt; into the system. If not called the system may use some default key.&lt;br /&gt;
; &amp;lt;code&amp;gt;pAABBCCDDEEFF00112233445566778899\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: Encrypts the data &amp;lt;code&amp;gt;AABBCCDDEEFF00112233445566778899&amp;lt;/code&amp;gt; with the key loaded with the 'k' command. The system will respond with a string starting with r, as shown next.&lt;br /&gt;
; &amp;lt;code&amp;gt;rCBBD4A2B34F2571758FF6A797E09859D\\n&amp;lt;/code&amp;gt;&lt;br /&gt;
: This is the response from the system. If data has been encrypted with a 'p' for example, the system will respond with the 'r' sequence automatically. So sending the earlier example means the result of the encryption was &amp;lt;code&amp;gt;cbbd4a2b34f2571758ff6a797e09859d&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Building the Basic Example &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll need to have installed avr-gcc and avr-libc. You may have already done this by following the installation guide, or if using the ChipWhisperer-VM it comes prepared with avr-gcc already setup. See the [[Installing_ChipWhisperer]] guide for details.&lt;br /&gt;
&lt;br /&gt;
Once you have a working compiler (check by typing 'avr-gcc' at the command line - if using Windows you may need to setup a special batch file to provide you with a avr-gcc command prompt).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;We want to use the existing SimpleSerial firmware as a base for our project, but we don't want to edit the existing firmware. Instead, we'll make a new project with a copy of this firmware. Copy the directory &amp;lt;code&amp;gt;simpleserial-base&amp;lt;/code&amp;gt; which is found at &amp;lt;code&amp;gt;chipwhisperer/hardware/victims/firmware/&amp;lt;/code&amp;gt; of the chipwhisperer release to a new directory called &amp;lt;code&amp;gt;simpleserial-base-lab1&amp;lt;/code&amp;gt;. You must keep it in the same directory, as it will reference other files within that directory for the build process.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;Open a terminal with avr-gcc in the path. If using Windows the sidebar on the [[Installing_ChipWhisperer]] page - you can either add WinAVR to your system path, or you can run the 'winavr.bat' file suggested.&amp;lt;/dt&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Change the terminal to the newly copied directory. For example:&amp;lt;/p&amp;gt;&lt;br /&gt;
Windows:&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-base-lab1&amp;lt;/pre&amp;gt;&lt;br /&gt;
Linux/macOS:&amp;lt;pre&amp;gt;cd chipwhisperer/hardware/victims/firmware/simpleserial-base-lab1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then, run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to build the system. Make sure you specify which platform you're using as your target. For example, for the ChipWhisperer Lite target, run&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;make PLATFORM=CW303&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Which should have the following output:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;...Bunch of lines removed...&lt;br /&gt;
Creating Extended Listing: simpleserial-base.lss&lt;br /&gt;
avr-objdump -h -S -z simpleserial-base.elf &amp;amp;gt; simpleserial-base.lss&lt;br /&gt;
&lt;br /&gt;
Creating Symbol Table: simpleserial-base.sym&lt;br /&gt;
avr-nm -n simpleserial-base.elf &amp;amp;gt; simpleserial-base.sym&lt;br /&gt;
&lt;br /&gt;
Size after:&lt;br /&gt;
AVR Memory Usage&lt;br /&gt;
----------------&lt;br /&gt;
Device: atxmega128d3&lt;br /&gt;
&lt;br /&gt;
Program:    1524 bytes (1.1% Full)&lt;br /&gt;
(.text + .data + .bootloader)&lt;br /&gt;
&lt;br /&gt;
Data:        224 bytes (2.7% Full)&lt;br /&gt;
(.data + .bss + .noinit)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Built for platform CW-Lite XMEGA&lt;br /&gt;
&lt;br /&gt;
-------- end --------&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
Ensure that the &amp;quot;Built for platform ___&amp;quot; matches your target device.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/h1&amp;gt; Modifying the Basic Example &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point we want to modify the system to perform 'something' with the data, such that we can confirm the system is working. To do so, open the file &amp;lt;code&amp;gt;simpleserial-base.c&amp;lt;/code&amp;gt; with a code editor such as ''Programmer's Notepad'' (which ships with WinAVR).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Find the following code block towards the end of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Modify it to increment the value of each sent data byte:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;/**********************************&lt;br /&gt;
 * Start user-specific code here. */&lt;br /&gt;
trigger_high();&lt;br /&gt;
&lt;br /&gt;
//16 hex bytes held in 'pt' were sent&lt;br /&gt;
//from the computer. Store your response&lt;br /&gt;
//back into 'pt', which will send 16 bytes&lt;br /&gt;
//back to computer. Can ignore of course if&lt;br /&gt;
//not needed&lt;br /&gt;
&lt;br /&gt;
for(int i = 0; i &amp;lt; 16; i++){&lt;br /&gt;
    pt[i]++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger_low();&lt;br /&gt;
/* End user-specific code here. *&lt;br /&gt;
 ********************************/&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Rebuild the example using the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command. Remember you can press the up arrow on the keyboard to get recently typed commands in most OSes.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1173 (Lite) =&lt;br /&gt;
|content= Completing Tutorial with CW1173}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1200 (Pro) =&lt;br /&gt;
|content= Completing Tutorial with CW1200}}&lt;br /&gt;
&lt;br /&gt;
{{CollapsibleSection&lt;br /&gt;
|intro = = Completing Tutorial with CW1002 (ChipWhisperer Capture Rev2) =&lt;br /&gt;
|content= Completing Tutorial with CW1002 (ChipWhisperer Capture Rev2)}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Conclusion &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this tutorial you have learned how to build a custom program for the microcontroller on the ChipWhisperer target board. You have programmed the built .hex file into the microcontroller, and confirmed communications with the ChipWhisperer device.&lt;br /&gt;
&lt;br /&gt;
In future labs you will build on this knowledge to attack specific instructions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Troubleshooting &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Issues with compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;You may have to generate the .dep and objdir directories manually before make will work:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;mkdir .dep&lt;br /&gt;
mkdir objdir&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On Windows 8, you may get an error like fork: resyntaxhighlight temporarily unavailable. This requires you to install an updated mysys.dll. Download from http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip, unzip file, and copy the .dll to &amp;lt;code&amp;gt;C:\WinAVR-20100110\utils\bin&amp;lt;/code&amp;gt;, replacing the existing file.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For the AVR Studio USB Drivers, you'll need to download a [https://gallery.atmel.com/Products/Details/004ccabd-e18e-431a-8557-83deaea23341 Special Update] from Atmel.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You may wish to use the &amp;amp;quot;ChipWhisperer Virtual Machine&amp;amp;quot; on newer Windows systems, which does not require any of the above setup.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>DavidRysk</name></author>	</entry>

	</feed>