= Appendix C: AES-256 14th Round Key Script =
Full attack script, copy/paste into a file then add as active attack scriptrun from within ChipWhisperer-Analyzer:
<presyntaxhighlight lang=python># AES-256 14th Round Key Attackfrom chipwhisperer.common.scripts.base import UserScriptBase# Imports from Preprocessingimport chipwhisperer.analyzer.preprocessing as preprocessing# Imports from Attackcw
from chipwhisperer.analyzer.attacks.cpa import CPA
from chipwhisperer.analyzer.attacks.cpa_algorithms.progressive import CPAProgressive
import from chipwhisperer.analyzer.attacks.models.AES128_8bitimport AES128_8bit, InvSBox_output# Imports from utilListchipwhisperer.analyzer.preprocessing.add_noise_random import AddNoiseRandom
class UserScript#self.project = cw.openProject(UserScriptBase): name = "Auto2017-generated" description = "Automar23-generated Attack Scriptxmega-aes.cwp" def __init__(self, api): UserScriptBase.__init__(self, api) traces = self.initProject() self.initPreprocessing() self.initAnalysis() selfproject.initReportingtraceManager()
def initProjectattack = CPA(self): passleak_model = AES128_8bit(InvSBox_output)attack.setAnalysisAlgorithm(CPAProgressive, leak_model)attack.setTraceSource(traces)attack.setTraceStart(0)attack.setTracesPerAttack(-1)attack.setIterations(1)attack.setReportingInterval(10)attack.setTargetSubkeys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])attack.setPointRange((2900, 3400))
def initPreprocessing(self): self.traces = self.api.project().traceManager() def initAnalysis(self): self.attack = CPA() self.attack.setTraceSource(self.traces, blockSignal=True) self.attack.setAnalysisAlgorithm(CPAProgressive,chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit,chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit.LEAK_HW_INVSBOXOUT_FIRSTROUND) self.attack.setTraceStart(0) self.attack.setTracesPerAttack(200) self.attack.setIterations(1) self.attack.setReportingInterval(10) self.attack.setTargetSubkeys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) self.attack.setPointRange((0,10991)) def initReporting(self): # Configures the attack observers (usually a set of GUI widgets) self.api.getResults("Attack Settings")results_table.setAnalysisSource(self.attack) self.api.getResults("Correlation vs Traces in Attack")correlation_plot.setAnalysisSource(self.attack) self.api.getResults("Output vs Point Plot")output_plot.setAnalysisSource(self.attack) self.api.getResults("PGE vs Trace Plot")pge_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 run(self): self.attack.processTraces() if __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() # Comment if you don't need the GUI Parameter.usePyQtGraph = True # Comment if you don't need the GUI api = CWCoreAPI() # Instantiate the API gui = cwa.CWAnalyzerGUI(api) # Comment if you don't need the GUI gui.show() # Comment if you don't need the GUI api.runScriptClass(UserScript) # Run UserScript through the API app.exec_() # Comment if you don't need the GUI</presyntaxhighlight>
= Appendix D: AES-256 13th Round Key Script =