Skip to content

Commit 890af10

Browse files
author
lolololol
committed
des typo fix - how did we get here?
1 parent 6ad4c73 commit 890af10

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

emu/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@
33
This folder contains experiments for software-emulated side channel, using Ledger-Donjon's Rainbow framework. The example executable is DES. You can compile this with:
44

55
arm-none-eabi-gcc -nostdlib -o des.elf des.c
6+
7+
Now use des_loader.py (or equivalent) to generate traces. You need to modify:
8+
9+
- Where the data lives:
10+
- KEY_ADDR
11+
- DATA_ADDR
12+
- OUT_ADDR
13+
- Where the key function is:
14+
- DODES_START
15+
- DODES_END
16+

emu/des_loader.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
cs = None
3636

3737
KEY_ADDR = 0x18ce8
38-
DATA_ADDR = 0x18cd0
38+
DATA_ADDR = 0x18cd8
3939
OUT_ADDR = 0x18ce0
4040

41+
DODES_START = 0x8954
4142
DODES_END = 0x8974 # WHOLE
42-
# DODES_END = 0x8668 # FIRSTROUND
4343

4444
rand_key = np.array([0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88])
4545
key_str = " ".join(["%02x" % x for x in rand_key])
@@ -55,9 +55,10 @@
5555
rand_key = np.array([random.randint(0,0xFF) for i in range(0,8)],dtype=np.uint8)
5656
key_str = " ".join(["%02x" % x for x in rand_key])
5757
print("Key is %s" % key_str)
58-
out_data = emu[DATA_ADDR:DATA_ADDR+8]
59-
print("%s" % binascii.hexlify(out_data))
60-
emu.start(0x8954 , DODES_END)
58+
rand_input = np.array([random.randint(0,0xFF) for i in range(0,8)],dtype=np.uint8)
59+
emu[DATA_ADDR] = bytes(rand_input[0:4])
60+
emu[DATA_ADDR+4] = bytes(rand_input[4:8])
61+
emu.start(DODES_START , DODES_END)
6162
new_trace = np.fromiter(map(lambda event: event["register"], emu.trace),dtype=np.float32)
6263
out_output = emu[OUT_ADDR:OUT_ADDR+8]
6364
if cs is None:

lib/sparkgap/attacks/DES_SboxOut_HW.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def inv_permute(table,blk,default_char=2):
7070
return pt
7171

7272
def mapToInteger(in_s,bits=6):
73-
x in_r = in_s[::-1]
73+
in_r = in_s[::-1]
7474
out = 0
7575
for ix in range(0,bits):
7676
i = ix

0 commit comments

Comments
 (0)