-
Notifications
You must be signed in to change notification settings - Fork 1
/
norx64impl.cry
170 lines (150 loc) · 7.24 KB
/
norx64impl.cry
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* NORX 3.0 Cryptol implementation by Tim Taubert <[email protected]>.
*
* The specification can be found at <https://norx.io/data/norx.pdf>.
*
* To the extent possible under law, the author(s) have dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*
* You should have received a copy of the CC0 Public Domain Dedication along with
* this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
module NORX64Impl where
// Word size of the internal state.
type Nw = 64
// Rotation offsets.
rot : ([6], [6], [6], [6])
rot = (8, 19, 40, 63)
// Test vectors.
tests = {
// Initial state.
vec_init_const =
[0xe4d324772b91df79, 0x3aec9abaaeb02ccb, 0x9dfba13db4289311,
0xef9eb4bf5a97f2c8, 0x3f466e92c1532034, 0xe6e986626cc405c1,
0xace40f3b549184e1, 0xd9cfd35762614477, 0xb15e641748de5e6b,
0xaa95e955e10f8410, 0x28d1034441a9dd40, 0x7f31bbf964e93bf5,
0xb5e9e22493dffb96, 0xb980c852479fafbd, 0xda24516bf55eafd4,
0x86026ae8536f1501],
// State after initialisation.
vec_init4 =
[0xed1c05e4e034b18b, 0xa98c191c6015fa6d, 0x288c3313acf5e185,
0x94e37dca8c2b520f, 0x841d5fbe319581de, 0x6ba9ae4e997c10df,
0x9acc31c63498aab8, 0xbc4f4aa085b8fad9, 0x24a958d377b4fbbf,
0x8ddb5dc488a3a710, 0x7f776980aaa321ef, 0x4d4c321a44ee66d9,
0xc6439632673fbdc2, 0x950244cdfeaea45e, 0xeb8b0aff16bedbe0,
0x68a7a80b2838111f],
vec_init6 =
[0xfbe74f8b8f87b637, 0xd8cf91e950a5e7a3, 0xbf8b7d6ee6f66d23,
0x986681bc560a954d, 0xe7ec41745d71bb3e, 0x4ec9f3e9dddd549a,
0x04d80f76956abe4e, 0x40357e0a23b3a8dd, 0x45cc935dd4c35559,
0x6665ac3ae53ee95c, 0x92652f352b2741af, 0xa793face1833962f,
0x8e98df92b5cc6486, 0x811f60a1a563fca3, 0xc5208a2f80a021d7,
0xe356de42d6a7ffdf],
// State after header processing.
vec_header4 =
[0x07d9a7a131d4d6e0, 0x5b60b0b0847e0416, 0x57f3cb734ec314b3,
0xf9cfdc4b605a6ccc, 0x5e3f25a15bf57819, 0x3501ea9eddf5cc6c,
0x69baaf08d99f96c2, 0xcf86e9721020f64e, 0x3352d33f5677cbc4,
0x331c29a0674fef14, 0xcb74afffa9bd69d9, 0x5810e32f833f0370,
0x44c3442263959e68, 0x522fc8bbfe971c48, 0x4ec92e818ea35ad3,
0xbb223cbc51462414],
vec_header6 =
[0x86a6d4b372772d8e, 0x442dd22404c14516, 0xf545b5f6f138f2c8,
0xba8f26d2915db59b, 0x7e47657efdbd4a19, 0x227101e45166c034,
0x57788639f923f1b7, 0xf5d4510a6e2e43ce, 0x95fe28cedfa322b5,
0xaca45a91cda378e0, 0xaa3b58daeb4c0c89, 0x3cce3333a7a6d105,
0xd4e9de665c5f55a5, 0x360425f706d0732c, 0x1f0ac3505dbdd8a4,
0x0609356e2891d9fb],
// State after message encryption.
vec_encryption4 =
[0xa4461cdb6586e74b, 0xbddf7652bf4f1ab0, 0xdcf86684b8bfeb30,
0xd870d0d016787a89, 0xc5dc8f2cc92a2d60, 0x404de2d5457a5178,
0x8a2475887b1abf74, 0xad5befe2f99b111f, 0xd258c60c34fc528a,
0x69c0da88a6c5cd25, 0x3328d007c5c35cc3, 0x3744b8e898ec83dd,
0x70ab4d51f1570c40, 0x5e3331a6663c18ee, 0xba01ba7cfdf2c4bf,
0x36fa274968bf8b0a],
vec_encryption6 =
[0x6f50d4782b87f3c4, 0xbed2b8e33c65db40, 0xb756f47fe9f9a2a7,
0x232fe227928cdbf0, 0x163aa5e6aa2b8f1f, 0xbe9b93658dfea66c,
0x37afc3d1c18e7b4e, 0x1e405e25dc276bf0, 0x0942ec8e4d5cf8a8,
0x52642976abf1e083, 0xd92babc7dfdcc66d, 0x1a58a4388c3ec775,
0x6c2c708571473f82, 0x5d5415187a314fa7, 0xe6438637d8df9bbe,
0x81af89907beefbef],
// State after trailer processing.
vec_trailer4 =
[0xb1b64376441a2ab0, 0x2f5be2578863d5ec, 0x66f953e878e37e6b,
0xeee236c48dedffee, 0x6778f573276fdf5f, 0xe3c3e60edc6db52d,
0xb0aaeffff4764978, 0x2a0f46f39ed63cf1, 0xa9c34dcb7057873c,
0x594cc2d6e926d398, 0xd85f144a45107f10, 0xee584a7c1d80e6d3,
0x7b763e9fcbb1f9d3, 0x9a55d3cac654f97a, 0x9308df76f6d7995e,
0x6d9e59c21cc59e3b],
vec_trailer6 =
[0x803aaddc8c8a6c3c, 0x240e45c8dddf922f, 0x46612516e3b59292,
0xe8151bed6699777c, 0x94ea2f311f5fd215, 0xae34a389a9e4d09a,
0x2e1fc599862d05ce, 0x6ef55d773d4e3841, 0x37608855b6501422,
0x790724a43d36a080, 0x6d677be24077921b, 0x0b40c69e92d8d68e,
0x0a31b5155e7c5e32, 0x727a6a113c0dd6d6, 0x7aac1cfdd18eb31d,
0xdf4bc15545ba3cb2],
// State after finalisation.
vec_final4 =
[0x45d70450c188b282, 0x44cb44a8acc7d823, 0x6cf99985a76dd706,
0xf76d93b792f90c83, 0xbcb8ec0b3370f727, 0x011728d02d035e19,
0xcc7972f3e89e595a, 0xa75510060f10f800, 0xd3314c7cdf7c4c99,
0x52a16e0d4bd61f3c, 0x4ea70acd1a1f1d3a, 0xb56927ef60bb58d4,
0x7623a30533faf2d1, 0x3f3089c9d1613ae2, 0xe4175ba55a93bdbf,
0x8e4073c4334725e7],
vec_final6 =
[0xa2f7e3afa01dcffb, 0x14d342e71fe41b15, 0x8b8ac118983d0b11,
0xacc01ceaf112614b, 0x8abc00e2f599919b, 0x991aa67f0a29616b,
0x98a27a56ef31b1ae, 0xf294074232a3ba81, 0xf1470d44e094db73,
0xf93ed9fd0f5395b4, 0x02e9988e4a8272b2, 0xce07bc4da6dd7d99,
0xdbbe9152280dd1a0, 0x38e20f7ec4bd7c7b, 0xabbc57f0c55bf55b,
0x2c9bd283d0cc572c],
// Ciphertext.
vec_ciphertext4 =
[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],
vec_ciphertext6 =
[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, 0xd2, 0xbe,
0xa7, 0xa2, 0xf9, 0xe9, 0x7f, 0xf4, 0x56, 0xb7,
0xf0, 0xdb, 0x8c, 0x92, 0x27, 0xe2, 0x2f, 0x23],
// Authentication tag.
vec_tag4 =
[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],
vec_tag6 =
[0xa0, 0xd1, 0x0d, 0x28, 0x52, 0x91, 0xbe, 0xdb,
0x7b, 0x7c, 0xbd, 0xc4, 0x7e, 0x0f, 0xe2, 0x38,
0x5b, 0xf5, 0x5b, 0xc5, 0xf0, 0x57, 0xbc, 0xab,
0x2c, 0x57, 0xcc, 0xd0, 0x83, 0xd2, 0x9b, 0x2c]
}