As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com.

Difference between revisions of "Training"

From ChipWhisperer Wiki
Jump to: navigation, search
(DPA Lab Slides)
Line 55: Line 55:
  
 
plot(diff)
 
plot(diff)
 +
show()
 +
</SyntaxHighlight>
 +
 +
<SyntaxHighlight>
 +
#wiki.newae.com/Training
 +
from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
 +
from matplotlib.pylab import *
 +
import numpy as np
 +
cwapi = CWCoreAPI()
 +
cwapi.openProject(r'/home/cwuser/chipwhisperer/projects/aes_dpa_day1.cwp')
 +
tm = cwapi.project().traceManager()
 +
ntraces = tm.numTraces()
 +
npoints = tm.numPoints()
 +
 +
bytenum = 0
 +
##BITWISE GUESS STARTS HERE
 +
guess = 0x00
 +
#Do each trace loop
 +
for bit in range(0, 8):
 +
    #We will store 0-guess here
 +
    zeroguess = np.zeros((1,npoints))
 +
 +
    #We will store 1-guess here
 +
    oneguess = np.zeros((1,npoints))
 +
 +
    #Count 1 and 0 for averaging
 +
    numone = 0
 +
    numzero = 0
 +
 +
    for n in range(0, ntraces):
 +
        trace = tm.getTrace(n)
 +
        tin  = tm.getTextin(n)
 +
           
 +
        if tin[bytenum] & (1<<bit):
 +
            oneguess += trace
 +
            numone += 1
 +
        else:
 +
            zeroguess += trace
 +
            numzero += 1           
 +
 +
    oneguess = oneguess / float(numone)
 +
    zeroguess = zeroguess / float(numzero)
 +
 +
    diff = (oneguess - zeroguess).T
 +
 +
    if (diff[236] > 0):
 +
        guess |= (1<<bit)
 +
 +
    plot(diff)
 +
print "0x%02x"%guess
 
show()
 
show()
 
</SyntaxHighlight>
 
</SyntaxHighlight>

Revision as of 14:56, 6 August 2018

This page is used as a scratch-pad. Training related material and updates is posted here.

STM32F415 TVLA Demo

Download this file: File:tvla_stm32f415.zip

DPA Lab Slides

File:3.1 - DPA Lab 1A (Basic AES Attack) Capture Only .pptx

File:3.1 - DPA Lab 1B (Basic AES Attack) DPA Attack.pptx

from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
from matplotlib.pylab import *
import numpy as np

cwapi = CWCoreAPI()
cwapi.openProject(r'/home/cwuser/chipwhisperer/projects/dpa_dem.cwp')

tm = cwapi.project().traceManager()
ntraces = tm.numTraces()
npoints = tm.numPoints()

#We will store 0-guess here
zeroguess = np.zeros((1,npoints))

#We will store 1-guess here
oneguess = np.zeros((1,npoints))

bytenum = 0
bit = 0
##BITWISE GUESS STARTS HERE

#Count 1 and 0 for averaging
numone = 0
numzero = 0

#Do each trace loop
for n in range(0, ntraces):
    trace = tm.getTrace(n)
    tin   = tm.getTextin(n)
        
    if tin[bytenum] & (1<<bit):
        oneguess += trace
        numone += 1
    else:
        zeroguess += trace
        numzero += 1            

oneguess = oneguess / float(numone)
zeroguess = zeroguess / float(numzero)

diff = (oneguess - zeroguess).T

plot(diff)
show()
#wiki.newae.com/Training
from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
from matplotlib.pylab import *
import numpy as np
cwapi = CWCoreAPI()
cwapi.openProject(r'/home/cwuser/chipwhisperer/projects/aes_dpa_day1.cwp')
tm = cwapi.project().traceManager()
ntraces = tm.numTraces()
npoints = tm.numPoints()

bytenum = 0
##BITWISE GUESS STARTS HERE
guess = 0x00
#Do each trace loop
for bit in range(0, 8):
    #We will store 0-guess here
    zeroguess = np.zeros((1,npoints))

    #We will store 1-guess here
    oneguess = np.zeros((1,npoints))

    #Count 1 and 0 for averaging
    numone = 0
    numzero = 0

    for n in range(0, ntraces):
        trace = tm.getTrace(n)
        tin   = tm.getTextin(n)
            
        if tin[bytenum] & (1<<bit):
            oneguess += trace
            numone += 1
        else:
            zeroguess += trace
            numzero += 1            

    oneguess = oneguess / float(numone)
    zeroguess = zeroguess / float(numzero)

    diff = (oneguess - zeroguess).T

    if (diff[236] > 0):
        guess |= (1<<bit)

    plot(diff)
print "0x%02x"%guess
show()