def __init__(self, oldprojectname, newprojectname): cwapi_new = CWCoreAPI() cwapi_old = CWCoreAPI() cwapi_old.openProject(oldprojectname) cwapi_new.newProject() cwapi_new.saveProject(newprojectname) tm = cwapi_old.project().traceManager() ntraces = tm.numTraces() segs = tm.getSegmentList() numtraces = 0 for offset, seg_idx in enumerate(segs['offsetList']): seg_len = segs['lengthList'][seg_idx] seg = tm.getSegment(seg_idx) tc = TraceContainerNative() tc.clear() # Copy all aux data over # seg.config._configfile tc.config.config = seg.config.config prefix = tc.config.config['Trace Config']['prefix'] tc.config.setConfigFilename(cwapi_new.project().datadirectory + "traces/config_" + prefix + ".cfg") tc.setDirty(True) tc.config.syncFile() for tnum in range(offset, seg_len + offset): trace = tm.getTrace(tnum) textin = tm.getTextin(tnum) textout = tm.getTextout(tnum) key = tm.getKnownKey(tnum) try: textin, textout, trace, key = self.trace_callback( textin, textout, trace, key) except StopIteration: continue numtraces += 1 tc.addTrace(trace, textin, textout, key) tc.closeAll() cwapi_new.project().traceManager().appendSegment(tc) cwapi_new.saveProject()
def test_connectNone(self): t = CWCoreAPI() self.assertEqual(t.connectTarget, True) self.assertEqual(t.getTarget(), None) self.assertEqual(t.getScope(), None) self.assertEqual(t.capture1(), True) self.assertEqual(t.captureM(), True) sys.exit(self.app.exec_())
def main(): # Create the Qt Application app = makeApplication("Capture") Parameter.usePyQtGraph = True # Create and show the GUI window = CWCaptureGUI(CWCoreAPI()) window.show() # Run the main Qt loop app.exec_()
def main(): # Create the Qt Application app = makeApplication("Analyzer") # Create and show the GUI Parameter.usePyQtGraph = True window = CWAnalyzerGUI(CWCoreAPI()) window.show() # Run the main Qt loop app.exec_()
def cwconnect(offset=1250, totalsamples=3000): api = CWCoreAPI() # Instantiate the API api.setParameter( ['Generic Settings', 'Scope Module', 'ChipWhisperer/OpenADC']) api.setParameter(['Generic Settings', 'Target Module', 'Simple Serial']) #No actual need for saving data so we ignore this? #api.setParameter(['Generic Settings', 'Trace Format', 'ChipWhisperer/Native']) api.setParameter( ['Simple Serial', 'Connection', 'NewAE USB (CWLite/CW1200)']) api.setParameter( ['ChipWhisperer/OpenADC', 'Connection', 'NewAE USB (CWLite/CW1200)']) api.connect() # Example of using a list to set parameters. Slightly easier to copy/paste in this format lstexample = [ [ 'CW Extra Settings', 'Trigger Pins', 'Target IO4 (Trigger Line)', True ], ['CW Extra Settings', 'Target IOn Pins', 'Target IO1', 'Serial RXD'], ['CW Extra Settings', 'Target IOn Pins', 'Target IO2', 'Serial TXD'], [ 'OpenADC', 'Clock Setup', 'CLKGEN Settings', 'Desired Frequency', 7370000.0 ], ['CW Extra Settings', 'Target HS IO-Out', 'CLKGEN'], ['OpenADC', 'Clock Setup', 'ADC Clock', 'Source', 'CLKGEN x4 via DCM'], ['OpenADC', 'Trigger Setup', 'Total Samples', int(totalsamples)], ['OpenADC', 'Trigger Setup', 'Offset', int(offset)], ['OpenADC', 'Gain Setting', 'Setting', 45], ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'], # Final step: make DCMs relock in case they are lost ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None], ] # Download all hardware setup parameters for cmd in lstexample: api.setParameter(cmd) return api
# This is what the API will execute self.api.openProject("projects/tut_descpa.cwp") self.initPreprocessing() # Setup the analysis, widgets, and do the attack self.initAnalysis() self.initReporting() self.attack.processTraces() # Delete all pending scripts executions (that are observing the api be available again), # otherwise the current setup would be overridden self.api.executingScripts.disconnectAll() if __name__ == '__main__': from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.capture.ui.CWCaptureGUI as cwc import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwc.makeApplication(doDeleteLater=False) Parameter.usePyQtGraph = True api = CWCoreAPI() # Instantiate the API gui = cwc.CWCaptureGUI(api) # Instantiate the Capture GUI api.runScriptClass(Capture) gui.deleteLater() gui.reset() gui = cwa.CWAnalyzerGUI(api) # Instantiate the Analyzer GUI api.runScriptClass(Attack) # Run the script (default is the "run" method) app.exec_()
def main(): app = makeApplication("Test") CWMainGUI(CWCoreAPI(), app.applicationName()) app.exec_()
def __init__(self): Parameter.usePyQtGraph = True self.api = CWCoreAPI()
import chipwhisperer from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI from matplotlib.pylab import * cwapi = CWCoreAPI() #cwapi.openProject(r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group0_100k.cwp') #knownkey = "0000000000000000FFFFFFFFFFFFFFFF00000000FFFFFFFF0000000000000000" cwapi.openProject( r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group3_100k.cwp' ) knownkey = "5c3c3dc267b1d8f792f633c51389356c104100f0b52f1aa7f85c2c786d376cf8" #knownkey = "6d376cf8f85c2c78b52f1aa7104100f01389356c92f633c567b1d8f75c3c3dc2" knownkey = [int(knownkey[i:(i + 2)], 16) for i in range(0, 64, 2)] #HD Tests knownkey[4:] = [knownkey[i + 0] ^ knownkey[i + 4] for i in range(0, 32 - 4)] tm = cwapi.project().traceManager() #ppMod0 = chipwhisperer.analyzer.preprocessing.resync_sad.ResyncSAD(cwapi.project().traceManager(), connectTracePlot=False) #ppMod0.setEnabled(True) ##ppMod0.setReference(rtraceno=0, refpoints=(12,211), inputwindow=(0,487)) #ppMod0.setReference(rtraceno=0, refpoints=(513,657), inputwindow=(326,713)) #ppMod0.init() # #ppMod4 = chipwhisperer.analyzer.preprocessing.cache_traces.CacheTraces(ppMod0) #ppMod4.setEnabled(False) #ppMod4.init()