How to use the chipwhisperer.common.utils.pluginmanager.Plugin function in chipwhisperer

To help you get started, we’ve selected a few chipwhisperer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / picoscope_interface / picoscopes.py View on Github external
#Hack for picoscope - report channel 0 only right now
        channelNum = 0

        while not self.ps.isReady():
            time.sleep(0.01)
        data = self.ps.getDataV(self.findParam(['trace', 'tracesource']).getValue(), self.findParam('samplelength').getValue(), startIndex=self.findParam('sampleoffset').getValue(), returnOverflow=True)
        if data[1] is True:
            logging.warning('Overflow in data')
        self.datapoints = data[0]
        self.dataUpdated.emit(channelNum, self.datapoints, 0, self.ps.sampleRate)

        # No timeout?
        return data[1]


class PicoScope6000(PicoScopeBase, Plugin):
    _name = "PS6000"
    def __init__(self):
        PicoScopeBase.__init__(self, ps6000.PS6000(connect=False))


class PicoScope5000a(PicoScopeBase, Plugin):
    _name = "PS5000a"
    def __init__(self):
        PicoScopeBase.__init__(self, ps5000a.PS5000a(connect=False))


class PicoScope2000(PicoScopeBase, Plugin):
    _name = "PS2000"
    def __init__(self):
        PicoScopeBase.__init__(self, ps2000.PS2000(connect=False))
github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / openadc_interface / oadc_serial.py View on Github external
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================
import logging
import sys
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.utils.parameter import Parameterized, Parameter, setupSetParam

import serial
# import chipwhisperer.common.utils.serialport as scan
from chipwhisperer.common.utils import serialport as scan


class OpenADCInterface_Serial(Parameterized, Plugin):
    _name = "Serial Port (LX9)"

    def __init__(self, oadcInstance):
        self.portName = ''
        self.ser = None

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh List', 'type':'action', 'action':self.serialRefresh},
            {'name':'Selected Port', 'type':'list', 'values':[''], 'get':self.getPortName, 'set':self.setPortName},
        ])
        self.scope = oadcInstance

    def getPortName(self):
        return self.portName
github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / openadc_interface / ftdi.py View on Github external
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================
import logging
import sys
# import chipwhisperer.capture.scopes._qt as openadc_qt
from .. import _qt as openadc_qt
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.utils.parameter import Parameterized, Parameter, setupSetParam
try:
    import ftd2xx as ft
except:
    ft = None


class OpenADCInterface_FTDI(Parameterized, Plugin):
    _name = "FTDI (SASEBO-W/SAKURA-G)"

    def __init__(self, oadcInstance):
        self.serialNumber = ''
        self._serialnumbers = ['']

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh Device List', 'type':'action', 'action':self.serialRefresh},
            {'name':'Device Serial Number', 'key':'snum', 'type':'list', 'values':[''], 'get':self.getSerialNumber, 'set':self.setSelectedDevice},
        ])
        self.ser = None

        if (openadc_qt is None) or (ft is None):
            raise ImportError("Needed imports for FTDI missing")
        else:
github newaetech / chipwhisperer / software / chipwhisperer / common / results / waveform_widget.py View on Github external
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================

from .base import ResultsBase
from chipwhisperer.common.ui.GraphWidget import GraphWidget
from chipwhisperer.common.utils import util
from chipwhisperer.common.utils.tracesource import TraceSource, ActiveTraceObserver
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.ui.ProgressBar import *
import numpy as np
import logging

class WaveFormWidget(GraphWidget, ResultsBase, ActiveTraceObserver, Plugin):
    _name = 'Trace Output Plot'
    _description = 'Plots the waveform for a given trace source'

    def __init__(self, name=None):
        GraphWidget.__init__(self)
        if name is not None:
            self._name = name
        ActiveTraceObserver.__init__(self)

        self.params.addChildren([
            {'name':'Redraw after Each', 'type':'bool', 'value':False},
            #{'name':'Trace Range', 'key':'tracerng', 'type':'range', 'limits':(0, 0), 'value':(0, 0)},
            {'name':'Trace(s) to Plot', 'key':'tracecmd', 'type':'str', 'value':'0', 'help': '%namehdr%'+
                     "Selects a trace or two to plot. You can specify ranges, individual traces, and colours. Example commands:\n" +
                     " ==================== ========================================================== \n" +
                     "  Plot Command          Result"
github newaetech / chipwhisperer / software / chipwhisperer / common / results / attacksettings.py View on Github external
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================

from chipwhisperer.analyzer.attacks._base import AttackObserver
from .base import ResultsBase
from chipwhisperer.common.utils import util
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.utils.parameter import setupSetParam


class AttackSettings(ResultsBase, AttackObserver, Plugin):
    _name = "Attack Settings"
    _description = "General settings for all the attack widgets"

    def __init__(self, name=None):
        AttackObserver.__init__(self)
        self._overridedKey = [00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00]
        self.params = self.getParams()
        self.params.addChildren([
            {'name':'Highlighted key', 'type':'list', 'values':['Known key from attack', 'Override', 'Rank 0 key', 'None'],
             'value': 'Known key from attack', 'action':lambda p: self.setKnownKeySrc(p.getValue())},
            {'name':'Override with', 'type':'str', 'key':'knownkey', 'value':"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", 'action':lambda p:self.setKnownKey(p.getValue())},
            {'name':'Highlighted key color', 'type':'color', 'value':"F00", 'action':lambda p: self.setHighlightedKeyColor(p.getValue())},
            {'name':'Trace color', 'type':'color', 'value':"0F0", 'action':lambda p: self.setTraceColor(p.getValue())},
            {'name':'Redraw Widgets', 'type':'action', 'action':self.updateAll},
        ])
        self.findParam('knownkey').hide()
github newaetech / chipwhisperer / software / chipwhisperer / analyzer / preprocessing / _base.py View on Github external
#    chipwhisperer is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================

from chipwhisperer.common.api.autoscript import AutoScript
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.utils.tracesource import TraceSource, ActiveTraceObserver
from chipwhisperer.common.utils.parameter import setupSetParam


class PreprocessingBase(TraceSource, ActiveTraceObserver, AutoScript, Plugin):
    """
    Base Class for all preprocessing modules
    Derivate Classes work like this:
        - updateScript is used by the GUI to create the parameters list and generate the API scripts
        - the other methods are used by the API to apply the preprocessing filtering
          You need to pass the getTraceSource reference in the constructor in order to apply the preprocessing step
    """
    _name = "None"

    def __init__(self, parentParam=None, traceSource=None):
        self.enabled = False
        ActiveTraceObserver.__init__(self, parentParam=parentParam)
        TraceSource.__init__(self, self.getName())
        AutoScript.__init__(self)
        self.setTraceSource(traceSource, blockSignal=True)
        if traceSource:
github newaetech / chipwhisperer / software / chipwhisperer / common / results / corrvstraceplot.py View on Github external
#    chipwhisperer is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see .
#=================================================

from ._plotdata import AttackResultPlot
import numpy as np
from chipwhisperer.common.ui.ProgressBar import ProgressBar
from chipwhisperer.common.utils.pluginmanager import Plugin


class CorrelationVsTrace(AttackResultPlot, Plugin):
    _name = 'Correlation vs Traces in Attack'
    _description = "Plots maximum correlation vs number of traces in attack."

    def __init__(self, name=None):
        AttackResultPlot.__init__(self, name)
        self.setLabels(self.getName(), "Traces", self.getName())

    def redrawPlot(self):
        """Redraw the plot, loading data from attack"""
        if not self._analysisSource:
            return

        progress = ProgressBar("Redrawing " + CorrelationVsTrace._name, "Status:")

        with progress:
            data = self._analysisSource.getStatistics().maxes_list
github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / openadc_interface / ztex.py View on Github external
import sys
# import chipwhisperer.capture.scopes._qt as openadc_qt
from .. import _qt as openadc_qt
from chipwhisperer.capture.scopes.cwhardware.ChipWhispererFWLoader import CWCRev2_Loader
from chipwhisperer.capture.scopes.cwhardware.ChipWhispererFWLoader import FWLoaderConfig
from chipwhisperer.capture.scopes.cwhardware.ChipWhispererFWLoaderGUI import FWLoaderConfigGUI
from chipwhisperer.common.utils.pluginmanager import Plugin
from chipwhisperer.common.utils.parameter import Parameterized

try:
    import usb
except ImportError:
    usb = None


class OpenADCInterface_ZTEX(Parameterized, Plugin):
    _name = "ChipWhisperer Rev2"

    def __init__(self, oadcInstance):
        self.getParams().addChildren([
            {'name':'CW Firmware Preferences','tip':'Configure ChipWhisperer FW Paths', 'type':"menu", "action":lambda _:self.getFwLoaderConfigGUI.show()},
            {'name':'Download CW Firmware','tip':'Download Firmware+FPGA To Hardware', 'type':"menu", "action":lambda _:self.getCwFirmwareConfig.loadRequired()},
        ])
        self.ser = None

        if (openadc_qt is None) or (usb is None):
            missingInfo = ""
            if openadc_qt is None:
                missingInfo += "openadc.qt "
            if usb is None:
                missingInfo += " usb"
            raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo)
github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / OpenADC.py View on Github external
#=================================================
import logging
from usb import USBError
import chipwhisperer.capture.scopes.cwhardware.ChipWhispererDecodeTrigger as ChipWhispererDecodeTrigger
import chipwhisperer.capture.scopes.cwhardware.ChipWhispererDigitalPattern as ChipWhispererDigitalPattern
import chipwhisperer.capture.scopes.cwhardware.ChipWhispererExtra as ChipWhispererExtra
import chipwhisperer.capture.scopes.cwhardware.ChipWhispererSAD as ChipWhispererSAD
import _qt as openadc_qt
from base import ScopeTemplate
from chipwhisperer.capture.scopes.openadc_interface.naeusbchip import OpenADCInterface_NAEUSBChip
from chipwhisperer.common.utils import util, timer, pluginmanager
from chipwhisperer.common.utils.parameter import Parameter, setupSetParam
from chipwhisperer.common.utils.pluginmanager import Plugin


class OpenADC(ScopeTemplate, Plugin):
    """ Common API to OpenADC Hardware"""

    _name = "ChipWhisperer/OpenADC"

    def __init__(self):
        ScopeTemplate.__init__(self)

        self.qtadc = openadc_qt.OpenADCQt()
        self.qtadc.dataUpdated.connect(self.doDataUpdated)
        # Bonus Modules for ChipWhisperer
        self.advancedSettings = None
        self.advancedSAD = None
        self.digitalPattern = None

        scopes = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.capture.scopes.openadc_interface", True, False, self.qtadc)
        self.scopetype = scopes[OpenADCInterface_NAEUSBChip._name]
github newaetech / chipwhisperer / software / chipwhisperer / capture / scopes / picoscope_interface / picoscopes.py View on Github external
return data[1]


class PicoScope6000(PicoScopeBase, Plugin):
    _name = "PS6000"
    def __init__(self):
        PicoScopeBase.__init__(self, ps6000.PS6000(connect=False))


class PicoScope5000a(PicoScopeBase, Plugin):
    _name = "PS5000a"
    def __init__(self):
        PicoScopeBase.__init__(self, ps5000a.PS5000a(connect=False))


class PicoScope2000(PicoScopeBase, Plugin):
    _name = "PS2000"
    def __init__(self):
        PicoScopeBase.__init__(self, ps2000.PS2000(connect=False))