-
Notifications
You must be signed in to change notification settings - Fork 0
/
sboxes.py
141 lines (128 loc) · 11 KB
/
sboxes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from os import supports_bytes_environ
from threading import main_thread
from chipwhisperer.common.utils.util import hexstr2list
from tqdm.cli import main
sbox = [
# 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, # 0
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, # 1
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, # 2
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, # 3
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, # 4
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, # 5
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33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xa6, 0x14, 0xea, 0x45, 0xdd, 0xe1, 0x06, 0x8b, 0x56, 0x2d, 0x23, 0x85, 0x1a, # 7
0x90, 0x57, 0x91, 0x61, 0xa8, 0x3a, 0x49, 0x97, 0x0d, 0x29, 0x2c, 0x1b, 0x1e, 0x58, 0xe6, 0x48, # 8
0x40, 0x8d, 0x55, 0xa0, 0xf2, 0x6e, 0xde, 0xb5, 0x75, 0x3f, 0xec, 0xa9, 0xcf, 0xd1, 0xa3, 0xc6, # 9
0x79, 0x34, 0x5d, 0x04, 0xad, 0xb7, 0x20, 0xae, 0xbb, 0x96, 0x17, 0x9d, 0x99, 0xe9, 0x65, 0x53, # A
0x72, 0x77, 0xdc, 0x3c, 0xf4, 0xd2, 0xfb, 0x50, 0xd3, 0x81, 0x38, 0x3e, 0xe3, 0xd6, 0x5e, 0x63, # B
0xbf, 0x87, 0xd8, 0x7e, 0x52, 0x2a, 0x88, 0x80, 0x19, 0xaf, 0xc4, 0x59, 0x6a, 0x25, 0x2f, 0x94, # C
0xed, 0x15, 0x8e, 0x71, 0x7c, 0x0b, 0x93, 0xff, 0xcb, 0xab, 0xc5, 0xba, 0xd7, 0x4c, 0xc9, 0x89, # D
0x76, 0xb8, 0xd0, 0xb4, 0x73, 0x8a, 0xe7, 0xfc, 0xc2, 0x62, 0x1d, 0x37, 0x66, 0xc3, 0x12, 0xf6, # E
0xb9, 0x0c, 0xc1, 0xd9, 0x05, 0x6f, 0x16, 0xac, 0xf8, 0xee, 0xda, 0x02, 0x26, 0xa7, 0xef, 0xa1 # F
]
sbox_ozkaynak_1 = [
# 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x63, 0xA1, 0x9F, 0x98, 0x82, 0x6C, 0xEA, 0x5A, 0xFC, 0xF0, 0xC2, 0x28, 0x55, 0xCC, 0x39, 0x51, # 0
0x95, 0xCE, 0xD6, 0x58, 0x0F, 0x3E, 0x37, 0x69, 0x74, 0x3D, 0x53, 0xE1, 0x4A, 0x87, 0x76, 0xDA,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C
0xA7, 0x17, 0x49, 0xA2, 0x68, 0x56, 0xA6, 0xB2, 0x21, 0x85, 0x4E, 0x38, 0x83, 0xBE, 0xB7, 0x2E, # D
0x42, 0x4D, 0xB3, 0xDD, 0x77, 0xB0, 0x00, 0xE0, 0xCB, 0xC4, 0xE6, 0x67, 0x13, 0xC9, 0xE9, 0x5C, # E
0xAD, 0x10, 0xC3, 0xC5, 0x14, 0xCF, 0x06, 0x50, 0x5F, 0x59, 0x75, 0x0D, 0x99, 0xF3, 0x11, 0x26 # F
]
def hexify(sbox):
sbox_hex = [f"0x{num:02X}, " for num in sbox]
return sbox_hex
def compare(sbox_dec, sbox_hex):
for i in range(len(sbox_dec)):
if (sbox_dec[i] != sbox_hex[i]):
print(f"FUUUUUUUUCK @ {i}: {sbox_dec[i]} vs {sbox_hex[i]}")
if __name__== "__main__":
# sbocs = hexify(sbox_hussain_6)
compare(sbox_hussain_6, sbox_ozkaynak_1)