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 import ctypes import os 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 * #plot(traces[0,:], 'r') #plot(traces[1,:], 'b') #show() #Save as ChipWhisperer project tc = TraceContainerNative() for i in range(0, ntraces): tc.addWave(traces[i]) tc.addTextin(inp[i]) tc.addTextout(out[i]) #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. tc.addKey(*16) os.mkdir('rhme3') tc.saveAllTraces('rhme3') tc.config.setConfigFilename(r'rhme3\rhme.cfg') tc.config.saveTrace()
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).