本文整理汇总了Python中chipwhisperer.common.utils.parameter.Parameter.getChild方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.getChild方法的具体用法?Python Parameter.getChild怎么用?Python Parameter.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chipwhisperer.common.utils.parameter.Parameter
的用法示例。
在下文中一共展示了Parameter.getChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OpenADCInterface_Serial
# 需要导入模块: from chipwhisperer.common.utils.parameter import Parameter [as 别名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import getChild [as 别名]
class OpenADCInterface_Serial(Parameterized, Plugin):
_name = "Serial Port (LX9)"
def __init__(self, parentParam, oadcInstance):
self.portName = ''
self.ser = None
self.params = Parameter(name=self.getName(), type='group')
self.params.addChildren([
{'name':'Refresh List', 'type':'action', 'action':lambda _: self.serialRefresh()},
{'name':'Selected Port', 'type':'list', 'values':[''], 'get':self.getPortName, 'set':self.setPortName},
])
if (openadc_qt is None) or (serial is None):
raise ImportError("Needed imports for serial missing")
else:
self.scope = oadcInstance
def getPortName(self):
return self.portName
@setupSetParam("Selected Port")
def setPortName(self, snum):
self.portName = snum
def __del__(self):
if self.ser != None:
self.ser.close()
def con(self):
if self.ser == None:
self.ser = serial.Serial()
self.ser.port = self.portName
self.ser.baudrate = 512000
self.ser.timeout = 2 # 2 second timeout
attempts = 4
while attempts > 0:
try:
self.ser.open()
attempts = 0
except serial.SerialException as e:
attempts = attempts - 1
self.ser = None
if attempts == 0:
raise IOError("Could not open %s" % self.ser.name)
try:
self.scope.con(self.ser)
print("OpenADC Found, Connecting")
except IOError as e:
exctype, value = sys.exc_info()[:2]
raise IOError("OpenADC Error (Serial Port): %s" % (str(exctype) + str(value)))
def dis(self):
if self.ser != None:
self.ser.close()
self.ser = None
def serialRefresh(self):
serialnames = scan.scan()
if serialnames == None or len(serialnames) == 0:
serialnames = [" "]
p = self.params.getChild('Selected Port')
p.setLimits(serialnames)
p.setValue(serialnames[0])
def getTextName(self):
try:
return self.ser.name
except:
return "None?"
示例2: CWCoreAPI
# 需要导入模块: from chipwhisperer.common.utils.parameter import Parameter [as 别名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import getChild [as 别名]
class CWCoreAPI(Parameterized):
"""
ChipWisperer API Class.
Provides access to the most important parts of the tool.
It has a singleton method called CWCoreAPI.getInstance() that returns a reference to the API instance.
"""
__name__ = "ChipWhisperer"
__organization__ = "NewAE Technology Inc."
__version__ = "V3.1.9"
_name = 'Generic Settings'
instance = None
def __init__(self):
CWCoreAPI.instance = self
self.sigNewProject = util.Signal()
self.sigNewScopeData = util.Signal()
self.sigConnectStatus = util.Signal()
self.sigAttackChanged = util.Signal()
self.sigNewInputData = util.Signal()
self.sigNewTextResponse = util.Signal()
self.sigTraceDone = util.Signal()
self.sigCampaignStart = util.Signal()
self.sigCampaignDone = util.Signal()
self.sigTracesChanged = util.Signal()
self.executingScripts = util.Observable(False)
self.valid_scopes = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.capture.scopes", True, True)
self.valid_targets = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.capture.targets", True, True)
self.valid_traces = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.common.traces", True, True)
self.valid_aux = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.capture.auxiliary", True, True)
self.valid_acqPatterns = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.capture.acq_patterns", True, False)
self.valid_attacks = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.analyzer.attacks", True, False)
self.valid_preprocessingModules = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.analyzer.preprocessing", False, True)
self.settings = Settings()
# Initialize default values
self._project = self._scope = self._target = self._attack = self._traceFormat = self._acqPattern = None
self._attack = self.valid_attacks.get("CPA", None)
self._acqPattern = self.valid_acqPatterns["Basic"]
self._auxList = [None] # TODO: implement it as a list in the whole class
self._numTraces = 50
self._numTraceSets = 1
self.params = Parameter(name='Generic Settings', type='group', addLoadSave=True).register()
self.params.addChildren([
{'name':'Scope Module', 'key':'scopeMod', 'type':'list', 'values':self.valid_scopes, 'get':self.getScope, 'set':self.setScope},
{'name':'Target Module', 'key':'targetMod', 'type':'list', 'values':self.valid_targets, 'get':self.getTarget, 'set':self.setTarget},
{'name':'Trace Format', 'type':'list', 'values':self.valid_traces, 'get':self.getTraceFormat, 'set':self.setTraceFormat},
{'name':'Auxiliary Module', 'type':'list', 'values':self.valid_aux, 'get':self.getAuxModule, 'set':self.setAux},
{'name':'Acquisition Settings', 'type':'group', 'children':[
{'name':'Number of Traces', 'type':'int', 'limits':(1, 1E9), 'get':self.getNumTraces, 'set':self.setNumTraces, 'linked':['Traces per Set']},
{'name':'Number of Sets', 'type':'int', 'limits':(1, 1E6), 'get':self.getNumTraceSets, 'set':self.setNumTraceSets, 'linked':['Traces per Set'], 'tip': 'Break acquisition into N sets, '
'which may cause data to be saved more frequently. The default capture driver requires that NTraces/NSets is small enough to avoid running out of system memory '
'as each segment is buffered into RAM before being written to disk.'},
{'name':'Traces per Set', 'type':'int', 'readonly':True, 'get':self.tracesPerSet},
{'name':'Key/Text Pattern', 'type':'list', 'values':self.valid_acqPatterns, 'get':self.getAcqPattern, 'set':self.setAcqPattern},
]},
])
self.scopeParam = Parameter(name="Scope Settings", type='group', addLoadSave=True).register()
self.params.getChild('Scope Module').stealDynamicParameters(self.scopeParam)
self.targetParam = Parameter(name="Target Settings", type='group', addLoadSave=True).register()
self.params.getChild('Target Module').stealDynamicParameters(self.targetParam)
self.traceParam = Parameter(name="Trace Settings", type='group', addLoadSave=True).register()
self.params.getChild('Trace Format').stealDynamicParameters(self.traceParam)
self.auxParam = Parameter(name="Aux Settings", type='group', addLoadSave=True).register()
self.params.getChild('Auxiliary Module').stealDynamicParameters(self.auxParam)
# self.attackParam = Parameter(name="Attack Settings", type='group')
# self.params.getChild('Attack Module').getDynamicParameters(self.attackParam)
self.newProject()
def getResults(self, name):
"""Return the requested result widget. It should be registered."""
return ResultsBase.registeredObjects[name]
def getScope(self):
"""Return the current scope module object."""
return self._scope
@setupSetParam("Scope Module")
def setScope(self, driver):
"""Set the current scope module object."""
if self.getScope():
self.getScope().dis()
self._scope = driver
if self.getScope():
self.getScope().dataUpdated.connect(self.sigNewScopeData.emit)
self.getScope().connectStatus.connect(self.sigConnectStatus.emit)
def getTarget(self):
"""Return the current target module object."""
return self._target
@setupSetParam("Target Module")
#.........这里部分代码省略.........
示例3: AttackScriptGen
# 需要导入模块: from chipwhisperer.common.utils.parameter import Parameter [as 别名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import getChild [as 别名]
class AttackScriptGen(Parameterized):
_name = "Attack Script Generator"
def __init__(self, cwGUI):
self.cwGUI = cwGUI
self.locked = False
self.utilList = []
self.scriptList = []
self.scriptList.append({'widget':MainScriptEditor(self.cwGUI)})
self.scriptList[0]['filename'] = self.scriptList[0]['widget'].filename
self.scriptList[0]['dockname'] = 'Auto-Generated'
self.defaultEditor = self.scriptList[0]
autogen = (self.defaultEditor['dockname'], self.defaultEditor['filename'])
self.preprocessingListGUI = [None, None, None, None]
self.setAttack(self.cwGUI.api.valid_attacks.get("CPA", None), blockSignal=True)
self.getParams().addChildren([
{'name':'Attack Script', 'type':'group', 'children':[
{'name':'Filename', 'key':'attackfilelist', 'type':'filelist', 'values':{autogen:0}, 'value':0, 'editor':self.editorControl,},
]},
{'name':'Pre-Processing', 'type':'group', 'children':[
{'name':'Module #%d' % step, 'type':'list', 'values':self.cwGUI.api.valid_preprocessingModules, 'get':partial(self.getPreprocessing, step), 'set':partial(self.setPreprocessing, step)} for step in range(0, len(self.preprocessingListGUI))
]},
{'name':'Attack', 'type':'group', 'children':[
{'name':'Module', 'type':'list', 'values':self.cwGUI.api.valid_attacks, 'get':self.getAttack, 'set':self.setAttack},
]},
])
self.params.init()
self.preprocessingParams = Parameter(name="Preprocessing", type='group')
self.attackParams = Parameter(name="Attack", type='group')
self.params.getChild(['Attack','Module']).stealDynamicParameters(self.attackParams)
self.cwGUI.api.sigTracesChanged.connect(self.updateAttackTraceLimits)
def flushTimer(self):
"""Flush all pending script updates"""
[p.updateDelayTimer.flush() for p in self.preprocessingListGUI if p is not None]
self.attack.updateDelayTimer.flush()
def updateAttackTraceLimits(self):
self.attack.setTraceLimits(self.cwGUI.api.project().traceManager().numTraces(), self.cwGUI.api.project().traceManager().numPoints())
def editorControl(self, filename, filedesc, default=False, bringToFront=True):
"""This is the call-back from the script editor file list, which opens editors"""
# Find filename
thisEditor = None
for e in self.scriptList:
if e['filename'] == filename:
thisEditor = e
break
if thisEditor is None:
thisEditor = {'widget':MainScriptEditor(parent=self.cwGUI, filename=filename)}
thisEditor['filename'] = filename
thisEditor['dockname'] = filedesc
self.scriptList.append(thisEditor)
# Update all docks if required
thisEditor['dockname'] = filedesc
self.editorDocks()
if bringToFront:
thisEditor['dock'].show()
thisEditor['dock'].raise_()
if default:
# Set as default for attacks etc
self.defaultEditor = thisEditor
def editorDocks(self):
"""Ensure we have a script editor window for each referenced analyzer script file"""
for script in self.scriptList:
dockname = "Analysis Script: %s" % script['dockname']
# No previous dock, do setup
if 'dock' not in script.keys():
self.__runScriptConverter = partial(self.runScriptFunction, filename=script['filename'])
script['widget'].editWindow.runFunction.connect(self.__runScriptConverter)
script['dock'] = self.cwGUI.addDock(script['widget'], name=dockname, area=Qt.BottomDockWidgetArea)
script['dock'].setWindowTitle(dockname)
def getPreprocessing(self, num):
return self.preprocessingListGUI[num]
@setupSetParam("")
def setPreprocessing(self, num, module):
"""Insert the preprocessing module selected from the GUI into the list of active modules.
This ensures that the options for that module are then displayed in the GUI, along with
writing the auto-generated script.
"""
#Walk backwards to find previous trace source
last_trace_src = self.cwGUI.api.project().traceManager()
for i in range(num, 0, -1):
#.........这里部分代码省略.........
示例4: AttackGenericParameters
# 需要导入模块: from chipwhisperer.common.utils.parameter import Parameter [as 别名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import getChild [as 别名]
class AttackGenericParameters(Parameterized, AutoScript):
_name= 'Attack Settings'
def __init__(self):
self.maxSubKeys = 32
AutoScript.__init__(self)
self.useAbs = True
#TODO: Where to get this from?
self.numsubkeys = 16
self.allPointsSame = True
self.startPoint = [0]*self.numsubkeys
self.endPoint = [0]*self.numsubkeys
self.traceMax = 0
self.traceLimitsChanged = util.Signal()
self.setupTraceParam()
self.setupPointsParam()
self.getParams().addChildren([
{'name':'Hardware Model', 'type':'group', 'children':[
{'name':'Crypto Algorithm', 'key':'hw_algo', 'type':'list', 'values':{'AES-128 (8-bit)':models_AES128_8bit}, 'value':models_AES128_8bit, 'action':lambda _:self.updateScript()},
{'name':'Leakage Model', 'key':'hw_leak', 'type':'list', 'values':models_AES128_8bit.leakagemodels, 'value':'LEAK_HW_SBOXOUT_FIRSTROUND', 'action':lambda _:self.updateScript()},
]},
{'name':'Take Absolute', 'type':'bool', 'get':self.getAbsoluteMode, 'set':self.setAbsoluteMode},
#TODO: Should be called from the AES module to figure out # of bytes
{'name':'Attacked Bytes', 'type':'group', 'children': self.getByteList()},
])
self.params.append(self.pointsParams)
self.params.append(self.traceParams)
self.updateBytesVisible()
def updateScript(self):
pass
def getAbsoluteMode(self):
return self.useAbs
@setupSetParam("Take Absolute")
def setAbsoluteMode(self, mode):
self.useAbs = mode
def getByteList(self):
init = [dict(name='Byte %d' % bnum, type='bool', key='bnumenabled%d' % bnum, value=True, bytenum=bnum, action=lambda _:self.updateScriptBytesEnabled()) for bnum in range(0, self.maxSubKeys)]
init.insert(0,{'name':'All On', 'type':'action', 'action':lambda _:self.allBytesOn()})
init.insert(0,{'name':'All Off', 'type':'action', 'action':lambda _:self.allBytesOff()})
return init
def updateScriptBytesEnabled(self):
blist = []
for i,t in enumerate(self.bytesParameters()):
if i < self.numsubkeys:
if t.getValue() == True:
blist.append(t.opts['bytenum'])
self.addFunction("init", "setTargetBytes", str(blist))
def updateBytesVisible(self):
for i,t in enumerate(self.bytesParameters()):
if i < self.numsubkeys:
t.show()
else:
t.hide()
self.updateScriptBytesEnabled()
def allBytesOn(self):
for t in self.bytesParameters():
t.setValue(True)
def allBytesOff(self):
for t in self.bytesParameters():
t.setValue(False)
def bytesParameters(self):
blist = []
for i in range(0, 64):
p = self.findParam(['Attacked Bytes','bnumenabled%d' % i])
if p:
blist.append(p)
return blist
############ Trace-Specific
def setupTraceParam(self):
self.traceParams = Parameter(self, name='Trace Setup', type='group', children=[
{'name':'Starting Trace', 'key':'strace', 'type':'int', 'value':0, 'action':lambda _:self.updateGenericScript()},
{'name':'Traces per Attack', 'key':'atraces', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':lambda _:self.updateGenericScript()},
{'name':'Attack Runs', 'key':'runs', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':lambda _:self.updateGenericScript()},
{'name':'Reporting Interval', 'key':'reportinterval', 'type':'int', 'value':10, 'action':lambda _:self.updateGenericScript()},
])
self.addFunction("init", "setTraceStart", "0")
self.addFunction("init", "setTracesPerAttack", "1")
self.addFunction("init", "setIterations", "1")
self.addFunction("init", "setReportingInterval", "10")
def updateGenericScript(self, ignored=None):
runs = self.traceParams.getChild('runs')
atraces = self.traceParams.getChild('atraces')
strace = self.traceParams.getChild('strace')
#.........这里部分代码省略.........