Skip to content

Commit 6695e31

Browse files
author
lolololol
committed
telomere writefile fixes
1 parent 8a57195 commit 6695e31

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

experiments/ml/telomere-masked2.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
import sparkgap.filemanager
1313
import numpy as np
1414
import gc
15+
import binascii
1516

1617
TRACE = []
1718
TRACECOUNT = 1500
18-
WRITEFILE = "emu_normal.hdf"
19+
WRITEFILE = "emu_masked.hdf"
1920

2021
random.seed()
2122

@@ -32,6 +33,10 @@
3233
WRITEFILE = arg
3334

3435
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)
3540
cs = None
3641
for i in range(0,TRACECOUNT):
3742
emu = rainbow_arm(sca_mode=True)
@@ -41,6 +46,10 @@
4146
emu[0x20000000 + 4] = bytes(rand_text[4:8])
4247
emu[0x20000000 + 8] = bytes(rand_text[8:12])
4348
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])
4453
if rekey:
4554
(pt,keybyte) = cherrypicker.getRandomPair()
4655
rand_key = np.array([random.randint(0,0xFF) for i in range(0,16)],dtype=np.uint8)
@@ -52,9 +61,7 @@
5261
emu[0x20000010 + 4] = bytes(rand_key[4:8])
5362
emu[0x20000010 + 8] = bytes(rand_key[8:12])
5463
emu[0x20000010 + 12] = bytes(rand_key[12:16])
55-
print("stop1")
5664
emu.start(emu.functions["doAES"] | 1,0x08000262)
57-
print("stop2")
5865
new_trace = np.fromiter(map(hw,emu.sca_values_trace),dtype=np.float32)
5966
if cs is None:
6067
print("Creating CaptureSet")

experiments/ml/telomere.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
TRACECOUNT = 1500
1818
WRITEFILE = "emu_normal.hdf"
1919

20-
print("telomere")
2120
random.seed()
2221

2322
rekey = False
@@ -32,7 +31,12 @@
3231
elif opt in ("-w","--writefile"):
3332
WRITEFILE = arg
3433

34+
import binascii
35+
3536
rand_key = np.array([random.randint(0,0xFF) for i in range(0,16)],dtype=np.uint8)
37+
if rekey is False and WRITEFILE == "emu_normal.hdf":
38+
WRITEFILE = "normal_%s.hdf" % binascii.hexlify(rand_key).decode("utf-8")
39+
print("Configuring writefile to %s" % WRITEFILE)
3640
cs = None
3741
for i in range(0,TRACECOUNT):
3842
emu = rainbow_arm(sca_mode=True)

nddla.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
BYTENUM_MIN = 0
2121
BYTENUM_MAX = 1
22-
# KEYBYTE_MIN = 0xb0
23-
# KEYBYTE_MAX = 0xc0
22+
KEYBYTE_MIN = 0x63
23+
KEYBYTE_MAX = 0x69
2424

25-
KEYBYTE_MIN = 0xea
26-
KEYBYTE_MAX = 0xef
25+
# KEYBYTE_MIN = 0xea
26+
# KEYBYTE_MAX = 0xef
2727

2828
if __name__ == "__main__":
2929
opts, args = getopt.getopt(sys.argv[1:],"f:o:n:a:",["file=","offset=","numsamples=","attack="])

0 commit comments

Comments
 (0)