|
12 | 12 | import sparkgap.filemanager
|
13 | 13 | import numpy as np
|
14 | 14 | import gc
|
| 15 | +import binascii |
15 | 16 |
|
16 | 17 | TRACE = []
|
17 | 18 | TRACECOUNT = 1500
|
18 |
| -WRITEFILE = "emu_normal.hdf" |
| 19 | +WRITEFILE = "emu_masked.hdf" |
19 | 20 |
|
20 | 21 | random.seed()
|
21 | 22 |
|
|
32 | 33 | WRITEFILE = arg
|
33 | 34 |
|
34 | 35 | rand_key = np.array([random.randint(0,0xFF) for i in range(0,16)],dtype=np.uint8)
|
| 36 | +rand_mask = np.array([random.randint(0,0xFF) for i in range(0,16)],dtype=np.uint8) |
| 37 | +if rekey is False and WRITEFILE == "emu_masked.hdf": |
| 38 | + WRITEFILE = "%s_masked_%s.hdf" % (binascii.hexlify(rand_key).decode("utf-8"),binascii.hexlify(rand_mask).decode("utf-8")) |
| 39 | + print("Resetting writefile to %s" % WRITEFILE) |
35 | 40 | cs = None
|
36 | 41 | for i in range(0,TRACECOUNT):
|
37 | 42 | emu = rainbow_arm(sca_mode=True)
|
|
41 | 46 | emu[0x20000000 + 4] = bytes(rand_text[4:8])
|
42 | 47 | emu[0x20000000 + 8] = bytes(rand_text[8:12])
|
43 | 48 | emu[0x20000000 + 12] = bytes(rand_text[12:16])
|
| 49 | + emu[0x20000040] = bytes(rand_mask[0:4]) |
| 50 | + emu[0x20000040 + 4] = bytes(rand_mask[4:8]) |
| 51 | + emu[0x20000040 + 8] = bytes(rand_mask[8:12]) |
| 52 | + emu[0x20000040 + 12] = bytes(rand_mask[12:16]) |
44 | 53 | if rekey:
|
45 | 54 | (pt,keybyte) = cherrypicker.getRandomPair()
|
46 | 55 | rand_key = np.array([random.randint(0,0xFF) for i in range(0,16)],dtype=np.uint8)
|
|
52 | 61 | emu[0x20000010 + 4] = bytes(rand_key[4:8])
|
53 | 62 | emu[0x20000010 + 8] = bytes(rand_key[8:12])
|
54 | 63 | emu[0x20000010 + 12] = bytes(rand_key[12:16])
|
55 |
| - print("stop1") |
56 | 64 | emu.start(emu.functions["doAES"] | 1,0x08000262)
|
57 |
| - print("stop2") |
58 | 65 | new_trace = np.fromiter(map(hw,emu.sca_values_trace),dtype=np.float32)
|
59 | 66 | if cs is None:
|
60 | 67 | print("Creating CaptureSet")
|
|
0 commit comments