-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyNORXTESTCASES.py
108 lines (103 loc) · 7.09 KB
/
PyNORXTESTCASES.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
from collections import namedtuple;
def PyNORXTestCases(word_width):
"""
Return list of namedtuple NorxTestCase 'H P T L R K IV C Tag' for either 32-bit or 64-bit flavor of NORX.
Header, Payload, Trailer, Lanes (Parallelism), Rounds, Key, IV/Nonce, Ciphertext, Tag
"""
NorxTestCase = namedtuple('TestCase', 'H P T L R K IV C Tag');
assert word_width in (32, 64);
K32 = bytearray(16);
K64 = bytearray(32);
N32 = bytearray(16);
N64 = bytearray(32);
X = bytearray(128);
for i in range(0, 128):
if (i < 32): K64[i] = i;
if (i < 16): K32[i] = i;
if (i < 32): N64[i] = i + 0x20;
if (i < 16): N32[i] = i + 0x20;
X[i] = i;
cases = []
if (word_width == 32):
cases.append(NorxTestCase( # 0
H=X[:], P=X[:], T=X[:],
L=1, R=4,
K=K32[:], IV=N32[:],
C=bytearray((0x6C, 0xE9, 0x4C, 0xB5, 0x48, 0xB2, 0x0F, 0xED, 0x7B, 0x68, 0xC6, 0xAC, 0x60, 0xAC, 0x4C, 0xB5,
0xEB, 0xB1, 0xF0, 0x9A, 0xEC, 0x5A, 0x75, 0x0E, 0xCF, 0x50, 0xEC, 0x0E, 0x64, 0x93, 0x8B, 0xF2,
0x40, 0x17, 0xA4, 0xFF, 0x06, 0x84, 0xF8, 0x08, 0xA6, 0x7C, 0x19, 0x6C, 0x31, 0xA0, 0xAF, 0x12,
0x56, 0x9B, 0xE5, 0xF7, 0xC5, 0x6A, 0xD3, 0xBC, 0xAC, 0x88, 0xDA, 0x36, 0x86, 0x57, 0x5F, 0x93,
0x43, 0x96, 0x8D, 0xA2, 0x20, 0x77, 0xEE, 0xCC, 0xE7, 0xD6, 0x63, 0x17, 0x49, 0x08, 0xA3, 0xF7,
0x3C, 0x9E, 0x9A, 0xC1, 0x49, 0xB5, 0xCE, 0x6B, 0xE6, 0x9C, 0x9E, 0x31, 0x7C, 0xD7, 0xE7, 0xE8,
0x0C, 0x85, 0x69, 0x97, 0x74, 0x02, 0x24, 0x41, 0x3A, 0xE0, 0x64, 0xA2, 0x5A, 0x81, 0x08, 0xB8,
0xD3, 0xA6, 0x85, 0x92, 0x74, 0xC7, 0x65, 0x86, 0xE2, 0x9C, 0x27, 0xED, 0x11, 0xFB, 0x71, 0x95)),
Tag=bytearray((0xD5, 0x54, 0xE4, 0xBC, 0x6B, 0x5B, 0xB7, 0x89, 0x54, 0x77, 0x59, 0xEA, 0xCD, 0xFF, 0xCF, 0x47))
));
cases.append(NorxTestCase( # 1
H=X[:], P=X[:], T=X[:],
L=1, R=6,
K=K32[:], IV=N32[:],
C=bytearray((0x20, 0x9B, 0x0B, 0x2A, 0xFE, 0x36, 0x2A, 0x83, 0x3B, 0xB1, 0x8A, 0xCF, 0x03, 0xE1, 0xD0, 0xC2,
0x7C, 0x69, 0x47, 0x52, 0x66, 0x79, 0x47, 0xFC, 0x73, 0x8C, 0x0E, 0x40, 0xE3, 0xD5, 0x97, 0xC2,
0x2D, 0x74, 0xE9, 0x06, 0xE8, 0xC4, 0x73, 0xAD, 0xF0, 0xDB, 0x63, 0x61, 0xD3, 0x97, 0x41, 0xC4,
0x26, 0x0F, 0xB3, 0xD3, 0x9F, 0x84, 0x22, 0xA3, 0xCF, 0xDF, 0x93, 0x0D, 0x2D, 0x17, 0x75, 0xEB,
0x3F, 0x97, 0x0E, 0x52, 0x95, 0x23, 0x07, 0xC9, 0xAA, 0x07, 0x3F, 0xC5, 0xE1, 0x19, 0xBA, 0xDF,
0xB2, 0xFF, 0x00, 0x9E, 0x69, 0x7C, 0x8E, 0x85, 0x61, 0x4F, 0x44, 0x78, 0xC5, 0x7B, 0xD2, 0xB4,
0xAC, 0xC5, 0x57, 0xF3, 0xD2, 0xDC, 0xE7, 0x11, 0xA5, 0x43, 0x0A, 0x48, 0x8C, 0x16, 0x63, 0xA2,
0x07, 0x67, 0x81, 0x48, 0x9A, 0xC7, 0x3A, 0x6B, 0xFB, 0x6A, 0xFE, 0x39, 0x6A, 0xE7, 0x9F, 0x97)),
Tag=bytearray((0xB3, 0xB1, 0x1A, 0x8F, 0x9A, 0x94, 0xF1, 0xB1, 0xAC, 0x18, 0x53, 0xE9, 0x4C, 0x43, 0x26, 0x4A))
));
elif (word_width == 64):
#64-bit with 16-byte keys
cases.append(NorxTestCase( # 0
H=X[:], P=X[:], T=X[:],
L=1, R=4,
K=K64[:], IV=N64[:],
C=bytearray((0xC0, 0x81, 0x6E, 0x50, 0x8A, 0xE4, 0xA0, 0x50, 0x0B, 0x93, 0x38, 0x7B, 0xBB, 0xAB, 0xC2, 0x41,
0xAC, 0x42, 0x38, 0x7E, 0xF5, 0xE8, 0xBF, 0x0E, 0xC3, 0x82, 0x6C, 0xED, 0xE1, 0x66, 0xA1, 0xD5,
0xCA, 0xA3, 0xE8, 0xD6, 0x2C, 0xD6, 0x41, 0xB3, 0xFA, 0xF2, 0xAA, 0x2A, 0xDD, 0xE3, 0xE5, 0xED,
0x0A, 0x13, 0xBD, 0x8B, 0x96, 0xD5, 0xF0, 0xFB, 0x7F, 0xE3, 0x9C, 0xA7, 0x80, 0x95, 0x31, 0x75,
0xE2, 0x45, 0xBC, 0x3E, 0x53, 0x4B, 0x80, 0x0E, 0x96, 0x46, 0x77, 0x1F, 0x13, 0xEA, 0x40, 0x85,
0xCB, 0x3E, 0x26, 0x7F, 0x10, 0x6F, 0x5F, 0x17, 0xA0, 0x64, 0xFF, 0x23, 0x4A, 0x02, 0x7C, 0x64,
0x4B, 0xE7, 0x86, 0x65, 0xDB, 0x1C, 0x46, 0xA4, 0xB0, 0x1A, 0x4F, 0xBF, 0x52, 0x76, 0xDF, 0xBD,
0x30, 0xEB, 0xBF, 0xB8, 0x84, 0x66, 0xF8, 0xDC, 0x89, 0x7A, 0x78, 0x16, 0xD0, 0xD0, 0x70, 0xD8 )),
Tag=bytearray((0xD1, 0xF2, 0xFA, 0x33, 0x05, 0xA3, 0x23, 0x76, 0xE2, 0x3A, 0x61, 0xD1, 0xC9, 0x89, 0x30, 0x3F,
0xBF, 0xBD, 0x93, 0x5A, 0xA5, 0x5B, 0x17, 0xE4, 0xE7, 0x25, 0x47, 0x33, 0xC4, 0x73, 0x40, 0x8E))
));
cases.append(NorxTestCase( # 1
H=X[:], P=X[:], T=X[:],
L=1, R=6,
K=K64[:], IV=N64[:],
C=bytearray((0x50, 0xCE, 0x69, 0x2C, 0x19, 0xCB, 0x91, 0x02, 0xC6, 0x12, 0x96, 0x6F, 0x0F, 0x62, 0x6B, 0x62,
0x96, 0xDE, 0x89, 0x27, 0x1C, 0x98, 0x29, 0x10, 0xAA, 0xC1, 0xC3, 0x55, 0x52, 0x2E, 0x8F, 0xA7,
0x13, 0x03, 0xF8, 0xD5, 0xC9, 0xDE, 0x39, 0x04, 0x84, 0xBA, 0x91, 0xA9, 0x94, 0xCF, 0xF9, 0x1B,
0xF7, 0x15, 0xD6, 0xCB, 0x22, 0xCC, 0x00, 0xF3, 0x64, 0x02, 0x10, 0x03, 0x17, 0x19, 0x61, 0x68,
0x72, 0x39, 0xDD, 0x94, 0x53, 0x02, 0x9B, 0x87, 0x85, 0x9C, 0x10, 0x93, 0x21, 0x13, 0x59, 0x40,
0xBC, 0x1B, 0xC8, 0x1A, 0x55, 0xA9, 0x51, 0xC7, 0x1B, 0x29, 0x42, 0xFF, 0xDE, 0xBF, 0x8D, 0x13,
0xC4, 0xF3, 0x87, 0x2B, 0x78, 0xD4, 0x50, 0x6F, 0x40, 0xDB, 0x65, 0x3C, 0xE3, 0xB8,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x63, 0xFF, 0x56, 0x18, 0x40, 0x01, 0x28, 0x8C, 0xC1, 0xBE, 0xEC)),
Tag=bytearray((0x01, 0x61, 0x3B, 0x7E, 0x49, 0x80, 0x00, 0xA7, 0x67, 0xF5, 0xD5, 0x35, 0x3F, 0x8F, 0xFD, 0x99,
0x78, 0x72, 0x05, 0x7C, 0x1F, 0xDC, 0x50, 0x14, 0xCF, 0x82, 0x27, 0xEB, 0xB8, 0xA7, 0x5C, 0xAC))
));
else:
return None;
return cases;
if (__name__ == "__main__"):
print(len(PyNORXTestCases(32)));
print(len(PyNORXTestCases(64)));
print("PyNORXTestCases.py **NOT A STANDALONE MODULE!**");