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)
(DPA Lab Slides)
Line 10: Line 10:
  
 
[[:File:3.1 - DPA Lab 1B (Basic AES Attack) DPA Attack.pptx]]
 
[[:File:3.1 - DPA Lab 1B (Basic AES Attack) DPA Attack.pptx]]
 +
 +
<SyntaxHighlight>
 +
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()
 +
</SyntaxHighlight>

Revision as of 13:33, 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()