本文整理汇总了Python中chipwhisperer.common.api.CWCoreAPI.CWCoreAPI类的典型用法代码示例。如果您正苦于以下问题:Python CWCoreAPI类的具体用法?Python CWCoreAPI怎么用?Python CWCoreAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CWCoreAPI类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resetDevice
def resetDevice(self):
# Reset the target by reading its signature
target = self.findParam('target').getValue()
if target == 'xmega (PDI)':
CWCoreAPI.getInstance().getScope().scopetype.dev.getCwliteXMEGA().readSignature()
else:
CWCoreAPI.getInstance().getScope().scopetype.dev.getCwliteAVR().readSignature()
示例2: trigger
def trigger(self, _=None):
print "AUXIO: Trigger pin %d" % self.pin
self.checkMode()
CWCoreAPI.getInstance().getScope().advancedSettings.cwEXTRA.setGPIOState(state=(not self.standby), IONumber=self.pin)
self.nonblockingSleep(self.triglength)
CWCoreAPI.getInstance().getScope().advancedSettings.cwEXTRA.setGPIOState(state=self.standby, IONumber=self.pin)
self.nonblockingSleep(self.postdelay)
示例3: test_connectNone
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_())
示例4: processTraces
def processTraces(self, _=None):
tstart = self.findParam('tracerng').getValue()[0]
tend = self.findParam('tracerng').getValue()[1]
pstart = self.findParam('pointrng').getValue()[0]
pend = self.findParam('pointrng').getValue()[1]
trace = CWCoreAPI.getInstance().getNewTrace(self.findParam('tracefmt').getValue())
trace.config.setAttr("notes", "Recorded from \"%s\" output: Traces (%s,%s). Points (%s,%s)" % (self.findParam('Input').getValueKey(), tstart, tend, pstart, pend))
for tnum in range(tstart, tend+1):
trace.addTrace(self.getTraceSource().getTrace(tnum)[pstart:pend+1], self.getTraceSource().getTextin(tnum), self.getTraceSource().getTextout(tnum), self.getTraceSource().getKnownKey(tnum))
trace.closeAll()
CWCoreAPI.getInstance().project().traceManager().appendSegment(trace, enabled=False)
示例5: checkMode
def checkMode(self):
cwa = CWCoreAPI.getInstance().getScope().advancedSettings.cwEXTRA
if self.pin != self.lastPin:
# Turn off last used pin
if self.lastPin:
cwa.setTargetIOMode(IONumber=self.lastPin, setting=0)
# Setup new pin
cwa.setTargetIOMode(IONumber=self.pin, setting=cwa.IOROUTE_GPIOE)
# Don't do this again
self.lastPin = self.pin
示例6: __init__
def __init__(self, parent):
AutoScript.__init__(self)
self._autoscript_init = False
self.parent = parent
self.poi = POI(self)
self.poiDock = CWMainGUI.getInstance().addDock(self.poi, "Partition Comparison POI Table", area=Qt.TopDockWidgetArea)
self.poiDock.hide()
self.defineName()
self._traces = None
self.api = CWCoreAPI.getInstance()
self.graph = GraphWidget()
self.bselection = QToolBar()
self.graph.addWidget(self.bselection)
self.graphDock = CWMainGUI.getInstance().addDock(self.graph, "Partition Comparison Graph", area=Qt.TopDockWidgetArea)
self.graphDock.hide()
示例7: CWCoreAPI
['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: self.api.setParameter(cmd)
#Let's only do a few traces
self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 50])
#Throw away first few
self.api.capture1()
self.api.capture1()
#Capture a set of traces and save the project
# self.api.captureM()
# self.api.saveProject("../../../projects/test.cwp")
if __name__ == '__main__':
app = cwc.makeApplication() # Comment this line if you don't want to use the GUI
Parameter.usePyQtGraph = True # Comment this line if you don't want to use the GUI
api = CWCoreAPI() # Instantiate the API
# app.setApplicationName("Capture Scripted") # If you DO NOT want to overwrite settings from the GUI
gui = cwc.CWCaptureGUI(api) # Comment this line if you don't want to use the GUI
gui.show() # Comment this line if you don't want to use the GUI
api.runScriptClass(UserScript) # Run the User Script
sys.exit(app.exec_()) # Comment this line if you don't want to use the GUI
示例8: range
for i in range(5):
for c in trylist:
# Get a power trace using our next attempt
nextPass = password + '{}'.format(c)
self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])
self.api.capture1()
# Grab the trace
nextTrace = self.api.getScope().datapoints
# Check location 153, 225, etc. If it's too low, we've failed
if nextTrace[153 + 72*i] < -0.2:
continue
# If we got here, we've found the right letter
password += c
print '{} characters: {}'.format(i+1, password)
break
if __name__ == '__main__':
import chipwhisperer.capture.ui.CWCaptureGUI as cwc # Import the ChipWhispererCapture GUI
from chipwhisperer.common.utils.parameter import Parameter # Comment this line if you don't want to use the GUI
Parameter.usePyQtGraph = True # Comment this line if you don't want to use the GUI
api = CWCoreAPI() # Instantiate the API
app = cwc.makeApplication("Capture") # Change the name if you want a different settings scope
gui = cwc.CWCaptureGUI(api) # Comment this line if you don't want to use the GUI
gui.show() # Comment this line if you don't want to use the GUI
api.runScriptClass(UserScript) # Run the User Script (executes "run()" by default)
app.exec_() # Comment this line if you don't want to use the GUI
示例9: addTraces
def addTraces(self, tracedata, tracerange, progressBar=None, pointRange=None):
keyround=self.keyround
modeltype=self.modeltype
brange=self.brange
foundkey = []
self.all_diffs = range(0,16)
tdiff = self.findParam('reportinterval').getValue()
numtraces = tracerange[1] - tracerange[0]
if progressBar:
progressBar.setMinimum(0)
progressBar.setMaximum(len(brange) * 256 * (numtraces/tdiff + 1))
#r = Parallel(n_jobs=4)(delayed(traceOneSubkey)(bnum, pointRange, traces_all, numtraces, plaintexts, ciphertexts, keyround, modeltype, progressBar, self.model, pbcnt) for bnum in brange)
#self.all_diffs, pb = zip(*r)
cpa = [None]*(max(brange)+1)
for bnum in brange:
cpa[bnum] = CPAProgressiveOneSubkey()
# cpa[bnum] = MinDistOneSubkey()
# cpa[bnum] = TemplateOneSubkey()
brangeMap = [None]*(max(brange)+1)
i = 1
for bnum in brange:
brangeMap[bnum] = i
i += 1
skipPGE = self.findParam('checkpge').getValue()
bf = self.findParam('itmode').getValue() == 'bf'
#bf specifies a 'breadth-first' search. bf means we search across each
#subkey by only the amount of traces specified. Depth-First means we
#search each subkey completely, then move onto the next.
if bf:
brange_df = [0]
brange_bf = brange
else:
brange_bf = [0]
brange_df = brange
#H = np.load('channelinfo-masked.npy')
#H = np.load('csi-masked-newkey.npy')
#H = np.load('channelinfo.npy')
#mio = sio.loadmat('equalizer.mat')
#H = mio['equaltotal']
# H = np.load('equalization.npy')
# self.project() ?
project = CWCoreAPI.getInstance().project()
section = project.getDataConfig("Template Data", "Equalization Matrix")
# section = project.getDataConfig("Template Data", "AOF Matrix")
fname = project.convertDataFilepathAbs(section[0]["filename"])
H = np.load(fname)
#for j in range(0, 16):
#4 = 500-800
#test = H.copy()
#for i in range(0, 5):
# threshold = max(abs(test[j]))
# test[j, abs(test[j,:]) >= threshold ] = 0
#print "%f %d"%(threshold, (abs(H[j,:]) > threshold).sum())
#H[j, abs(H[j,:]) < threshold] = 0
for bnum_df in brange_df:
#CPAMemoryOneSubkey
#CPASimpleOneSubkey
#(self.all_diffs[bnum], pbcnt) = sCPAMemoryOneSubkey(bnum, pointRange, traces_all, numtraces, plaintexts, ciphertexts, keyround, modeltype, progressBar, self.model, pbcnt)
tstart = 0
tend = tdiff
while tstart < numtraces:
pbcnt = 0
if tend > numtraces:
tend = numtraces
if tstart > numtraces:
tstart = numtraces
data = []
textins = []
textouts = []
knownkeys = []
for i in range(tstart, tend):
# Handle Offset
tnum = i + tracerange[0]
d = tracedata.getTrace(tnum)
if d is None:
continue
#.........这里部分代码省略.........
示例10: savePOI
def savePOI(self):
poiDict = {"poi":self.poiArray, "partitiontype":self.parent.partObject.partMethod.__class__.__name__}
CWCoreAPI.getInstance().project().addDataConfig(poiDict, "Template Data", "Points of Interest")
示例11: TraceExplorerDialog_PartitionDisplay_findPOI
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)
if __name__ == '__main__':
import sys
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
api.runScriptClass(Capture)
gui = cwa.CWAnalyzerGUI(api) # Comment if you don't need the GUI
gui.show() # Comment if you don't need the GUI
api.runScriptClass(Attack)
sys.exit(app.exec_()) # Comment if you don't need the GUI
示例12: captureInit
def captureInit(self):
self.checkMode()
CWCoreAPI.getInstance().getScope().advancedSettings.cwEXTRA.setGPIOState(state=self.standby, IONumber=self.pin)
if self.triglocation == 0:
self.trigger()