def initAnalysis(self):
     # Setup the Profiling algorith to generate the templates
     self.attack = Profiling()
     self.attack.setProject(self.api.project())
     self.attack.setTraceSource(self.traces)
     self.attack.setAnalysisAlgorithm(ProfilingTemplate)
     self.attack.setTraceStart(0)
     self.attack.setTracesPerAttack(1500)
     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, 2999))
 def initAnalysis(self):
     # Setup the Profiling algorith to generate the templates
     self.attack = Profiling()
     self.attack.setProject(self.api.project())
     self.attack.setTraceSource(self.traces)
     leakage_object = chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit(
         chipwhisperer.analyzer.attacks.models.AES128_8bit.SBox_output)
     self.attack.setAnalysisAlgorithm(ProfilingTemplate, leakage_object)
     self.attack.setTraceStart(0)
     self.attack.setTracesPerAttack(1500)
     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, 2999))
 def initAnalysis2(self):
     self.attack = Profiling()
     self.attack.setProject(self.api.project())
     self.attack.setTraceSource(self.traces)
     self.attack.setAnalysisAlgorithm(ProfilingTemplate)
     self.attack.setTraceStart(0)
     self.attack.setTracesPerAttack(20)
     self.attack.setIterations(1)
     self.attack.setReportingInterval(1)
     self.attack.setTargetBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
     self.attack.setPointRange((0,2999))
Ejemplo n.º 4
0
 def initAnalysis(self):
     # Setup the Profiling algorith to generate the templates
     self.attack = Profiling()
     self.attack.setProject(self.api.project())
     self.attack.setTraceSource(self.traces)
     leakage_object = chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit(chipwhisperer.analyzer.attacks.models.AES128_8bit.SBox_output)
     self.attack.setAnalysisAlgorithm(ProfilingTemplate, leakage_object)
     self.attack.setTraceStart(0)
     self.attack.setTracesPerAttack(1500)
     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,2999))
class Attack(UserScriptBase):
    _name = "Template Attack Script"

    def initAnalysis(self):
        # Setup the Profiling algorith to generate the templates
        self.attack = Profiling()
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        leakage_object = chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit(
            chipwhisperer.analyzer.attacks.models.AES128_8bit.SBox_output)
        self.attack.setAnalysisAlgorithm(ProfilingTemplate, leakage_object)
        self.attack.setTraceStart(0)
        self.attack.setTracesPerAttack(1500)
        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, 2999))

    def initAnalysis2(self):
        # Setup the Profiling algorith to perform the actual attack
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        self.attack.setTracesPerAttack(20)
        self.attack.setReportingInterval(1)

    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 run(self):
        # This is what the API will execute
        self.api.openProject("projects/tut_randkey_randplain.cwp")
        self.traces = self.api.project().traceManager()
        self.initAnalysis()
        self.initReporting()
        self.generateTemplates()
        self.api.saveProject()
        template = self.api.project().getDataConfig(
            sectionName="Template Data", subsectionName="Templates")
        self.api.openProject("projects/tut_fixedkey_randplain.cwp")
        self.api.project().addDataConfig(template[-1],
                                         sectionName="Template Data",
                                         subsectionName="Templates")
        self.traces = self.api.project().traceManager()
        self.initAnalysis2()
        self.attack.processTraces()

        # Delete all pending script executions (that are observing the api to be available again),
        # otherwise the current setup would be overridden
        self.api.executingScripts.disconnectAll()

    def TraceExplorerDialog_PartitionDisplay_displayPartitionStats(self):
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        ted.setTraceSource(self.traces)
        progressBar = ted.parent.getProgressIndicator()
        ted.partObject.setPartMethod(PartitionHWIntermediate)
        partData = ted.partObject.generatePartitions(saveFile=True,
                                                     loadFile=False)
        partStats = ted.generatePartitionStats(partitionData={
            "partclass": PartitionHWIntermediate,
            "partdata": partData
        },
                                               saveFile=True,
                                               progressBar=progressBar)
        partDiffs = ted.generatePartitionDiffs(DifferenceModeSAD,
                                               statsInfo={
                                                   "partclass":
                                                   PartitionHWIntermediate,
                                                   "stats": partStats
                                               },
                                               saveFile=True,
                                               loadFile=False,
                                               progressBar=progressBar)
        ted.displayPartitions(differences={
            "partclass": PartitionHWIntermediate,
            "diffs": partDiffs
        })
        ted.poi.setDifferences(partDiffs)

    def TraceExplorerDialog_PartitionDisplay_findPOI(self):
        # Calculate the POIs
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        return ted.poi.calcPOI(numMax=3, pointRange=(0, 3000),
                               minSpace=5)['poi']

    def generateTemplates(self):
        # Generate the templates and save to the project
        self.TraceExplorerDialog_PartitionDisplay_displayPartitionStats()
        tRange = (0, 1499)
        poiList = self.TraceExplorerDialog_PartitionDisplay_findPOI()
        partMethod = PartitionHWIntermediate()
        templatedata = chipwhisperer.analyzer.attacks.profiling_algorithms.template.TemplateUsingMVS.generate(
            self.attack.getTraceSource(), tRange, poiList, partMethod)
        tfname = self.attack.attack.saveTemplatesToProject(
            tRange, templatedata)
Ejemplo n.º 6
0
class Attack(UserScriptBase):
    _name = "Template Attack Script"

    def initAnalysis(self):
        # Setup the Profiling algorith to generate the templates
        self.attack = Profiling()
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        leakage_object = chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit(chipwhisperer.analyzer.attacks.models.AES128_8bit.SBox_output)
        self.attack.setAnalysisAlgorithm(ProfilingTemplate, leakage_object)
        self.attack.setTraceStart(0)
        self.attack.setTracesPerAttack(1500)
        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,2999))

    def initAnalysis2(self):
        # Setup the Profiling algorith to perform the actual attack
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        self.attack.setTracesPerAttack(20)
        self.attack.setReportingInterval(1)

    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 run(self):
        # This is what the API will execute
        self.api.openProject("projects/tut_randkey_randplain.cwp")
        self.traces = self.api.project().traceManager()
        self.initAnalysis()
        self.initReporting()
        self.generateTemplates()
        self.api.saveProject()
        template = self.api.project().getDataConfig(sectionName="Template Data", subsectionName="Templates")
        self.api.openProject("projects/tut_fixedkey_randplain.cwp")
        self.api.project().addDataConfig(template[-1], sectionName="Template Data", subsectionName="Templates")
        self.traces = self.api.project().traceManager()
        self.initAnalysis2()
        self.attack.processTraces()

        # Delete all pending script executions (that are observing the api to be available again),
        # otherwise the current setup would be overridden
        self.api.executingScripts.disconnectAll()

    def TraceExplorerDialog_PartitionDisplay_displayPartitionStats(self):
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        ted.setTraceSource(self.traces)
        progressBar = ted.parent.getProgressIndicator()
        ted.partObject.setPartMethod(PartitionHWIntermediate)
        partData = ted.partObject.generatePartitions(saveFile=True, loadFile=False)
        partStats = ted.generatePartitionStats(partitionData={"partclass":PartitionHWIntermediate, "partdata":partData}, saveFile=True, progressBar=progressBar)
        partDiffs = ted.generatePartitionDiffs(DifferenceModeSAD, statsInfo={"partclass":PartitionHWIntermediate, "stats":partStats}, saveFile=True, loadFile=False, progressBar=progressBar)
        ted.displayPartitions(differences={"partclass":PartitionHWIntermediate, "diffs":partDiffs})
        ted.poi.setDifferences(partDiffs)

    def TraceExplorerDialog_PartitionDisplay_findPOI(self):
        # Calculate the POIs
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        return ted.poi.calcPOI(numMax=3, pointRange=(0, 3000), minSpace=5)['poi']

    def generateTemplates(self):
        # Generate the templates and save to the project
        self.TraceExplorerDialog_PartitionDisplay_displayPartitionStats()
        tRange = (0, 1499)
        poiList = self.TraceExplorerDialog_PartitionDisplay_findPOI()
        partMethod = PartitionHWIntermediate()
        templatedata = chipwhisperer.analyzer.attacks.profiling_algorithms.template.TemplateUsingMVS.generate(self.attack.getTraceSource(), tRange, poiList, partMethod)
        tfname = self.attack.attack.saveTemplatesToProject(tRange, templatedata)
class Attack(UserScriptBase):
    _name = "Template Attack Script"
    _description = "Template Attack Script"

    def initAnalysis(self):
        self.attack = Profiling()
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        self.attack.setAnalysisAlgorithm(ProfilingTemplate)
        self.attack.setTraceStart(0)
        self.attack.setTracesPerAttack(1500)
        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])
        self.attack.setPointRange((0,2999))

    def initAnalysis2(self):
        self.attack = Profiling()
        self.attack.setProject(self.api.project())
        self.attack.setTraceSource(self.traces)
        self.attack.setAnalysisAlgorithm(ProfilingTemplate)
        self.attack.setTraceStart(0)
        self.attack.setTracesPerAttack(20)
        self.attack.setIterations(1)
        self.attack.setReportingInterval(1)
        self.attack.setTargetBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
        self.attack.setPointRange((0,2999))

    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 run(self):
        self.api.openProject("../../projects/tut_randkey_randplain.cwp")
        self.traces = self.api.project().traceManager()
        self.initAnalysis()
        self.initReporting()
        self.generateTemplates()
        self.api.saveProject()
        template = self.api.project().getDataConfig(sectionName="Template Data", subsectionName="Templates")
        self.api.openProject("../../projects/tut_fixedkey_randplain.cwp")
        self.api.project().addDataConfig(template[-1], sectionName="Template Data", subsectionName="Templates")
        self.traces = self.api.project().traceManager()
        self.initAnalysis2()
        self.initReporting()
        self.attack.processTraces()

    def TraceExplorerDialog_PartitionDisplay_displayPartitionStats(self):
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        ted.setTraceSource(self.traces)
        progressBar = ted.parent.getProgressIndicator()
        ted.partObject.setPartMethod(PartitionHWIntermediate)
        partData = ted.partObject.generatePartitions(saveFile=True, loadFile=False)
        partStats = ted.generatePartitionStats(partitionData={"partclass":PartitionHWIntermediate, "partdata":partData}, saveFile=True, progressBar=progressBar)
        partDiffs = ted.generatePartitionDiffs(DifferenceModeSAD, statsInfo={"partclass":PartitionHWIntermediate, "stats":partStats}, saveFile=True, loadFile=False, progressBar=progressBar)
        ted.displayPartitions(differences={"partclass":PartitionHWIntermediate, "diffs":partDiffs})
        ted.poi.setDifferences(partDiffs)

    def TraceExplorerDialog_PartitionDisplay_findPOI(self):
        self.cwagui = CWAnalyzerGUI.getInstance()
        ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0]
        return ted.poi.calcPOI(numMax=3, pointRange=(0, 3000), minSpace=5)['poi']

    def generateTemplates(self):
        self.TraceExplorerDialog_PartitionDisplay_displayPartitionStats()
        tRange = (0, 1499)
        poiList = self.TraceExplorerDialog_PartitionDisplay_findPOI()
        partMethod = PartitionHWIntermediate()
        templatedata = self.attack.attack.profiling.generate(tRange, poiList, partMethod)
        tfname = self.attack.attack.saveTemplatesToProject(tRange, templatedata)