def __init__(self, parent=None):
        super(DesKeyScheduleDialog, self).__init__(parent)
        self.model = DES()

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.indata = QtFixes.QLineEdit("")
        self.indata.setFont(QFont("Courier"))

        self.keysched = QTextEdit("")
        self.keysched.setFont(QFont("Courier"))

        self.inprnd = QComboBox()
        self.inprnd.currentIndexChanged.connect(self.inTextChanged)

        indataL = QHBoxLayout()
        indataL.addWidget(QLabel("Key:"))
        indataL.addWidget(self.indata)
        indataL.addWidget(QLabel("Round:"))
        indataL.addWidget(self.inprnd)
        self.indata.textChanged.connect(self.inTextChanged)

        gbIndata = QGroupBox("Round Key/Subkey")
        gbIndata.setLayout(indataL)
        layout.addWidget(gbIndata)

        gbKeySched = QGroupBox("Full Key Schedule")
        keyschedL = QVBoxLayout()
        keyschedL.addWidget(self.keysched)
        keyschedL.addWidget(
            QLabel(
                "X - Parity bits (not used); ? - Unknown/lost bits (could not be recovered)"
            ))
        gbKeySched.setLayout(keyschedL)

        layout.addWidget(gbKeySched)

        self.setWindowTitle("DES Key Schedule Calculator")
        self.setObjectName("DES Key Schedule")
        self.refreshRoundKeysLength()
        self.setMinimumSize(800, 400)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(DesKeyScheduleDialog, self).__init__(parent)
        self.model = DES()

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.indata = QtFixes.QLineEdit("")
        self.indata.setFont(QFont("Courier"))

        self.keysched = QTextEdit("")
        self.keysched.setFont(QFont("Courier"))

        self.inprnd = QComboBox()
        self.inprnd.currentIndexChanged.connect(self.inTextChanged)

        indataL = QHBoxLayout()
        indataL.addWidget(QLabel("Key:"))
        indataL.addWidget(self.indata)
        indataL.addWidget(QLabel("Round:"))
        indataL.addWidget(self.inprnd)
        self.indata.textChanged.connect(self.inTextChanged)

        gbIndata = QGroupBox("Round Key/Subkey")
        gbIndata.setLayout(indataL)
        layout.addWidget(gbIndata)

        gbKeySched = QGroupBox("Full Key Schedule")
        keyschedL = QVBoxLayout()
        keyschedL.addWidget(self.keysched)
        keyschedL.addWidget(QLabel("X - Parity bits (not used); ? - Unknown/lost bits (could not be recovered)"))
        gbKeySched.setLayout(keyschedL)

        layout.addWidget(gbKeySched)

        self.setWindowTitle("DES Key Schedule Calculator")
        self.setObjectName("DES Key Schedule")
        self.refreshRoundKeysLength()
        self.setMinimumSize(800,400)
Exemplo n.º 3
0
class DesKeyScheduleDialog(QtFixes.QDialog):

    def __init__(self, parent=None):
        super(DesKeyScheduleDialog, self).__init__(parent)
        self.model = DES()

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.indata = QtFixes.QLineEdit("")
        self.indata.setFont(QFont("Courier"))

        self.keysched = QTextEdit("")
        self.keysched.setFont(QFont("Courier"))

        self.inprnd = QComboBox()
        self.inprnd.currentIndexChanged.connect(self.inTextChanged)

        indataL = QHBoxLayout()
        indataL.addWidget(QLabel("Key:"))
        indataL.addWidget(self.indata)
        indataL.addWidget(QLabel("Round:"))
        indataL.addWidget(self.inprnd)
        self.indata.textChanged.connect(self.inTextChanged)

        gbIndata = QGroupBox("Round Key/Subkey")
        gbIndata.setLayout(indataL)
        layout.addWidget(gbIndata)

        gbKeySched = QGroupBox("Full Key Schedule")
        keyschedL = QVBoxLayout()
        keyschedL.addWidget(self.keysched)
        keyschedL.addWidget(QLabel("X - Parity bits (not used); ? - Unknown/lost bits (could not be recovered)"))
        gbKeySched.setLayout(keyschedL)

        layout.addWidget(gbKeySched)

        self.setWindowTitle("DES Key Schedule Calculator")
        self.setObjectName("DES Key Schedule")
        self.refreshRoundKeysLength()
        self.setMinimumSize(800,400)

    def refreshRoundKeysLength(self):
        self.inprnd.blockSignals(True)
        self.inprnd.clear()
        for n in range(self.model.getNumRoundKeys()+1):
            self.inprnd.addItem(str(n), n)
        self.inprnd.setCurrentIndex(0)
        self.inprnd.blockSignals(False)

    def inTextChanged(self, _=None):
        try:
            key = util.hexstr2list(self.indata.text())
            key = [int(d) for d in key]

            #Read settings
            inpround = self.inprnd.itemData(self.inprnd.currentIndex())

            # Get entire key schedule
            totalrndstr = ""
            roundKeys = self.model.getRoundKeys(key, inpround)
            for i, key in enumerate(roundKeys):
                totalrndstr += "%2d: " % i
                for j, bit in enumerate(key):
                    if bit is not None:
                        totalrndstr += str(bit)
                    elif i == 0 and j % 8 == 7:
                        totalrndstr += 'X'
                    else:
                        totalrndstr += '?'
                totalrndstr += "\n"

            self.keysched.setText(totalrndstr)

        except:
            self.keysched.clear()
class DesKeyScheduleDialog(QtFixes.QDialog):
    def __init__(self, parent=None):
        super(DesKeyScheduleDialog, self).__init__(parent)
        self.model = DES()

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.indata = QtFixes.QLineEdit("")
        self.indata.setFont(QFont("Courier"))

        self.keysched = QTextEdit("")
        self.keysched.setFont(QFont("Courier"))

        self.inprnd = QComboBox()
        self.inprnd.currentIndexChanged.connect(self.inTextChanged)

        indataL = QHBoxLayout()
        indataL.addWidget(QLabel("Key:"))
        indataL.addWidget(self.indata)
        indataL.addWidget(QLabel("Round:"))
        indataL.addWidget(self.inprnd)
        self.indata.textChanged.connect(self.inTextChanged)

        gbIndata = QGroupBox("Round Key/Subkey")
        gbIndata.setLayout(indataL)
        layout.addWidget(gbIndata)

        gbKeySched = QGroupBox("Full Key Schedule")
        keyschedL = QVBoxLayout()
        keyschedL.addWidget(self.keysched)
        keyschedL.addWidget(
            QLabel(
                "X - Parity bits (not used); ? - Unknown/lost bits (could not be recovered)"
            ))
        gbKeySched.setLayout(keyschedL)

        layout.addWidget(gbKeySched)

        self.setWindowTitle("DES Key Schedule Calculator")
        self.setObjectName("DES Key Schedule")
        self.refreshRoundKeysLength()
        self.setMinimumSize(800, 400)

    def refreshRoundKeysLength(self):
        self.inprnd.blockSignals(True)
        self.inprnd.clear()
        for n in range(self.model.getNumRoundKeys() + 1):
            self.inprnd.addItem(str(n), n)
        self.inprnd.setCurrentIndex(0)
        self.inprnd.blockSignals(False)

    def inTextChanged(self, _=None):
        try:
            key = util.hexstr2list(self.indata.text())
            key = [int(d) for d in key]

            #Read settings
            inpround = self.inprnd.itemData(self.inprnd.currentIndex())

            # Get entire key schedule
            totalrndstr = ""
            roundKeys = self.model.getRoundKeys(key, inpround)
            for i, key in enumerate(roundKeys):
                totalrndstr += "%2d: " % i
                for j, bit in enumerate(key):
                    if bit is not None:
                        totalrndstr += str(bit)
                    elif i == 0 and j % 8 == 7:
                        totalrndstr += 'X'
                    else:
                        totalrndstr += '?'
                totalrndstr += "\n"

            self.keysched.setText(totalrndstr)

        except:
            self.keysched.clear()
Exemplo n.º 5
0
"""CPA attack script.

Assumes that a project with XMEGA software DES traces is already open.
"""

import chipwhisperer as cw
from chipwhisperer.analyzer.attacks.cpa import CPA
from chipwhisperer.analyzer.attacks.cpa_algorithms.progressive import CPAProgressive
from chipwhisperer.analyzer.attacks.models.DES import DES, SBox_output

#self.project = cw.openProject("2017-mar23-xmega-des.cwp")
traces = self.project.traceManager()

attack = CPA()
leak_model = DES(SBox_output)
attack.setAnalysisAlgorithm(CPAProgressive, leak_model)
attack.setTraceSource(traces)

attack.setTraceStart(0)
attack.setTracesPerAttack(-1)
attack.setIterations(1)
attack.setReportingInterval(10)
attack.setTargetSubkeys([0, 1, 2, 3, 4, 5, 6, 7])
attack.setPointRange((0, -1))

self.results_table.setAnalysisSource(attack)
self.correlation_plot.setAnalysisSource(attack)
self.output_plot.setAnalysisSource(attack)
self.pge_plot.setAnalysisSource(attack)
attack.processTraces()