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()
#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() #tm = ppMod4 hold(True)