For anyone playing with RHME3, I thought I’d post some file conversion hints.
The default .mat file don’t load in scipy.io it seems, so the example conversion utilities on the wiki are no good. A quick-n-dirty method of fixing this is to:
Split the .mat file (it’s text, open it in a text editor) into two text-files. The first contains the list of data (AFTER the header of ‘300 32’) which can be loaded by numpy. The second file contains the other block of data which is in a slightly different format.
Run the below script. It will create a directory ‘rhme3’.
Open ChipWhisperer analyzer, open the “Trace Manager”, and then hit “Add Trace” (the + button). Point it at the generated .cfg file.
import numpy as np
from chipwhisperer.common.traces.TraceContainerNative import TraceContainerNative
ntraces = 300
inout = np.loadtxt('inout.txt')
traces = np.loadtxt('traces.txt')
inout = np.reshape(inout, (32, ntraces))
inout = inout.T
inp = np.uint8(inout[:, 0:16])
out = np.uint8(inout[:, 16:32])
#If you'd like to plot a trace to see it
from matplotlib.pylab import *
#Save as ChipWhisperer project
tc = TraceContainerNative()
for i in range(0, ntraces):
#Temp - add fake key info. Required on Linux possibly, will be fixed to avoid this. Be sure to turn
#highlight key off to avoid being confused.
EDIT: There is a short hack needed for now - open the .cfg file generated, and change the line:
prefix = None
The first line worked OK on Windows, but the Linux version failed. The real fix is a code patch but that work-around is good for now (or you can set a prefix as well solves the problem).
I’m using the latest chipwisperer analyser from github develop branch (tried the pip one too).
It is working really good until I turn on SAD resync.
When I start the attack, getting the following error after a few seconds
Could not execute method run in script class UserScript: 'IndexError: too many indices for array:too many indices for array'
line number 56 [inside function oneSubkey] variable traces_all expected to be a multidimensional array [it is, if you disable SAD] but which is coming as a single dimensional array.
When I do print traces_all.shape in the the code, it is printing b[/b] with SAD enabled, (10, 6095) with SAD disabled
You get that error if you try to run the attack with the default SAD parameters (everything set to 0?). Once you vary the reference points and the window in the preprocessing setup it works ( although some combinations of values may still result in that error).