Skip to content

Commit a463f49

Browse files
author
lolololol
committed
key reminder function :)
1 parent a56d389 commit a463f49

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ lib/sparkgap.egg-info/
55

66
# go away preprocessor files
77
*.hdf
8+
**/*.hdf
89
*.cmd
910

1011
# Byte-compiled / optimized / DLL files

experiments/teacup/des_loader.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414

1515
CONFIG_INFILE = None
1616
CONFIG_OUTFILE = None
17+
CONFIG_REKEY = False
1718

18-
opts, rems = getopt.getopt(sys.argv[1:],"f:w:",["--file=","--writefile="])
19+
opts, rems = getopt.getopt(sys.argv[1:],"f:w:k",["--file=","--writefile=","--rekey"])
1920
for arg,val in opts:
2021
if arg in ("-w","--writefile"):
2122
CONFIG_OUTFILE = val
2223
elif arg in ("-f","--file"):
2324
CONFIG_INFILE = val
25+
elif arg in ("-k","--rekey"):
26+
CONFIG_REKEY = True
2427

2528
if CONFIG_INFILE is None or CONFIG_OUTFILE is None:
2629
print("You must populate both -f and -w")
@@ -34,11 +37,22 @@
3437

3538
DODES_END = 0x8974
3639

37-
for i in range(0,50):
38-
print("Beginning attempt")
40+
rand_key = np.array([random.randint(0,0xFF) for i in range(0,8)],dtype=np.uint8)
41+
key_str = " ".join(["%02x" % x for x in rand_key])
42+
43+
if CONFIG_REKEY is False:
44+
print("Key is %s" % key_str)
45+
46+
for i in range(0,25):
3947
emu = rainbow_arm(trace_config=TraceConfig(register=HammingWeight()))
4048
emu.load(CONFIG_INFILE)
4149
emu.setup()
50+
if CONFIG_REKEY is True:
51+
rand_key = np.array([random.randint(0,0xFF) for i in range(0,8)],dtype=np.uint8)
52+
key_str = " ".join(["%02x" % x for x in rand_key])
53+
print("Key is %s" % key_str)
54+
emu[KEY_ADDR] = bytes(rand_key[0:4])
55+
emu[KEY_ADDR+4] = bytes(rand_key[4:8])
4256
rand_input = np.array([random.randint(0,0xFF) for i in range(0,8)],dtype=np.uint8)
4357
emu[DATA_ADDR] = bytes(rand_input[0:4])
4458
emu[DATA_ADDR + 4] = bytes(rand_input[4:8])
@@ -55,3 +69,6 @@
5569
gc.collect()
5670

5771
cs.save(CONFIG_OUTFILE)
72+
73+
if CONFIG_REKEY is False:
74+
print("Reminder: key is %s" % key_str)

0 commit comments

Comments
 (0)