<?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=Adriel</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=Adriel"/>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/Special:Contributions/Adriel"/>
		<updated>2026-06-04T19:36:22Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2791</id>
		<title>CW-Capture Tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2791"/>
				<updated>2017-07-26T02:31:52Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tool captures traces from scopes while is also capable of synchronize it with different targets devices. &lt;br /&gt;
&lt;br /&gt;
Main features:&lt;br /&gt;
* View the wave form of each trace;&lt;br /&gt;
* Save/load/import/edit/manage the traces;&lt;br /&gt;
* Run custom capture scripts;&lt;br /&gt;
* Automated glitch exploring with a nice scatterplot widget to visualize the result;&lt;br /&gt;
* Convenient firmware programmer to flash files to the target board;&lt;br /&gt;
* Record traces using fixed/random encryption keys and fixed/random plaintext inputs;&lt;br /&gt;
* Serial Terminal&lt;br /&gt;
[[File:Screen Shot 2016-07-15 at 10.00.52 AM.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== The Basic ==&lt;br /&gt;
The capture tool comes with a list of built-in scripts to connect to different pairs of target-scope hardwares. The easiest way to start using it is accessing the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Example Scripts&amp;quot; menu and select the appropriate item in the list.&lt;br /&gt;
&lt;br /&gt;
If you want more advanced setups, you will have to configure the capture environment manually using the Setting tabs, starting with the &amp;quot;Generic Settings&amp;quot;:&lt;br /&gt;
# Select the desired &amp;quot;Scope Module&amp;quot;  (e.g., ChipWhisperer/OpenADC). Leave it as None if you only want to use the target.&lt;br /&gt;
# Select the desired &amp;quot;Target Module&amp;quot; (e.g., Simple Serial). Leave it as None if you only want to use the scope.&lt;br /&gt;
# Select the desired &amp;quot;Trace Format&amp;quot; (e.g., ChipWhisperer/Native). Leave it as None if you don't need to save the traces, as often happen when executing the Glitching attack.&lt;br /&gt;
# Switch to the &amp;quot;Scope Settings&amp;quot; tab and setup your scope connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Switch to the &amp;quot;Target Settings&amp;quot; tab and setup your target connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Connect to the desired scope/target pair, using the toolbar buttons. The master button connects to both at the same time.&lt;br /&gt;
#* At this point, you may want to flash the desired firmware to the target, using the Programmer option in the Tools' menu.&lt;br /&gt;
# Once connected, both the &amp;quot;Scope Settings&amp;quot; and &amp;quot;Target Settings&amp;quot; list of parameters may expand, giving access to more advanced settings. You will have to set these parameters which depend on what you want to capture. It usually involves setting the following parameters:&lt;br /&gt;
#* Trigger Pins&lt;br /&gt;
#* Target IOn Pins&lt;br /&gt;
#* Target HS IO-Out&lt;br /&gt;
#* Clock Setup&lt;br /&gt;
#* Trigger Setup-&amp;gt;Total Samples&lt;br /&gt;
#* Trigger Setup-&amp;gt;Offset&lt;br /&gt;
#* Trigger Setup-&amp;gt;Mode&lt;br /&gt;
#* Gain&lt;br /&gt;
#* Relock/reset the DCM in case it is lost.&lt;br /&gt;
#* TIP: check the content of the &amp;quot;Example Scripts&amp;quot; at chipwhisperer/software/chipwhisperer/capture/scripts if you are lost.&lt;br /&gt;
# You may want to check if everything is working properly by clicking in the &amp;quot;Capture 1&amp;quot; button and adjusting the above settings if necessary.&lt;br /&gt;
# Once it is working as expected, you can set the &amp;quot;Generic Settings&amp;quot;-&amp;gt;&amp;quot;Acquisition Settings&amp;quot;-&amp;gt;&amp;quot;Number of Traces&amp;quot; option to the desired amount (e.g. 50-100) and click the &amp;quot;Capture M&amp;quot; button in the toolbar. This time the traces will be saved to the &amp;quot;Trace Manager&amp;quot; if you specified a &amp;quot;Trace Format&amp;quot;.&lt;br /&gt;
# In order to view the saved traces, you will have to change the &amp;quot;Result&amp;quot;-&amp;gt;&amp;quot;Trace Output Plot&amp;quot;-&amp;gt;&amp;quot;Input&amp;quot; from the scope channel to the &amp;quot;Trace Manager&amp;quot;. You may also want to change the &amp;quot;X Axis&amp;quot; temporal sequence from Samples to Time. &lt;br /&gt;
# You can also import, delete, edit or select/deselect the trace segments by opening the &amp;quot;Trace Manager&amp;quot; in the Project menu.&lt;br /&gt;
# Don't forget to save the Project after each change in the traces. A &amp;quot;Consolidate&amp;quot; option is also available to move/copy all the trace files to the current project directory. It is useful if you imported existing traces or captured it before creating the project.&lt;br /&gt;
Once you master this procedure and get tired of doing it over and over again, there are two things you can do about it:&lt;br /&gt;
# Create your own script (based on the existing ones) and add it to the chipwhisperer/software/chipwhisperer/capture/scripts or ~/chipwhisperer_projects/chipwhisperer/capture/scripts directories. You may want to copy/paste the lines from the &amp;quot;Script Commands&amp;quot; window, once the environment is already set, in order to make it easier.&lt;br /&gt;
# Set your capture environment and save the parameter groups using the Save buttons in the top of the Settings tabs. Other possibility would be to use the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Save Settings&amp;quot; option to save all the settings at the same time to the &amp;quot;settings.cwset&amp;quot; file inside your project directory. The '''settings are NOT loaded automatically''' when the project is opened. Instead, you should click in the Load button for each group of settings that you want to restore. It is possible to have multiple settings profiles using different settings files. The capture tool also records the settings with the traces when they are captured. If you want to configure the tool to the same environment used in a previous capture, it is possible by loading the setting file saved inside the traces directory.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
Follow the [[Tutorial B5 Breaking AES (Straightforward)|B5 tutorial]] to learn how to use it with different targets.&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
Click in this link to learn how to use the [[Glitch Explorer]].&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2790</id>
		<title>CW-Capture Tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2790"/>
				<updated>2017-07-26T02:15:23Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tool captures traces from scopes while is also capable of synchronize it with different targets devices. &lt;br /&gt;
&lt;br /&gt;
Main features:&lt;br /&gt;
* View the wave form of each trace;&lt;br /&gt;
* Save/load/import/edit/manage the traces;&lt;br /&gt;
* Run custom capture scripts;&lt;br /&gt;
* Automated glitch exploring with a nice scatterplot widget to visualize the result;&lt;br /&gt;
* Convenient firmware programmer to flash files to the target board;&lt;br /&gt;
* Record traces using fixed/random encryption keys and fixed/random plaintext inputs;&lt;br /&gt;
* Serial Terminal&lt;br /&gt;
[[File:Screen Shot 2016-07-15 at 10.00.52 AM.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== The Basic ==&lt;br /&gt;
The capture tool comes with a list of built-in scripts to connect to different pairs of target-scope hardwares. The easiest way to start using it is accessing the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Example Scripts&amp;quot; menu and select the appropriate item in the list.&lt;br /&gt;
&lt;br /&gt;
If you want more advanced setups, you will have to configure the capture environment manually using the Setting tabs, starting with the &amp;quot;Generic Settings&amp;quot;:&lt;br /&gt;
# Select the desired &amp;quot;Scope Module&amp;quot;  (e.g., ChipWhisperer/OpenADC). Leave it as None if you only want to use the target.&lt;br /&gt;
# Select the desired &amp;quot;Target Module&amp;quot; (e.g., Simple Serial). Leave it as None if you only want to use the scope.&lt;br /&gt;
# Select the desired &amp;quot;Trace Format&amp;quot; (e.g., ChipWhisperer/Native). Leave it as None if you don't need to save the traces, as often happen when executing the Glitching attack.&lt;br /&gt;
# Switch to the &amp;quot;Scope Settings&amp;quot; tab and setup your scope connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Switch to the &amp;quot;Target Settings&amp;quot; tab and setup your target connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Connect to the desired scope/target pair, using the toolbar buttons. The master button connects to both at the same time.&lt;br /&gt;
#* At this point, you may want to flash the desired firmware to the target, using the Programmer option in the Tools' menu.&lt;br /&gt;
# Once connected, both the &amp;quot;Scope Settings&amp;quot; and &amp;quot;Target Settings&amp;quot; list of parameters may expand, giving access to more advanced settings. You will have to set these parameters which depend on what you want to capture. It usually involves setting the following parameters:&lt;br /&gt;
#* Trigger Pins&lt;br /&gt;
#* Target IOn Pins&lt;br /&gt;
#* Target HS IO-Out&lt;br /&gt;
#* Clock Setup&lt;br /&gt;
#* Trigger Setup-&amp;gt;Total Samples&lt;br /&gt;
#* Trigger Setup-&amp;gt;Offset&lt;br /&gt;
#* Trigger Setup-&amp;gt;Mode&lt;br /&gt;
#* Gain&lt;br /&gt;
#* Relock/reset the DCM in case it is lost.&lt;br /&gt;
#* TIP: check the content of the &amp;quot;Example Scripts&amp;quot; at chipwhisperer/software/chipwhisperer/capture/scripts if you are lost.&lt;br /&gt;
# You may want to check if everything is working properly by clicking in the &amp;quot;Capture 1&amp;quot; button and adjusting the above settings if necessary.&lt;br /&gt;
# Once it is working as expected, you can set the &amp;quot;Generic Settings&amp;quot;-&amp;gt;&amp;quot;Acquisition Settings&amp;quot;-&amp;gt;&amp;quot;Number of Traces&amp;quot; option to the desired amount (i.e. 50-100) and click the &amp;quot;Capture M&amp;quot; button in the toolbar. This time the traces will be saved to the &amp;quot;Trace Manager&amp;quot; if you specified a &amp;quot;Trace Format&amp;quot;.&lt;br /&gt;
# In order to view the saved traces, you will have to change the &amp;quot;Result&amp;quot;-&amp;gt;&amp;quot;Trace Output Plot&amp;quot;-&amp;gt;&amp;quot;Input&amp;quot; from the scope channel to the &amp;quot;Trace Manager&amp;quot;. You may also want to change the &amp;quot;X Axis&amp;quot; temporal sequence from Samples to Time. &lt;br /&gt;
# You can also import, delete, edit or select/deselect the trace segments by opening the &amp;quot;Trace Manager&amp;quot; in the Project menu.&lt;br /&gt;
# Don't forget to save the Project after each change in the traces. A &amp;quot;Consolidate&amp;quot; option is also available to move/copy all the trace files to the current project directory. It is useful if you imported existing traces or captured it before creating the project.&lt;br /&gt;
Once you master this procedure and get tired of doing it over and over again, there are two things you can do about it:&lt;br /&gt;
# Create your own script (based on the existing ones) and add it to the chipwhisperer/software/chipwhisperer/capture/scripts or ~/chipwhisperer_projects/chipwhisperer/capture/scripts directories. You may want to copy/paste the lines from the &amp;quot;Script Commands&amp;quot; window, once the environment is already set, in order to make it easier.&lt;br /&gt;
# Set your capture environment and save the parameter groups using the Save buttons in the top of the Settings tabs. Other possibility would be to use the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Save Settings&amp;quot; option to save all the settings at the same time to the &amp;quot;settings.cwset&amp;quot; file inside your project directory. The '''settings are NOT loaded automatically''' when the project is opened. Instead, you should click in the Load button for each group of settings that you want to restore. It is possible to have multiple settings profiles using different settings files. The capture tool also records the settings with the traces when they are captured. If you want to configure the tool to the same environment used in a previous capture, it is possible by loading the setting file saved inside the traces directory.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
Follow the [[Tutorial B5 Breaking AES (Straightforward)|B5 tutorial]] to learn how to use it with different targets.&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
Click in this link to learn how to use the [[Glitch Explorer]].&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2789</id>
		<title>CW-Capture Tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=2789"/>
				<updated>2017-07-26T02:13:51Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tool captures traces from scopes while is also capable of synchronize it with different targets devices. &lt;br /&gt;
&lt;br /&gt;
Main features:&lt;br /&gt;
* View the wave form of each trace;&lt;br /&gt;
* Save/load/import/edit/manage the traces;&lt;br /&gt;
* Run custom capture scripts;&lt;br /&gt;
* Automated glitch exploring with a nice scatterplot widget to visualize the result;&lt;br /&gt;
* Convenient firmware programmer to flash files to the target board;&lt;br /&gt;
* Record traces using fixed/random encryption keys and fixed/random plaintext inputs;&lt;br /&gt;
* Serial Terminal&lt;br /&gt;
[[File:Screen Shot 2016-07-15 at 10.00.52 AM.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== The Basic ==&lt;br /&gt;
The capture tool comes with a list of built-in scripts to connect to different pairs of target-scope hardwares. The easiest way to start using it is accessing the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Example Scripts&amp;quot; menu and select the appropriate item in the list.&lt;br /&gt;
&lt;br /&gt;
If you want more advanced setups, you will have to configure the capture environment manually using the Setting tabs, starting with the &amp;quot;Generic Settings&amp;quot;:&lt;br /&gt;
# Select the desired &amp;quot;Scope Module&amp;quot;  (e.g., ChipWhisperer/OpenADC). Leave it as None if you only want to use the target.&lt;br /&gt;
# Select the desired &amp;quot;Target Module&amp;quot; (e.g., Simple Serial). Leave it as None if you only want to use the scope.&lt;br /&gt;
# Select the desired &amp;quot;Trace Format&amp;quot; (e.g., ChipWhisperer/Native). Leave it as None if you don't need to save the traces, as often happen when executing the Glitching attack.&lt;br /&gt;
# Switch to the &amp;quot;Scope Settings&amp;quot; tab and setup your scope connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Switch to the &amp;quot;Target Settings&amp;quot; tab and setup your target connection (e.g., selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Connect to the desired scope/target pair, using the toolbar buttons. The master button connects to both at the same time.&lt;br /&gt;
#* At this point, you may want to flash the desired firmware to the target, using the Programmer option in the Tools' menu.&lt;br /&gt;
# Once connected, both the &amp;quot;Scope Settings&amp;quot; and &amp;quot;Target Settings&amp;quot; list of parameters may expand, giving access to more advanced settings. You will have to setup these parameters which depend on what you want to capture. It usually involves setting the following parameters:&lt;br /&gt;
#* Trigger Pins&lt;br /&gt;
#* Target IOn Pins&lt;br /&gt;
#* Target HS IO-Out&lt;br /&gt;
#* Clock Setup&lt;br /&gt;
#* Trigger Setup-&amp;gt;Total Samples&lt;br /&gt;
#* Trigger Setup-&amp;gt;Offset&lt;br /&gt;
#* Trigger Setup-&amp;gt;Mode&lt;br /&gt;
#* Gain&lt;br /&gt;
#* Relock/reset the DCM in case it is lost.&lt;br /&gt;
#* TIP: check the content of the &amp;quot;Example Scripts&amp;quot; at chipwhisperer/software/chipwhisperer/capture/scripts if you are lost.&lt;br /&gt;
# You may want to check if everything is working properly by clicking in the &amp;quot;Capture 1&amp;quot; button and adjusting the above settings if necessary.&lt;br /&gt;
# Once it is working as expected, you can set the &amp;quot;Generic Settings&amp;quot;-&amp;gt;&amp;quot;Acquisition Settings&amp;quot;-&amp;gt;&amp;quot;Number of Traces&amp;quot; option to the desired amount (i.e. 50-100) and click the &amp;quot;Capture M&amp;quot; button in the toolbar. This time the traces will be saved to the &amp;quot;Trace Manager&amp;quot; if you specified a &amp;quot;Trace Format&amp;quot;.&lt;br /&gt;
# In order to view the saved traces, you will have to change the &amp;quot;Result&amp;quot;-&amp;gt;&amp;quot;Trace Output Plot&amp;quot;-&amp;gt;&amp;quot;Input&amp;quot; from the scope channel to the &amp;quot;Trace Manager&amp;quot;. You may also want to change the &amp;quot;X Axis&amp;quot; temporal sequence from Samples to Time. &lt;br /&gt;
# You can also import, delete, edit or select/deselect the trace segments by opening the &amp;quot;Trace Manager&amp;quot; in the Project menu.&lt;br /&gt;
# Don't forget to save the Project after each change in the traces. A &amp;quot;Consolidate&amp;quot; option is also available to move/copy all the trace files to the current project directory. It is useful if you imported existing traces or captured it before creating the project.&lt;br /&gt;
Once you master this procedure and get tired of doing it over and over again, there are two things you can do about it:&lt;br /&gt;
# Create your own script (based on the existing ones) and add it to the chipwhisperer/software/chipwhisperer/capture/scripts or ~/chipwhisperer_projects/chipwhisperer/capture/scripts directories. You may want to copy/paste the lines from the &amp;quot;Script Commands&amp;quot; window, once the environment is already set, in order to make it easier.&lt;br /&gt;
# Set your capture environment and save the parameter groups using the Save buttons in the top of the Settings tabs. Other possibility would be to use the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Save Settings&amp;quot; option to save all the settings at the same time to the &amp;quot;settings.cwset&amp;quot; file inside your project directory. The '''settings are NOT loaded automatically''' when the project is opened. Instead, you should click in the Load button for each group of settings that you want to restore. It is possible to have multiple settings profiles using different settings files. The capture tool also records the settings with the traces when they are captured. If you want to configure the tool to the same environment used in a previous capture, it is possible by loading the setting file saved inside the traces directory.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
Follow the [[Tutorial B5 Breaking AES (Straightforward)|B5 tutorial]] to learn how to use it with different targets.&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
Click in this link to learn how to use the [[Glitch Explorer]].&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=2788</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=2788"/>
				<updated>2017-07-23T19:01:03Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=2787</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=2787"/>
				<updated>2017-07-23T17:37:27Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 significant 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;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Adding_Modules/Parameters&amp;diff=1803</id>
		<title>Adding Modules/Parameters</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Adding_Modules/Parameters&amp;diff=1803"/>
				<updated>2017-02-13T01:13:19Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* auxiliary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Adding New Modules=&lt;br /&gt;
&lt;br /&gt;
In the new CW plugin architecture, all modules are scanned during the tool initialization, so new functionalities can be added by just dropping its file inside the respective folder:&lt;br /&gt;
&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/common/results&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/common/traces&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/acq_patterns&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/auxiliary&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scopes&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scripts&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/targets&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/attacks&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/preprocessing&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/scripts&lt;br /&gt;
* and some of the above subfolders.&lt;br /&gt;
&lt;br /&gt;
These paths are checked both inside the tool's root directory (where the tool is installed), and in the Project Folder (default is ~/chipwhisperer_projects), allowing the usage of custom modules without the requirement of being system administer. The CW tools scan these directories looking for classes that inherits from the ''Plugin'' class (a marker interface actually) in each public module (that doesn't begin with &amp;quot;_&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT''': Accessing &amp;quot;Help-&amp;gt;List Enabled/Disabled Plugins&amp;quot; in the tool's menu you'll find a list with all modules it tried to load. In case of any problem, you can check in the table the error message and its details. It should be easier to visuallise if you copy and paste the cell cotent to a text editor (example: notepad).&lt;br /&gt;
&lt;br /&gt;
These folders usually have a file called ''base.py'' or ''_base.py'' that contains the base class to all plugins in these directories. Ex.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from .base import PreprocessingBase&lt;br /&gt;
from chipwhisperer.common.utils.pluginmanager import Plugin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class AddNoiseRandom(PreprocessingBase, Plugin):&lt;br /&gt;
    _name = &amp;quot;Add Noise: Amplitude&amp;quot;&lt;br /&gt;
    _description = &amp;quot;Add random noise&amp;quot;&lt;br /&gt;
     &lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Adding Parameters=&lt;br /&gt;
&lt;br /&gt;
Parameters are used to allow easy access and manipulation of all object's main attibutes and actions. All parameters can be accessed anywhere in the code throught the Parameter class. It means that if you want to set/get any parameter, you can do it easily adding the follow lines to your code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
...&lt;br /&gt;
Parameter.setParameter([path,..., value])&lt;br /&gt;
value = Parameter.getParameter([path,...])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, if you have access to the api:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
api.setParameter([path,..., value])&lt;br /&gt;
value = api.getParameter([path,...])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The easiest way to add parameters to your class, is to make it ''Parameterized'' (extending this class). It is an abstract class that declares a public interface and implements two manipulation methods to create/get the parameters and find it. As a general rule, you just need to:&lt;br /&gt;
&lt;br /&gt;
* import the ''Parameterized'' class: from chipwhisperer.common.utils.parameter import Parameterized&lt;br /&gt;
* make your class extend it (no construtor call is needed here since the idea is to use it as an interface to avoid the problems with multiple inheritance - i.e.: the diamont one)&lt;br /&gt;
* define a _name and a _description&lt;br /&gt;
* register it if it is not readily accessible through a higher parameter hierarchy: self.getParams().register() &lt;br /&gt;
* call self.getParams().addChildren([...])&lt;br /&gt;
&lt;br /&gt;
The getParams() method does four things: &lt;br /&gt;
* create a new Parameter if it doesn't exist; &lt;br /&gt;
* create a group called _name; &lt;br /&gt;
* create a child description parameter with the specified _description label; &lt;br /&gt;
* return a reference to the parent group parameter. &lt;br /&gt;
Search is performed using the findParam([fullpath]) method.&lt;br /&gt;
&lt;br /&gt;
Each parameter stores the data internally or externally, using a set/get pair - usefull to retrieve dynamic data. In this case, the @setupSetParam(nameOrPath) decorator should be used in the set method in order to syncronize the GUI when the method is called directly without using the parameter class.&lt;br /&gt;
&lt;br /&gt;
More information about the Parameterized and the Parameter class can be found in its docstrings.&lt;br /&gt;
&lt;br /&gt;
Basic example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.utils.parameter import Parameterized, setupSetParam&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class ResultsSave(Parameterized):&lt;br /&gt;
    _name = &amp;quot;Save to Files&amp;quot;&lt;br /&gt;
    _description = &amp;quot;Save correlation output to files.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        # self.getParams().register()&lt;br /&gt;
        self.getParams().addChildren([&lt;br /&gt;
            {'name':'Save Raw Results', 'type':'bool', 'get':self.getEnabled, 'set':self.setEnabled},  # With value saved externally&lt;br /&gt;
            {'name':'Symbol', 'type':'list', 'values':['o', 's', 't', 'd', '+'], 'value':'o'},         # With value saved internally&lt;br /&gt;
        ])&lt;br /&gt;
&lt;br /&gt;
        self.findParam(&amp;quot;Symbol&amp;quot;).setValue('t')&lt;br /&gt;
        s = self.findParam(&amp;quot;Symbol&amp;quot;).getValue()  # s = 't'&lt;br /&gt;
&lt;br /&gt;
    def getEnabled(self):&lt;br /&gt;
        return self._enabled&lt;br /&gt;
&lt;br /&gt;
    @setupSetParam(&amp;quot;Save Raw Results&amp;quot;)&lt;br /&gt;
    def setEnabled(self, enabled):&lt;br /&gt;
        self._enabled = enabled&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What to tweak? ==&lt;br /&gt;
&lt;br /&gt;
=== acq_patterns ===&lt;br /&gt;
Has the modules that generate the keys. If you want to generate custom key or plaintext sequences, or read it from a file, this is the place to go.&lt;br /&gt;
&lt;br /&gt;
=== auxiliary ===&lt;br /&gt;
Usefull if you want to execute something before, during or after the capture.&lt;br /&gt;
&lt;br /&gt;
Exemple ([http://newae.com/forum/viewtopic.php?f=7&amp;amp;t=202#p1026 provided by GABRIEL_F]):&lt;br /&gt;
 import logging&lt;br /&gt;
 import time&lt;br /&gt;
 from chipwhisperer.capture.auxiliary._base import AuxiliaryTemplate&lt;br /&gt;
 from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
 from chipwhisperer.common.utils import util, timer&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 class SerialBeforeArm(AuxiliaryTemplate):&lt;br /&gt;
     &amp;lt;nowiki&amp;gt;'''&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
     This auxillary module allows for serial data to be sent to the target&lt;br /&gt;
     during the capture process i.e., before and after arming the scope&lt;br /&gt;
     and after the trace has recorded. This enables the ability for the&lt;br /&gt;
     scope to trigger on serial communication that need to start after a&lt;br /&gt;
     reset but before the scope is armed and after.&lt;br /&gt;
     &lt;br /&gt;
     Compare to SimpleSerial send Go Command.&lt;br /&gt;
     &lt;br /&gt;
     TODO:&lt;br /&gt;
     Parser to chop up multiple commands sent in single string seperated by&lt;br /&gt;
     whitespace. Modify to iterate over returned lists.&lt;br /&gt;
 &lt;br /&gt;
     Uses non-blocking sleep methods poached from ResetCW1173Read.&lt;br /&gt;
     &amp;lt;br&amp;gt;    Gabe 25-NOV-16&lt;br /&gt;
     &amp;lt;nowiki&amp;gt;'''&amp;lt;/nowiki&amp;gt;    &lt;br /&gt;
     _name = &amp;quot;Send Serial During Capture&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
     def __init__(self):&lt;br /&gt;
         AuxiliaryTemplate.__init__(self)&lt;br /&gt;
         self.getParams().addChildren([&lt;br /&gt;
             {'name':'Pre-Arm Message', 'type':'str', 'key':'prearmmssg', 'value':''},''&lt;br /&gt;
             {'name':'Post-Arm Message', 'type':'str', 'key':'postarmmssg', 'value':''},''&lt;br /&gt;
             {'name':'Post-Capture Message', 'type':'str', 'key':'postcapmssg', 'value':''},''&lt;br /&gt;
             {'name':'Delay (Pre-Message)' , 'type':'int',  'key':'predelay',  'limits':(0, 10E3), 'value':0, 'suffix':' ms'},&lt;br /&gt;
             {'name':'Delay (Post-Message)', 'type':'int',  'key':'postdelay', 'limits':(0, 10E3), 'value':0, 'suffix':' ms'},&lt;br /&gt;
             {'name':'Test Reset', 'type':'action', 'action':self.testSend}&lt;br /&gt;
         ])&lt;br /&gt;
 &lt;br /&gt;
     def traceArm(self):&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;Before arming the scope, send some serial messages and wait&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
         string = self.findParam('prearmmssg').getValue()&lt;br /&gt;
         self.sendSerial(string)&lt;br /&gt;
 &lt;br /&gt;
     def traceArmPost(self):&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;After arming the scope, send some serial message and wait&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
         string = self.findParam('postarmmssg').getValue()&lt;br /&gt;
         self.sendSerial(string)&lt;br /&gt;
 &lt;br /&gt;
     def traceDone(self):&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;After the trace is captured, send some serial messages and wait&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
         string = self.findParam('postcapmssg').getValue()&lt;br /&gt;
         self.sendSerial(string)&lt;br /&gt;
 &lt;br /&gt;
     def sendSerial(self, string):&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;Send a string!&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
         if string is None or len(string) == 0:&lt;br /&gt;
             return&lt;br /&gt;
 &lt;br /&gt;
         dly = self.findParam('predelay').getValue()&lt;br /&gt;
         if dly &amp;gt; 0:&lt;br /&gt;
             self.nonblockingSleep(dly / 1000.0)&lt;br /&gt;
 &lt;br /&gt;
         CWCoreAPI.getInstance().getTarget().ser.write(string)&lt;br /&gt;
         &lt;br /&gt;
         dly = self.findParam('postdelay').getValue()&lt;br /&gt;
         if dly &amp;gt; 0:&lt;br /&gt;
             self.nonblockingSleep(dly / 1000.0)&lt;br /&gt;
 &lt;br /&gt;
     def nonblockingSleep_done(self):&lt;br /&gt;
         self._sleeping = False&lt;br /&gt;
 &lt;br /&gt;
     def nonblockingSleep(self, stime):&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;Sleep for given number of seconds (~50mS resolution), but don't block GUI while we do it&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
         timer.Timer.singleShot(stime * 1000, self.nonblockingSleep_done)&lt;br /&gt;
         self._sleeping = True&lt;br /&gt;
         while(self._sleeping):&lt;br /&gt;
             time.sleep(0.01)&lt;br /&gt;
             util.updateUI()&lt;br /&gt;
 &lt;br /&gt;
     def testSend(self, _=None):&lt;br /&gt;
         self.sendSerial('Hello')&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Adding_Modules/Parameters&amp;diff=1802</id>
		<title>Adding Modules/Parameters</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Adding_Modules/Parameters&amp;diff=1802"/>
				<updated>2017-02-13T01:09:06Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Adding New Modules=&lt;br /&gt;
&lt;br /&gt;
In the new CW plugin architecture, all modules are scanned during the tool initialization, so new functionalities can be added by just dropping its file inside the respective folder:&lt;br /&gt;
&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/common/results&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/common/traces&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/acq_patterns&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/auxiliary&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scopes&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scripts&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/targets&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/attacks&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/preprocessing&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/scripts&lt;br /&gt;
* and some of the above subfolders.&lt;br /&gt;
&lt;br /&gt;
These paths are checked both inside the tool's root directory (where the tool is installed), and in the Project Folder (default is ~/chipwhisperer_projects), allowing the usage of custom modules without the requirement of being system administer. The CW tools scan these directories looking for classes that inherits from the ''Plugin'' class (a marker interface actually) in each public module (that doesn't begin with &amp;quot;_&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT''': Accessing &amp;quot;Help-&amp;gt;List Enabled/Disabled Plugins&amp;quot; in the tool's menu you'll find a list with all modules it tried to load. In case of any problem, you can check in the table the error message and its details. It should be easier to visuallise if you copy and paste the cell cotent to a text editor (example: notepad).&lt;br /&gt;
&lt;br /&gt;
These folders usually have a file called ''base.py'' or ''_base.py'' that contains the base class to all plugins in these directories. Ex.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from .base import PreprocessingBase&lt;br /&gt;
from chipwhisperer.common.utils.pluginmanager import Plugin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class AddNoiseRandom(PreprocessingBase, Plugin):&lt;br /&gt;
    _name = &amp;quot;Add Noise: Amplitude&amp;quot;&lt;br /&gt;
    _description = &amp;quot;Add random noise&amp;quot;&lt;br /&gt;
     &lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Adding Parameters=&lt;br /&gt;
&lt;br /&gt;
Parameters are used to allow easy access and manipulation of all object's main attibutes and actions. All parameters can be accessed anywhere in the code throught the Parameter class. It means that if you want to set/get any parameter, you can do it easily adding the follow lines to your code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
...&lt;br /&gt;
Parameter.setParameter([path,..., value])&lt;br /&gt;
value = Parameter.getParameter([path,...])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, if you have access to the api:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
api.setParameter([path,..., value])&lt;br /&gt;
value = api.getParameter([path,...])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The easiest way to add parameters to your class, is to make it ''Parameterized'' (extending this class). It is an abstract class that declares a public interface and implements two manipulation methods to create/get the parameters and find it. As a general rule, you just need to:&lt;br /&gt;
&lt;br /&gt;
* import the ''Parameterized'' class: from chipwhisperer.common.utils.parameter import Parameterized&lt;br /&gt;
* make your class extend it (no construtor call is needed here since the idea is to use it as an interface to avoid the problems with multiple inheritance - i.e.: the diamont one)&lt;br /&gt;
* define a _name and a _description&lt;br /&gt;
* register it if it is not readily accessible through a higher parameter hierarchy: self.getParams().register() &lt;br /&gt;
* call self.getParams().addChildren([...])&lt;br /&gt;
&lt;br /&gt;
The getParams() method does four things: &lt;br /&gt;
* create a new Parameter if it doesn't exist; &lt;br /&gt;
* create a group called _name; &lt;br /&gt;
* create a child description parameter with the specified _description label; &lt;br /&gt;
* return a reference to the parent group parameter. &lt;br /&gt;
Search is performed using the findParam([fullpath]) method.&lt;br /&gt;
&lt;br /&gt;
Each parameter stores the data internally or externally, using a set/get pair - usefull to retrieve dynamic data. In this case, the @setupSetParam(nameOrPath) decorator should be used in the set method in order to syncronize the GUI when the method is called directly without using the parameter class.&lt;br /&gt;
&lt;br /&gt;
More information about the Parameterized and the Parameter class can be found in its docstrings.&lt;br /&gt;
&lt;br /&gt;
Basic example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.utils.parameter import Parameterized, setupSetParam&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class ResultsSave(Parameterized):&lt;br /&gt;
    _name = &amp;quot;Save to Files&amp;quot;&lt;br /&gt;
    _description = &amp;quot;Save correlation output to files.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        # self.getParams().register()&lt;br /&gt;
        self.getParams().addChildren([&lt;br /&gt;
            {'name':'Save Raw Results', 'type':'bool', 'get':self.getEnabled, 'set':self.setEnabled},  # With value saved externally&lt;br /&gt;
            {'name':'Symbol', 'type':'list', 'values':['o', 's', 't', 'd', '+'], 'value':'o'},         # With value saved internally&lt;br /&gt;
        ])&lt;br /&gt;
&lt;br /&gt;
        self.findParam(&amp;quot;Symbol&amp;quot;).setValue('t')&lt;br /&gt;
        s = self.findParam(&amp;quot;Symbol&amp;quot;).getValue()  # s = 't'&lt;br /&gt;
&lt;br /&gt;
    def getEnabled(self):&lt;br /&gt;
        return self._enabled&lt;br /&gt;
&lt;br /&gt;
    @setupSetParam(&amp;quot;Save Raw Results&amp;quot;)&lt;br /&gt;
    def setEnabled(self, enabled):&lt;br /&gt;
        self._enabled = enabled&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What to tweak? ==&lt;br /&gt;
&lt;br /&gt;
=== acq_patterns ===&lt;br /&gt;
Has the modules that generate the keys. If you want to generate custom key or plaintext sequences, or read it from a file, this is the place to go.&lt;br /&gt;
&lt;br /&gt;
=== auxiliary ===&lt;br /&gt;
Usefull if you want to execute something before, during or after the capture.&lt;br /&gt;
&lt;br /&gt;
Exemple ([http://newae.com/forum/viewtopic.php?f=7&amp;amp;t=202#p1026 provided by GABRIEL_F]):&lt;br /&gt;
 import logging&amp;lt;br&amp;gt;&lt;br /&gt;
 import time&amp;lt;br&amp;gt;&lt;br /&gt;
 from chipwhisperer.capture.auxiliary._base import AuxiliaryTemplate&amp;lt;br&amp;gt;&lt;br /&gt;
 from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&amp;lt;br&amp;gt;&lt;br /&gt;
 from chipwhisperer.common.utils import util, timer&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
 class SerialBeforeArm(AuxiliaryTemplate):&amp;lt;br&amp;gt;&lt;br /&gt;
     '''&amp;lt;br&amp;gt;&lt;br /&gt;
     This auxillary module allows for serial data to be sent to the target&amp;lt;br&amp;gt;&lt;br /&gt;
     during the capture process i.e., before and after arming the scope&amp;lt;br&amp;gt;&lt;br /&gt;
     and after the trace has recorded. This enables the ability for the&amp;lt;br&amp;gt;&lt;br /&gt;
     scope to trigger on serial communication that need to start after a&amp;lt;br&amp;gt;&lt;br /&gt;
     reset but before the scope is armed and after.&amp;lt;br&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     Compare to SimpleSerial send Go Command.&amp;lt;br&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     TODO:&amp;lt;br&amp;gt;&lt;br /&gt;
     Parser to chop up multiple commands sent in single string seperated by&amp;lt;br&amp;gt;&lt;br /&gt;
     whitespace. Modify to iterate over returned lists.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     Uses non-blocking sleep methods poached from ResetCW1173Read.&amp;lt;br&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     Gabe 25-NOV-16&amp;lt;br&amp;gt;&lt;br /&gt;
     '''&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     _name = &amp;quot;Send Serial During Capture&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def __init__(self):&amp;lt;br&amp;gt;&lt;br /&gt;
         AuxiliaryTemplate.__init__(self)&amp;lt;br&amp;gt;&lt;br /&gt;
         self.getParams().addChildren([&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Pre-Arm Message', 'type':'str', 'key':'prearmmssg', 'value':''},&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Post-Arm Message', 'type':'str', 'key':'postarmmssg', 'value':''},&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Post-Capture Message', 'type':'str', 'key':'postcapmssg', 'value':''},&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Delay (Pre-Message)' , 'type':'int',  'key':'predelay',  'limits':(0, 10E3), 'value':0, 'suffix':' ms'},&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Delay (Post-Message)', 'type':'int',  'key':'postdelay', 'limits':(0, 10E3), 'value':0, 'suffix':' ms'},&amp;lt;br&amp;gt;&lt;br /&gt;
             {'name':'Test Reset', 'type':'action', 'action':self.testSend}&amp;lt;br&amp;gt;&lt;br /&gt;
         ])&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def traceArm(self):&amp;lt;br&amp;gt;&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;Before arming the scope, send some serial messages and wait&amp;quot;&amp;quot;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
         string = self.findParam('prearmmssg').getValue()&amp;lt;br&amp;gt;&lt;br /&gt;
         self.sendSerial(string)&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def traceArmPost(self):&amp;lt;br&amp;gt;&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;After arming the scope, send some serial message and wait&amp;quot;&amp;quot;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
         string = self.findParam('postarmmssg').getValue()&amp;lt;br&amp;gt;&lt;br /&gt;
         self.sendSerial(string)&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def traceDone(self):&amp;lt;br&amp;gt;&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;After the trace is captured, send some serial messages and wait&amp;quot;&amp;quot;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
         string = self.findParam('postcapmssg').getValue()&amp;lt;br&amp;gt;&lt;br /&gt;
         self.sendSerial(string)&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def sendSerial(self, string):&amp;lt;br&amp;gt;&lt;br /&gt;
         # Send a string!&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
         if string is None or len(string) == 0:&amp;lt;br&amp;gt;&lt;br /&gt;
             return&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
         dly = self.findParam('predelay').getValue()&amp;lt;br&amp;gt;&lt;br /&gt;
         if dly &amp;gt; 0:&amp;lt;br&amp;gt;&lt;br /&gt;
             self.nonblockingSleep(dly / 1000.0)&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
         CWCoreAPI.getInstance().getTarget().ser.write(string)&amp;lt;br&amp;gt;&lt;br /&gt;
         &lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
         dly = self.findParam('postdelay').getValue()&amp;lt;br&amp;gt;&lt;br /&gt;
         if dly &amp;gt; 0:&amp;lt;br&amp;gt;&lt;br /&gt;
             self.nonblockingSleep(dly / 1000.0)&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def nonblockingSleep_done(self):&amp;lt;br&amp;gt;&lt;br /&gt;
         self._sleeping = False&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def nonblockingSleep(self, stime):&amp;lt;br&amp;gt;&lt;br /&gt;
         &amp;quot;&amp;quot;&amp;quot;Sleep for given number of seconds (~50mS resolution), but don't block GUI while we do it&amp;quot;&amp;quot;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
         timer.Timer.singleShot(stime * 1000, self.nonblockingSleep_done)&amp;lt;br&amp;gt;&lt;br /&gt;
         self._sleeping = True&amp;lt;br&amp;gt;&lt;br /&gt;
         while(self._sleeping):&amp;lt;br&amp;gt;&lt;br /&gt;
             time.sleep(0.01)&amp;lt;br&amp;gt;&lt;br /&gt;
             util.updateUI()&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
     def testSend(self, _=None):&amp;lt;br&amp;gt;&lt;br /&gt;
         self.sendSerial('Hello')&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1462</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1462"/>
				<updated>2016-11-19T17:54:44Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Making sure that everything is working */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using VMWare Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
== Windows XP/7 ==&lt;br /&gt;
&lt;br /&gt;
Assuming you want to install the full ChipWhisperer software, you can follow the following steps to do so. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
You may already have Python installed, in which case you can skip some of these steps. If you already have Python installed make sure it is the correct version (2.7.x). Python 3.x will not work with this codebase.&lt;br /&gt;
&lt;br /&gt;
==== Installing Python via WinPython ====&lt;br /&gt;
&lt;br /&gt;
The recommend method of installing Python is to use a distribution called [http://winpython.sourceforge.net/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.&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;Install WinPython 2.7.x. Download the latest release in the 2.7.x branch from the [http://winpython.sourceforge.net/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as &amp;lt;code&amp;gt;c:\WinPython32bit-2.7.6.4&amp;lt;/code&amp;gt;, or into your local directory such as &amp;lt;code&amp;gt;c:\Users\yourname\WinPython-32bit-2.7.6.4&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Run the following commands to get needed packages:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyqtgraph&lt;br /&gt;
pip install configobj&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb==1.0.0b1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&amp;amp;gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) from that command prompt.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Optional Packages ====&lt;br /&gt;
&lt;br /&gt;
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:&lt;br /&gt;
&lt;br /&gt;
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install&amp;lt;/pre&amp;gt;&lt;br /&gt;
This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp;amp;amp; install that.&lt;br /&gt;
&lt;br /&gt;
'''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install umysql&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting &amp;amp;amp; Installing ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
Assuming you've got a working Python installation, the next step is to install &amp;amp;amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp;amp;amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository &amp;lt;code&amp;gt;git://git.assembla.com/chipwhisperer.git&amp;lt;/code&amp;gt; instead, but this '''may be broken''' so you should start with the latest release instead.&lt;br /&gt;
&lt;br /&gt;
Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen &amp;lt;code&amp;gt;C:\chipwhisperer&amp;lt;/code&amp;gt; as your working directory.&lt;br /&gt;
&lt;br /&gt;
Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\openadc\controlsw\python&lt;br /&gt;
python setup.py develop&lt;br /&gt;
cd c:\chipwhisperer\software&lt;br /&gt;
python setup.py develop&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\software\chipwhisperer\&lt;br /&gt;
python CWAnalyzer.pyw&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively you can just double-click on &amp;lt;code&amp;gt;CWAnalyzer.py&amp;lt;/code&amp;gt; from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''.&lt;br /&gt;
&lt;br /&gt;
You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&amp;amp;hd=1 Video] of the Installation Procedure:&lt;br /&gt;
&lt;br /&gt;
[[File:Youtube-win7-install.png|YouTubeWin7Install]]_&lt;br /&gt;
&lt;br /&gt;
=== Installing Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section.&lt;br /&gt;
&lt;br /&gt;
=== Getting AVR Compiler Toolchain ===&lt;br /&gt;
&lt;br /&gt;
The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however!&lt;br /&gt;
&lt;br /&gt;
To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already).&lt;br /&gt;
&lt;br /&gt;
Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps:&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;&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory with the avr-serial example, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aes&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If this is successful, you'll see an output like the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Avr-build-ok.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If instead you get an error something like &amp;lt;code&amp;gt;make: *** No rule to make target `simpleserial.elf', needed by `elf'.  Stop.&amp;lt;/code&amp;gt;, this means a required file was missing.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external &amp;quot;AVR Studio&amp;quot; program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
On Linux, installing Python &amp;amp;amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Ubuntu or similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip&lt;br /&gt;
$ sudo pip install pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://git.assembla.com/chipwhisperer.git&lt;br /&gt;
$ cd chipwhisperer&lt;br /&gt;
$ git clone git://git.assembla.com/openadc.git&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ cd software&lt;br /&gt;
$ sudo python setup.py develop&lt;br /&gt;
$ cd ../openadc/controlsw/python&lt;br /&gt;
$ sudo python setup.py develop&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called &amp;lt;code&amp;gt;/etc/udev/rules.d/99-newae.rules&amp;lt;/code&amp;gt; . The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# CW-Lite&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace2&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-1200&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace3&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-305 (Artix Target)&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;c305&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-CR2&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;04b4&amp;quot;, ATTRS{idProduct}==&amp;quot;8613&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;221a&amp;quot;, ATTRS{idProduct}==&amp;quot;0100&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) ===&lt;br /&gt;
&lt;br /&gt;
'''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the D2XX drivers &amp;amp;amp; python module. See the section [[#Optional_Packages]].&lt;br /&gt;
&lt;br /&gt;
Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file &amp;lt;code&amp;gt;/etc/udev/rules.d/99-libftdi.rules&amp;lt;/code&amp;gt; . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, RUN+=&amp;quot;/bin/sh -c 'echo $kernel &amp;amp;gt; /sys/bus/usb/drivers/ftdi_sio/unbind'&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group (if not already done):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
== MAC OS X ==&lt;br /&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;
=== Python 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;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;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;
=== Working SciPy Distribution ===&lt;br /&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;
=== AVR-GCC Install ===&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;br /&gt;
&lt;br /&gt;
== Making sure that everything works ==&lt;br /&gt;
Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example:&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py &lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.py&lt;br /&gt;
They should all work out of the box with the Chipwhisper Lite hardware.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1461</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1461"/>
				<updated>2016-11-19T17:54:07Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Making sure that everything is working */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using VMWare Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
== Windows XP/7 ==&lt;br /&gt;
&lt;br /&gt;
Assuming you want to install the full ChipWhisperer software, you can follow the following steps to do so. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
You may already have Python installed, in which case you can skip some of these steps. If you already have Python installed make sure it is the correct version (2.7.x). Python 3.x will not work with this codebase.&lt;br /&gt;
&lt;br /&gt;
==== Installing Python via WinPython ====&lt;br /&gt;
&lt;br /&gt;
The recommend method of installing Python is to use a distribution called [http://winpython.sourceforge.net/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.&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;Install WinPython 2.7.x. Download the latest release in the 2.7.x branch from the [http://winpython.sourceforge.net/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as &amp;lt;code&amp;gt;c:\WinPython32bit-2.7.6.4&amp;lt;/code&amp;gt;, or into your local directory such as &amp;lt;code&amp;gt;c:\Users\yourname\WinPython-32bit-2.7.6.4&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Run the following commands to get needed packages:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyqtgraph&lt;br /&gt;
pip install configobj&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb==1.0.0b1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&amp;amp;gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) from that command prompt.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Optional Packages ====&lt;br /&gt;
&lt;br /&gt;
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:&lt;br /&gt;
&lt;br /&gt;
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install&amp;lt;/pre&amp;gt;&lt;br /&gt;
This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp;amp;amp; install that.&lt;br /&gt;
&lt;br /&gt;
'''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install umysql&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting &amp;amp;amp; Installing ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
Assuming you've got a working Python installation, the next step is to install &amp;amp;amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp;amp;amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository &amp;lt;code&amp;gt;git://git.assembla.com/chipwhisperer.git&amp;lt;/code&amp;gt; instead, but this '''may be broken''' so you should start with the latest release instead.&lt;br /&gt;
&lt;br /&gt;
Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen &amp;lt;code&amp;gt;C:\chipwhisperer&amp;lt;/code&amp;gt; as your working directory.&lt;br /&gt;
&lt;br /&gt;
Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\openadc\controlsw\python&lt;br /&gt;
python setup.py develop&lt;br /&gt;
cd c:\chipwhisperer\software&lt;br /&gt;
python setup.py develop&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\software\chipwhisperer\&lt;br /&gt;
python CWAnalyzer.pyw&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively you can just double-click on &amp;lt;code&amp;gt;CWAnalyzer.py&amp;lt;/code&amp;gt; from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''.&lt;br /&gt;
&lt;br /&gt;
You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&amp;amp;hd=1 Video] of the Installation Procedure:&lt;br /&gt;
&lt;br /&gt;
[[File:Youtube-win7-install.png|YouTubeWin7Install]]_&lt;br /&gt;
&lt;br /&gt;
=== Installing Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section.&lt;br /&gt;
&lt;br /&gt;
=== Getting AVR Compiler Toolchain ===&lt;br /&gt;
&lt;br /&gt;
The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however!&lt;br /&gt;
&lt;br /&gt;
To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already).&lt;br /&gt;
&lt;br /&gt;
Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps:&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;&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory with the avr-serial example, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aes&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If this is successful, you'll see an output like the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Avr-build-ok.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If instead you get an error something like &amp;lt;code&amp;gt;make: *** No rule to make target `simpleserial.elf', needed by `elf'.  Stop.&amp;lt;/code&amp;gt;, this means a required file was missing.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external &amp;quot;AVR Studio&amp;quot; program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
On Linux, installing Python &amp;amp;amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Ubuntu or similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip&lt;br /&gt;
$ sudo pip install pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://git.assembla.com/chipwhisperer.git&lt;br /&gt;
$ cd chipwhisperer&lt;br /&gt;
$ git clone git://git.assembla.com/openadc.git&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ cd software&lt;br /&gt;
$ sudo python setup.py develop&lt;br /&gt;
$ cd ../openadc/controlsw/python&lt;br /&gt;
$ sudo python setup.py develop&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called &amp;lt;code&amp;gt;/etc/udev/rules.d/99-newae.rules&amp;lt;/code&amp;gt; . The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# CW-Lite&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace2&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-1200&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace3&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-305 (Artix Target)&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;c305&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-CR2&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;04b4&amp;quot;, ATTRS{idProduct}==&amp;quot;8613&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;221a&amp;quot;, ATTRS{idProduct}==&amp;quot;0100&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) ===&lt;br /&gt;
&lt;br /&gt;
'''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the D2XX drivers &amp;amp;amp; python module. See the section [[#Optional_Packages]].&lt;br /&gt;
&lt;br /&gt;
Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file &amp;lt;code&amp;gt;/etc/udev/rules.d/99-libftdi.rules&amp;lt;/code&amp;gt; . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, RUN+=&amp;quot;/bin/sh -c 'echo $kernel &amp;amp;gt; /sys/bus/usb/drivers/ftdi_sio/unbind'&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group (if not already done):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
== MAC OS X ==&lt;br /&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;
=== Python 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;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;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;
=== Working SciPy Distribution ===&lt;br /&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;
=== AVR-GCC Install ===&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;br /&gt;
&lt;br /&gt;
== Making sure that everything is working ==&lt;br /&gt;
Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example:&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py &lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.py&lt;br /&gt;
They should all work out of the box with the Chipwhisper Lite hardware.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1460</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1460"/>
				<updated>2016-11-19T17:53:35Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Making sure that everything is working */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using VMWare Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
== Windows XP/7 ==&lt;br /&gt;
&lt;br /&gt;
Assuming you want to install the full ChipWhisperer software, you can follow the following steps to do so. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
You may already have Python installed, in which case you can skip some of these steps. If you already have Python installed make sure it is the correct version (2.7.x). Python 3.x will not work with this codebase.&lt;br /&gt;
&lt;br /&gt;
==== Installing Python via WinPython ====&lt;br /&gt;
&lt;br /&gt;
The recommend method of installing Python is to use a distribution called [http://winpython.sourceforge.net/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.&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;Install WinPython 2.7.x. Download the latest release in the 2.7.x branch from the [http://winpython.sourceforge.net/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as &amp;lt;code&amp;gt;c:\WinPython32bit-2.7.6.4&amp;lt;/code&amp;gt;, or into your local directory such as &amp;lt;code&amp;gt;c:\Users\yourname\WinPython-32bit-2.7.6.4&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Run the following commands to get needed packages:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyqtgraph&lt;br /&gt;
pip install configobj&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb==1.0.0b1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&amp;amp;gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) from that command prompt.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Optional Packages ====&lt;br /&gt;
&lt;br /&gt;
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:&lt;br /&gt;
&lt;br /&gt;
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install&amp;lt;/pre&amp;gt;&lt;br /&gt;
This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp;amp;amp; install that.&lt;br /&gt;
&lt;br /&gt;
'''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install umysql&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting &amp;amp;amp; Installing ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
Assuming you've got a working Python installation, the next step is to install &amp;amp;amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp;amp;amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository &amp;lt;code&amp;gt;git://git.assembla.com/chipwhisperer.git&amp;lt;/code&amp;gt; instead, but this '''may be broken''' so you should start with the latest release instead.&lt;br /&gt;
&lt;br /&gt;
Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen &amp;lt;code&amp;gt;C:\chipwhisperer&amp;lt;/code&amp;gt; as your working directory.&lt;br /&gt;
&lt;br /&gt;
Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\openadc\controlsw\python&lt;br /&gt;
python setup.py develop&lt;br /&gt;
cd c:\chipwhisperer\software&lt;br /&gt;
python setup.py develop&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\software\chipwhisperer\&lt;br /&gt;
python CWAnalyzer.pyw&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively you can just double-click on &amp;lt;code&amp;gt;CWAnalyzer.py&amp;lt;/code&amp;gt; from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''.&lt;br /&gt;
&lt;br /&gt;
You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&amp;amp;hd=1 Video] of the Installation Procedure:&lt;br /&gt;
&lt;br /&gt;
[[File:Youtube-win7-install.png|YouTubeWin7Install]]_&lt;br /&gt;
&lt;br /&gt;
=== Installing Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section.&lt;br /&gt;
&lt;br /&gt;
=== Getting AVR Compiler Toolchain ===&lt;br /&gt;
&lt;br /&gt;
The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however!&lt;br /&gt;
&lt;br /&gt;
To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already).&lt;br /&gt;
&lt;br /&gt;
Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps:&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;&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory with the avr-serial example, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aes&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If this is successful, you'll see an output like the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Avr-build-ok.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If instead you get an error something like &amp;lt;code&amp;gt;make: *** No rule to make target `simpleserial.elf', needed by `elf'.  Stop.&amp;lt;/code&amp;gt;, this means a required file was missing.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external &amp;quot;AVR Studio&amp;quot; program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
On Linux, installing Python &amp;amp;amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Ubuntu or similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip&lt;br /&gt;
$ sudo pip install pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://git.assembla.com/chipwhisperer.git&lt;br /&gt;
$ cd chipwhisperer&lt;br /&gt;
$ git clone git://git.assembla.com/openadc.git&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ cd software&lt;br /&gt;
$ sudo python setup.py develop&lt;br /&gt;
$ cd ../openadc/controlsw/python&lt;br /&gt;
$ sudo python setup.py develop&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called &amp;lt;code&amp;gt;/etc/udev/rules.d/99-newae.rules&amp;lt;/code&amp;gt; . The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# CW-Lite&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace2&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-1200&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace3&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-305 (Artix Target)&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;c305&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-CR2&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;04b4&amp;quot;, ATTRS{idProduct}==&amp;quot;8613&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;221a&amp;quot;, ATTRS{idProduct}==&amp;quot;0100&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) ===&lt;br /&gt;
&lt;br /&gt;
'''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the D2XX drivers &amp;amp;amp; python module. See the section [[#Optional_Packages]].&lt;br /&gt;
&lt;br /&gt;
Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file &amp;lt;code&amp;gt;/etc/udev/rules.d/99-libftdi.rules&amp;lt;/code&amp;gt; . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, RUN+=&amp;quot;/bin/sh -c 'echo $kernel &amp;amp;gt; /sys/bus/usb/drivers/ftdi_sio/unbind'&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group (if not already done):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
== MAC OS X ==&lt;br /&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;
=== Python 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;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;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;
=== Working SciPy Distribution ===&lt;br /&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;
=== AVR-GCC Install ===&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;br /&gt;
&lt;br /&gt;
== Making sure that everything is working ==&lt;br /&gt;
Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example:&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py &lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.p&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.py&lt;br /&gt;
They should all work out of the box with the Chipwhisper Lite hardware.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1459</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1459"/>
				<updated>2016-11-19T17:53:03Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Making sure that everything is working */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using VMWare Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
== Windows XP/7 ==&lt;br /&gt;
&lt;br /&gt;
Assuming you want to install the full ChipWhisperer software, you can follow the following steps to do so. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
You may already have Python installed, in which case you can skip some of these steps. If you already have Python installed make sure it is the correct version (2.7.x). Python 3.x will not work with this codebase.&lt;br /&gt;
&lt;br /&gt;
==== Installing Python via WinPython ====&lt;br /&gt;
&lt;br /&gt;
The recommend method of installing Python is to use a distribution called [http://winpython.sourceforge.net/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.&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;Install WinPython 2.7.x. Download the latest release in the 2.7.x branch from the [http://winpython.sourceforge.net/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as &amp;lt;code&amp;gt;c:\WinPython32bit-2.7.6.4&amp;lt;/code&amp;gt;, or into your local directory such as &amp;lt;code&amp;gt;c:\Users\yourname\WinPython-32bit-2.7.6.4&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Run the following commands to get needed packages:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyqtgraph&lt;br /&gt;
pip install configobj&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb==1.0.0b1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&amp;amp;gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) from that command prompt.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Optional Packages ====&lt;br /&gt;
&lt;br /&gt;
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:&lt;br /&gt;
&lt;br /&gt;
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install&amp;lt;/pre&amp;gt;&lt;br /&gt;
This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp;amp;amp; install that.&lt;br /&gt;
&lt;br /&gt;
'''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install umysql&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting &amp;amp;amp; Installing ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
Assuming you've got a working Python installation, the next step is to install &amp;amp;amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp;amp;amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository &amp;lt;code&amp;gt;git://git.assembla.com/chipwhisperer.git&amp;lt;/code&amp;gt; instead, but this '''may be broken''' so you should start with the latest release instead.&lt;br /&gt;
&lt;br /&gt;
Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen &amp;lt;code&amp;gt;C:\chipwhisperer&amp;lt;/code&amp;gt; as your working directory.&lt;br /&gt;
&lt;br /&gt;
Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\openadc\controlsw\python&lt;br /&gt;
python setup.py develop&lt;br /&gt;
cd c:\chipwhisperer\software&lt;br /&gt;
python setup.py develop&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\software\chipwhisperer\&lt;br /&gt;
python CWAnalyzer.pyw&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively you can just double-click on &amp;lt;code&amp;gt;CWAnalyzer.py&amp;lt;/code&amp;gt; from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''.&lt;br /&gt;
&lt;br /&gt;
You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&amp;amp;hd=1 Video] of the Installation Procedure:&lt;br /&gt;
&lt;br /&gt;
[[File:Youtube-win7-install.png|YouTubeWin7Install]]_&lt;br /&gt;
&lt;br /&gt;
=== Installing Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section.&lt;br /&gt;
&lt;br /&gt;
=== Getting AVR Compiler Toolchain ===&lt;br /&gt;
&lt;br /&gt;
The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however!&lt;br /&gt;
&lt;br /&gt;
To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already).&lt;br /&gt;
&lt;br /&gt;
Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps:&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;&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory with the avr-serial example, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aes&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If this is successful, you'll see an output like the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Avr-build-ok.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If instead you get an error something like &amp;lt;code&amp;gt;make: *** No rule to make target `simpleserial.elf', needed by `elf'.  Stop.&amp;lt;/code&amp;gt;, this means a required file was missing.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external &amp;quot;AVR Studio&amp;quot; program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
On Linux, installing Python &amp;amp;amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Ubuntu or similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip&lt;br /&gt;
$ sudo pip install pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://git.assembla.com/chipwhisperer.git&lt;br /&gt;
$ cd chipwhisperer&lt;br /&gt;
$ git clone git://git.assembla.com/openadc.git&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ cd software&lt;br /&gt;
$ sudo python setup.py develop&lt;br /&gt;
$ cd ../openadc/controlsw/python&lt;br /&gt;
$ sudo python setup.py develop&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called &amp;lt;code&amp;gt;/etc/udev/rules.d/99-newae.rules&amp;lt;/code&amp;gt; . The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# CW-Lite&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace2&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-1200&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace3&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-305 (Artix Target)&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;c305&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-CR2&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;04b4&amp;quot;, ATTRS{idProduct}==&amp;quot;8613&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;221a&amp;quot;, ATTRS{idProduct}==&amp;quot;0100&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) ===&lt;br /&gt;
&lt;br /&gt;
'''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the D2XX drivers &amp;amp;amp; python module. See the section [[#Optional_Packages]].&lt;br /&gt;
&lt;br /&gt;
Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file &amp;lt;code&amp;gt;/etc/udev/rules.d/99-libftdi.rules&amp;lt;/code&amp;gt; . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, RUN+=&amp;quot;/bin/sh -c 'echo $kernel &amp;amp;gt; /sys/bus/usb/drivers/ftdi_sio/unbind'&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group (if not already done):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
== MAC OS X ==&lt;br /&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;
=== Python 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;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;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;
=== Working SciPy Distribution ===&lt;br /&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;
=== AVR-GCC Install ===&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;br /&gt;
&lt;br /&gt;
== Making sure that everything is working ==&lt;br /&gt;
Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example:&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py &lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.p&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.py&lt;br /&gt;
They should all work out of the boxwith the Chipwhisper Lite hardware.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1458</id>
		<title>Installing ChipWhisperer</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Installing_ChipWhisperer&amp;diff=1458"/>
				<updated>2016-11-19T17:52:25Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using VMWare Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
== Windows XP/7 ==&lt;br /&gt;
&lt;br /&gt;
Assuming you want to install the full ChipWhisperer software, you can follow the following steps to do so. Note it is recommended to use the VMWare image if possible, since it includes all required tools out of the box!&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
You may already have Python installed, in which case you can skip some of these steps. If you already have Python installed make sure it is the correct version (2.7.x). Python 3.x will not work with this codebase.&lt;br /&gt;
&lt;br /&gt;
==== Installing Python via WinPython ====&lt;br /&gt;
&lt;br /&gt;
The recommend method of installing Python is to use a distribution called [http://winpython.sourceforge.net/ WinPython]. This setup avoids installing Python globally, and includes most of the software you will need. In addition it makes it possible to install 32-bit and 64-bit Python on the same system with minimal problems. This can be very useful as the 64-bit version is handy for doing analysis on large data sets.&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;Install WinPython 2.7.x. Download the latest release in the 2.7.x branch from the [http://winpython.sourceforge.net/ WinPython] site. It's recommended to use the 32-bit version, but you can also use the 64-bit version. Note that certain drivers (such as the SmartCard driver) ''do not'' work on the 64-bit version. Choose a reasonable location to install this to - note the default is simply in the download directory. Instead it's recommended to find a directory such as &amp;lt;code&amp;gt;c:\WinPython32bit-2.7.6.4&amp;lt;/code&amp;gt;, or into your local directory such as &amp;lt;code&amp;gt;c:\Users\yourname\WinPython-32bit-2.7.6.4&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to your installation directory for WinPython, and run the shortcut called '''WinPython Command Prompt.exe'''. This will give you a command prompt which is setup to run Python along with associated scripts.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Run the following commands to get needed packages:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyqtgraph&lt;br /&gt;
pip install configobj&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Assuming you are planning on using the ChipWhisperer Capture Rev2 hardware, you also require [http://sourceforge.net/projects/pyusb/ PyUSB]. The easiest method is to again use pip:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If that command fails, you may need to specify a version. Note the latest version printed by the command, and try:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install pyusb==1.0.0b1&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Optional: You can add the python.exe you just installed to your path. To do so navigate to your installation folder, and run the '''WinPython Control Panel.exe''' program. Then select ''Advanced -&amp;amp;gt; Register distribution...''. If you do not do this, you will have to run all commands in this document via the '''WinPython Command Prompt.exe'''.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you plan on running both 32-bit and 64-bit Python, you should not register them. Instead explicitly call the correct Python by always running the '''WinPython Command Prompt.exe''', and then calling specific programs (such as CW Capture or Analyzer) from that command prompt.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Jump to [[#Getting_.26_Installing_ChipWhisperer]] to install ChipWhisperer software.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Optional Packages ====&lt;br /&gt;
&lt;br /&gt;
Note there are some optional packages you may want. Generally you can avoid them unless you have specific need of the features they enable:&lt;br /&gt;
&lt;br /&gt;
'''FTD2XX''': [https://github.com/snmishra/ftd2xx ftd2xx] is required for SASEBO-W, SAKURA-G, and SASEBO-GII Support. To install this package, [https://github.com/snmishra/ftd2xx/archive/master.zip download a copy of the ftd2xx repository] and unzip it somewhere. Then run the following where you unzipped it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install&amp;lt;/pre&amp;gt;&lt;br /&gt;
This package will also require you to install the [http://www.ftdichip.com/Drivers/D2XX.htm FTDI D2XX Drivers]. In the preceeding link simply find the correct driver for your OS Version &amp;amp;amp; install that.&lt;br /&gt;
&lt;br /&gt;
'''MYSQL''': If you want to use the MySQL trace format (not used by default), you'll need to install [https://pypi.python.org/pypi/umysql umysql]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;pip install umysql&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''PYSCARD''': If planning on using a PS/SC smartcard reader (i.e. standard USB-connected reader), you will need to install [https://sourceforge.net/projects/pyscard/files/pyscard/ pyscard].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting &amp;amp;amp; Installing ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
Assuming you've got a working Python installation, the next step is to install &amp;amp;amp; run ChipWhisperer itself. This requires you to get a copy of ChipWhisperer, you should download the [https://www.assembla.com/wiki/show/chipwhisperer/ChipWhisperer_Software_Firmware_Releases Latest Release]. Download &amp;amp;amp; unzip the file somewhere. Note if you are adventurous you can clone the GIT Repository &amp;lt;code&amp;gt;git://git.assembla.com/chipwhisperer.git&amp;lt;/code&amp;gt; instead, but this '''may be broken''' so you should start with the latest release instead.&lt;br /&gt;
&lt;br /&gt;
Generally 'somewhere' will become your ChipWhisperer working directory. These examples assume you've chosen &amp;lt;code&amp;gt;C:\chipwhisperer&amp;lt;/code&amp;gt; as your working directory.&lt;br /&gt;
&lt;br /&gt;
Once you've got the file, we run the Python install procedure again (setup.py). We slightly modify it to use the ''develop'' command to reflect that the files will probably be changing frequently. Again open a terminal and run the following, adjusting paths as needed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\openadc\controlsw\python&lt;br /&gt;
python setup.py develop&lt;br /&gt;
cd c:\chipwhisperer\software&lt;br /&gt;
python setup.py develop&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you wish to confirm the installation worked, you can run ChipWhispererAnalyzer in the same terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\software\chipwhisperer\&lt;br /&gt;
python CWAnalyzer.pyw&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively you can just double-click on &amp;lt;code&amp;gt;CWAnalyzer.py&amp;lt;/code&amp;gt; from Windows explorer, which should run the file using Python, ''provided you've registered Python to execute the .py extension''.&lt;br /&gt;
&lt;br /&gt;
You can see a [http://www.youtube.com/watch?v=qd86cUD8iBs&amp;amp;hd=1 Video] of the Installation Procedure:&lt;br /&gt;
&lt;br /&gt;
[[File:Youtube-win7-install.png|YouTubeWin7Install]]_&lt;br /&gt;
&lt;br /&gt;
=== Installing Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
Details of driver installation are on specific pages for supported hardware (such as hwcapturerev2 and naecw1173_cwlite). Drivers are available from [http://chipwhisperer.com ChipWhisperer] release section.&lt;br /&gt;
&lt;br /&gt;
=== Getting AVR Compiler Toolchain ===&lt;br /&gt;
&lt;br /&gt;
The following section is '''NOT REQUIRED''' for your first attack - you can jump right to the tutorial if you wish. However you'll ultimately wish to modify the code of the device under test, and these instructions tell you how. You should first follow the tutorial to confirm your system is working before modifying the code however!&lt;br /&gt;
&lt;br /&gt;
To build the code, you'll need to install WinAVR on Windows (if using the Virtual Machine, the following is ''not required'', as the VM comes setup with the AVR compiler already).&lt;br /&gt;
&lt;br /&gt;
Note that the default codebase ''does not'' include the cryptographic code we attack. Instead you are required to add this code into the system -- if the external code changes, this may eventually be instead rolled into the main codebase. To setup the code, follow the following steps:&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;&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the directory with the avr-serial example, and run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd c:\chipwhisperer\hardware\victims\firmware\simpleserial-aes&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If this is successful, you'll see an output like the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:Avr-build-ok.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If instead you get an error something like &amp;lt;code&amp;gt;make: *** No rule to make target `simpleserial.elf', needed by `elf'.  Stop.&amp;lt;/code&amp;gt;, this means a required file was missing.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Programming the target AVR is accomplished in one of two methods depending on your hardware. The ChipWhisperer Capture Rev 2 uses the external &amp;quot;AVR Studio&amp;quot; program, whereas the CW1173 and CW1200 use a programmer menu from the ChipWhisperer-Capture software. To see details refer to either [[CW1002_ChipWhisperer_Capture-Rev2#CWCR2:_Using_the_AVR_Programmer]] or [[CW1173_ChipWhisperer-Lite#CW-Lite:_Programming_AVR.2FXMEGA_Device]].&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
=== Python Setup ===&lt;br /&gt;
&lt;br /&gt;
On Linux, installing Python &amp;amp;amp; all the associated packages is much easier than on Windows. Typically you can install them from a package manager, if you are using Fedora Core or similar, just type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo yum install python27 python27-devel python27-libs python-pyside numpy scipy python-configobj pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Ubuntu or similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo apt-get install python2.7 python2.7-dev python2.7-libs python-numpy python-scipy python-pyside python-configobj python-setuptools python-pip&lt;br /&gt;
$ sudo pip install pyusb&lt;br /&gt;
$ sudo pip install pyqtgraph&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting ChipWhisperer ===&lt;br /&gt;
&lt;br /&gt;
As in the Windows release, you can download a complete ChipWhisperer software release. Alternatively you can clone the ChipWhisperer repository with git, which is very simple on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://git.assembla.com/chipwhisperer.git&lt;br /&gt;
$ cd chipwhisperer&lt;br /&gt;
$ git clone git://git.assembla.com/openadc.git&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
Be aware that the git code may be broken, although we try not to commit completely untested code to the master branch. Either way once you have the chipwhisperer directory somewhere, do the following from within that directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;$ cd software&lt;br /&gt;
$ sudo python setup.py develop&lt;br /&gt;
$ cd ../openadc/controlsw/python&lt;br /&gt;
$ sudo python setup.py develop&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NB''': This assumes the python command links to Python-2.7, and not Python-3.x. You may need to specify either python2.7 or python27 as the command instead of python to force this.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Drivers ===&lt;br /&gt;
&lt;br /&gt;
The ''driver'' for Linux is built in, however you need to allow your user account to access the peripheral. To do so, you'll have to make a file called &amp;lt;code&amp;gt;/etc/udev/rules.d/99-newae.rules&amp;lt;/code&amp;gt; . The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# CW-Lite&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace2&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-1200&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;ace3&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-305 (Artix Target)&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;2b3e&amp;quot;, ATTRS{idProduct}==&amp;quot;c305&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# CW-CR2&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;04b4&amp;quot;, ATTRS{idProduct}==&amp;quot;8613&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;221a&amp;quot;, ATTRS{idProduct}==&amp;quot;0100&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
You can always find the latest version of this file in [https://app.assembla.com/spaces/chipwhisperer/git/source/master/hardware/99-newae.rules GIT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== FTDI Hardware Driver (SASEBO-W, SAKURA-G, SASEBO-GII) ===&lt;br /&gt;
&lt;br /&gt;
'''This is only required for supporting FTDI-connected hardware''' such as the SASEBO-W, SAKURA-G, SASEBO-GII. This is NOT required for the ChipWhisperer Capture Rev2.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the D2XX drivers &amp;amp;amp; python module. See the section [[#Optional_Packages]].&lt;br /&gt;
&lt;br /&gt;
Currently, there is a bit of a hack needed. You have to create (or modify if it exists) the file &amp;lt;code&amp;gt;/etc/udev/rules.d/99-libftdi.rules&amp;lt;/code&amp;gt; . The following modifications will cause '''any FTDI-serial device to stop working''', so backup the existing file! The contents of this file should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, MODE=&amp;quot;0664&amp;quot;, GROUP=&amp;quot;plugdev&amp;quot;&lt;br /&gt;
ATTRS{idVendor}==&amp;quot;0403&amp;quot;, ATTRS{idProduct}==&amp;quot;6010&amp;quot;, RUN+=&amp;quot;/bin/sh -c 'echo $kernel &amp;amp;gt; /sys/bus/usb/drivers/ftdi_sio/unbind'&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then add your username to the plugdev group (if not already done):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo usermod -a -G plugdev YOUR-USERNAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
And reset the udev system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sudo udevadm control --reload-rules&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally log out &amp;amp;amp; in again for the group change to take effect.&lt;br /&gt;
&lt;br /&gt;
== MAC OS X ==&lt;br /&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;
=== Python 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;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;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;
=== Working SciPy Distribution ===&lt;br /&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;
=== AVR-GCC Install ===&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;br /&gt;
&lt;br /&gt;
== Making sure that everything is working ==&lt;br /&gt;
Try running the automated test scripts at chipwhisperer/software/chipwhisperer/tests/. Example:&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/aescpaeattackscript.py&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/descpaeattackscript.py &lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/glitchscript.p&lt;br /&gt;
 $ python chipwhisperer/software/chipwhisperer/tests/templateattackscript.py&lt;br /&gt;
They should all work out of the box.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=1457</id>
		<title>CW-Capture Tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=CW-Capture_Tool&amp;diff=1457"/>
				<updated>2016-11-19T17:03:21Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tool captures traces from scopes while is also capable of synchronize it with different targets devices. &lt;br /&gt;
&lt;br /&gt;
Main features:&lt;br /&gt;
* View the wave form of each trace;&lt;br /&gt;
* Save/load/import/edit/manage the traces;&lt;br /&gt;
* Run custom capture scripts;&lt;br /&gt;
* Automated glitch exploring with a nice scatterplot widget to visualize the result;&lt;br /&gt;
* Convenient firmware programmer to flash files to the target board;&lt;br /&gt;
* Record traces using fixed/random encryption keys and fixed/random plaintext inputs;&lt;br /&gt;
* Serial Terminal&lt;br /&gt;
[[File:Screen Shot 2016-07-15 at 10.00.52 AM.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== The Basic ==&lt;br /&gt;
The capture tool comes with a list of built-in scripts to connect to different pairs of target-scope hardwares. The easiest way to start using it is accessing the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Example Scripts&amp;quot; menu and select the appropriate item in the list.&lt;br /&gt;
&lt;br /&gt;
If you want more advanced setups, you will have to configure the capture environment manually using the Setting tabs, starting with the &amp;quot;Generic Settings&amp;quot;:&lt;br /&gt;
# Select the desired &amp;quot;Scope Module&amp;quot;  (i.e.: ChipWhisperer/OpenADC). Leave it as None if you only want to use the target.&lt;br /&gt;
# Select the desired &amp;quot;Target Module&amp;quot; (i.e.: Simple Serial). Leave it as None if you only want to use the scope.&lt;br /&gt;
# Select the desired &amp;quot;Trace Format&amp;quot; (i.e.: ChipWhisperer/Native). Leave it as None if you don't need to save the traces, as often happen when executing the Glitching attack.&lt;br /&gt;
# Switch to the &amp;quot;Scope Settings&amp;quot; tab and setup your scope connection (i.e. selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Switch to the &amp;quot;Target Settings&amp;quot; tab and setup your target connection (i.e. selecting 'NewAE USB (CWLite/CW1200)').&lt;br /&gt;
# Connect to the desired scope/target pair, using the toolbar buttons. The master button connects to both at the same time.&lt;br /&gt;
#* At this point, you may want to flash the desired firmware to the target, using the Programmer option in the Tools' menu.&lt;br /&gt;
# Once connected, both the &amp;quot;Scope Settings&amp;quot; and &amp;quot;Target Settings&amp;quot; list of parameters may expand, giving access to more advanced settings. You will have to setup these parameters which depend on what you want to capture. It usually involves setting the following parameters:&lt;br /&gt;
#* Trigger Pins&lt;br /&gt;
#* Target IOn Pins&lt;br /&gt;
#* Target HS IO-Out&lt;br /&gt;
#* Clock Setup&lt;br /&gt;
#* Trigger Setup-&amp;gt;Total Samples&lt;br /&gt;
#* Trigger Setup-&amp;gt;Offset&lt;br /&gt;
#* Trigger Setup-&amp;gt;Mode&lt;br /&gt;
#* Gain&lt;br /&gt;
#* Relock/reset the DCM in case it is lost.&lt;br /&gt;
#* TIP: check the content of the &amp;quot;Example Scripts&amp;quot; at chipwhisperer/software/chipwhisperer/capture/scripts if you are lost.&lt;br /&gt;
# You may want to check if everything is working properly by clicking in the &amp;quot;Capture 1&amp;quot; button and adjusting the above settings if necessary.&lt;br /&gt;
# Once it is working as expected, you can set the &amp;quot;Generic Settings&amp;quot;-&amp;gt;&amp;quot;Acquisition Settings&amp;quot;-&amp;gt;&amp;quot;Number of Traces&amp;quot; option to the desired amount (i.e. 50-100) and click the &amp;quot;Capture M&amp;quot; button in the toolbar. This time the traces will be saved to the &amp;quot;Trace Manager&amp;quot; if you specified a &amp;quot;Trace Format&amp;quot;.&lt;br /&gt;
# In order to view the saved traces, you will have to change the &amp;quot;Result&amp;quot;-&amp;gt;&amp;quot;Trace Output Plot&amp;quot;-&amp;gt;&amp;quot;Input&amp;quot; from the scope channel to the &amp;quot;Trace Manager&amp;quot;. You may also want to change the &amp;quot;X Axis&amp;quot; temporal sequence from Samples to Time. &lt;br /&gt;
# You can also import, delete, edit or select/deselect the trace segments by opening the &amp;quot;Trace Manager&amp;quot; in the Project menu.&lt;br /&gt;
# Don't forget to save the Project after each change in the traces. A &amp;quot;Consolidate&amp;quot; option is also available to move/copy all the trace files to the current project directory. It is useful if you imported existing traces or captured it before creating the project.&lt;br /&gt;
Once you master this procedure and get tired of doing it over and over again, there are two things you can do about it:&lt;br /&gt;
# Create your own script (based on the existing ones) and add it to the chipwhisperer/software/chipwhisperer/capture/scripts or ~/chipwhisperer_projects/chipwhisperer/capture/scripts directories. You may want to copy/paste the lines from the &amp;quot;Script Commands&amp;quot; window, once the environment is already set, in order to make it easier.&lt;br /&gt;
# Set your capture environment and save the parameter groups using the Save buttons in the top of the Settings tabs. Other possibility would be to use the &amp;quot;Project&amp;quot;-&amp;gt;&amp;quot;Save Settings&amp;quot; option to save all the settings at the same time to the &amp;quot;settings.cwset&amp;quot; file inside your project directory. The '''settings are NOT loaded automatically''' when the project is opened. Instead, you should click in the Load button for each group of settings that you want to restore. It is possible to have multiple settings profiles using different settings files. The capture tool also records the settings with the traces when they are captured. If you want to configure the tool to the same environment used in a previous capture, it is possible by loading the setting file saved inside the traces directory.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
Follow the [[Tutorial B5 Breaking AES (Straightforward)|B5 tutorial]] to learn how to use it with different targets.&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
Click in this link to learn how to use the [[Glitch Explorer]].&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_A3_VCC_Glitch_Attacks&amp;diff=1386</id>
		<title>Tutorial A3 VCC Glitch Attacks</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_A3_VCC_Glitch_Attacks&amp;diff=1386"/>
				<updated>2016-09-29T03:34:21Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This advanced tutorial will demonstrate power glitch attacks using the ChipWhisperer system.&lt;br /&gt;
&lt;br /&gt;
You can follow along with this video for details of this page too:&lt;br /&gt;
&lt;br /&gt;
[[File:youtube-vccglitch.png|link=http://www.youtube.com/watch?v=hxU5uVbYCYo&amp;amp;hd=1]]&lt;br /&gt;
&lt;br /&gt;
== Background on VCC (Power) Glitching ==&lt;br /&gt;
&lt;br /&gt;
The previous clock glitching tutorials looked into the assumption of a constant clock. But instead we can modify the voltage of the device, causing for example a failure to correctly read a memory location or otherwise cause havoc with the proper functioning.&lt;br /&gt;
&lt;br /&gt;
[[File:vccglitch_working.png|frame|none|alt=|caption Top trace is the VCC (power) measured at the microcontroller pin, lower trace is the clock to the device.]]&lt;br /&gt;
&lt;br /&gt;
[[File:vccglitch_working_zoom.png|frame|none|alt=|caption A zoom in of the previous figure, showing the offset between the clock and the glitches.]]&lt;br /&gt;
&lt;br /&gt;
[[File:vccglitch_notworking_zoom.png|frame|none|alt=|caption Changing the offset means the glitches are ineffective - this requries considerable experimentation to discover the value for offset, glitch width, and number of glitches.]]&lt;br /&gt;
&lt;br /&gt;
=== Background on Glitch Generation ===&lt;br /&gt;
&lt;br /&gt;
For more details, please see [[Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)]], this tutorials assumes you have already performed the clock glitching tutorial. This tutorial will use the ''Glitch Explorer'', which is described in the previous tutorial.&lt;br /&gt;
&lt;br /&gt;
The glitch generation hardware is the same as used in the clock glitching attack. The generated glitches are synchronous to the device clock, and inserted at a precise offset from the clock edge.&lt;br /&gt;
&lt;br /&gt;
Glitches can be inserted continuously or triggered by some event. The following figure shows the generation of two glitches:&lt;br /&gt;
&lt;br /&gt;
[[File:glitchgen-mux-glitchonly.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
The VCC glitching method here uses an electronic switch (a MOSFET) to short the power line to GND at specific instances. The following figure shows the basic function of this system:&lt;br /&gt;
&lt;br /&gt;
[[File:glitch-vccglitcher.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
This method allows use with the standard side-channel analysis development board, which has resistors inserted into the VCC lines already. The downside of this method is that it can only generate short glitches, since the power consumption through the shunt resistor will short out the resistor.&lt;br /&gt;
&lt;br /&gt;
The MOSFET glitching hardware is built into the ChipWhisperer-Lite (both CW1173 and CW1180) board. The ChipWhisperer-Capture Rev2 uses an external VCC glitching board.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
&lt;br /&gt;
=== ChipWhisperer-Lite (CW1173) with built-in XMEGA Target ===&lt;br /&gt;
&lt;br /&gt;
The XMEGA target will work out-of-the-box for this tutorial. As usual, no hardware setup is required - everything on the CW-Lite board is ready to go.&lt;br /&gt;
&lt;br /&gt;
=== ChipWhisperer-Lite (CW1173/CW1180) with external AVR (NOTDUino/Multi-Target) ===&lt;br /&gt;
&lt;br /&gt;
The AVR is an extremely reliable target to glitch. To do this, you need to connect the following cables:&lt;br /&gt;
&lt;br /&gt;
# SMA Cable from the ''Glitch'' port to the VCC shunt.&lt;br /&gt;
# 20-Pin Target Cable for Clock &amp;amp;amp; Data.&lt;br /&gt;
# Optional: SMA Cable from the ''Measure'' port to the VCC shunt (can be used to monitor glitch insertion).&lt;br /&gt;
&lt;br /&gt;
The following shows an example of connecting the NOTDuino target to the ChipWhisperer-Lite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:notduino_cwlite.jpg|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
If using a target with only a single SMA, only connect the ''Glitch'' port. The measure port is optional to allow you to monitor the VCC line as you are inserting the glitch.&lt;br /&gt;
&lt;br /&gt;
If using the ChipWhisperer-Lite with Multi-Target board, you can connect both ports by doing the following:&lt;br /&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;Connect the ''Glitch'' port to the ''VOUT'' pin.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect the ''Measure'' port to the ''LNAIN'' pin.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add the jumper across JP21 to route the ''VOUT'' to the ''LNAIN''.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
=== Using VCC Glitching Add-on with Multi-Target Board ===&lt;br /&gt;
&lt;br /&gt;
If using the ChipWhisperer Capture Rev2 (CW1002), you do not have a glitch output port. Instead you need the VCC glitching add-on.&lt;br /&gt;
&lt;br /&gt;
The VCC glitching add-on can be added to the AVR or SmartCard 6-pin headers, or connected to the XMEGA by a few additional jumper wires.&lt;br /&gt;
&lt;br /&gt;
The connection between the glitch input and FPGAOUT pin must be done via a jumper wire. This connects the glitch module output to the MOSFET input, such that whenever a glitch is requested the VCC on the target is shorted.&lt;br /&gt;
&lt;br /&gt;
Note that the VCC glitcher is '''capable of being damaged''' or '''causing damage to''' the multi-target board. In particular the shunt resistor mounted on the VCC line (e.g. R1 for the AVR) is rated only for 0.1 watts. Shorting a 3.3V VCC to GND however causes 0.2 watts to be dissipated. Provided the glitch is only short-lived (as the glitches are for this system), the total average dissipation will not cause damage. If however the glitch module accidently caused a continous short of the VCC to GND, the power dissipation of the resistor may cause it to burn out.&lt;br /&gt;
&lt;br /&gt;
The hardware is almost as in previous incarnations. Note that unlike the [[Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)]] you do not connect the FPGAOUT to the AVR Clock, instead you use the 7.37 MHz oscillator bridged to both the AVR clock and FPGAIN. This is the ''same clock setup as in the side-channel power analysis tutorials''.&lt;br /&gt;
&lt;br /&gt;
The following figure shows the clock jumper configuration, which are the same as the settings from [[Tutorial_B5_Breaking_AES_(Straightforward)]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:hw-2.jpg|600px|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
In addition the VCC glitcher board must be mounted, which means removing the jumpers on the 6-pin header around the AVR. Also the 'IN' pin on the VCC glitcher board connected to the FPGAOUT pin. This is done via a jumper wire. Both of these are shown in the following figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:vccglitcher_routing.jpg|frame|none|alt=|The control line for the VCC glitcher board comes from the FPGAOUT pin.]]&lt;br /&gt;
&lt;br /&gt;
[[File:vccglitcher_mounted.jpg|frame|none|alt=|The VCC glitcher board must be mounted with &amp;lt;code&amp;gt;GND&amp;lt;/code&amp;gt; at the bottom matching, exactly as shown here.]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
== Setting up Glitch Example ==&lt;br /&gt;
&lt;br /&gt;
=== Firmware Setup ===&lt;br /&gt;
&lt;br /&gt;
Just as in the clock glitching example, you will be required to program the AVR microcontroller with an example you can glitch. Once again program in the glitch example code to use the &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt; function, as described in [[Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)]].&lt;br /&gt;
&lt;br /&gt;
If using the AVR target, be sure to modify the &amp;lt;code&amp;gt;makefile&amp;lt;/code&amp;gt; to select the new target type (i.e. if you previously targeted the XMEGA, that hex-file will not work on the NOTDuino).&lt;br /&gt;
&lt;br /&gt;
Programming the device is also described in Step #4 in the following section.&lt;br /&gt;
&lt;br /&gt;
=== Software 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;&amp;lt;p&amp;gt;Connect to the ChipWhisperer device:&amp;lt;/p&amp;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;As the ''Scope Module'', select the ''ChipWhisperer/OpenADC'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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 ''Scope Settings'' tab, and as the ''connection'', select the ''ChipWhisperer Rev2'' or ''ChipWhisperer-Lite'' 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 Rev2'' or ''ChipWhisperer-Lite'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run connect on both the Scope &amp;amp;amp; Target. They should both switch to green circles indicating the system is connected.&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;&amp;lt;p&amp;gt;Setup the CLKGEN Module to Generate a 7.37 MHz clock and route it through the Glitch Generator&amp;lt;/p&amp;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;Switch the ''Freq Counter Src'' to the ''CLKGEN Output''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Desired Frequency'' to 7.37 MHz. Note you should only adjust the 'frequency' portion of this, if you highlight the entire field you may not be able to type the frequency into the system.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Confirm the ''DCM Locked'' checkbox is checked, if not hit the ''Reset CLKGEN DCM'' box. Check the ''Freq Counter'' to ensure the system is correctly generating about a 7.37 MHz clock.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Under the ''Glitch Module'' set the ''Clock Source'' as ''CLKGEN'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitchgen-clkgen.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set the ''Target HS IO-Out'' appropriately. This depends on the hardware in use:&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;For the ChipWhisperer-Lite (CW1173/CW1180), set ''Target HS IO-Out'' option to ''CLKGEN''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For the ChipWhisperer-Capture Rev 2 (CW1002), set ''Target HS IO-Out'' option to ''Glitch Module''.&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;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Connect the Serial Port&amp;lt;/p&amp;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;For the XMEGA Target (including the CW-Lite integrated target), 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;Switch to the ''Scope Settings'' tab, and scroll down to ''Target IOn Pins''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO1'' to be ''Serial RXD''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO2'' to be ''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;&amp;lt;p&amp;gt;From the ''Tools'' menu select ''Open Terminal'', and press ''Connect'' on the terminal:&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;The baud rate for this system is 38400, which should be the default for the ChipWhisperer serial port.&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;&amp;lt;p&amp;gt;Program the &amp;lt;code&amp;gt;.hex&amp;lt;/code&amp;gt; file into the target. When programming the AVR, it needs a working clock source before the programming will succeed. Now that this is enabled, you can use the appropriate programmer (such as the AVR or XMEGA programming from the ''Tools'' menu if using a CW-Lite) to program the hex file.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You should see the &amp;amp;quot;Hello&amp;amp;quot; message printed on the terminal emulator window.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''warning'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Releases of the ChipWhisperer-Capture software prior to 0.13 had a bug in the AVR reset logic, which never released the device from reset. You must update your ChipWhisperer-Capture release in order to complete this tutorial.&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;Setup the Glitch Module to NOT output anything by default '''VERY IMPORTANT TO AVOID DAMAGE'''&amp;lt;/p&amp;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;Under the ''Glitch Module'' set the ''Output Mode'' as ''Glitch Only'', this is the step that insurances '''you do not cause constant glitches''':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:glitchexample-capsetup1.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;For the ChipWhisperer-Lite (CW1173 or CW1180):&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;&amp;lt;p&amp;gt;Under the ''Glitch Module'' set the ''Clock Source'' as ''CLKGEN''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:glitchexample-capsetupclkgen.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;Check the box marked ''HS-Glitch Out Enable (Low Power)'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:glitchexample-capsetup2B.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;
&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;For the ChipWhisperer-Capture Rev 2 (CW1002):&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;&amp;lt;p&amp;gt;Under the ''Glitch Module'' set the ''Clock Source'' as ''TargetIO-IN'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:glitchexample-capsetup2.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;Under the ''Target HS IO-Out'' option select the ''Glitch Module'', ensuring you've already set the ''Output Mode'' as ''Glitch Only'' under ''Glitch Module'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:targioout.png|image]]&amp;lt;/p&amp;gt;&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;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch the ''Glitch Trigger'' mode to ''Ext Trigger:Single-Shot'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:singleshot.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''General Settings'' tab, and select the appropriate &amp;amp;quot;Auxiliary Module&amp;amp;quot;:&amp;lt;/p&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;For ChipWhisperer-Lite (CW1173/CW1180), select &amp;amp;quot;Reset AVR/XMEGA via CW-Lite&amp;amp;quot;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For ChipWhisperer-Capture Rev 2, select &amp;amp;quot;Reset AVR via ISP-MKII&amp;amp;quot;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitching_aux_1.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Aux Settings'' tab. Depending on your module you will see different settings here, for example the ChipWhisperer-Lite lets you select between AVR and XMEGA targets. This normally defaults to the &amp;amp;quot;XMEGA&amp;amp;quot; device, so be sure to switch this to the &amp;amp;quot;AVR&amp;amp;quot; device if using the NOTDuino or Multi-Target boards!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press the ''Test Reset'' button in the ''Aux Settings'' tab. This should reset the AVR target. Confirm this by monitoring the terminal emulator window, and check the startup message (of &amp;amp;quot;hello&amp;amp;quot;) is printed again.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can also use the &amp;amp;quot;Reset&amp;amp;quot; button on the NOTDuino to confirm the startup message is printed.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Target Settings'' tab, and remove all the text in the ''Load Key Command'', ''Go Command'', and ''Output Format'' fields.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally, you can also configure the power measurement setup too:&lt;br /&gt;
&lt;br /&gt;
=== Monitoring Glitch Insertion ===&lt;br /&gt;
&lt;br /&gt;
We can optionally enable the power analysis capture, and monitor how the power consumption changes as we insert a glitch. To do this:&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;Switch to the ''Scope Settings'' tab.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''ADC Clock Source'' as being ''CLKGEN x4''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press ''Reset ADC DCM'', confirm the frequency is 29.5 MHz as expected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Mode'' to be ''Rising Edge''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Total Samples'' to be ''1000''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Gain Setting'' --&amp;amp;gt; ''Setting'' to be ''40''. You might need to adjust this for different hardware.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture 1'', confirm some waveform is displayed. For example with the NOTDuino Target on the ChipWhisperer-Lite, the waveform looks like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:waveform-notduino-normal.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If this does't work: check the trigger in use is the ''Target IO4'' pin.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Play around a bit with the glitch width, offset, and repeat. You should see different effects in the power consumption traces. For example the following shows a narrow (15% pulse width) glitch being inserted:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:waveform-notduino-glitch1.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting the Glitch Attack ===&lt;br /&gt;
&lt;br /&gt;
We'll now look at glitching this routine. As before after sending the &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; the system goes into an infinite loop, and sends &amp;lt;code&amp;gt;1234&amp;lt;/code&amp;gt; after exiting from the loop. Using VCC glitching we'll escape from this loop!&lt;br /&gt;
&lt;br /&gt;
Rather than using the manual trigger, we'll jump right into using the Glitch Explorer to break this target. First, we'll setup some basic glitch parameters for your specific 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;Switch to the ''Target Settings'' tab, and set the ''Output Format'' to &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Open the ''Glitch Explorer'', and hit ''Capture 1'' a few times. Confirm this populates the table with various examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge-normal.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;We need to setup the ''Normal Response'' and ''Successful Response''. Note in this example the normal response has a little random noise we want to ignore, but we want to capture when the device resets after the glitch and sends the &amp;amp;quot;hello&amp;amp;quot; message twice. We could accomplish this with the following bit of Python code:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;s.endswith(&amp;amp;quot;hello\nA&amp;amp;quot;) and (len(s) &amp;amp;lt; 12)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This looks for both the ending without glitch, and the length of the string isn't too long. In the case of the successful glitch, we just want to see if &amp;amp;quot;1234&amp;amp;quot; is printed. This can be accomplished in Python with:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;amp;quot;1234&amp;amp;quot; in s&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can always experiment using the ''Python Console'' to see how your potential systems work. For example here is checking that the first line works:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; s = &amp;amp;quot;\x1ahello\nA&amp;amp;quot;&lt;br /&gt;
&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; s.endswith(&amp;amp;quot;hello\nA&amp;amp;quot;) and (len(s) &amp;amp;lt; 12)&lt;br /&gt;
True&lt;br /&gt;
&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; s = &amp;amp;quot;\x1ahello\nAhello\nA&amp;amp;quot;&lt;br /&gt;
&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; s.endswith(&amp;amp;quot;hello\nA&amp;amp;quot;) and (len(s) &amp;amp;lt; 12)&lt;br /&gt;
False&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Finally, configure the Glitch Explorer:&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 ''Normal Response'' to &amp;lt;code&amp;gt;s.endswith(&amp;amp;quot;hello\nA&amp;amp;quot;) and (len(s) &amp;amp;lt; 12)&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Successful Response'' to &amp;lt;code&amp;gt;&amp;amp;quot;1234&amp;amp;quot; in s&amp;lt;/code&amp;gt;&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 can test the updated color-coding seems to be working too with a few ''Capture 1'' events.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the following table, set the ''Glitch Width (as % of period)'' and ''Repeat'' on the ''Scope Settings'' tab:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter&lt;br /&gt;
! AVR on Multi-Target or NOTDuino&lt;br /&gt;
|-&lt;br /&gt;
| Glitch Width (as % of period)&lt;br /&gt;
| 49&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 10&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, let's configure the Glitch Explorer to give us the required sweep of the ''Offset'' parameter.&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;Adjust the ''Glitch Offset (as % of period)'' up or down by 1 in the ''Glitch Module'' settings. We do this only to get the required string printed to the ''Script Commands'' output.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Tuning Parameters'' to ''1'' in the Glitch Explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set the parameters as appropriate:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Offset&lt;br /&gt;
|-&lt;br /&gt;
| Script Command&lt;br /&gt;
| ['Glitch Module', 'Glitch Offset (as % of period)']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Float&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| -49 : 49&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| -49&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 0.5&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&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;&amp;lt;p&amp;gt;On the ''General Settings'' tab:&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;Ensure the ''Trace Format'' is set to ''None'' (i.e., no traces will be written to disk).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Number of Traces'' to 200.&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;Press the ''Capture Multi'' button. You will get a warning as there is no trace writer, but can just hit ''Continue Anyway'', since we do not want to store traces to disk.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Hopefully you will determine some useful parameters for glitching this target:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:ge-success.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;Try reducing the ''Repeat'' parameter in the ''Glitch Module'' settings. See how few cycles you can glitch while still achieving a reliable glitch.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have the glitch parameter determined, you can work on trying to recreate some of the previous tutorials such as glitching passed the password prompt.&lt;br /&gt;
&lt;br /&gt;
== Glitching More Advanced Targets: Raspberry Pi ==&lt;br /&gt;
&lt;br /&gt;
It is also possible to glitch more advanced targets, such as the Raspberry Pi development board! This requires some additional hardware setup which will be discussed here.&lt;br /&gt;
&lt;br /&gt;
The Raspberry Pi is a small ARM-based computer that runs Linux. This tutorial will show you how to influence a program running in userland via voltage glitching.&lt;br /&gt;
&lt;br /&gt;
We will use the ChipWhisperer-Lite board, as it has integrated high-power glitching MOSFET.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Setup ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''warning'''&lt;br /&gt;
&lt;br /&gt;
This tutorial can cause permanent damage to your Raspberry Pi board. The generation of glitches means driving the power supply and device beyond limits specified in the absolute maximum ratings. Only perform this tutorial if you are not too attached to your Raspberry Pi board.&lt;br /&gt;
&lt;br /&gt;
YOU PERFORM THIS TUTORIAL AT YOUR OWN RISK. NEWAE TECHNOLOGY INC. IS NOT RESPONSIBLE FOR DAMAGE CAUSED BY FOLLOWING THIS TUTORIAL.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
To glitch the board, you must solder a wire onto the ''VDD_CORE'' power supply, ideally as close to the BGA power pin as possible. To do this identify the power plane by looking at the schematic:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:rpi_schematic.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
And then solder a wire onto the VCC side of a decoupling capacitor, such as C65. Check the polarity with a DMM to ensure you have the positive side and solder a fine wire to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:rpi_solder1.jpg|400px|image]]&lt;br /&gt;
&lt;br /&gt;
[[File:rpi_solder2.jpg|400px|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
We will now mount a connector so we can connect this to the ChipWhisperer-Lite Glitch port. This will require you to check your specific revision - on this board an empty hole (test point) labeled &amp;amp;quot;TP2&amp;amp;quot; connects to ground, and made a handy location to connect the SMA connector to ground.&lt;br /&gt;
&lt;br /&gt;
The following shows an example of soldering the SMA connector onto the board, note the GND is soldered on both top and bottom to give additional strength:&lt;br /&gt;
&lt;br /&gt;
[[File:rpi_sma.jpg|400px|image]]&lt;br /&gt;
&lt;br /&gt;
The positive side of the capacitor connects to the inner conductor of the SMA &amp;amp;quot;GLITCH&amp;amp;quot; port, and connect the outer connector to ground on the Raspberry Pi. At this point do not yet plug into the GLITCH port, we will do that once setup is complete.&lt;br /&gt;
&lt;br /&gt;
Finally you need to boot the Raspberry Pi and connect to it. This is suggested to be done with a SSH shell over the Ethernet connection, as the Ethernet connection typically has very good protection against voltage transients. If you connect the Raspberry Pi to a monitor over HDMI, there is a chance the glitches may cause invalid voltage levels on the HDMI port which could damage your monitor.&lt;br /&gt;
&lt;br /&gt;
Once you have connected to it, simply make a file called &amp;lt;code&amp;gt;glitch.c&amp;lt;/code&amp;gt; with the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;amp;lt;stdio.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(void){&lt;br /&gt;
    int i,j,k,cnt;&lt;br /&gt;
    k = 0;&lt;br /&gt;
    while(1){&lt;br /&gt;
     cnt = 0;&lt;br /&gt;
     for(i=0; i&amp;amp;lt;5000; i++){&lt;br /&gt;
       for(j=0; j&amp;amp;lt;5000; j++){&lt;br /&gt;
          cnt++;&lt;br /&gt;
       }&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;amp;quot;%d %d %d %d\n&amp;amp;quot;, cnt, i, j,k++);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
Compile to an executable with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc glitch.c -o glitch&amp;lt;/pre&amp;gt;&lt;br /&gt;
And run the executable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ./glitch&lt;br /&gt;
25000000 5000 5000 0&lt;br /&gt;
25000000 5000 5000 1&lt;br /&gt;
25000000 5000 5000 2&lt;br /&gt;
25000000 5000 5000 3&lt;br /&gt;
25000000 5000 5000 4&lt;br /&gt;
25000000 5000 5000 5&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is split into two parts. The first three are used to monitor the glitch insertion (this is the &amp;lt;code&amp;gt;25000000 5000 5000&amp;lt;/code&amp;gt;, the second makes it easier for you to confirm if the Raspberry Pi has crashed.&lt;br /&gt;
&lt;br /&gt;
Now that you have a working system - let's break it!&lt;br /&gt;
&lt;br /&gt;
=== Glitch Parameters ===&lt;br /&gt;
&lt;br /&gt;
Glitching the Raspberry Pi is very simple. We just need to generate an appropriately sized glitch, as the following shows:&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;Set the ''Scope Module'' to ''ChipWhisperer/OpenADC'', and the ''connection'' to ''ChipWhisperer-Lite''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the ''Scope Connect'' button. There is no target for this example.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the CLKGEN frequency to ''120 MHz''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the Glitch module Source to ''CLKGEN''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the Glitch Mode to ''Enable Only''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Ensure the ''Glitch Trigger'' is ''Manual''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Repeat'' to ''38''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Click the ''HS-Glitch Out Enable (High Power)'' check-box.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Connect the SMA cable for the glitch output to the Raspberry Pi.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;With the output of the ''glitch'' program running, hit the ''Manual Trigger'' button. This will cause a glitch to be inserted, and observe the output of your glitch program.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Most likely the glitch width was insufficient for a glitch to be inserted, so increase the ''Repeat'' count to increase the width, and try pressing the ''Manual Trigger'' button again. In this example a glitch was successfully inserted with a width of ''52'', so you might want to try a few larger numbers. If you do things wrong your Raspberry Pi will crash and you'll need to reboot it and continue experimenting.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The following shows an example of inserting several glitches successfully:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:rpi-glitch.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Common_Tool_Information&amp;diff=1385</id>
		<title>Common Tool Information</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Common_Tool_Information&amp;diff=1385"/>
				<updated>2016-09-29T03:25:16Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Class Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Loading/Saving the Project ==&lt;br /&gt;
The save option inside the file menu of both the Capture and Analyzer tools creates the project directoryes and the .cwp file with traces information that is shared between both tools. The exact content of this file can be viewed and edited in the &amp;quot;Project Text Editor&amp;quot; widget.&lt;br /&gt;
&lt;br /&gt;
The traces data is captured to the tmp directory if no project was created. In this case, the &amp;quot;Consolidate&amp;quot; option in the Project menu can be used to copy/move this files to the current Project directory as soon as you create one. This option may also be usefull if you manually added existing traces (editing the .cwp file or using the import option in the Trace Manager) to the project.&lt;br /&gt;
&lt;br /&gt;
== Loading/Saving the Settings ==&lt;br /&gt;
The settings are not saved with the project (we may improve it in the future), but instead, you can use the &amp;quot;Save Settings&amp;quot; option (inside the Project menu) to dump this information to the &amp;quot;settings.cwset&amp;quot; file, inside the project directory. Once saved, the settings can be re-loaded using the load button in the settings tabs (general, scope, traget,...). Another possibility would be to use the Save Button and choose different filenames for each settings profile that you want to use.&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
[[File:Cw classdiagram.png|1100x1100px]]&lt;br /&gt;
&lt;br /&gt;
The general architectural idea is to start the Flow with a TraceSource, allow the connection of multiple preprocessing modules (that are both: ActiveTraceObserver and TraceSource) and end the chain in a TraceObserver (that can be a widget or an AnalysisSource). The sigTracesChanged signal (in the TraceSource objects) is used to propagate this notification through the chain and activate a callback method (processTraces) in the ActiveTraceObserver objects (like the WaveFormWidget) to read the new data. The PassiveTraceObservers (like the AnalysisSource and the TraceRecorder widget) will ignore this signal, so the processSignal() should be called manually.&lt;br /&gt;
&lt;br /&gt;
In the diagram bellow, the arrows show the data flow (the requests are made in the opposite direction) and the vertical lines the inheritance structure:&lt;br /&gt;
&lt;br /&gt;
  TraceSource -&amp;gt; [ActiveTraceObserver, TraceSource] -&amp;gt; [ActiveTraceObserver/PassiveTraceObserver]  AnalysisSource -&amp;gt; AnalysisObserver&lt;br /&gt;
        |                          |     /                  |                    |        \             /                   |&lt;br /&gt;
     Channel                 PreprocessingBase              |                    |        AttackBaseClass             AttackObserver&lt;br /&gt;
   TraceManager                      |                WaveFormWidget             |               |                          |&lt;br /&gt;
                                 ResyncSAD                                 TraceRecorder         |                     ResultsTable&lt;br /&gt;
                               AddNoiseJitter                                                   CPA                 CorrelationVsTrace&lt;br /&gt;
                                    ...                                                       Template                     ...&lt;br /&gt;
&lt;br /&gt;
Description of some other important classes:&lt;br /&gt;
&lt;br /&gt;
AnalysisSource - define signals (started, updated and done) that the AnalysisObserver objects will &amp;quot;listen&amp;quot; when emitted by these objects to execute the appropriate operation.&lt;br /&gt;
&lt;br /&gt;
AttackObserver - specialized class that will listen for AttackBaseClass emitted signals and update the ResultWidgets (table, plots...).&lt;br /&gt;
&lt;br /&gt;
ResultsBase - have a list of registered objects. When changes in this list happen, a signal is emitted to notify the GUI to create a new dock and add it to the Window menu. This list is also largely used in the current code base to allow easy access to the existing widgets (if they exist).&lt;br /&gt;
&lt;br /&gt;
Plugin - marker interface that informs that the class should be considered when importing plugins from a module.&lt;br /&gt;
&lt;br /&gt;
AutoScript - helper class with methods to setup the output when the class that uses it need to have scripts as output.&lt;br /&gt;
&lt;br /&gt;
Parameterized - helper class with methods to maintain (add/find/delete) the parameters when the class that extends it makes use of parameters.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1146</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=1146"/>
				<updated>2016-08-14T21:25:29Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1145</id>
		<title>File:Key des.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1145"/>
				<updated>2016-08-14T21:24:50Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: Adriel uploaded a new version of File:Key des.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1144</id>
		<title>File:Key des.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1144"/>
				<updated>2016-08-14T21:21:39Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: Adriel uploaded a new version of File:Key des.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1143</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=1143"/>
				<updated>2016-08-14T21:19:17Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1142</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=1142"/>
				<updated>2016-08-14T21:18:46Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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|800x800px]]&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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1141</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=1141"/>
				<updated>2016-08-14T21:18:39Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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|800x800px]]&lt;br /&gt;
&lt;br /&gt;
In this example, it matches the original key that was:&lt;br /&gt;
[[File:key_des.png|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1140</id>
		<title>File:Key des.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=File:Key_des.png&amp;diff=1140"/>
				<updated>2016-08-14T21:18:27Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1139</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=1139"/>
				<updated>2016-08-14T21:18:13Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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|800x800px]]&lt;br /&gt;
&lt;br /&gt;
In this example, it matches the original key that was:&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1138</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=1138"/>
				<updated>2016-08-14T21:01:50Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 significant 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1137</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=1137"/>
				<updated>2016-08-14T20:58:57Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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-box x 6 bits each]]), while the original key has 56 significant 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1136</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=1136"/>
				<updated>2016-08-14T20:45:30Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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 first round subkey, which only has 48bits, while the original key has 56 significant bits (64 if we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1135</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=1135"/>
				<updated>2016-08-14T20:44:11Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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|400px]]&lt;br /&gt;
&lt;br /&gt;
Note that the attack attemps to recover the first round subkey, which only has 48bits, while the original key has 56 significant bits (64 if we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=File:Breaking_des.png&amp;diff=1134</id>
		<title>File:Breaking des.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=File:Breaking_des.png&amp;diff=1134"/>
				<updated>2016-08-14T20:43:42Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1133</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=1133"/>
				<updated>2016-08-14T19:58:44Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only has 48bits, while the original key has 56 significant bits (64 if we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1132</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=1132"/>
				<updated>2016-08-14T19:35:38Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only has 48bits, while the original key has 54 significant bits (64 if we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1131</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=1131"/>
				<updated>2016-08-14T19:35:02Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only has 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1130</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=1130"/>
				<updated>2016-08-14T19:33:50Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|800x800px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1129</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=1129"/>
				<updated>2016-08-14T19:17:07Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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|400px]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=File:Deskeyschedulecalc.png&amp;diff=1128</id>
		<title>File:Deskeyschedulecalc.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=File:Deskeyschedulecalc.png&amp;diff=1128"/>
				<updated>2016-08-14T19:16:56Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1126</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=1126"/>
				<updated>2016-08-14T18:00:00Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: Adriel moved page Tutorial B5 2 Breaking DES (Straightforward) to Tutorial B5-2 Breaking DES (Straightforward)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5_2_Breaking_DES_(Straightforward)&amp;diff=1127</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=1127"/>
				<updated>2016-08-14T18:00:00Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: Adriel moved page Tutorial B5 2 Breaking DES (Straightforward) to Tutorial B5-2 Breaking DES (Straightforward)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Tutorial B5-2 Breaking DES (Straightforward)]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1125</id>
		<title>Template:Tutorials</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1125"/>
				<updated>2016-08-14T17:59:14Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div id=&amp;quot;contents-footer&amp;quot; class=&amp;quot;hlist plainlinks selfreference&amp;quot; style=&amp;quot;font-size:100%; margin-top:5px; border:1px solid {{{1|#B8C7D9}}}; background-color:{{{2|#E6F2FF}}}; padding:1em; text-align:left&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:140%; font-weight:bold&amp;quot;&amp;gt;Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Basic Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/format/type-related:--&amp;gt;&lt;br /&gt;
: [[Tutorial B1 Building a SimpleSerial Project]]&lt;br /&gt;
: [[Tutorial B2 Viewing Instruction Power Differences]]&lt;br /&gt;
: [[Tutorial B3-1 Timing Analysis with Power for Password Bypass]]&lt;br /&gt;
: [[Tutorial B3-2 Timing Analysis with Power for Attacking TSB]]&lt;br /&gt;
: [[Tutorial B4 Testing Two Partitions of Traces]]&lt;br /&gt;
: [[Tutorial B5 Breaking AES (Straightforward)]]&lt;br /&gt;
: [[Tutorial B5-2 Breaking DES (Straightforward)]]&lt;br /&gt;
: [[Tutorial B6 Breaking AES (Manual CPA Attack)]]&lt;br /&gt;
: [[Tutorial B7 Profiling Attacks (with HW Assumption)]]&lt;br /&gt;
: [[Tutorial B8 Profiling Attacks (Manual Template Attack)]]&lt;br /&gt;
: [[Tutorial B9 The Preprocessing Modules]]&lt;br /&gt;
: [[Tutorial B10 Using with SASEBO-W CardOS or DPA Contest v4.2]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/topic-related:--&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Advanced Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
: [[Tutorial A1 Synchronization to Communication Lines]]&lt;br /&gt;
: [[Tutorial A2 Introduction to Glitch Attacks (including Glitch Explorer)]]&lt;br /&gt;
: [[Tutorial A3 VCC Glitch Attacks]]&lt;br /&gt;
: [[Tutorial A4 SAD Trigger for SCA and Glitch]]&lt;br /&gt;
: [[Tutorial A5 Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A5-Bonus Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A6 Replication of Ilya Kizhvatov's XMEGA® Attack]]&lt;br /&gt;
: [[Tutorial A7 Glitch Buffer Attacks]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1124</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=1124"/>
				<updated>2016-08-14T17:58:20Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
* Flashing the DES firmware to the target device (i.e. 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' and 'Offset' 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''.&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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1123</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=1123"/>
				<updated>2016-08-14T17:53:51Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in : [[Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
- Flashing the DES firmware at the target (i.e. chipwhisperer/hardware/victims/firmware/simpleserial-des/simpleserial-des-xmega.hex), instead;&lt;br /&gt;
&lt;br /&gt;
and:&lt;br /&gt;
&lt;br /&gt;
- Setting an appropriate 'Total Samples' and 'Offset' 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.&lt;br /&gt;
Or, alternatively, the script &amp;quot;ChipWhisperer-Lite: DES SimpleSerial on XMEGA&amp;quot; can be executed 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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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). However, it can be easily recovered using brute force.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1122</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=1122"/>
				<updated>2016-08-14T17:53:20Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in [[Creating Tutorial B5 Breaking AES (Straightforward)]], but:&lt;br /&gt;
- Flashing the DES firmware at the target (i.e. chipwhisperer/hardware/victims/firmware/simpleserial-des/simpleserial-des-xmega.hex), instead;&lt;br /&gt;
&lt;br /&gt;
and:&lt;br /&gt;
&lt;br /&gt;
- Setting an appropriate 'Total Samples' and 'Offset' 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.&lt;br /&gt;
Or, alternatively, the script &amp;quot;ChipWhisperer-Lite: DES SimpleSerial on XMEGA&amp;quot; can be executed 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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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). However, it can be easily recovered using brute force.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B5-2_Breaking_DES_(Straightforward)&amp;diff=1121</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=1121"/>
				<updated>2016-08-14T17:52:54Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: Created page with &amp;quot;Follow the same procedure as in [Creating Tutorial B5 Breaking AES (Straightforward)], but: - Flashing the DES firmware at the target (i.e. chipwhisperer/hardware/victims/firm...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Follow the same procedure as in [Creating Tutorial B5 Breaking AES (Straightforward)], but:&lt;br /&gt;
- Flashing the DES firmware at the target (i.e. chipwhisperer/hardware/victims/firmware/simpleserial-des/simpleserial-des-xmega.hex), instead;&lt;br /&gt;
&lt;br /&gt;
and:&lt;br /&gt;
&lt;br /&gt;
- Setting an appropriate 'Total Samples' and 'Offset' 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.&lt;br /&gt;
Or, alternatively, the script &amp;quot;ChipWhisperer-Lite: DES SimpleSerial on XMEGA&amp;quot; can be executed 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;
Note that the attack attemps to recover the first round subkey, which only have 48bits, while the original key has 54 significant bits (64 we count the parity bits that are irrelevant). So, if we map the first round subkey, 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). However, it can be easily recovered using brute force.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1120</id>
		<title>Template:Tutorials</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1120"/>
				<updated>2016-08-14T17:29:58Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div id=&amp;quot;contents-footer&amp;quot; class=&amp;quot;hlist plainlinks selfreference&amp;quot; style=&amp;quot;font-size:100%; margin-top:5px; border:1px solid {{{1|#B8C7D9}}}; background-color:{{{2|#E6F2FF}}}; padding:1em; text-align:left&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:140%; font-weight:bold&amp;quot;&amp;gt;Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Basic Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/format/type-related:--&amp;gt;&lt;br /&gt;
: [[Tutorial B1 Building a SimpleSerial Project]]&lt;br /&gt;
: [[Tutorial B2 Viewing Instruction Power Differences]]&lt;br /&gt;
: [[Tutorial B3-1 Timing Analysis with Power for Password Bypass]]&lt;br /&gt;
: [[Tutorial B3-2 Timing Analysis with Power for Attacking TSB]]&lt;br /&gt;
: [[Tutorial B4 Testing Two Partitions of Traces]]&lt;br /&gt;
: [[Tutorial B5 Breaking AES (Straightforward)]]&lt;br /&gt;
: [[Tutorial B5_2 Breaking DES (Straightforward)]]&lt;br /&gt;
: [[Tutorial B6 Breaking AES (Manual CPA Attack)]]&lt;br /&gt;
: [[Tutorial B7 Profiling Attacks (with HW Assumption)]]&lt;br /&gt;
: [[Tutorial B8 Profiling Attacks (Manual Template Attack)]]&lt;br /&gt;
: [[Tutorial B9 The Preprocessing Modules]]&lt;br /&gt;
: [[Tutorial B10 Using with SASEBO-W CardOS or DPA Contest v4.2]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/topic-related:--&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Advanced Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
: [[Tutorial A1 Synchronization to Communication Lines]]&lt;br /&gt;
: [[Tutorial A2 Introduction to Glitch Attacks (including Glitch Explorer)]]&lt;br /&gt;
: [[Tutorial A3 VCC Glitch Attacks]]&lt;br /&gt;
: [[Tutorial A4 SAD Trigger for SCA and Glitch]]&lt;br /&gt;
: [[Tutorial A5 Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A5-Bonus Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A6 Replication of Ilya Kizhvatov's XMEGA® Attack]]&lt;br /&gt;
: [[Tutorial A7 Glitch Buffer Attacks]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1119</id>
		<title>Template:Tutorials</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Template:Tutorials&amp;diff=1119"/>
				<updated>2016-08-14T17:28:59Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div id=&amp;quot;contents-footer&amp;quot; class=&amp;quot;hlist plainlinks selfreference&amp;quot; style=&amp;quot;font-size:100%; margin-top:5px; border:1px solid {{{1|#B8C7D9}}}; background-color:{{{2|#E6F2FF}}}; padding:1em; text-align:left&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:140%; font-weight:bold&amp;quot;&amp;gt;Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Basic Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/format/type-related:--&amp;gt;&lt;br /&gt;
: [[Tutorial B1 Building a SimpleSerial Project]]&lt;br /&gt;
: [[Tutorial B2 Viewing Instruction Power Differences]]&lt;br /&gt;
: [[Tutorial B3-1 Timing Analysis with Power for Password Bypass]]&lt;br /&gt;
: [[Tutorial B3-2 Timing Analysis with Power for Attacking TSB]]&lt;br /&gt;
: [[Tutorial B4 Testing Two Partitions of Traces]]&lt;br /&gt;
: [[Tutorial B5 Breaking AES/DES (Straightforward)]]&lt;br /&gt;
: [[Tutorial B6 Breaking AES (Manual CPA Attack)]]&lt;br /&gt;
: [[Tutorial B7 Profiling Attacks (with HW Assumption)]]&lt;br /&gt;
: [[Tutorial B8 Profiling Attacks (Manual Template Attack)]]&lt;br /&gt;
: [[Tutorial B9 The Preprocessing Modules]]&lt;br /&gt;
: [[Tutorial B10 Using with SASEBO-W CardOS or DPA Contest v4.2]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;!--Overview/topic-related:--&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:105%; font-weight:bold&amp;quot;&amp;gt;Advanced Tutorials&amp;lt;/div&amp;gt;&lt;br /&gt;
: [[Tutorial A1 Synchronization to Communication Lines]]&lt;br /&gt;
: [[Tutorial A2 Introduction to Glitch Attacks (including Glitch Explorer)]]&lt;br /&gt;
: [[Tutorial A3 VCC Glitch Attacks]]&lt;br /&gt;
: [[Tutorial A4 SAD Trigger for SCA and Glitch]]&lt;br /&gt;
: [[Tutorial A5 Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A5-Bonus Breaking AES-256 Bootloader]]&lt;br /&gt;
: [[Tutorial A6 Replication of Ilya Kizhvatov's XMEGA® Attack]]&lt;br /&gt;
: [[Tutorial A7 Glitch Buffer Attacks]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B10_Using_with_SASEBO-W_CardOS_or_DPA_Contest_v4.2&amp;diff=1107</id>
		<title>Tutorial B10 Using with SASEBO-W CardOS or DPA Contest v4.2</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B10_Using_with_SASEBO-W_CardOS_or_DPA_Contest_v4.2&amp;diff=1107"/>
				<updated>2016-07-20T16:11:08Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Software Setup and Example Capture (CardOS) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Tutorial #B10: Using with SASEBO-W CardOS or DPA Contest v4.2 =&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
A number of extremely useful tools for side channel analysis are distributed by Morita Tech Co., Ltd under the [http://satoh.cs.uec.ac.jp/SAKURA/index.html SAKURA] project name. In fact much the original ChipWhisperer system was developed on these tools, and a great debt is owed to Akashi Satoh for this development.&lt;br /&gt;
&lt;br /&gt;
This tutorial will demonstrate how the ChipWhisperer system can be used in tandem with the SASEBO-W system. The first part of this tutorial will target the same ATMegaCard used by the SASEBO-W, and the second part of the tutorial will demonstrate how the ATMega328p can be connected to the SASEBO-W using the interposer board.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
&lt;br /&gt;
=== About the ATMega Card ===&lt;br /&gt;
&lt;br /&gt;
The ATMega Card is shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:megacard.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
This card contains an Atmel ATMega163 die along with a 24C256 EEPROM. You can see the internal pinout of these cards online. It should be noted that this card is in a SmartCard ''form factor'', but is essentially just a very old microcontroller (AtMega163). If you are unable to find this card but still wish to perform these experiments, there are two other options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Purchase an ATMega16, which can be programmed with the ATMega163 binary (.hex file). See an [http://www.atmel.com/Images/doc2517.pdf Atmel App-Note] on the subject. The AtMega16 ''will not'' fit on the Multi-Target board, meaning you must build your own board. You can then connect the appropriate IO lines to the SmartCard interface.&lt;br /&gt;
# Rebuild your code for the ATMega328p. This should require minimal changes to the source code, but note you cannot program a .hex file for a Mega163 into a Mega328P directly. You will need the complete source code.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Alternatively of course you can package your target algorithm into something like the demo SimpleSerial project too. There is no real need to use the SmartCard APDU format, and the interface tends to be much slower on the ChipWhisperer system.&lt;br /&gt;
&lt;br /&gt;
=== Programming ===&lt;br /&gt;
&lt;br /&gt;
You will need an image to program into the SmartCard. This tutorial uses the SASEBO-W Card OS. Details of this are available from the [http://satoh.cs.uec.ac.jp/SAKURA/hardware/SASEBO-W.html SASEBO-W Page]. Download the file entitled ''Smartcard sample binary for ATMega 163'', which is described in the document entitled ''SASEBO-W Smart Card OS Specification Ver. 0.4-5''.&lt;br /&gt;
&lt;br /&gt;
The first file will have a .hex inside it, which you must program using AVRStudio or similar. To use the built-in programmer, the following connections should be set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Remove all jumpers from the AVR and XMEGA sections of the MultiTarget board.&lt;br /&gt;
# Remove the AtMega328p from the socket.&lt;br /&gt;
# Set the oscillator for ''3.579 MHz'' (JP18), and set the ''CLKOSC'' jumper (JP17).&lt;br /&gt;
# Mount all four jumpers on the ''AVR-PROG'' section (JP8).&lt;br /&gt;
# Shunt both the ''GND'' and ''VCC'' resistors, as the programming will fail with those resistors in the power lines (JP7).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The following image shows these connections:&lt;br /&gt;
&lt;br /&gt;
[[File:programming.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Then use AVRStudio to program the .hex file. The instructions for doing this are as in [[Installing_ChipWhisperer#Getting_AVR_Compiler_Toolchain]], however when selecting the AVR type select ''ATMega163'' instead of ''ATMega328p''. Check the ''Read Signature'' option works, if not double-check the above hardware connections.&lt;br /&gt;
&lt;br /&gt;
=== Hardware setup for using Card Socket ===&lt;br /&gt;
&lt;br /&gt;
The following describes the jumper settings when using the SmartCard socket on the MultiTarget Victim Board:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# NO jumpers mounted in XMEGA Portion or AVR Portion, ideally remove the AVR Chip as well&lt;br /&gt;
# 3.3V IO Level (JP20 set to ''INT''.)&lt;br /&gt;
# The ''3.579 MHz'' oscillator is selected as the CLKOSC source (JP18)&lt;br /&gt;
# The ''CLKOSC'' is connected to the SmartCard Clock Network, along with connected to the ''FPGAIN'' pin (JP4)&lt;br /&gt;
# #; Trigger is selected as ''AX2'' (JP22) [NOTE: The silkscreen on the multi-target board is incorrect - this is actually the AUX1 pin. This tutorial will&lt;br /&gt;
#: use the silkscreen notation instead of the actual pin for jumper settings]&lt;br /&gt;
# Power measurement taken from VCC shunt (JP7)&lt;br /&gt;
# Jumpers removed from the AVR-PROG header (JP8)&lt;br /&gt;
# Connect the GPIO1 line to the ''RESET'' line. This is done with a jumper from a line labeled ''RXD'' on the AVR section to one of the pins on the AVR-PROG section. Note you can alternatively connect this line to the ''RST'' pin on the blue 8-pin smartcard connector header.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The following image shows this setup:&lt;br /&gt;
&lt;br /&gt;
[[File:attacksettings_new.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Connect the 20-pin cable and SMA cable if not already connected, and plug your programmed MegaCard into the SmartCard socket. This completes the hardware setup when using the card socket.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Setup using ATMega16 ===&lt;br /&gt;
&lt;br /&gt;
The AtMega16 is binary-compatible with the AtMega163, meaning a hex file for the ATMega163 can be programmed directly into the ATMega16. Assuming you have the SASEBO-W adapter, this simple schematic shows the required circuit:&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/atmega16_sch.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Note that we are not using the shunt on the SASEBO-W, as we have added filtering capacitors. Due to the long ribbon cable (with a high-frequency clock), you'll end up with a lot of noise if you attempted to use the shunt on the SASEBO-W (which means no filtering caps on the AtMega16). The implementation looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/atmega16.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
You'll have to program the AtMega16 device, which you can do as described in the SASEBO-W Quickstart guide. The only difference is you'll need to change the device to the mega16. You'll also need to program the fuse bits, as by default the ATMega16 uses an internal oscillator, which has the wrong frequency for the SASEBO-W communications.&lt;br /&gt;
&lt;br /&gt;
Here's an example of the batch file which will program the ATMega16, along with programming the fuse bytes. You only need to program the fuse bytes the first time you use this, otherwise you can just program the .hex file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;avrdude -c sasebow -p m16 -P ft0 -B 115200 -u -e -U flash:w:AES.hex:a -U lfuse:w:0xD0:m -U hfuse:w:0x99:m -v&lt;br /&gt;
pause&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Hardware Setup using ATMega328p ===&lt;br /&gt;
&lt;br /&gt;
See [[SASEBO-W_Target#Connecting_the_Multi-Target_Board_to_the_SASEBO-W]] for details of connecting the Multi-Target board to the SASEBO-W.&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/sasebow_scardfake.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
== Software Setup and Example Capture (CardOS) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Run the ChipWhisperer Capture software&lt;br /&gt;
# Select the following options on the ''General Settings'' tab:&lt;br /&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;Scope Module: ''ChipWhisperer/OpenADC''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Target Module: ''Smart Card''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Trace Format: ''ChipWhisperer/Native''&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;3&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Target Settings'' tab. Set the following two options:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&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;Reader Hardware: ''ChipWhisperer-SER'' (NOTE: This is new a new option as of 0.09, the old ChipWhisperer-USI is not recommended anymore)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;SmartCard Protocol: ''SASEBO-W SmartCard OS''&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;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press the ''Master Connect'' button, the scope and target should both show as connected:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:allcon.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the ''Scope Settings'' tab, make the following changes:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&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;OpenADC--&amp;amp;gt;Gain--&amp;amp;gt;Setting: ''35''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Trigger Setup--&amp;amp;gt;Mode: ''Rising Edge''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Clock Source: ''TargetIO-IN''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Trigger Pins: Uncheck ''Front Panel A''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Trigger Pins: Check ''Target IO4 (Trigger Line)''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Clock Setup--&amp;amp;gt;ADC Clock--&amp;amp;gt;Source: ''EXTCLK x4 via DCM''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Reset ADC DCM'' button in that area, confirm the ''ADC Freq'' reads 14.3 MHz indicating the clock routing is working.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Trigger Setup--&amp;amp;gt;Total Samples: ''5000''&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;6&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Target'' tab, confirm the correct ATR was found. You can reset the card as well from this page:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:scard_cwser.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally press the ''Capture 1'' button. You should see a waveform like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:waveform.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Use the encryption monitor to check the output:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:encmonitor.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can now run a capture campaign and save the traces as before.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changes for DPAContest v4.2 Card ==&lt;br /&gt;
&lt;br /&gt;
As of ChipWhisperer Release 0.09, the DPAContest v4.2 protocol is also supported. This protocol uses AES-128 RSM, making an interesting attack of a protected target. The following details settings required to attack this card.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Change the ''TRIG'' jumper to ''AX1'' instead of ''AX2'' (again this is based on silkscreen markings)&lt;br /&gt;
# In step 3-b above: Select the ''DPA Contest 4.2'' as the SmartCard Protocol&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Otherwise you can follow the above example. With those settings, and the .hex and .eeprom file programmed into the card. Note the ''ATR'' does not seem to work properly, possibly as it is sent too soon after reset for the ChipWhisperer reader to capture.&lt;br /&gt;
&lt;br /&gt;
You should see a power signature that looks something like this, note again the use of the encryption monitor to confirm correct operation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:dpacontestv42.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_B10_Using_with_SASEBO-W_CardOS_or_DPA_Contest_v4.2&amp;diff=1106</id>
		<title>Tutorial B10 Using with SASEBO-W CardOS or DPA Contest v4.2</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_B10_Using_with_SASEBO-W_CardOS_or_DPA_Contest_v4.2&amp;diff=1106"/>
				<updated>2016-07-20T15:39:42Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* About the ATMega Card */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Tutorial #B10: Using with SASEBO-W CardOS or DPA Contest v4.2 =&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
A number of extremely useful tools for side channel analysis are distributed by Morita Tech Co., Ltd under the [http://satoh.cs.uec.ac.jp/SAKURA/index.html SAKURA] project name. In fact much the original ChipWhisperer system was developed on these tools, and a great debt is owed to Akashi Satoh for this development.&lt;br /&gt;
&lt;br /&gt;
This tutorial will demonstrate how the ChipWhisperer system can be used in tandem with the SASEBO-W system. The first part of this tutorial will target the same ATMegaCard used by the SASEBO-W, and the second part of the tutorial will demonstrate how the ATMega328p can be connected to the SASEBO-W using the interposer board.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
&lt;br /&gt;
=== About the ATMega Card ===&lt;br /&gt;
&lt;br /&gt;
The ATMega Card is shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:megacard.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
This card contains an Atmel ATMega163 die along with a 24C256 EEPROM. You can see the internal pinout of these cards online. It should be noted that this card is in a SmartCard ''form factor'', but is essentially just a very old microcontroller (AtMega163). If you are unable to find this card but still wish to perform these experiments, there are two other options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Purchase an ATMega16, which can be programmed with the ATMega163 binary (.hex file). See an [http://www.atmel.com/Images/doc2517.pdf Atmel App-Note] on the subject. The AtMega16 ''will not'' fit on the Multi-Target board, meaning you must build your own board. You can then connect the appropriate IO lines to the SmartCard interface.&lt;br /&gt;
# Rebuild your code for the ATMega328p. This should require minimal changes to the source code, but note you cannot program a .hex file for a Mega163 into a Mega328P directly. You will need the complete source code.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Alternatively of course you can package your target algorithm into something like the demo SimpleSerial project too. There is no real need to use the SmartCard APDU format, and the interface tends to be much slower on the ChipWhisperer system.&lt;br /&gt;
&lt;br /&gt;
=== Programming ===&lt;br /&gt;
&lt;br /&gt;
You will need an image to program into the SmartCard. This tutorial uses the SASEBO-W Card OS. Details of this are available from the [http://satoh.cs.uec.ac.jp/SAKURA/hardware/SASEBO-W.html SASEBO-W Page]. Download the file entitled ''Smartcard sample binary for ATMega 163'', which is described in the document entitled ''SASEBO-W Smart Card OS Specification Ver. 0.4-5''.&lt;br /&gt;
&lt;br /&gt;
The first file will have a .hex inside it, which you must program using AVRStudio or similar. To use the built-in programmer, the following connections should be set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Remove all jumpers from the AVR and XMEGA sections of the MultiTarget board.&lt;br /&gt;
# Remove the AtMega328p from the socket.&lt;br /&gt;
# Set the oscillator for ''3.579 MHz'' (JP18), and set the ''CLKOSC'' jumper (JP17).&lt;br /&gt;
# Mount all four jumpers on the ''AVR-PROG'' section (JP8).&lt;br /&gt;
# Shunt both the ''GND'' and ''VCC'' resistors, as the programming will fail with those resistors in the power lines (JP7).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The following image shows these connections:&lt;br /&gt;
&lt;br /&gt;
[[File:programming.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Then use AVRStudio to program the .hex file. The instructions for doing this are as in [[Installing_ChipWhisperer#Getting_AVR_Compiler_Toolchain]], however when selecting the AVR type select ''ATMega163'' instead of ''ATMega328p''. Check the ''Read Signature'' option works, if not double-check the above hardware connections.&lt;br /&gt;
&lt;br /&gt;
=== Hardware setup for using Card Socket ===&lt;br /&gt;
&lt;br /&gt;
The following describes the jumper settings when using the SmartCard socket on the MultiTarget Victim Board:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# NO jumpers mounted in XMEGA Portion or AVR Portion, ideally remove the AVR Chip as well&lt;br /&gt;
# 3.3V IO Level (JP20 set to ''INT''.)&lt;br /&gt;
# The ''3.579 MHz'' oscillator is selected as the CLKOSC source (JP18)&lt;br /&gt;
# The ''CLKOSC'' is connected to the SmartCard Clock Network, along with connected to the ''FPGAIN'' pin (JP4)&lt;br /&gt;
# #; Trigger is selected as ''AX2'' (JP22) [NOTE: The silkscreen on the multi-target board is incorrect - this is actually the AUX1 pin. This tutorial will&lt;br /&gt;
#: use the silkscreen notation instead of the actual pin for jumper settings]&lt;br /&gt;
# Power measurement taken from VCC shunt (JP7)&lt;br /&gt;
# Jumpers removed from the AVR-PROG header (JP8)&lt;br /&gt;
# Connect the GPIO1 line to the ''RESET'' line. This is done with a jumper from a line labeled ''RXD'' on the AVR section to one of the pins on the AVR-PROG section. Note you can alternatively connect this line to the ''RST'' pin on the blue 8-pin smartcard connector header.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The following image shows this setup:&lt;br /&gt;
&lt;br /&gt;
[[File:attacksettings_new.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Connect the 20-pin cable and SMA cable if not already connected, and plug your programmed MegaCard into the SmartCard socket. This completes the hardware setup when using the card socket.&lt;br /&gt;
&lt;br /&gt;
=== Hardware Setup using ATMega16 ===&lt;br /&gt;
&lt;br /&gt;
The AtMega16 is binary-compatible with the AtMega163, meaning a hex file for the ATMega163 can be programmed directly into the ATMega16. Assuming you have the SASEBO-W adapter, this simple schematic shows the required circuit:&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/atmega16_sch.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
Note that we are not using the shunt on the SASEBO-W, as we have added filtering capacitors. Due to the long ribbon cable (with a high-frequency clock), you'll end up with a lot of noise if you attempted to use the shunt on the SASEBO-W (which means no filtering caps on the AtMega16). The implementation looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/atmega16.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
You'll have to program the AtMega16 device, which you can do as described in the SASEBO-W Quickstart guide. The only difference is you'll need to change the device to the mega16. You'll also need to program the fuse bits, as by default the ATMega16 uses an internal oscillator, which has the wrong frequency for the SASEBO-W communications.&lt;br /&gt;
&lt;br /&gt;
Here's an example of the batch file which will program the ATMega16, along with programming the fuse bytes. You only need to program the fuse bytes the first time you use this, otherwise you can just program the .hex file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;avrdude -c sasebow -p m16 -P ft0 -B 115200 -u -e -U flash:w:AES.hex:a -U lfuse:w:0xD0:m -U hfuse:w:0x99:m -v&lt;br /&gt;
pause&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Hardware Setup using ATMega328p ===&lt;br /&gt;
&lt;br /&gt;
See [[SASEBO-W_Target#Connecting_the_Multi-Target_Board_to_the_SASEBO-W]] for details of connecting the Multi-Target board to the SASEBO-W.&lt;br /&gt;
&lt;br /&gt;
[[File:/images/sasebow/sasebow_scardfake.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
== Software Setup and Example Capture (CardOS) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Run the ChipWhisperer Capture software&lt;br /&gt;
# Select the following options on the ''General Settings'' tab:&lt;br /&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;Scope Module: ''ChipWhisperer/OpenADC''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Target Module: ''Smart Card''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Trace Format: ''ChipWhisperer/Native''&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;3&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch to the ''Target Settings'' tab. Set the following two options:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&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;Reader Hardware: ''ChipWhisperer-SER'' (NOTE: This is new a new option as of 0.09, the old ChipWhisperer-USI is not recommended anymore)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;SmartCard Protocol: ''SASEBO-W SmartCard OS''&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;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press the ''Master Connect'' button, the scope and target should both show as connected:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:allcon.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Under the ''Scope Settings'' tab, make the following changes:&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&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;OpenADC--&amp;amp;gt;Gain--&amp;amp;gt;Setting: ''35''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Trigger Setup--&amp;amp;gt;Mode: ''Rising Edge''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Clock Source: ''TargetIO-IN''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Trigger Pins: Uncheck ''Front Panel A''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CW Extra--&amp;amp;gt;Trigger Pins: Check ''Target IO4 (Trigger Line)''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Clock Setup--&amp;amp;gt;ADC Clock--&amp;amp;gt;Source: ''EXTCLK x4 via DCM''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Reset ADC DCM'' button in that area, confirm the ''ADC Freq'' reads 14.3 MHz indicating the clock routing is working.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OpenADC--&amp;amp;gt;Trigger Setup--&amp;amp;gt;Total Samples: ''5000''&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;6&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Target'' tab, confirm the correct ATR was found. You can reset the card as well from this page:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:scard_cwser.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally press the ''Capture 1'' button. You should see a waveform like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:waveform.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the encryption monitor, you can check the encryption monitor:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:encmonitor.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You can now run a capture campaign and save the traces as before.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
== Changes for DPAContest v4.2 Card ==&lt;br /&gt;
&lt;br /&gt;
As of ChipWhisperer Release 0.09, the DPAContest v4.2 protocol is also supported. This protocol uses AES-128 RSM, making an interesting attack of a protected target. The following details settings required to attack this card.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;# Change the ''TRIG'' jumper to ''AX1'' instead of ''AX2'' (again this is based on silkscreen markings)&lt;br /&gt;
# In step 3-b above: Select the ''DPA Contest 4.2'' as the SmartCard Protocol&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Otherwise you can follow the above example. With those settings, and the .hex and .eeprom file programmed into the card. Note the ''ATR'' does not seem to work properly, possibly as it is sent too soon after reset for the ChipWhisperer reader to capture.&lt;br /&gt;
&lt;br /&gt;
You should see a power signature that looks something like this, note again the use of the encryption monitor to confirm correct operation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:dpacontestv42.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Making_Scripts&amp;diff=1104</id>
		<title>Making Scripts</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Making_Scripts&amp;diff=1104"/>
				<updated>2016-07-18T12:31:43Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Adding user scripts to the GUI menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=The Basic=&lt;br /&gt;
User scripts allows partial (i.e.: setting up the environment) or total automation of the execution flow. &lt;br /&gt;
&lt;br /&gt;
A basic script would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.scripts.base import UserScriptBase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class UserScript(UserScriptBase):&lt;br /&gt;
    _name = &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot;&lt;br /&gt;
    _description = &amp;quot;SimpleSerial with Standard Target for AES (XMEGA)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, api):&lt;br /&gt;
        super(UserScript, self).__init__(api)&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        #User commands here&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;
                &lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        #Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
        lstexample = [['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&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;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['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', 1250],&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;
                      ]&lt;br /&gt;
        for cmd in lstexample: self.api.setParameter(cmd)&lt;br /&gt;
        &lt;br /&gt;
        #Let's only do a few traces&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 50])&lt;br /&gt;
                      &lt;br /&gt;
        #The environment is already set, lets do our first capture&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
User scripts should inherit from UserScriptBase that specifies the run() method that is called when clicking it in the menu or pressing the attack button (in the analyzer tool).&lt;br /&gt;
&lt;br /&gt;
The API is passed as an argument by the GUI through the constructor in order to allow the script to &amp;quot;remote control&amp;quot; the existing section. A name and a description should also be specified.&lt;br /&gt;
&lt;br /&gt;
==Running from the Terminal==&lt;br /&gt;
This step is only needed if you want to run the script from the terminal. In this case, you don't need to use the GUI, the capture can be performed using only the API. In order to do it, you should add the following lines to the end of your script file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    api = CWCoreAPI()               # Instantiate the API&lt;br /&gt;
    api.runScriptClass(UserScript)  # Run UserScript through the API&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or if you want the GUI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc       # Import the ChipWhispererCapture GUI&lt;br /&gt;
    from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
    app = cwc.makeApplication()  &lt;br /&gt;
    Parameter.usePyQtGraph = True &lt;br /&gt;
    api = CWCoreAPI()               # Instantiate the API&lt;br /&gt;
    gui = cwc.CWAnalyzerGUI(api)    # Instantiate the GUI&lt;br /&gt;
    gui.show() &lt;br /&gt;
    api.runScriptClass(UserScript)  # Run UserScript through the API&lt;br /&gt;
&lt;br /&gt;
    app.exec_()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding user scripts to the GUI menu==&lt;br /&gt;
New scripts can be added to the tool menu automatically by saving it in its respective script folder inside the chipwhisperer installation folder or user projects folder:&lt;br /&gt;
&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scripts&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/scripts&lt;br /&gt;
* ~/chipwhisperer_projects/chipwhisperer/capture/scripts&lt;br /&gt;
* ~/chipwhisperer_projects/chipwhisperer/analyzer/scripts&lt;br /&gt;
&lt;br /&gt;
Files put in these directories are scanned during the GUI initialization and all UserScriptBase classes are added to the menu. You can copy and past the content of the ''Analysis Script'' window to a text editor or use the ''Attack Script Generator''-&amp;gt;''Attack Script''-&amp;gt;''Copy'' option.&lt;br /&gt;
&lt;br /&gt;
== Other examples==&lt;br /&gt;
The directories listed above already have some examples which can be used as a reference to create new scripts. More advanced scripts can be located in the chipwhisperer/software/chipwhisperer/tests folder. &lt;br /&gt;
&lt;br /&gt;
Scripts auto-generated by the analyzer tool can also be executed standalone or saved into the scripts directory so that it will show up in the next GUI execution.&lt;br /&gt;
&lt;br /&gt;
=Advanced=&lt;br /&gt;
&lt;br /&gt;
If you decide to run both tools in sequence, do as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc&lt;br /&gt;
    import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa&lt;br /&gt;
    from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
    app = cwc.makeApplication()&lt;br /&gt;
    Parameter.usePyQtGraph = True&lt;br /&gt;
    api = CWCoreAPI()             # Instantiate the API&lt;br /&gt;
    gui = cwc.CWCaptureGUI(api)   # Instantiate the Capture GUI&lt;br /&gt;
    gui.show()&lt;br /&gt;
    api.runScriptClass(Capture)&lt;br /&gt;
    gui.close()&lt;br /&gt;
    gui.reset()                   # Delete saved geometry settings in the Capture tool so it will not be used by the Analyzer&lt;br /&gt;
&lt;br /&gt;
    gui = cwa.CWAnalyzerGUI(api)  # Instantiate the Analyzer GUI&lt;br /&gt;
    gui.show()&lt;br /&gt;
    api.runScriptClass(Attack)    # Run the script (default is the &amp;quot;run&amp;quot; method)&lt;br /&gt;
&lt;br /&gt;
    app.exec_()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Making_Scripts&amp;diff=1103</id>
		<title>Making Scripts</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Making_Scripts&amp;diff=1103"/>
				<updated>2016-07-18T12:28:07Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Adding user scripts to the GUI menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=The Basic=&lt;br /&gt;
User scripts allows partial (i.e.: setting up the environment) or total automation of the execution flow. &lt;br /&gt;
&lt;br /&gt;
A basic script would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from chipwhisperer.common.scripts.base import UserScriptBase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class UserScript(UserScriptBase):&lt;br /&gt;
    _name = &amp;quot;ChipWhisperer-Lite: AES SimpleSerial on XMEGA&amp;quot;&lt;br /&gt;
    _description = &amp;quot;SimpleSerial with Standard Target for AES (XMEGA)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, api):&lt;br /&gt;
        super(UserScript, self).__init__(api)&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        #User commands here&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;
                &lt;br /&gt;
        self.api.connect()&lt;br /&gt;
        &lt;br /&gt;
        #Example of using a list to set parameters. Slightly easier to copy/paste in this format&lt;br /&gt;
        lstexample = [['CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True],&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;
                      ['OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0],&lt;br /&gt;
                      ['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', 1250],&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;
                      ]&lt;br /&gt;
        for cmd in lstexample: self.api.setParameter(cmd)&lt;br /&gt;
        &lt;br /&gt;
        #Let's only do a few traces&lt;br /&gt;
        self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 50])&lt;br /&gt;
                      &lt;br /&gt;
        #The environment is already set, lets do our first capture&lt;br /&gt;
        self.api.capture1()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
User scripts should inherit from UserScriptBase that specifies the run() method that is called when clicking it in the menu or pressing the attack button (in the analyzer tool).&lt;br /&gt;
&lt;br /&gt;
The API is passed as an argument by the GUI through the constructor in order to allow the script to &amp;quot;remote control&amp;quot; the existing section. A name and a description should also be specified.&lt;br /&gt;
&lt;br /&gt;
==Running from the Terminal==&lt;br /&gt;
This step is only needed if you want to run the script from the terminal. In this case, you don't need to use the GUI, the capture can be performed using only the API. In order to do it, you should add the following lines to the end of your script file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    api = CWCoreAPI()               # Instantiate the API&lt;br /&gt;
    api.runScriptClass(UserScript)  # Run UserScript through the API&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or if you want the GUI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc       # Import the ChipWhispererCapture GUI&lt;br /&gt;
    from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
    app = cwc.makeApplication()  &lt;br /&gt;
    Parameter.usePyQtGraph = True &lt;br /&gt;
    api = CWCoreAPI()               # Instantiate the API&lt;br /&gt;
    gui = cwc.CWAnalyzerGUI(api)    # Instantiate the GUI&lt;br /&gt;
    gui.show() &lt;br /&gt;
    api.runScriptClass(UserScript)  # Run UserScript through the API&lt;br /&gt;
&lt;br /&gt;
    app.exec_()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding user scripts to the GUI menu==&lt;br /&gt;
New scripts can be added to the tool menu automatically by saving it in its respective script folder inside the chipwhisperer installation folder or user projects folder:&lt;br /&gt;
&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/capture/scripts&lt;br /&gt;
* chipwhisperer/software/chipwhisperer/analyzer/scripts&lt;br /&gt;
* ~/chipwhisperer_projects/chipwhisperer/capture/scripts&lt;br /&gt;
* ~/chipwhisperer_projects/chipwhisperer/analyzer/scripts&lt;br /&gt;
&lt;br /&gt;
Files put in these directories are scanned during the GUI initialization and all UserScriptBase classes are added to the menu.&lt;br /&gt;
&lt;br /&gt;
== Other examples==&lt;br /&gt;
The directories listed above already have some examples which can be used as a reference to create new scripts. More advanced scripts can be located in the chipwhisperer/software/chipwhisperer/tests folder. &lt;br /&gt;
&lt;br /&gt;
Scripts auto-generated by the analyzer tool can also be executed standalone or saved into the scripts directory so that it will show up in the next GUI execution.&lt;br /&gt;
&lt;br /&gt;
=Advanced=&lt;br /&gt;
&lt;br /&gt;
If you decide to run both tools in sequence, do as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI&lt;br /&gt;
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc&lt;br /&gt;
    import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa&lt;br /&gt;
    from chipwhisperer.common.utils.parameter import Parameter&lt;br /&gt;
    app = cwc.makeApplication()&lt;br /&gt;
    Parameter.usePyQtGraph = True&lt;br /&gt;
    api = CWCoreAPI()             # Instantiate the API&lt;br /&gt;
    gui = cwc.CWCaptureGUI(api)   # Instantiate the Capture GUI&lt;br /&gt;
    gui.show()&lt;br /&gt;
    api.runScriptClass(Capture)&lt;br /&gt;
    gui.close()&lt;br /&gt;
    gui.reset()                   # Delete saved geometry settings in the Capture tool so it will not be used by the Analyzer&lt;br /&gt;
&lt;br /&gt;
    gui = cwa.CWAnalyzerGUI(api)  # Instantiate the Analyzer GUI&lt;br /&gt;
    gui.show()&lt;br /&gt;
    api.runScriptClass(Attack)    # Run the script (default is the &amp;quot;run&amp;quot; method)&lt;br /&gt;
&lt;br /&gt;
    app.exec_()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=CW-Analyzer_Tool&amp;diff=1090</id>
		<title>CW-Analyzer Tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=CW-Analyzer_Tool&amp;diff=1090"/>
				<updated>2016-07-15T21:46:20Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The objective of this tool is to analyze the traces captured from a given scope.&lt;br /&gt;
&lt;br /&gt;
Main features:&lt;br /&gt;
* CPA and Profiling types of attack;&lt;br /&gt;
* Built-in preprocessing modules (decimation, resync, digital filter, normalize and noise);&lt;br /&gt;
* Record preprocessed traces output;&lt;br /&gt;
* Execute custom analysis scripts;&lt;br /&gt;
* AES Key schedule calculator;&lt;br /&gt;
* Set of result widgets: Correlation vs Traces plot; Output vs Point plot; PGE vs Trace plot; PGE Table; Waveform Viewer.&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2016-07-12 at 4.02.17 PM.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== Using the Analyzer ==&lt;br /&gt;
After loading the project, you will need to setup the analysis environment first. &lt;br /&gt;
&lt;br /&gt;
In the analyzer, the settings tabs are used to automatically generate the analysis script (shown in the &amp;quot;Analysis Script&amp;quot; dock). This code can be edited by the user for a more &amp;quot;advanced&amp;quot; usage. It can also be saved and loaded through:&lt;br /&gt;
* the console ($python script.py); &lt;br /&gt;
* using the &amp;quot;Attack Script Generator&amp;quot; tab;&lt;br /&gt;
* copying it to the scripts folder (chipwhisperer/software/chipwhisperer/analyzer/scripts or ˜/chipwhisperer_projects/chipwhisperer/analyzer/scripts) so that it will appear in the Project-&amp;gt;&amp;quot;Example Scripts&amp;quot; menu the next time you execute the tool.&lt;br /&gt;
In the &amp;quot;Analysis Script&amp;quot; dock, the constructor of the script object is called automatically every time that a new script is generated. It is done because widgets like the waveform viewer should update the trace output of the preprocessing modules when the user modify its settings. The run() method is executed only when the &amp;quot;Start Analysis&amp;quot; button in the toolbar is pressed. Custom methods can be executed by selecting it in the code and right clicking: a &amp;quot;Run Function&amp;quot; option will show up.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Attack Script Generator&amp;quot; is the main settings tab. It allows the user to set the Preprocessing modules that should be applied over the original traces and the Attack module. The Preprocessing and the Attack tabs will update accordingly.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Trace Explorer&amp;quot; tab enables a set of helper scripts needed by some of the analysis algorithms (like the POI detection in the Template attack).&lt;br /&gt;
&lt;br /&gt;
== Preprocessing Modules ==&lt;br /&gt;
Are filters that modify the traces from a given trace source (that can be another Preprocessing Module or the Trace Manager) and works as a new trace source to the next module in the chain (called trace observer).&lt;br /&gt;
&lt;br /&gt;
=== Add Noise: Amplitude ===&lt;br /&gt;
Add random noise to the traces. Used for testing, has no use in actual analysis.&lt;br /&gt;
&lt;br /&gt;
=== Add Noise: Time Jitter ===&lt;br /&gt;
Add random jitter. Used for testing, has no use in actual analysis.&lt;br /&gt;
&lt;br /&gt;
=== Decimation: Clock Recovery ===&lt;br /&gt;
Attempts to 'recover' the clock by band-pass filtering, and then uses that to decimate to only points of interest. ****CURRENTLY NOT SUPPORTED****&lt;br /&gt;
&lt;br /&gt;
=== Decimation: Fixed ===&lt;br /&gt;
Decimate (reduce the sample rate) by a fixed factor.&lt;br /&gt;
&lt;br /&gt;
=== Digital Filter ===&lt;br /&gt;
Frequency specific filter.&lt;br /&gt;
&lt;br /&gt;
=== Normalize ===&lt;br /&gt;
Normalize by standard deviation.&lt;br /&gt;
&lt;br /&gt;
=== Resync: Cross Correlation ===&lt;br /&gt;
Use cross-correlation to detect shift between a 'reference trace' and every input trace. In practice the other resync methods seem to work better.&lt;br /&gt;
&lt;br /&gt;
=== Resync: Peak Detect ===&lt;br /&gt;
Line up traces so peak (either max positive or max negative) within some given range of points all aligns.&lt;br /&gt;
&lt;br /&gt;
For each trace the following must hold or the trace is rejected:&lt;br /&gt;
* (1-valid limit) &amp;lt; (peak value from candidate trace) / (peak value from reference) &amp;lt; (1+valid limit)&lt;br /&gt;
&lt;br /&gt;
* If 'valid limit' is 0 then this is ignored, and all traces are kept.&lt;br /&gt;
&lt;br /&gt;
=== Resync: Resample based on Zero-Crossing ===&lt;br /&gt;
Deal with resampling 'bins' based on zero-crossing detection.&lt;br /&gt;
&lt;br /&gt;
=== Resync: Sum-of-Difference ===&lt;br /&gt;
Minimize the 'Sum of Absolute Difference' (SAD), also known as 'Sum of Absolute Error'. Uses a portion of one of the traces as the 'reference'. This reference is then slid over the 'input window' for each trace, and the amount of shift resulting in the minimum SAD criteria is selected as the shift amount for that trace. &lt;br /&gt;
&lt;br /&gt;
See [[Sum of Absolute Difference (SAD) Pre-Processing]] for more information.&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)&amp;diff=1089</id>
		<title>Tutorial A2 Introduction to Glitch Attacks (including Glitch Explorer)</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)&amp;diff=1089"/>
				<updated>2016-07-15T21:45:19Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Parameter Settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This advanced tutorial will demonstrate clock glitch attacks using the ChipWhisperer system. This will introduce you to many required features of the ChipWhisperer system when it comes to glitching. This will be built on in later tutorials to generate voltage glitching attacks, or when you wish to attack other targets.&lt;br /&gt;
&lt;br /&gt;
You can follow along with this video for details of this page too:&lt;br /&gt;
&lt;br /&gt;
[[File:youtube-glitch.png|YouTubeGlitch]]_&lt;br /&gt;
&lt;br /&gt;
= Background on Clock Glitching =&lt;br /&gt;
&lt;br /&gt;
Digital hardware devices almost always expect some form of reliable clock. We can manipulate the clock being presented to the device to cause unintended behaviour. We'll be concentrating on microcontrollers here, however other digital devices (e.g. hardware encryption accelerators) can also have faults injected using this technique.&lt;br /&gt;
&lt;br /&gt;
Consider a microcontroller first. The following figure is an excerpt the Atmel AVR ATMega328P datasheet:&lt;br /&gt;
&lt;br /&gt;
[[File:mcu-unglitched.png|image]]&lt;br /&gt;
&lt;br /&gt;
Rather than loading each instruction from FLASH and performing the entire execution, the system has a pipeline to speed up the execution process. This means that an instruction is being decoded while the next one is being retrieved, as the following diagram shows:&lt;br /&gt;
&lt;br /&gt;
[[File:clock-normal.png|image]]&lt;br /&gt;
&lt;br /&gt;
But if we modify the clock, we could have a situation where the system doesn't have enough time to actually perform an instruction. Consider the following, where Execute #1 is effectively skipped. Before the system has time to actually execute it another clock edge comes, causing the microcontroller to start execution of the next instruction:&lt;br /&gt;
&lt;br /&gt;
[[File:clock-glitched.png|image]]&lt;br /&gt;
&lt;br /&gt;
This causes the microcontroller to skip an instruction. Such attacks can be immensely powerful in practice. Consider for example the following code from `linux-util-2.24`:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 *   auth.c -- PAM authorization code, common between chsh and chfn&lt;br /&gt;
 *   (c) 2012 by Cody Maloney &amp;amp;lt;cmaloney@theoreticalchaos.com&amp;amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 *   this program is free software.  you can redistribute it and&lt;br /&gt;
 *   modify it under the terms of the gnu general public license.&lt;br /&gt;
 *   there is no warranty.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;quot;auth.h&amp;amp;quot;&lt;br /&gt;
#include &amp;amp;quot;pamfail.h&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
int auth_pam(const char *service_name, uid_t uid, const char *username)&lt;br /&gt;
{&lt;br /&gt;
    if (uid != 0) {&lt;br /&gt;
        pam_handle_t *pamh = NULL;&lt;br /&gt;
        struct pam_conv conv = { misc_conv, NULL };&lt;br /&gt;
        int retcode;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_start(service_name, username, &amp;amp;amp;conv, &amp;amp;amp;pamh);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_authenticate(pamh, 0);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_acct_mgmt(pamh, 0);&lt;br /&gt;
        if (retcode == PAM_NEW_AUTHTOK_REQD)&lt;br /&gt;
            retcode =&lt;br /&gt;
                pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_setcred(pamh, 0);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        pam_end(pamh, 0);&lt;br /&gt;
        /* no need to establish a session; this isn't a&lt;br /&gt;
         * session-oriented activity...  */&lt;br /&gt;
    }&lt;br /&gt;
    return TRUE;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
This is the login code for the Linux OS. Note that if we could skip the check of &amp;lt;code&amp;gt;if (uid != 0)&amp;lt;/code&amp;gt; and simply branch to the end, we could avoid having to enter a password. This is the power of glitch attacks - not that we are breaking encryption, but simply bypassing the entire authentication module!&lt;br /&gt;
&lt;br /&gt;
= Glitch Hardware =&lt;br /&gt;
&lt;br /&gt;
The ChipWhisperer Glitch system uses the same synchronous methodology as it's Side Channel Analysis (SCA) capture. A system clock (which can come from either the ChipWhisperer or the Device Under Test (DUT)) is used to generate the glitches. These glitches are then inserted back into the clock, although it's possible to use the glitches alone for other purposes (i.e. for voltage glitching, EM glitching).&lt;br /&gt;
&lt;br /&gt;
The generation of glitches is done with two variable phase shift modules, configured as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:glitchgen-phaseshift.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
The enable line is used to determine when glitches are inserted. Glitches can be inserted continuously (useful for development) or triggered by some event. The following figure shows how the glitch can be muxd to output to the Device Under Test (DUT).&lt;br /&gt;
&lt;br /&gt;
[[File:glitchgen-mux.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
== Hardware Support ==&lt;br /&gt;
&lt;br /&gt;
The phase shift blocks use the Digital Clock Manager (DCM) blocks within the FPGA. These blocks have limited support for run-time configuration of parameters such as phase delay and frequency generation, and for maximum performance the configuration must be fixed at design time. The Xilinx-provided run-time adjustment can shift the phase only by about +/- 5nS in 30pS increments (exact values vary with operating conditions).&lt;br /&gt;
&lt;br /&gt;
For most operating conditions this is insufficient - if attacking a target at 7.37MHz the clock cycle would have a period of 136nS. In order to provide a larger adjustment range, an advanced FPGA feature called Partial Reconfiguration (PR) is used. The PR system requires special partial bitstreams which contain modifications to the FPGA bitstream. These are stored as two files inside a &amp;amp;quot;firmware&amp;amp;quot; zip which contains both the FPGA bitstream along with a file called &amp;lt;code&amp;gt;glitchwidth.p&amp;lt;/code&amp;gt; and a file called &amp;lt;code&amp;gt;glitchoffset.p&amp;lt;/code&amp;gt;. If a lone bitstream is being loaded into the FPGA (i.e. not from the zip-file), the partial reconfiguration system is disabled, as loading incorrect partial reconfiguration files could damage the FPGA. This damage is mostly theoretical, more likely the FPGA will fail to function correctly.&lt;br /&gt;
&lt;br /&gt;
If in the course of following this tutorial you find the FPGA appears to stop responding (i.e. certain features no longer work correctly), it could be the partial reconfiguration data is incorrect.&lt;br /&gt;
&lt;br /&gt;
== Python GUI Interface ==&lt;br /&gt;
&lt;br /&gt;
The portion of the GUI of interest to us is primarily located in this section:&lt;br /&gt;
&lt;br /&gt;
[[File:prgui.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
If the Partial Reconfiguration system has been disabled (due to missing PR files or files differing from the FPGA bitstream) the two fields marked that say (as % of period) will be disabled. Only the fields labeled (fine adjust) will be available.&lt;br /&gt;
&lt;br /&gt;
= Setting up Glitch Example =&lt;br /&gt;
&lt;br /&gt;
== Firmware Setup ==&lt;br /&gt;
&lt;br /&gt;
The glitch examples requires you to program the target device. The software to program is located at &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple&amp;lt;/code&amp;gt; of your ChipWhisperer release or GIT clone. As before, open the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; and be sure to uncomment the appropriate target to reflect your hardware:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#Multi-Target Board, AVR Device (ATMega328P)&lt;br /&gt;
#PLATFORM = CW301_AVR&lt;br /&gt;
&lt;br /&gt;
#CW-Lite XMEGA Target Device (XMEGA128D4)&lt;br /&gt;
PLATFORM = CW303&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can build the software by running the make command as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;make&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should also open the file &amp;lt;code&amp;gt;glitchsimple.c&amp;lt;/code&amp;gt; which is the source code. The subroutine being glitched in this example looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch_infinite(void)&lt;br /&gt;
{&lt;br /&gt;
    char str[64];&lt;br /&gt;
    //Declared volatile to avoid optimizing away loop.&lt;br /&gt;
    //This also adds lots of SRAM access&lt;br /&gt;
    volatile uint16_t i, j;&lt;br /&gt;
    volatile uint32_t cnt;&lt;br /&gt;
    while(1){&lt;br /&gt;
        cnt = 0;&lt;br /&gt;
        for(i=0; i&amp;amp;lt;500; i++){&lt;br /&gt;
            for(j=0; j&amp;amp;lt;500; j++){&lt;br /&gt;
                cnt++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        sprintf(str, &amp;amp;quot;%lu %d %d\n&amp;amp;quot;, cnt, i, j);&lt;br /&gt;
        uart_puts(str);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should confirm that &amp;lt;code&amp;gt;glitch_infinite()&amp;lt;/code&amp;gt; is actually called from the main subroutine. There are several glitch examples and it's possible the wrong subroutine has been setup previously:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(void){&lt;br /&gt;
&lt;br /&gt;
    platform_init();&lt;br /&gt;
    init_uart();    &lt;br /&gt;
    trigger_setup();&lt;br /&gt;
&lt;br /&gt;
    /* Uncomment this to get a HELLO message for debug */&lt;br /&gt;
    putch('h');&lt;br /&gt;
    putch('e');&lt;br /&gt;
    putch('l');&lt;br /&gt;
    putch('l');&lt;br /&gt;
    putch('o');&lt;br /&gt;
    putch('\n');&lt;br /&gt;
    _delay_ms(20);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    while(1){&lt;br /&gt;
        glitch_infinite();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return 1;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once the AVR/XMEGA is programmed (see previous tutorials), you may need to setup a few jumpers depending on your hardware.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
&lt;br /&gt;
=== XMEGA Target (CW1173 + CW303) ===&lt;br /&gt;
&lt;br /&gt;
The XMEGA target on the ChipWhisperer-Lite requires no configuration. If you have separated the boards, you can attach them with the 20-pin cable.&lt;br /&gt;
&lt;br /&gt;
=== Multi-Target Board, AVR (CW301) ===&lt;br /&gt;
&lt;br /&gt;
The hardware is almost as in previous incarnations. The difference is the 'FPGAOUT' is bridged to the AVR clock. This example will use the CLKGEN feature.&lt;br /&gt;
&lt;br /&gt;
The AVR is being used as the glitch target. The following figure shows the expected jumper settings:&lt;br /&gt;
&lt;br /&gt;
[[File:glitchhw.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
== Software 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;&amp;lt;p&amp;gt;Connect to the ChipWhisperer device:&amp;lt;/p&amp;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;As the ''Scope Module'', select the ''ChipWhisperer/OpenADC'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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 ''Scope Settings'' tab, and as the ''connection'', select the ''ChipWhisperer Rev2'' or ''ChipWhisperer-Lite'' 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 Rev2'' or ''ChipWhisperer-Lite'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run connect on both the Scope &amp;amp;amp; Target. They should both switch to green circles indicating the system is connected.&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;&amp;lt;p&amp;gt;Setup the CLKGEN Module to Generate a 7.37 MHz clock and route it through the Glitch Generator&amp;lt;/p&amp;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;Switch the ''Freq Counter Src'' to the ''CLKGEN Output''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Desired Frequency'' to 7.37 MHz. Note you should only adjust the 'frequency' portion of this, if you highlight the entire field you may not be able to type the frequency into the system.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Confirm the ''DCM Locked'' checkbox is checked, if not hit the ''Reset CLKGEN DCM'' box. Check the ''Freq Counter'' to ensure the system is correctly generating a 7.37 MHz clock.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Under the ''Glitch Module'' set the ''Clock Source'' as ''CLKGEN'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitchgen-clkgen.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Under the ''Target HS IO-Out'' option select the ''Glitch Module'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:targioout.png|image]]&amp;lt;/p&amp;gt;&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;&amp;lt;p&amp;gt;Connect the Serial Port&amp;lt;/p&amp;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;For the XMEGA Target (including the CW-Lite integrated target), 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;Switch to the ''Scope Settings'' tab, and scroll down to ''Target IOn Pins''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO1'' to be ''Serial RXD''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO2'' to be ''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;&amp;lt;p&amp;gt;From the ''Tools'' menu select ''Open Terminal'', and press ''Connect'' on the terminal:&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;The baud rate for this system is 38400, which should be the default for the ChipWhisperer serial port.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the target programmer window, we will use the Read Signature or Check Signature button to reset the target every time we want to restart the program. Confirm this works by pressing the Read Signature button, for example if using the ChipWhisperer-Lite integrated programmer, you would see this window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:xmegaprog_main.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;But if using the external AVR Studio programmer for the ChipWhisperer Capture Rev2, you would see this window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:readsig.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When you press this button the AVR will display the Hello message, which should look something like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:termhello.png|image]]&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;If you uncheck the ''RX: Show non-ASCII as hex'' you will not see the red text with ASCII values of newline (&amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''hint'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Sometimes the &amp;amp;quot;reset&amp;amp;quot; message won't appear. This happens often on the virtual machine version, or if your host computer is slow or loaded. Generally you can ignore this error, for example in the video version the welcome message is never printed. You will just have to trust the system is reseting correctly.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&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;
&lt;br /&gt;
We'll now look at glitching this routine. You should inspect the source code to determine that a simple series of calculations are performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch_infinite(void)&lt;br /&gt;
{&lt;br /&gt;
    char str[64];&lt;br /&gt;
    //Declared volatile to avoid optimizing away loop.&lt;br /&gt;
    //This also adds lots of SRAM access&lt;br /&gt;
    volatile uint16_t i, j;&lt;br /&gt;
    volatile uint32_t cnt;&lt;br /&gt;
    while(1){&lt;br /&gt;
        cnt = 0;&lt;br /&gt;
        for(i=0; i&amp;amp;lt;500; i++){&lt;br /&gt;
            for(j=0; j&amp;amp;lt;500; j++){&lt;br /&gt;
                cnt++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        sprintf(str, &amp;amp;quot;%lu %d %d\n&amp;amp;quot;, cnt, i, j);&lt;br /&gt;
        uart_puts(str);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the routine works as expected, we would expect it to print &amp;lt;code&amp;gt;250000 500 500&amp;lt;/code&amp;gt;. If a glitch interrupts the program flow, we would expect some of those values to be incorrect. This could be because a loop was skipped, an addition done incorrectly, or the program flow was exited unexpectedly.&lt;br /&gt;
&lt;br /&gt;
= Manual Glitch Trigger =&lt;br /&gt;
&lt;br /&gt;
To begin with, you'll simply use the manual glitch triggering. This works well in the examples where we have a simple loop we are breaking out of. Doing so requires modifying the glitch width and glitch offset experimentally. The exact values will vary for every device and setup.&lt;br /&gt;
&lt;br /&gt;
It is recommended to only use the ''glitch width (as % of period)'' option, as the fine adjust is too small of a change for this lower-speed example. Other hardware may need the precision added by the fine adjust however!&lt;br /&gt;
&lt;br /&gt;
The following figure shows several different settings for a 7.37 MHz clock. The width is set to 10%, which for the 136nS clock period of the 7.37 MHz clock means the glitch width is about 13.6 nS. When the offset is negative, the glitch is placed in-front of the clock. The glitch is XORd with the clock, meaning this becomes a small positive-going glitch in-front of the regular clock pulse.&lt;br /&gt;
&lt;br /&gt;
If the offset is positive, the glitch occurs ''after'' the rising edge of the clock pulse. Because this glitch pulse is XORd with the clock, it becomes a negative-going glitch inserted in the 'middle' of the regular clock pulse.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:clockglitch-examplesettings.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
With some background, let's now check some glitches. Assuming you've setup the example as before, do the following:&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;Adjust the settings for ''Glitch Width (as % of period)'' , ''Glitch Offset (as % of period)'', and ''Repeat'' based on your target and the following table for different targets:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter&lt;br /&gt;
! AVR on Multi-Target (CW301)&lt;br /&gt;
! CW-Lite XMEGA Board&lt;br /&gt;
|-&lt;br /&gt;
| Glitch Width (as % of period)&lt;br /&gt;
| 7.5&lt;br /&gt;
| 10&lt;br /&gt;
|-&lt;br /&gt;
| Glitch Offset (as % of period)&lt;br /&gt;
| -10&lt;br /&gt;
| 26.6&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 5&lt;br /&gt;
| 105&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Ensure ''Glitch Trigger'' is ''Manual''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the ''Manual Trigger'' button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;See if you end up with either the target resetting (reprints &amp;lt;code&amp;gt;hello\n&amp;lt;/code&amp;gt;), or if the loop count becomes wrong. You may need to press the ''Manual Trigger'' button several times quickly. The objective is to have an incorrect loop count, meaning you caused a glitch!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;To force a reset of the target, use the Signature Read option on the programmer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Adjust the glith width &amp;amp;amp; offset as needed.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You may also adjust the ''Repeat'' option, or cause it to glitch several instructions.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Be aware that you may crash the target!''' In the previous examples the target could have reset after each glitch. It may simply go into another infinite loop however, or even enter invalid states. Again force a hardware reset of the target in these cases. It may appear like the target was never glitched, whereas in reality it was glitched into some invalid state.&lt;br /&gt;
&lt;br /&gt;
{{Infobox|The boards are extremely sensitive to the glitch width and offset. You may have trouble finding settings that cause a glitch. Don't get too hung up on this; the following sections provide a more reliable method of glitching a target by determining the appropriate parameter settings.}}&lt;br /&gt;
&lt;br /&gt;
= Automatically Resetting Target =&lt;br /&gt;
&lt;br /&gt;
If we are going to start with the target at a pre-determined state, we need to reset the target. There are two ways of automatically performing this. The method used here will use the existing programmer interface to reset the device by performing that &amp;amp;quot;read signature&amp;amp;quot; operation we have already been using. The other method is to toggle a GPIO pin, which is more generic for future use.&lt;br /&gt;
&lt;br /&gt;
To setup the automatic reset, perform the following:&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;Switch to the ''General Settings'' tab, and select the appropriate &amp;amp;quot;Auxiliary Module&amp;amp;quot;:&amp;lt;/p&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;For ChipWhisperer-Lite (CW1173/CW1180), select &amp;amp;quot;Reset AVR/XMEGA via CW-Lite&amp;amp;quot;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For ChipWhisperer-Capture Rev 2, select &amp;amp;quot;Reset AVR via ISP-MKII&amp;amp;quot;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitching_aux_1.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Aux Settings'' tab. Depending on your module you will see different settings here, for example the ChipWhisperer-Lite lets you select between AVR and XMEGA targets. The defaults should be ok:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitching_aux_2.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the &amp;amp;quot;Test Reset&amp;amp;quot; button. This should reset the AVR target. Confirm this by monitoring the terminal emulator window, and check the startup message (of &amp;amp;quot;hello&amp;amp;quot;) is printed again.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now confirm the reset works with the &amp;amp;quot;Capture 1&amp;amp;quot; button. This requires us to disable the normal routing of the output data to a file for analysis, as we want to just dump data to the terminal emulator. To do this:&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;Switch to the ''Target Settings'' tab.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Remove all of the ''Load Key Command'', ''Go Command'', and ''Output Format'' options:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:targetsettings_clear.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the &amp;amp;quot;Capture 1&amp;amp;quot; button a few times, which should confirm on each &amp;amp;quot;capture&amp;amp;quot; the target device is resetting.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will switch the glitch target to give us a more realistic target to glitch. To do this open the file &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple\glitchsimple.c&amp;lt;/code&amp;gt; and modify the call in &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt;, such that we now call the &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt; function. This means the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;while(1){&lt;br /&gt;
    glitch_infinite();&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;can be changed to:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;while(1){&lt;br /&gt;
    glitch1();&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;After which recompile (with &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;), and reprogram the target device. Note the new function being glitched looks like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch1(void)&lt;br /&gt;
{&lt;br /&gt;
    led_ok(1);&lt;br /&gt;
    led_error(0);&lt;br /&gt;
&lt;br /&gt;
    //Some fake variable&lt;br /&gt;
    volatile uint8_t a = 0;&lt;br /&gt;
&lt;br /&gt;
    putch('A');&lt;br /&gt;
&lt;br /&gt;
    //External trigger logic&lt;br /&gt;
    trigger_high();&lt;br /&gt;
    trigger_low();&lt;br /&gt;
&lt;br /&gt;
    //Should be an infinite loop&lt;br /&gt;
    while(a != 2){&lt;br /&gt;
    ;&lt;br /&gt;
    }    &lt;br /&gt;
&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
&lt;br /&gt;
    uart_puts(&amp;amp;quot;1234&amp;amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
&lt;br /&gt;
    //Several loops in order to try and prevent restarting&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }    &lt;br /&gt;
}&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;When you perform a ''Capture 1'', the terminal should print &amp;lt;code&amp;gt;hello\nA&amp;lt;/code&amp;gt;, based on the above source code. Note the objective will be to glitch past the infinite loop, such that &amp;lt;code&amp;gt;1234&amp;lt;/code&amp;gt; is printed. If using the XMEGA target board this will also turn on the RED led.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''hint'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If the startup message isn't visible, it may be related to issues with the Capture software not being fast enough after reset to display the serial port contents on the terminal emulator. This happens often on the virtual machine environment, as can be seen in the demo video. You can ignore this error for now.&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;
= Automatically Triggering Glitch =&lt;br /&gt;
&lt;br /&gt;
The manual trigger used previously is suitable when the embedded system is waiting for further input. For example if the embedded system is waiting for a password, you could insert glitches without requiring accurate timing. We'll explore the use of the capture trigger for glitching here, which also improves the repeatability of your glitch attempts.&lt;br /&gt;
&lt;br /&gt;
To use this system, you must first understand the routing of the trigger to the glitch module. The following figure shows the trigger routing, which is more basic than the power capture trigger:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:triggerrouting.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Note in particular that if using an external IO pin, you only have a ''rising edge trigger''. The example glitch program includes a line which is set 'High' at critical moments, allowing you to experiment with this basic IO trigger.&lt;br /&gt;
&lt;br /&gt;
Based on the source code loaded, we currently have a trigger to time the glitch. This is very useful during the characterization phase, where we wish to determine what sort of glitch affects this specific hardware. Once we know that, we can move onto glitching a more &amp;amp;quot;realistic&amp;amp;quot; routine.&lt;br /&gt;
&lt;br /&gt;
Before doing that, we will actually enable the power analysis capture. To do this:&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;Switch to the ''Scope Settings'' tab.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''ADC Clock Source'' as being ''CLKGEN x4''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press ''Reset ADC DCM'', confirm the frequency is 29.5 MHz as expected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Mode'' to be ''Rising Edge''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Total Samples'' to be ''1000''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Gain Setting'' --&amp;amp;gt; ''Setting'' to be ''40''. You might need to adjust this for different hardware.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture 1'', confirm some waveform is displayed. For example with the XMEGA Target on the ChipWhisperer-Lite, the waveform looks like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:basic_waveform.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If this does't work: check the trigger in use is the ''Target IO4'' pin.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we can enable the trigger of the glitch to occur based on this external trigger pin. This can be accomplished by:&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;Switch the ''Glitch Trigger'' mode to ''Ext Trigger:Single-Shot'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:singleshot.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Performing a ''Capture 1'', you'll notice that the waveform is now perturbed. This is due to the clock glitches causing odd power consumption behavior:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:basic_waveform_glitchy.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Play around a bit with the glitch width, offset, and repeat. You should see different effects in the power consumption traces.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Using the Glitch Explorer =&lt;br /&gt;
&lt;br /&gt;
Now that we can automatically perform the glitching, we can use the ''glitch explorer'' to automatically vary glitch parameters while recording what the target device is doing. Before continuing with the tutorial, we'll go through an overview of the the glitch explorer.&lt;br /&gt;
&lt;br /&gt;
== Glitch Explorer ==&lt;br /&gt;
&lt;br /&gt;
The main window of the glitch explorer looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_main.png|image]]&lt;br /&gt;
&lt;br /&gt;
Where you can see the following parts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
# In |1| the output of the system combined with the parameters of the glitch is displayed (the 'output window').&lt;br /&gt;
# In |2| you can adjust general parameters of the glitching system, such as what counts as a successful glitch or not and how many parameters to fiddle with.&lt;br /&gt;
# In |3| you actually specify the parameters to adjust during the glitching attempts, and what range you would like to adjust them over.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
We'll be looking at each of these sections in more detail next.&lt;br /&gt;
&lt;br /&gt;
=== The Output Window ===&lt;br /&gt;
&lt;br /&gt;
[[File:ge_top.png|image]]&lt;br /&gt;
&lt;br /&gt;
The output window highlights different types of output. In this example we have an output |1| highlighted in green, which is flagged as a successful glitch. This example code was waiting for the ''rrrr'' sequence.&lt;br /&gt;
&lt;br /&gt;
Glitches can also be flagged as 'normal', in which case there is no highlight as in |2|. Finally the glitch could be flagged as an error, in which case it will be highlighted in red.&lt;br /&gt;
&lt;br /&gt;
In order for the glitch explorer to receive the output value, you must insert the special code &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; into the ''Target Settings'' --&amp;amp;gt; ''Output Format'' settings. This will mean data is no longer sent to the terminal emulator when using the capture 1 or capture multi buttons, but instead is logged in the glitch explorer window.&lt;br /&gt;
&lt;br /&gt;
=== The Main Settings ===&lt;br /&gt;
&lt;br /&gt;
Details of the main settings:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_middle.png|image]]&lt;br /&gt;
&lt;br /&gt;
The number of tuning parameters is set at |1|. This defines how many different parameters to adjust.&lt;br /&gt;
&lt;br /&gt;
The response of the system during normal operation is set at |2|. This defines what happens when no glitching or unexpected behavior happened.&lt;br /&gt;
&lt;br /&gt;
The desired response of the system if the glitch was successful is set at |3|.&lt;br /&gt;
&lt;br /&gt;
The expected and desired responses are expected to be Python expressions, where &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; is a str-type variable which contains the response of the system. The expression must evaulate to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;. For example, the following shows examples of what you could use as possible expressions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Desired Behavior&lt;br /&gt;
! Parameter Expression&lt;br /&gt;
|-&lt;br /&gt;
| Check for &amp;amp;quot;hellon&amp;amp;quot; exactly.&lt;br /&gt;
| s == &amp;amp;quot;hellon&amp;amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Check for &amp;amp;quot;hellon&amp;amp;quot; at end of string.&lt;br /&gt;
| s.endswith(&amp;amp;quot;hellon&amp;amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
| Check for hex 0xAF in last byte position.&lt;br /&gt;
| ord(s[-1]) == 0xAF&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that there is sometimes garbage in the first position. This occurs because if the target device is being reset before the glitch, you may see the serial lines floating. These floating lines may cause invalid characters to be recorded.&lt;br /&gt;
&lt;br /&gt;
=== Parameter Settings ===&lt;br /&gt;
&lt;br /&gt;
Details of the parameter settings:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_bottom.png|image]]&lt;br /&gt;
&lt;br /&gt;
The name of the parameter to be tuned is set at |1|. This name will be displayed in the table, so should be some useful reminder of the parameter name.&lt;br /&gt;
&lt;br /&gt;
The ''Parameter Path'' at |2| defines what is modified. This string is simply copied from the ''Script Commands'' tab of the main window. This lets you modify ''any'' parameter of the GUI, but most likely you will want to modify some of the glitch settings. The numeric value in this string should be deleted.&lt;br /&gt;
&lt;br /&gt;
The ''Data Format'' at |3| defines what type of data will be inserted into the parameter. For example for the ''Glitch Offset (as % of period)'' used here, this would need to be set to ''Float'', meaning fractional values such as &amp;amp;quot;4.5&amp;amp;quot; are allowed. The data format should match the data format expected.&lt;br /&gt;
&lt;br /&gt;
The ''Range'' at |4| defines the range from the minimum to maximum that will be swept for the parameter. Valid values depend on the parameter being adjusted. For example if you are adjusting the ''Glitch Offset'' a negative and positive offset makes sense, but if you were adjusting the ''Repeat'' it would only make sense to adjust over the range &amp;lt;code&amp;gt;(1,255)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The ''Value'' at |5| defines the starting value of the sweep. This is '''NOT''' automatically set to the minimum value of your sweep. If you want to perform the full sweep, you must manually set this to the minimum of the range.&lt;br /&gt;
&lt;br /&gt;
The ''Step'' at |6| defines the amount the value is incremented on each glitch attempt. When the value reaches the maximum defined by the range, it will loop around to the minimum and continue incrementing.&lt;br /&gt;
&lt;br /&gt;
The ''Repeat'' at |7| defines how many times to perform the same value. This can be used to determine the reliability of each glitch value.&lt;br /&gt;
&lt;br /&gt;
If using multiple parameters, they will be looped as shown in this pseudo-code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;param_value_0 = starting_value_0&lt;br /&gt;
param_value_1 = starting_value_1&lt;br /&gt;
&lt;br /&gt;
while capture_in_progress:&lt;br /&gt;
    while param_value_1 &amp;amp;lt; param_value_1_max:&lt;br /&gt;
&lt;br /&gt;
      while param_value_0 &amp;amp;lt; param_value_0_max:&lt;br /&gt;
          param_value_0 += param_value_0_incr&lt;br /&gt;
          run_glitch_here()&lt;br /&gt;
&lt;br /&gt;
      param_value_0 = param_value_0_min        &lt;br /&gt;
      param_value_1 += param_value_1_incr&lt;br /&gt;
&lt;br /&gt;
    param_value_1 = param_value_1_min&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note you can quickly cause very long captures to occur! To run the glitch explorer, you need to set the appropriate number of traces on the ''General Settings'' tab, and use the ''Capture Multi'' to run the glitch explorer.&lt;br /&gt;
&lt;br /&gt;
== Example Running the Glitch Explorer ==&lt;br /&gt;
&lt;br /&gt;
This example will attempt to break out the loop in &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt;. Moving ahead from where you were in [[#Automatically Triggering Glitch]], we will see how we can view the output of the target device in the glitch explorer.&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;Switch to the ''Target Settings'' tab, and set the ''Output Format'' to be &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:output_glitch.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Tools'' menu select ''Glitch Monitor'' to open the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press the ''Capture 1'' button a few times, and you should see the table populated with outputs:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_setup1.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;We want to mark them as &amp;amp;quot;normal&amp;amp;quot; or &amp;amp;quot;glitch successful&amp;amp;quot; to get the color-coding working appropriately.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Double-click on a normal response, and copy the text. In the ''Normal Response'' field, we need to compare the magic variable &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; with that copied text. Do this by setting the ''Normal Response'' to be: &amp;lt;code&amp;gt;s == '\x00hello\nA'&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;We want to mark a string ending with &amp;lt;code&amp;gt;1234&amp;lt;/code&amp;gt; as a pass. Thus in the ''Successful Response'' field, set the test to be &amp;lt;code&amp;gt;s.endswith('1234')&amp;lt;/code&amp;gt; (remember in Python both &amp;lt;code&amp;gt;'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;quot;&amp;lt;/code&amp;gt; are valid for string start/end characters).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture 1'' a few more times, and check the color-coding has changed:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_setup2.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to tune the glitch offset to attempt to get a successful clock glitch. These steps are listed as follows:&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;Change the ''Tuning Parameters'' to be ''1''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set the following in Parameter 0 options:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Offset&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Glitch Offset (as % of period)']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Float&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| -30 : 30&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| -30&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 0.5&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Parameter Path'' option can be found by manually making an adjustment to the ''Glitch Offset (as % of period)'' in the GUI, and observing the string printed to the ''Script Commands'' tab. The numeric value of the command is not included in the parameter path (i.e., do not copy the value).&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;On the main GUI in the ''Scope Settings'' tab, change the following values for the ''Glitch Module'':&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;''Repeat'' set to 10.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;''Glitch Width (as % of period)'' set to 8.0.&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;These values will be used during the glitch explorer run. We have not specified anything for the tuning, so they will not be changed from whatever is already in the GUI.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;On the ''General Settings'' tab:&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;Ensure the ''Trace Format'' is set to ''None'' (i.e., no traces will be written to disk).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Number of Traces'' to 121.&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;Press the ''Capture Multi'' button. You will get a warning as there is no trace writer, but can just hit ''Continue Anyway'', since we do not want to store traces to disk.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;With any luck, at least one of the glitches will be successful:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you get a reset (prints 'hello' again), you might need to reduce the &amp;amp;quot;repeat&amp;amp;quot; value. If you have no successful glitches, double-check all settings. You can continue to the next step anyway, as in that step we will also tune the &amp;amp;quot;glitch width&amp;amp;quot;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We may also need to tune the &amp;amp;quot;Glitch Width&amp;amp;quot;. We can use knowledge of the successful glitch from the previous step to reduce our search space. In this case, assume we had a successful glitch with a width of 8.0 and offset of 17.5. We'll search around those values to see if we can achieve a more successful glitch performance.&lt;br /&gt;
&lt;br /&gt;
To continue the tutorial, the following steps will be taken:&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;In the ''Glitch Explorer'', set the ''Tuning Parameters'' to ''2''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Configure the second parameter with the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Width&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Glitch Width (as % of period)']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Float&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| 5 : 15&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 0.5&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Change the ''Range'' of the first parameter ''Glitch Offset'' to span from 1 to 25, since it appeared that negative offsets were never successful in our previous attempts. Be sure to reset the ''Value'' of this parameter to your desired starting point (probably ''1''). This will reduce the search time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the main GUI in the ''Scope Settings'' tab, adjust the ''Glitch Module'' repeat parameter to be 1. We are now attempting to acheive success with a single clock cycle being glitched.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the main GUI, adjust the number of traces per capture to be 1000. This reflects the number of iterations required to run through both loops (20 x 50).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the ''Capture Multi'' button and cross your fingers! Hopefully you will see a successful glitch for some combination of glitch width and offset. We aren't quite done yet, as you will also need to do some fine-tuning to achieve high reliability on the glitch.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record some of the useful parameters by scrolling through the window (WARNING: changing parameters will clear the table, so record useful values now). In this example there was a success at Offset = 8.5%, and Width = 7.5%. Let's see how to fine-tune those values:&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;Plug those values into the main GUI ''Glitch Module'' setting. If we use the ''Capture 1'' button values are taken from the main GUI, instead of the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button a few times. You'll note it records the output of the device, which may not be generating successful glitches (NB: the &amp;amp;quot;offset&amp;amp;quot; and &amp;amp;quot;width&amp;amp;quot; recorded in the table may be wrong when using the Capture 1 button, as the glitch explorer is not recording values from the main GUI correctly. This is a bug in the display only, the correct values are being sent to the device).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using arrow keys, nudge the ''Glitch Offset (fine adjust)'' up and down. Try performing a ''Capture 1'' to see if you are able to achieve a reliable glitch. In this example setting the fine adjust to 44 resulted in a very reliable glitch:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_examplebasic2.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You might want to try seeing if there is an upper limit to this setting, and putting it mid-way between the lower and upper limits for generating a glitch.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats! You've now performed some tuning to achieve a reliable glitch on the target device. The next step is to glitch something more fun - like a password check.&lt;br /&gt;
&lt;br /&gt;
= Glitching a Password Check =&lt;br /&gt;
&lt;br /&gt;
This assumes you now have a set of parameters which caused a reliable glitch. We'll now glitch past a password check, initially using our trigger as a crutch. The function of interest compares a received password to some known password. The &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt; function looks as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch3(void)&lt;br /&gt;
{&lt;br /&gt;
    char inp[16];&lt;br /&gt;
    char c = 'A';&lt;br /&gt;
    unsigned char cnt = 0;&lt;br /&gt;
    uart_puts(&amp;amp;quot;Password:&amp;amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    while((c != '\n') &amp;amp;amp; (cnt &amp;amp;lt; 16)){&lt;br /&gt;
        c = getch();&lt;br /&gt;
        inp[cnt] = c;&lt;br /&gt;
        cnt++;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    char passwd[] = &amp;amp;quot;touch&amp;amp;quot;;&lt;br /&gt;
    char passok = 1;&lt;br /&gt;
&lt;br /&gt;
    trigger_high();&lt;br /&gt;
    trigger_low();&lt;br /&gt;
&lt;br /&gt;
    //Simple test - doesn't check for too-long password!&lt;br /&gt;
    for(cnt = 0; cnt &amp;amp;lt; 5; cnt++){&lt;br /&gt;
        if (inp[cnt] != passwd[cnt]){&lt;br /&gt;
            passok = 0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!passok){&lt;br /&gt;
        uart_puts(&amp;amp;quot;Denied\n&amp;amp;quot;);&lt;br /&gt;
    } else {&lt;br /&gt;
        uart_puts(&amp;amp;quot;Welcome\n&amp;amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following assumes you have already completed the previous steps:&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;Close the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Modify the file &amp;lt;code&amp;gt;glitchexample.c&amp;lt;/code&amp;gt; to call &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt;, which is to say simply change the main function called from &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; in the folder &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Program the target device with your &amp;lt;code&amp;gt;.hex&amp;lt;/code&amp;gt; file.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the ''Target Settings'' tab, clear the ''Output Format'' field. That is remove the &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; text, as we are no longer using the glitch explorer. If you don't do this, you will not see any output of the device on the terminal emulator.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the terminal emulator, and connect to it again (if you closed it).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Reset the device, it should prompt you for a password. The correct password is &amp;lt;code&amp;gt;touch&amp;lt;/code&amp;gt;, try both correct and incorrect passwords. The program as designed loops after a password try to prompt you again. You should see both correct and incorrect responses:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:password_normal.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the ''Scope Settings'' tab, adjust the ''Timeout(s)'' to a larger value such as 20. We need a longer timeout to work with the serial terminal.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Let's try a glitch insertion! 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;Press the ''Capture 1'' button. This will reset the target and arm the glitch.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Before the timeout, enter a wrong password such as &amp;lt;code&amp;gt;test&amp;lt;/code&amp;gt; in the terminal and hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;See if you can get the wrong password accepted. If not, let's use the Glitch Explorer to automate the parameter adjustments.&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;&amp;lt;p&amp;gt;Switching to the ''Auxiliary Settings'' tab, adjust the delay on the reset such that you have a ''150 mS'' delay. This will mean once the device resets there is a delay while it prints the startup message.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:aux_delay150ms.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Target Settings'' tab:&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;In the ''Go Command'' field, put the bad password such as &amp;lt;code&amp;gt;test\n&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;In the ''Output Format'' field, put &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; to route the output to the glitch explorer.&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;Open the ''Glitch Explorer'', and press ''Capture 1''. You should see the ''Denied'' message come across.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;In the ''Glitch Explorer'', adjust the following settings:&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 ''Tuning Parameters'' to 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set Parameter 0 options to:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Trigger Offset&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Ext Trigger Offset']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Int&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| 0 : 200&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&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;Set the number of traces on the ''General Settings'' tab to 200.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the main GUI, in the ''Scope Settings'' tab, ensure that you have the number of repeats on the ''Glitch Module'' set to 1. We will start with a single clock cycle glitched.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture Multi''. Monitor the glitch outputs, you may see some errors or a successful glitch. Note that sometimes the errors are useful - here is an example where the glitched code actually dumped the password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:password_glitch_dump.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;More likely you might see a &amp;amp;quot;Welcome&amp;amp;quot; message indicating the password check was glitched:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:password_glitch_success.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;If the previous step isn't successful, increase the &amp;amp;quot;repeat&amp;amp;quot; count on the ''Glitch Module'' section of the ''Scope Settings'' tab, and try again. In this example I actually needed a repeat count of &amp;amp;quot;3&amp;amp;quot; to get the successful &amp;amp;quot;Welcome&amp;amp;quot; message printed above.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can also increase the repeat count in the glitch explorer, which simply tries the same settings multiple times. You will likely find that the successful glitch does not have 100% success rate, so using a repeat count of 2 or 3 is helpful to increase your chances of success.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Glitching Onward =&lt;br /&gt;
&lt;br /&gt;
This basic tutorial has introduced you to glitch attacks. They are a powerful tool for bypassing authentication in embedded hardware devices. There are many ways to expand your knowledge with additional practice, such as:&lt;br /&gt;
&lt;br /&gt;
* Use manual glitches to try simply glitching past the prompt in &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Download some example source code (bootloaders, login prompts, etc) and port them to the AVR. See how you can glitch past security checks.&lt;br /&gt;
* Use one of the IO triggers discussed in [[Tutorial_A1_Synchronization_to_Communication_Lines]].&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	<entry>
		<id>http://wiki.newae.com/index.php?title=Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)&amp;diff=1088</id>
		<title>Tutorial A2 Introduction to Glitch Attacks (including Glitch Explorer)</title>
		<link rel="alternate" type="text/html" href="http://wiki.newae.com/index.php?title=Tutorial_A2_Introduction_to_Glitch_Attacks_(including_Glitch_Explorer)&amp;diff=1088"/>
				<updated>2016-07-15T21:44:04Z</updated>
		
		<summary type="html">&lt;p&gt;Adriel: /* Parameter Settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This advanced tutorial will demonstrate clock glitch attacks using the ChipWhisperer system. This will introduce you to many required features of the ChipWhisperer system when it comes to glitching. This will be built on in later tutorials to generate voltage glitching attacks, or when you wish to attack other targets.&lt;br /&gt;
&lt;br /&gt;
You can follow along with this video for details of this page too:&lt;br /&gt;
&lt;br /&gt;
[[File:youtube-glitch.png|YouTubeGlitch]]_&lt;br /&gt;
&lt;br /&gt;
= Background on Clock Glitching =&lt;br /&gt;
&lt;br /&gt;
Digital hardware devices almost always expect some form of reliable clock. We can manipulate the clock being presented to the device to cause unintended behaviour. We'll be concentrating on microcontrollers here, however other digital devices (e.g. hardware encryption accelerators) can also have faults injected using this technique.&lt;br /&gt;
&lt;br /&gt;
Consider a microcontroller first. The following figure is an excerpt the Atmel AVR ATMega328P datasheet:&lt;br /&gt;
&lt;br /&gt;
[[File:mcu-unglitched.png|image]]&lt;br /&gt;
&lt;br /&gt;
Rather than loading each instruction from FLASH and performing the entire execution, the system has a pipeline to speed up the execution process. This means that an instruction is being decoded while the next one is being retrieved, as the following diagram shows:&lt;br /&gt;
&lt;br /&gt;
[[File:clock-normal.png|image]]&lt;br /&gt;
&lt;br /&gt;
But if we modify the clock, we could have a situation where the system doesn't have enough time to actually perform an instruction. Consider the following, where Execute #1 is effectively skipped. Before the system has time to actually execute it another clock edge comes, causing the microcontroller to start execution of the next instruction:&lt;br /&gt;
&lt;br /&gt;
[[File:clock-glitched.png|image]]&lt;br /&gt;
&lt;br /&gt;
This causes the microcontroller to skip an instruction. Such attacks can be immensely powerful in practice. Consider for example the following code from `linux-util-2.24`:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 *   auth.c -- PAM authorization code, common between chsh and chfn&lt;br /&gt;
 *   (c) 2012 by Cody Maloney &amp;amp;lt;cmaloney@theoreticalchaos.com&amp;amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 *   this program is free software.  you can redistribute it and&lt;br /&gt;
 *   modify it under the terms of the gnu general public license.&lt;br /&gt;
 *   there is no warranty.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;quot;auth.h&amp;amp;quot;&lt;br /&gt;
#include &amp;amp;quot;pamfail.h&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
int auth_pam(const char *service_name, uid_t uid, const char *username)&lt;br /&gt;
{&lt;br /&gt;
    if (uid != 0) {&lt;br /&gt;
        pam_handle_t *pamh = NULL;&lt;br /&gt;
        struct pam_conv conv = { misc_conv, NULL };&lt;br /&gt;
        int retcode;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_start(service_name, username, &amp;amp;amp;conv, &amp;amp;amp;pamh);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_authenticate(pamh, 0);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_acct_mgmt(pamh, 0);&lt;br /&gt;
        if (retcode == PAM_NEW_AUTHTOK_REQD)&lt;br /&gt;
            retcode =&lt;br /&gt;
                pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        retcode = pam_setcred(pamh, 0);&lt;br /&gt;
        if (pam_fail_check(pamh, retcode))&lt;br /&gt;
            return FALSE;&lt;br /&gt;
&lt;br /&gt;
        pam_end(pamh, 0);&lt;br /&gt;
        /* no need to establish a session; this isn't a&lt;br /&gt;
         * session-oriented activity...  */&lt;br /&gt;
    }&lt;br /&gt;
    return TRUE;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
This is the login code for the Linux OS. Note that if we could skip the check of &amp;lt;code&amp;gt;if (uid != 0)&amp;lt;/code&amp;gt; and simply branch to the end, we could avoid having to enter a password. This is the power of glitch attacks - not that we are breaking encryption, but simply bypassing the entire authentication module!&lt;br /&gt;
&lt;br /&gt;
= Glitch Hardware =&lt;br /&gt;
&lt;br /&gt;
The ChipWhisperer Glitch system uses the same synchronous methodology as it's Side Channel Analysis (SCA) capture. A system clock (which can come from either the ChipWhisperer or the Device Under Test (DUT)) is used to generate the glitches. These glitches are then inserted back into the clock, although it's possible to use the glitches alone for other purposes (i.e. for voltage glitching, EM glitching).&lt;br /&gt;
&lt;br /&gt;
The generation of glitches is done with two variable phase shift modules, configured as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:glitchgen-phaseshift.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
The enable line is used to determine when glitches are inserted. Glitches can be inserted continuously (useful for development) or triggered by some event. The following figure shows how the glitch can be muxd to output to the Device Under Test (DUT).&lt;br /&gt;
&lt;br /&gt;
[[File:glitchgen-mux.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
== Hardware Support ==&lt;br /&gt;
&lt;br /&gt;
The phase shift blocks use the Digital Clock Manager (DCM) blocks within the FPGA. These blocks have limited support for run-time configuration of parameters such as phase delay and frequency generation, and for maximum performance the configuration must be fixed at design time. The Xilinx-provided run-time adjustment can shift the phase only by about +/- 5nS in 30pS increments (exact values vary with operating conditions).&lt;br /&gt;
&lt;br /&gt;
For most operating conditions this is insufficient - if attacking a target at 7.37MHz the clock cycle would have a period of 136nS. In order to provide a larger adjustment range, an advanced FPGA feature called Partial Reconfiguration (PR) is used. The PR system requires special partial bitstreams which contain modifications to the FPGA bitstream. These are stored as two files inside a &amp;amp;quot;firmware&amp;amp;quot; zip which contains both the FPGA bitstream along with a file called &amp;lt;code&amp;gt;glitchwidth.p&amp;lt;/code&amp;gt; and a file called &amp;lt;code&amp;gt;glitchoffset.p&amp;lt;/code&amp;gt;. If a lone bitstream is being loaded into the FPGA (i.e. not from the zip-file), the partial reconfiguration system is disabled, as loading incorrect partial reconfiguration files could damage the FPGA. This damage is mostly theoretical, more likely the FPGA will fail to function correctly.&lt;br /&gt;
&lt;br /&gt;
If in the course of following this tutorial you find the FPGA appears to stop responding (i.e. certain features no longer work correctly), it could be the partial reconfiguration data is incorrect.&lt;br /&gt;
&lt;br /&gt;
== Python GUI Interface ==&lt;br /&gt;
&lt;br /&gt;
The portion of the GUI of interest to us is primarily located in this section:&lt;br /&gt;
&lt;br /&gt;
[[File:prgui.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
If the Partial Reconfiguration system has been disabled (due to missing PR files or files differing from the FPGA bitstream) the two fields marked that say (as % of period) will be disabled. Only the fields labeled (fine adjust) will be available.&lt;br /&gt;
&lt;br /&gt;
= Setting up Glitch Example =&lt;br /&gt;
&lt;br /&gt;
== Firmware Setup ==&lt;br /&gt;
&lt;br /&gt;
The glitch examples requires you to program the target device. The software to program is located at &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple&amp;lt;/code&amp;gt; of your ChipWhisperer release or GIT clone. As before, open the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; and be sure to uncomment the appropriate target to reflect your hardware:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#Multi-Target Board, AVR Device (ATMega328P)&lt;br /&gt;
#PLATFORM = CW301_AVR&lt;br /&gt;
&lt;br /&gt;
#CW-Lite XMEGA Target Device (XMEGA128D4)&lt;br /&gt;
PLATFORM = CW303&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can build the software by running the make command as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;make&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should also open the file &amp;lt;code&amp;gt;glitchsimple.c&amp;lt;/code&amp;gt; which is the source code. The subroutine being glitched in this example looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch_infinite(void)&lt;br /&gt;
{&lt;br /&gt;
    char str[64];&lt;br /&gt;
    //Declared volatile to avoid optimizing away loop.&lt;br /&gt;
    //This also adds lots of SRAM access&lt;br /&gt;
    volatile uint16_t i, j;&lt;br /&gt;
    volatile uint32_t cnt;&lt;br /&gt;
    while(1){&lt;br /&gt;
        cnt = 0;&lt;br /&gt;
        for(i=0; i&amp;amp;lt;500; i++){&lt;br /&gt;
            for(j=0; j&amp;amp;lt;500; j++){&lt;br /&gt;
                cnt++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        sprintf(str, &amp;amp;quot;%lu %d %d\n&amp;amp;quot;, cnt, i, j);&lt;br /&gt;
        uart_puts(str);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should confirm that &amp;lt;code&amp;gt;glitch_infinite()&amp;lt;/code&amp;gt; is actually called from the main subroutine. There are several glitch examples and it's possible the wrong subroutine has been setup previously:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(void){&lt;br /&gt;
&lt;br /&gt;
    platform_init();&lt;br /&gt;
    init_uart();    &lt;br /&gt;
    trigger_setup();&lt;br /&gt;
&lt;br /&gt;
    /* Uncomment this to get a HELLO message for debug */&lt;br /&gt;
    putch('h');&lt;br /&gt;
    putch('e');&lt;br /&gt;
    putch('l');&lt;br /&gt;
    putch('l');&lt;br /&gt;
    putch('o');&lt;br /&gt;
    putch('\n');&lt;br /&gt;
    _delay_ms(20);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    while(1){&lt;br /&gt;
        glitch_infinite();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return 1;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once the AVR/XMEGA is programmed (see previous tutorials), you may need to setup a few jumpers depending on your hardware.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
&lt;br /&gt;
=== XMEGA Target (CW1173 + CW303) ===&lt;br /&gt;
&lt;br /&gt;
The XMEGA target on the ChipWhisperer-Lite requires no configuration. If you have separated the boards, you can attach them with the 20-pin cable.&lt;br /&gt;
&lt;br /&gt;
=== Multi-Target Board, AVR (CW301) ===&lt;br /&gt;
&lt;br /&gt;
The hardware is almost as in previous incarnations. The difference is the 'FPGAOUT' is bridged to the AVR clock. This example will use the CLKGEN feature.&lt;br /&gt;
&lt;br /&gt;
The AVR is being used as the glitch target. The following figure shows the expected jumper settings:&lt;br /&gt;
&lt;br /&gt;
[[File:glitchhw.jpg|image]]&lt;br /&gt;
&lt;br /&gt;
== Software 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;&amp;lt;p&amp;gt;Connect to the ChipWhisperer device:&amp;lt;/p&amp;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;As the ''Scope Module'', select the ''ChipWhisperer/OpenADC'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;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 ''Scope Settings'' tab, and as the ''connection'', select the ''ChipWhisperer Rev2'' or ''ChipWhisperer-Lite'' 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 Rev2'' or ''ChipWhisperer-Lite'' option&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run connect on both the Scope &amp;amp;amp; Target. They should both switch to green circles indicating the system is connected.&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;&amp;lt;p&amp;gt;Setup the CLKGEN Module to Generate a 7.37 MHz clock and route it through the Glitch Generator&amp;lt;/p&amp;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;Switch the ''Freq Counter Src'' to the ''CLKGEN Output''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Desired Frequency'' to 7.37 MHz. Note you should only adjust the 'frequency' portion of this, if you highlight the entire field you may not be able to type the frequency into the system.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Confirm the ''DCM Locked'' checkbox is checked, if not hit the ''Reset CLKGEN DCM'' box. Check the ''Freq Counter'' to ensure the system is correctly generating a 7.37 MHz clock.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Under the ''Glitch Module'' set the ''Clock Source'' as ''CLKGEN'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitchgen-clkgen.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Under the ''Target HS IO-Out'' option select the ''Glitch Module'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:targioout.png|image]]&amp;lt;/p&amp;gt;&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;&amp;lt;p&amp;gt;Connect the Serial Port&amp;lt;/p&amp;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;For the XMEGA Target (including the CW-Lite integrated target), 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;Switch to the ''Scope Settings'' tab, and scroll down to ''Target IOn Pins''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO1'' to be ''Serial RXD''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Target IO2'' to be ''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;&amp;lt;p&amp;gt;From the ''Tools'' menu select ''Open Terminal'', and press ''Connect'' on the terminal:&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;The baud rate for this system is 38400, which should be the default for the ChipWhisperer serial port.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using the target programmer window, we will use the Read Signature or Check Signature button to reset the target every time we want to restart the program. Confirm this works by pressing the Read Signature button, for example if using the ChipWhisperer-Lite integrated programmer, you would see this window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:xmegaprog_main.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;But if using the external AVR Studio programmer for the ChipWhisperer Capture Rev2, you would see this window:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:readsig.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When you press this button the AVR will display the Hello message, which should look something like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:termhello.png|image]]&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;If you uncheck the ''RX: Show non-ASCII as hex'' you will not see the red text with ASCII values of newline (&amp;lt;code&amp;gt;0a&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''hint'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Sometimes the &amp;amp;quot;reset&amp;amp;quot; message won't appear. This happens often on the virtual machine version, or if your host computer is slow or loaded. Generally you can ignore this error, for example in the video version the welcome message is never printed. You will just have to trust the system is reseting correctly.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&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;
&lt;br /&gt;
We'll now look at glitching this routine. You should inspect the source code to determine that a simple series of calculations are performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch_infinite(void)&lt;br /&gt;
{&lt;br /&gt;
    char str[64];&lt;br /&gt;
    //Declared volatile to avoid optimizing away loop.&lt;br /&gt;
    //This also adds lots of SRAM access&lt;br /&gt;
    volatile uint16_t i, j;&lt;br /&gt;
    volatile uint32_t cnt;&lt;br /&gt;
    while(1){&lt;br /&gt;
        cnt = 0;&lt;br /&gt;
        for(i=0; i&amp;amp;lt;500; i++){&lt;br /&gt;
            for(j=0; j&amp;amp;lt;500; j++){&lt;br /&gt;
                cnt++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        sprintf(str, &amp;amp;quot;%lu %d %d\n&amp;amp;quot;, cnt, i, j);&lt;br /&gt;
        uart_puts(str);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the routine works as expected, we would expect it to print &amp;lt;code&amp;gt;250000 500 500&amp;lt;/code&amp;gt;. If a glitch interrupts the program flow, we would expect some of those values to be incorrect. This could be because a loop was skipped, an addition done incorrectly, or the program flow was exited unexpectedly.&lt;br /&gt;
&lt;br /&gt;
= Manual Glitch Trigger =&lt;br /&gt;
&lt;br /&gt;
To begin with, you'll simply use the manual glitch triggering. This works well in the examples where we have a simple loop we are breaking out of. Doing so requires modifying the glitch width and glitch offset experimentally. The exact values will vary for every device and setup.&lt;br /&gt;
&lt;br /&gt;
It is recommended to only use the ''glitch width (as % of period)'' option, as the fine adjust is too small of a change for this lower-speed example. Other hardware may need the precision added by the fine adjust however!&lt;br /&gt;
&lt;br /&gt;
The following figure shows several different settings for a 7.37 MHz clock. The width is set to 10%, which for the 136nS clock period of the 7.37 MHz clock means the glitch width is about 13.6 nS. When the offset is negative, the glitch is placed in-front of the clock. The glitch is XORd with the clock, meaning this becomes a small positive-going glitch in-front of the regular clock pulse.&lt;br /&gt;
&lt;br /&gt;
If the offset is positive, the glitch occurs ''after'' the rising edge of the clock pulse. Because this glitch pulse is XORd with the clock, it becomes a negative-going glitch inserted in the 'middle' of the regular clock pulse.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:clockglitch-examplesettings.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
With some background, let's now check some glitches. Assuming you've setup the example as before, do the following:&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;Adjust the settings for ''Glitch Width (as % of period)'' , ''Glitch Offset (as % of period)'', and ''Repeat'' based on your target and the following table for different targets:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter&lt;br /&gt;
! AVR on Multi-Target (CW301)&lt;br /&gt;
! CW-Lite XMEGA Board&lt;br /&gt;
|-&lt;br /&gt;
| Glitch Width (as % of period)&lt;br /&gt;
| 7.5&lt;br /&gt;
| 10&lt;br /&gt;
|-&lt;br /&gt;
| Glitch Offset (as % of period)&lt;br /&gt;
| -10&lt;br /&gt;
| 26.6&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 5&lt;br /&gt;
| 105&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Ensure ''Glitch Trigger'' is ''Manual''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the ''Manual Trigger'' button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;See if you end up with either the target resetting (reprints &amp;lt;code&amp;gt;hello\n&amp;lt;/code&amp;gt;), or if the loop count becomes wrong. You may need to press the ''Manual Trigger'' button several times quickly. The objective is to have an incorrect loop count, meaning you caused a glitch!&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;To force a reset of the target, use the Signature Read option on the programmer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Adjust the glith width &amp;amp;amp; offset as needed.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;You may also adjust the ''Repeat'' option, or cause it to glitch several instructions.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Be aware that you may crash the target!''' In the previous examples the target could have reset after each glitch. It may simply go into another infinite loop however, or even enter invalid states. Again force a hardware reset of the target in these cases. It may appear like the target was never glitched, whereas in reality it was glitched into some invalid state.&lt;br /&gt;
&lt;br /&gt;
{{Infobox|The boards are extremely sensitive to the glitch width and offset. You may have trouble finding settings that cause a glitch. Don't get too hung up on this; the following sections provide a more reliable method of glitching a target by determining the appropriate parameter settings.}}&lt;br /&gt;
&lt;br /&gt;
= Automatically Resetting Target =&lt;br /&gt;
&lt;br /&gt;
If we are going to start with the target at a pre-determined state, we need to reset the target. There are two ways of automatically performing this. The method used here will use the existing programmer interface to reset the device by performing that &amp;amp;quot;read signature&amp;amp;quot; operation we have already been using. The other method is to toggle a GPIO pin, which is more generic for future use.&lt;br /&gt;
&lt;br /&gt;
To setup the automatic reset, perform the following:&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;Switch to the ''General Settings'' tab, and select the appropriate &amp;amp;quot;Auxiliary Module&amp;amp;quot;:&amp;lt;/p&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;For ChipWhisperer-Lite (CW1173/CW1180), select &amp;amp;quot;Reset AVR/XMEGA via CW-Lite&amp;amp;quot;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For ChipWhisperer-Capture Rev 2, select &amp;amp;quot;Reset AVR via ISP-MKII&amp;amp;quot;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitching_aux_1.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Aux Settings'' tab. Depending on your module you will see different settings here, for example the ChipWhisperer-Lite lets you select between AVR and XMEGA targets. The defaults should be ok:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:glitching_aux_2.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the &amp;amp;quot;Test Reset&amp;amp;quot; button. This should reset the AVR target. Confirm this by monitoring the terminal emulator window, and check the startup message (of &amp;amp;quot;hello&amp;amp;quot;) is printed again.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now confirm the reset works with the &amp;amp;quot;Capture 1&amp;amp;quot; button. This requires us to disable the normal routing of the output data to a file for analysis, as we want to just dump data to the terminal emulator. To do this:&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;Switch to the ''Target Settings'' tab.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Remove all of the ''Load Key Command'', ''Go Command'', and ''Output Format'' options:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:targetsettings_clear.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the &amp;amp;quot;Capture 1&amp;amp;quot; button a few times, which should confirm on each &amp;amp;quot;capture&amp;amp;quot; the target device is resetting.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Finally, we will switch the glitch target to give us a more realistic target to glitch. To do this open the file &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple\glitchsimple.c&amp;lt;/code&amp;gt; and modify the call in &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt;, such that we now call the &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt; function. This means the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;while(1){&lt;br /&gt;
    glitch_infinite();&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;can be changed to:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;while(1){&lt;br /&gt;
    glitch1();&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;After which recompile (with &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;), and reprogram the target device. Note the new function being glitched looks like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch1(void)&lt;br /&gt;
{&lt;br /&gt;
    led_ok(1);&lt;br /&gt;
    led_error(0);&lt;br /&gt;
&lt;br /&gt;
    //Some fake variable&lt;br /&gt;
    volatile uint8_t a = 0;&lt;br /&gt;
&lt;br /&gt;
    putch('A');&lt;br /&gt;
&lt;br /&gt;
    //External trigger logic&lt;br /&gt;
    trigger_high();&lt;br /&gt;
    trigger_low();&lt;br /&gt;
&lt;br /&gt;
    //Should be an infinite loop&lt;br /&gt;
    while(a != 2){&lt;br /&gt;
    ;&lt;br /&gt;
    }    &lt;br /&gt;
&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
&lt;br /&gt;
    uart_puts(&amp;amp;quot;1234&amp;amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
    led_error(1);&lt;br /&gt;
&lt;br /&gt;
    //Several loops in order to try and prevent restarting&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }&lt;br /&gt;
    while(1){&lt;br /&gt;
    ;&lt;br /&gt;
    }    &lt;br /&gt;
}&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;When you perform a ''Capture 1'', the terminal should print &amp;lt;code&amp;gt;hello\nA&amp;lt;/code&amp;gt;, based on the above source code. Note the objective will be to glitch past the infinite loop, such that &amp;lt;code&amp;gt;1234&amp;lt;/code&amp;gt; is printed. If using the XMEGA target board this will also turn on the RED led.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;'''hint'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If the startup message isn't visible, it may be related to issues with the Capture software not being fast enough after reset to display the serial port contents on the terminal emulator. This happens often on the virtual machine environment, as can be seen in the demo video. You can ignore this error for now.&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;
= Automatically Triggering Glitch =&lt;br /&gt;
&lt;br /&gt;
The manual trigger used previously is suitable when the embedded system is waiting for further input. For example if the embedded system is waiting for a password, you could insert glitches without requiring accurate timing. We'll explore the use of the capture trigger for glitching here, which also improves the repeatability of your glitch attempts.&lt;br /&gt;
&lt;br /&gt;
To use this system, you must first understand the routing of the trigger to the glitch module. The following figure shows the trigger routing, which is more basic than the power capture trigger:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;[[File:triggerrouting.png|image]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Note in particular that if using an external IO pin, you only have a ''rising edge trigger''. The example glitch program includes a line which is set 'High' at critical moments, allowing you to experiment with this basic IO trigger.&lt;br /&gt;
&lt;br /&gt;
Based on the source code loaded, we currently have a trigger to time the glitch. This is very useful during the characterization phase, where we wish to determine what sort of glitch affects this specific hardware. Once we know that, we can move onto glitching a more &amp;amp;quot;realistic&amp;amp;quot; routine.&lt;br /&gt;
&lt;br /&gt;
Before doing that, we will actually enable the power analysis capture. To do this:&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;Switch to the ''Scope Settings'' tab.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''ADC Clock Source'' as being ''CLKGEN x4''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press ''Reset ADC DCM'', confirm the frequency is 29.5 MHz as expected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Mode'' to be ''Rising Edge''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Trigger Setup'' --&amp;amp;gt; ''Total Samples'' to be ''1000''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Switch the ''Gain Setting'' --&amp;amp;gt; ''Setting'' to be ''40''. You might need to adjust this for different hardware.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture 1'', confirm some waveform is displayed. For example with the XMEGA Target on the ChipWhisperer-Lite, the waveform looks like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:basic_waveform.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If this does't work: check the trigger in use is the ''Target IO4'' pin.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we can enable the trigger of the glitch to occur based on this external trigger pin. This can be accomplished by:&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;Switch the ''Glitch Trigger'' mode to ''Ext Trigger:Single-Shot'':&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:singleshot.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Performing a ''Capture 1'', you'll notice that the waveform is now perturbed. This is due to the clock glitches causing odd power consumption behavior:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:basic_waveform_glitchy.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Play around a bit with the glitch width, offset, and repeat. You should see different effects in the power consumption traces.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Using the Glitch Explorer =&lt;br /&gt;
&lt;br /&gt;
Now that we can automatically perform the glitching, we can use the ''glitch explorer'' to automatically vary glitch parameters while recording what the target device is doing. Before continuing with the tutorial, we'll go through an overview of the the glitch explorer.&lt;br /&gt;
&lt;br /&gt;
== Glitch Explorer ==&lt;br /&gt;
&lt;br /&gt;
The main window of the glitch explorer looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_main.png|image]]&lt;br /&gt;
&lt;br /&gt;
Where you can see the following parts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
# In |1| the output of the system combined with the parameters of the glitch is displayed (the 'output window').&lt;br /&gt;
# In |2| you can adjust general parameters of the glitching system, such as what counts as a successful glitch or not and how many parameters to fiddle with.&lt;br /&gt;
# In |3| you actually specify the parameters to adjust during the glitching attempts, and what range you would like to adjust them over.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
We'll be looking at each of these sections in more detail next.&lt;br /&gt;
&lt;br /&gt;
=== The Output Window ===&lt;br /&gt;
&lt;br /&gt;
[[File:ge_top.png|image]]&lt;br /&gt;
&lt;br /&gt;
The output window highlights different types of output. In this example we have an output |1| highlighted in green, which is flagged as a successful glitch. This example code was waiting for the ''rrrr'' sequence.&lt;br /&gt;
&lt;br /&gt;
Glitches can also be flagged as 'normal', in which case there is no highlight as in |2|. Finally the glitch could be flagged as an error, in which case it will be highlighted in red.&lt;br /&gt;
&lt;br /&gt;
In order for the glitch explorer to receive the output value, you must insert the special code &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; into the ''Target Settings'' --&amp;amp;gt; ''Output Format'' settings. This will mean data is no longer sent to the terminal emulator when using the capture 1 or capture multi buttons, but instead is logged in the glitch explorer window.&lt;br /&gt;
&lt;br /&gt;
=== The Main Settings ===&lt;br /&gt;
&lt;br /&gt;
Details of the main settings:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_middle.png|image]]&lt;br /&gt;
&lt;br /&gt;
The number of tuning parameters is set at |1|. This defines how many different parameters to adjust.&lt;br /&gt;
&lt;br /&gt;
The response of the system during normal operation is set at |2|. This defines what happens when no glitching or unexpected behavior happened.&lt;br /&gt;
&lt;br /&gt;
The desired response of the system if the glitch was successful is set at |3|.&lt;br /&gt;
&lt;br /&gt;
The expected and desired responses are expected to be Python expressions, where &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; is a str-type variable which contains the response of the system. The expression must evaulate to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;. For example, the following shows examples of what you could use as possible expressions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Desired Behavior&lt;br /&gt;
! Parameter Expression&lt;br /&gt;
|-&lt;br /&gt;
| Check for &amp;amp;quot;hellon&amp;amp;quot; exactly.&lt;br /&gt;
| s == &amp;amp;quot;hellon&amp;amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Check for &amp;amp;quot;hellon&amp;amp;quot; at end of string.&lt;br /&gt;
| s.endswith(&amp;amp;quot;hellon&amp;amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
| Check for hex 0xAF in last byte position.&lt;br /&gt;
| ord(s[-1]) == 0xAF&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that there is sometimes garbage in the first position. This occurs because if the target device is being reset before the glitch, you may see the serial lines floating. These floating lines may cause invalid characters to be recorded.&lt;br /&gt;
&lt;br /&gt;
=== Parameter Settings ===&lt;br /&gt;
&lt;br /&gt;
Details of the parameter settings:&lt;br /&gt;
&lt;br /&gt;
[[File:ge_bottom.png|image]]&lt;br /&gt;
&lt;br /&gt;
The name of the parameter to be tuned is set at |1|. This name will be displayed in the table, so should be some useful reminder of the parameter name.&lt;br /&gt;
&lt;br /&gt;
The ''Parameter Path'' at |2| defines what is modified. This string is simply copied from the ''Script Commands'' tab of the main window. This lets you modify ''any'' parameter of the GUI, but most likely you will want to modify some of the glitch settings. The numeric value in this string is ignored - the numeric value will be automatically overwritten with the value of the parameter to try.&lt;br /&gt;
&lt;br /&gt;
The ''Data Format'' at |3| defines what type of data will be inserted into the parameter. For example for the ''Glitch Offset (as % of period)'' used here, this would need to be set to ''Float'', meaning fractional values such as &amp;amp;quot;4.5&amp;amp;quot; are allowed. The data format should match the data format expected.&lt;br /&gt;
&lt;br /&gt;
The ''Range'' at |4| defines the range from the minimum to maximum that will be swept for the parameter. Valid values depend on the parameter being adjusted. For example if you are adjusting the ''Glitch Offset'' a negative and positive offset makes sense, but if you were adjusting the ''Repeat'' it would only make sense to adjust over the range &amp;lt;code&amp;gt;(1,255)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The ''Value'' at |5| defines the starting value of the sweep. This is '''NOT''' automatically set to the minimum value of your sweep. If you want to perform the full sweep, you must manually set this to the minimum of the range.&lt;br /&gt;
&lt;br /&gt;
The ''Step'' at |6| defines the amount the value is incremented on each glitch attempt. When the value reaches the maximum defined by the range, it will loop around to the minimum and continue incrementing.&lt;br /&gt;
&lt;br /&gt;
The ''Repeat'' at |7| defines how many times to perform the same value. This can be used to determine the reliability of each glitch value.&lt;br /&gt;
&lt;br /&gt;
If using multiple parameters, they will be looped as shown in this pseudo-code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;param_value_0 = starting_value_0&lt;br /&gt;
param_value_1 = starting_value_1&lt;br /&gt;
&lt;br /&gt;
while capture_in_progress:&lt;br /&gt;
    while param_value_1 &amp;amp;lt; param_value_1_max:&lt;br /&gt;
&lt;br /&gt;
      while param_value_0 &amp;amp;lt; param_value_0_max:&lt;br /&gt;
          param_value_0 += param_value_0_incr&lt;br /&gt;
          run_glitch_here()&lt;br /&gt;
&lt;br /&gt;
      param_value_0 = param_value_0_min        &lt;br /&gt;
      param_value_1 += param_value_1_incr&lt;br /&gt;
&lt;br /&gt;
    param_value_1 = param_value_1_min&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note you can quickly cause very long captures to occur! To run the glitch explorer, you need to set the appropriate number of traces on the ''General Settings'' tab, and use the ''Capture Multi'' to run the glitch explorer.&lt;br /&gt;
&lt;br /&gt;
== Example Running the Glitch Explorer ==&lt;br /&gt;
&lt;br /&gt;
This example will attempt to break out the loop in &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt;. Moving ahead from where you were in [[#Automatically Triggering Glitch]], we will see how we can view the output of the target device in the glitch explorer.&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;Switch to the ''Target Settings'' tab, and set the ''Output Format'' to be &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:output_glitch.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;From the ''Tools'' menu select ''Glitch Monitor'' to open the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press the ''Capture 1'' button a few times, and you should see the table populated with outputs:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_setup1.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;We want to mark them as &amp;amp;quot;normal&amp;amp;quot; or &amp;amp;quot;glitch successful&amp;amp;quot; to get the color-coding working appropriately.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Double-click on a normal response, and copy the text. In the ''Normal Response'' field, we need to compare the magic variable &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; with that copied text. Do this by setting the ''Normal Response'' to be: &amp;lt;code&amp;gt;s == '\x00hello\nA'&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;We want to mark a string ending with &amp;lt;code&amp;gt;1234&amp;lt;/code&amp;gt; as a pass. Thus in the ''Successful Response'' field, set the test to be &amp;lt;code&amp;gt;s.endswith('1234')&amp;lt;/code&amp;gt; (remember in Python both &amp;lt;code&amp;gt;'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;quot;&amp;lt;/code&amp;gt; are valid for string start/end characters).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture 1'' a few more times, and check the color-coding has changed:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_setup2.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to tune the glitch offset to attempt to get a successful clock glitch. These steps are listed as follows:&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;Change the ''Tuning Parameters'' to be ''1''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set the following in Parameter 0 options:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Offset&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Glitch Offset (as % of period)']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Float&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| -30 : 30&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| -30&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 0.5&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The ''Parameter Path'' option can be found by manually making an adjustment to the ''Glitch Offset (as % of period)'' in the GUI, and observing the string printed to the ''Script Commands'' tab. The numeric value of the command is not included in the parameter path (i.e., do not copy the value).&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;On the main GUI in the ''Scope Settings'' tab, change the following values for the ''Glitch Module'':&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;''Repeat'' set to 10.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;''Glitch Width (as % of period)'' set to 8.0.&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;These values will be used during the glitch explorer run. We have not specified anything for the tuning, so they will not be changed from whatever is already in the GUI.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;On the ''General Settings'' tab:&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;Ensure the ''Trace Format'' is set to ''None'' (i.e., no traces will be written to disk).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set the ''Number of Traces'' to 121.&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;Press the ''Capture Multi'' button. You will get a warning as there is no trace writer, but can just hit ''Continue Anyway'', since we do not want to store traces to disk.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;With any luck, at least one of the glitches will be successful:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you get a reset (prints 'hello' again), you might need to reduce the &amp;amp;quot;repeat&amp;amp;quot; value. If you have no successful glitches, double-check all settings. You can continue to the next step anyway, as in that step we will also tune the &amp;amp;quot;glitch width&amp;amp;quot;.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We may also need to tune the &amp;amp;quot;Glitch Width&amp;amp;quot;. We can use knowledge of the successful glitch from the previous step to reduce our search space. In this case, assume we had a successful glitch with a width of 8.0 and offset of 17.5. We'll search around those values to see if we can achieve a more successful glitch performance.&lt;br /&gt;
&lt;br /&gt;
To continue the tutorial, the following steps will be taken:&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;In the ''Glitch Explorer'', set the ''Tuning Parameters'' to ''2''.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Configure the second parameter with the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Width&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Glitch Width (as % of period)']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Float&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| 5 : 15&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 0.5&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Change the ''Range'' of the first parameter ''Glitch Offset'' to span from 1 to 25, since it appeared that negative offsets were never successful in our previous attempts. Be sure to reset the ''Value'' of this parameter to your desired starting point (probably ''1''). This will reduce the search time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the main GUI in the ''Scope Settings'' tab, adjust the ''Glitch Module'' repeat parameter to be 1. We are now attempting to acheive success with a single clock cycle being glitched.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Still in the main GUI, adjust the number of traces per capture to be 1000. This reflects the number of iterations required to run through both loops (20 x 50).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hit the ''Capture Multi'' button and cross your fingers! Hopefully you will see a successful glitch for some combination of glitch width and offset. We aren't quite done yet, as you will also need to do some fine-tuning to achieve high reliability on the glitch.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record some of the useful parameters by scrolling through the window (WARNING: changing parameters will clear the table, so record useful values now). In this example there was a success at Offset = 8.5%, and Width = 7.5%. Let's see how to fine-tune those values:&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;Plug those values into the main GUI ''Glitch Module'' setting. If we use the ''Capture 1'' button values are taken from the main GUI, instead of the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Press the ''Capture 1'' button a few times. You'll note it records the output of the device, which may not be generating successful glitches (NB: the &amp;amp;quot;offset&amp;amp;quot; and &amp;amp;quot;width&amp;amp;quot; recorded in the table may be wrong when using the Capture 1 button, as the glitch explorer is not recording values from the main GUI correctly. This is a bug in the display only, the correct values are being sent to the device).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Using arrow keys, nudge the ''Glitch Offset (fine adjust)'' up and down. Try performing a ''Capture 1'' to see if you are able to achieve a reliable glitch. In this example setting the fine adjust to 44 resulted in a very reliable glitch:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:ge_examplebasic2.png|image]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You might want to try seeing if there is an upper limit to this setting, and putting it mid-way between the lower and upper limits for generating a glitch.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats! You've now performed some tuning to achieve a reliable glitch on the target device. The next step is to glitch something more fun - like a password check.&lt;br /&gt;
&lt;br /&gt;
= Glitching a Password Check =&lt;br /&gt;
&lt;br /&gt;
This assumes you now have a set of parameters which caused a reliable glitch. We'll now glitch past a password check, initially using our trigger as a crutch. The function of interest compares a received password to some known password. The &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt; function looks as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void glitch3(void)&lt;br /&gt;
{&lt;br /&gt;
    char inp[16];&lt;br /&gt;
    char c = 'A';&lt;br /&gt;
    unsigned char cnt = 0;&lt;br /&gt;
    uart_puts(&amp;amp;quot;Password:&amp;amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    while((c != '\n') &amp;amp;amp; (cnt &amp;amp;lt; 16)){&lt;br /&gt;
        c = getch();&lt;br /&gt;
        inp[cnt] = c;&lt;br /&gt;
        cnt++;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    char passwd[] = &amp;amp;quot;touch&amp;amp;quot;;&lt;br /&gt;
    char passok = 1;&lt;br /&gt;
&lt;br /&gt;
    trigger_high();&lt;br /&gt;
    trigger_low();&lt;br /&gt;
&lt;br /&gt;
    //Simple test - doesn't check for too-long password!&lt;br /&gt;
    for(cnt = 0; cnt &amp;amp;lt; 5; cnt++){&lt;br /&gt;
        if (inp[cnt] != passwd[cnt]){&lt;br /&gt;
            passok = 0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!passok){&lt;br /&gt;
        uart_puts(&amp;amp;quot;Denied\n&amp;amp;quot;);&lt;br /&gt;
    } else {&lt;br /&gt;
        uart_puts(&amp;amp;quot;Welcome\n&amp;amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following assumes you have already completed the previous steps:&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;Close the glitch explorer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Modify the file &amp;lt;code&amp;gt;glitchexample.c&amp;lt;/code&amp;gt; to call &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;glitch1()&amp;lt;/code&amp;gt;, which is to say simply change the main function called from &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; in the folder &amp;lt;code&amp;gt;chipwhisperer\hardware\victims\firmware\glitch-simple&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Program the target device with your &amp;lt;code&amp;gt;.hex&amp;lt;/code&amp;gt; file.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the ''Target Settings'' tab, clear the ''Output Format'' field. That is remove the &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; text, as we are no longer using the glitch explorer. If you don't do this, you will not see any output of the device on the terminal emulator.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the terminal emulator, and connect to it again (if you closed it).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Reset the device, it should prompt you for a password. The correct password is &amp;lt;code&amp;gt;touch&amp;lt;/code&amp;gt;, try both correct and incorrect passwords. The program as designed loops after a password try to prompt you again. You should see both correct and incorrect responses:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:password_normal.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the ''Scope Settings'' tab, adjust the ''Timeout(s)'' to a larger value such as 20. We need a longer timeout to work with the serial terminal.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Let's try a glitch insertion! 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;Press the ''Capture 1'' button. This will reset the target and arm the glitch.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Before the timeout, enter a wrong password such as &amp;lt;code&amp;gt;test&amp;lt;/code&amp;gt; in the terminal and hit enter.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;See if you can get the wrong password accepted. If not, let's use the Glitch Explorer to automate the parameter adjustments.&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;&amp;lt;p&amp;gt;Switching to the ''Auxiliary Settings'' tab, adjust the delay on the reset such that you have a ''150 mS'' delay. This will mean once the device resets there is a delay while it prints the startup message.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[File:aux_delay150ms.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Switch to the ''Target Settings'' tab:&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;In the ''Go Command'' field, put the bad password such as &amp;lt;code&amp;gt;test\n&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;In the ''Output Format'' field, put &amp;lt;code&amp;gt;$GLITCH$&amp;lt;/code&amp;gt; to route the output to the glitch explorer.&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;Open the ''Glitch Explorer'', and press ''Capture 1''. You should see the ''Denied'' message come across.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;In the ''Glitch Explorer'', adjust the following settings:&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 ''Tuning Parameters'' to 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set Parameter 0 options to:&amp;lt;/p&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| Trigger Offset&lt;br /&gt;
|-&lt;br /&gt;
| Parameter Path&lt;br /&gt;
| ['Glitch Module', 'Ext Trigger Offset']&lt;br /&gt;
|-&lt;br /&gt;
| Data Format&lt;br /&gt;
| Int&lt;br /&gt;
|-&lt;br /&gt;
| Range&lt;br /&gt;
| 0 : 200&lt;br /&gt;
|-&lt;br /&gt;
| Value&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
| Step&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| Repeat&lt;br /&gt;
| 1&lt;br /&gt;
|}&lt;br /&gt;
&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;Set the number of traces on the ''General Settings'' tab to 200.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;On the main GUI, in the ''Scope Settings'' tab, ensure that you have the number of repeats on the ''Glitch Module'' set to 1. We will start with a single clock cycle glitched.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Press ''Capture Multi''. Monitor the glitch outputs, you may see some errors or a successful glitch. Note that sometimes the errors are useful - here is an example where the glitched code actually dumped the password:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:password_glitch_dump.png|image]]&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;More likely you might see a &amp;amp;quot;Welcome&amp;amp;quot; message indicating the password check was glitched:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;[[File:password_glitch_success.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;If the previous step isn't successful, increase the &amp;amp;quot;repeat&amp;amp;quot; count on the ''Glitch Module'' section of the ''Scope Settings'' tab, and try again. In this example I actually needed a repeat count of &amp;amp;quot;3&amp;amp;quot; to get the successful &amp;amp;quot;Welcome&amp;amp;quot; message printed above.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can also increase the repeat count in the glitch explorer, which simply tries the same settings multiple times. You will likely find that the successful glitch does not have 100% success rate, so using a repeat count of 2 or 3 is helpful to increase your chances of success.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Glitching Onward =&lt;br /&gt;
&lt;br /&gt;
This basic tutorial has introduced you to glitch attacks. They are a powerful tool for bypassing authentication in embedded hardware devices. There are many ways to expand your knowledge with additional practice, such as:&lt;br /&gt;
&lt;br /&gt;
* Use manual glitches to try simply glitching past the prompt in &amp;lt;code&amp;gt;glitch3()&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Download some example source code (bootloaders, login prompts, etc) and port them to the AVR. See how you can glitch past security checks.&lt;br /&gt;
* Use one of the IO triggers discussed in [[Tutorial_A1_Synchronization_to_Communication_Lines]].&lt;br /&gt;
&lt;br /&gt;
{{Template:Tutorials}}&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Adriel</name></author>	</entry>

	</feed>