Changes

Tutorial A5 Breaking AES-256 Bootloader

1,176 bytes added, 17:50, 21 June 2016
Appendix D: AES-256 13th Round Key Script: Updated script
= Appendix D: AES-256 13th Round Key Script =
 
'''NB: This script works for 0.10 release or later, see local copy in doc/html directory of chipwhisperer release if you need earlier versions'''
 
Full attack script, copy/paste into a file then add as active attack script:
<pre># AES-256 13th Round Key Scriptfrom chipwhisperer.common.autoscript scripts.base import AutoScriptBaseUserScriptBase#Imports from Preprocessing
import chipwhisperer.analyzer.preprocessing as preprocessing
#Imports from CaptureAttackfrom chipwhisperer.analyzer.attacks.CPA cpa import CPAfrom chipwhisperer.analyzer.attacks.CPAProgressive cpa_algorithms.progressive import CPAProgressive
import chipwhisperer.analyzer.attacks.models.AES128_8bit
# Imports from utilList
from chipwhisperer.analyzer.attacks.models.AES128_8bit import getHW
from chipwhisperer.analyzer.models.aes.funcs import sbox, inv_sbox, inv_shiftrows, inv_mixcolumns, inv_subbytes
 
class AES256Attack(object):
return getHW(inv_sbox((result[bnum] ^ guess)))
class userScript(AutoScriptBase):
preProcessingList = []
def initProject(self):
pass
class UserScript(UserScriptBase): name = "Auto-generated" description = "Auto-generated Attack Script" def initPreprocessing__init__(self, api): UserScriptBase.__init__(self, api) self.preProcessingResyncSAD0 initProject() self.initPreprocessing() self.initAnalysis() self.initReporting()  def initProject(self): pass  def initPreprocessing(self): ppMod0 = preprocessing.ResyncSAD.ResyncSAD(None, self.parentapi.project() self.preProcessingResyncSAD0traceManager()) ppMod0.setEnabled(True) self.preProcessingResyncSAD0 ppMod0.setReference(rtraceno=0, refpoints=(90638973,91779089), inputwindow=(90108841,91809124)) ppMod0.init() self.preProcessingList traces = [ppMod0  def initAnalysis(self): self.preProcessingResyncSAD0attack = CPA() self.attack.setTraceSource(self.traces,blockSignal=True) self.attack.setAnalysisAlgorithm(CPAProgressive, AES256Attack, 13) self.attack.setTraceStart(0) self.attack.setTracesPerAttack(200) self.attack.setIterations(1) self.attack.setReportingInterval(10) self.attack.setTargetBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) return self.preProcessingListattack.setPointRange((0,10991))  def initReporting(self): # Configures the attack observers (usually a set of GUI widgets) self.api.getResults("Attack Settings").setAnalysisSource(self.attack) self.api.getResults("Correlation vs Traces in Attack").setAnalysisSource(self.attack) self.api.getResults("Output vs Point Plot").setAnalysisSource(self.attack) self.api.getResults("PGE vs Trace Plot").setAnalysisSource(self.attack) self.api.getResults("Results Table").setAnalysisSource(self.attack) self.api.getResults("Save to Files").setAnalysisSource(self.attack) self.api.getResults("Trace Output Plot").setTraceSource(self.traces) self.api.getResults("Trace Recorder").setTraceSource(self.traces)
def initAnalysisrun(self): self.attack = CPA(self.parent, console=self.console, showScriptParameter=self.showScriptParameter) self.attack.setAnalysisAlgorithmprocessTraces(CPAProgressive, AES256Attack, 13) self.attack.setTraceStart(0) self.attack.setTracesPerAttack(100) self.attack.setIterations(1) self.attack.setReportingInterval(25) self.attack.setTargetBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) self.attack.setTraceManager(self.traceManager()) self.attack.setProject(self.project()) self.attack.setPointRange((8000,10990)) return self.attack
def initReportingif __name__ == '__main__': from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwa.makeApplication(self, results): # Comment if you don't need the GUI results Parameter.setAttackusePyQtGraph = True # Comment if you don't need the GUI api = CWCoreAPI(self) # Instantiate the API gui = cwa.attackCWAnalyzerGUI(api) # Comment if you don't need the GUI results gui.setTraceManagershow(self) # Comment if you don't need the GUI api.traceManagerrunScriptClass(UserScript)) # Run UserScript through the API self app.results = resultsexec_() # Comment if you don't need the GUI
def doAnalysis(self): self.attack.doAttack()</pre>
{{Template:Tutorials}}
[[Category:Tutorials]]
Approved_users
510
edits