OXYGENHUB
◆ main oxygen / vendor / crc-fast / src / crc32 / consts.rs
18.4 KiB · Rust · last changed Strata: the cloud stores send through ureq, so every release target links 1 month ago source blame history raw
2cd40ea1 Andy McCall ↶ 1
// Copyright 2025 Don MacAskill. Licensed under MIT or Apache-2.0.
2
3
#![allow(dead_code)]
4
5
use crate::consts::{
6
    NAME_CRC32_AIXM, NAME_CRC32_AUTOSAR, NAME_CRC32_BASE91_D, NAME_CRC32_BZIP2,
7
    NAME_CRC32_CD_ROM_EDC, NAME_CRC32_CKSUM, NAME_CRC32_ISCSI, NAME_CRC32_ISO_HDLC,
8
    NAME_CRC32_JAMCRC, NAME_CRC32_MEF, NAME_CRC32_MPEG_2, NAME_CRC32_XFER,
9
};
10
use crate::structs::Algorithm;
11
use crate::CrcAlgorithm;
12
use crate::CrcParams;
13
14
pub const CRC_32_AIXM: Algorithm<u32> = Algorithm {
15
    width: 32,
16
    poly: 0x814141ab,
17
    init: 0x0,
18
    refin: false,
19
    refout: false,
20
    xorout: 0x0,
21
    check: 0x3010bf7f,
22
    residue: 0x0,
23
};
24
25
pub const CRC_32_AUTOSAR: Algorithm<u32> = Algorithm {
26
    width: 32,
27
    poly: 0xf4acfb13,
28
    init: 0xffffffff,
29
    refin: true,
30
    refout: true,
31
    xorout: 0xffffffff,
32
    check: 0x1697d06a,
33
    residue: 0x904cddbf,
34
};
35
36
pub const CRC_32_BASE91_D: Algorithm<u32> = Algorithm {
37
    width: 32,
38
    poly: 0xa833982b,
39
    init: 0xffffffff,
40
    refin: true,
41
    refout: true,
42
    xorout: 0xffffffff,
43
    check: 0x87315576,
44
    residue: 0x45270551,
45
};
46
47
pub const CRC_32_BZIP2: Algorithm<u32> = Algorithm {
48
    width: 32,
49
    poly: 0x4c11db7,
50
    init: 0xffffffff,
51
    refin: false,
52
    refout: false,
53
    xorout: 0xffffffff,
54
    check: 0xfc891918,
55
    residue: 0xc704dd7b,
56
};
57
58
pub const CRC_32_CD_ROM_EDC: Algorithm<u32> = Algorithm {
59
    width: 32,
60
    poly: 0x8001801b,
61
    init: 0x0,
62
    refin: true,
63
    refout: true,
64
    xorout: 0x0,
65
    check: 0x6ec2edc4,
66
    residue: 0x0,
67
};
68
69
pub const CRC_32_CKSUM: Algorithm<u32> = Algorithm {
70
    width: 32,
71
    poly: 0x4c11db7,
72
    init: 0x0,
73
    refin: false,
74
    refout: false,
75
    xorout: 0xffffffff,
76
    check: 0x765e7680,
77
    residue: 0xc704dd7b,
78
};
79
80
pub const CRC_32_ISCSI: Algorithm<u32> = Algorithm {
81
    width: 32,
82
    poly: 0x1edc6f41,
83
    init: 0xffffffff,
84
    refin: true,
85
    refout: true,
86
    xorout: 0xffffffff,
87
    check: 0xe3069283,
88
    residue: 0xb798b438,
89
};
90
91
pub const CRC_32_ISO_HDLC: Algorithm<u32> = Algorithm {
92
    width: 32,
93
    poly: 0x4c11db7,
94
    init: 0xffffffff,
95
    refin: true,
96
    refout: true,
97
    xorout: 0xffffffff,
98
    check: 0xcbf43926,
99
    residue: 0xdebb20e3,
100
};
101
102
pub const CRC_32_JAMCRC: Algorithm<u32> = Algorithm {
103
    width: 32,
104
    poly: 0x4c11db7,
105
    init: 0xffffffff,
106
    refin: true,
107
    refout: true,
108
    xorout: 0x0,
109
    check: 0x340bc6d9,
110
    residue: 0x0,
111
};
112
113
pub const CRC_32_MEF: Algorithm<u32> = Algorithm {
114
    width: 32,
115
    poly: 0x741b8cd7,
116
    init: 0xffffffff,
117
    refin: true,
118
    refout: true,
119
    xorout: 0x0,
120
    check: 0xd2c22f51,
121
    residue: 0x0,
122
};
123
124
pub const CRC_32_MPEG_2: Algorithm<u32> = Algorithm {
125
    width: 32,
126
    poly: 0x4c11db7,
127
    init: 0xffffffff,
128
    refin: false,
129
    refout: false,
130
    xorout: 0x0,
131
    check: 0x376e6e7,
132
    residue: 0x0,
133
};
134
135
pub const CRC_32_XFER: Algorithm<u32> = Algorithm {
136
    width: 32,
137
    poly: 0xaf,
138
    init: 0x0,
139
    refin: false,
140
    refout: false,
141
    xorout: 0x0,
142
    check: 0xbd0be338,
143
    residue: 0x0,
144
};
145
146
// width=32 poly=0x814141ab init=0x00000000 refin=false refout=false xorout=0x00000000 check=0x3010bf7f residue=0x00000000 name="CRC-32/AIXM"
147
pub const CRC32_AIXM: CrcParams = CrcParams {
148
    algorithm: CrcAlgorithm::Crc32Aixm,
149
    name: NAME_CRC32_AIXM,
150
    width: 32,
151
    poly: CRC_32_AIXM.poly as u64,
152
    init: CRC_32_AIXM.init as u64,
153
    init_algorithm: CRC_32_AIXM.init as u64,
154
    refin: CRC_32_AIXM.refin,   // false
155
    refout: CRC_32_AIXM.refout, // false
156
    xorout: CRC_32_AIXM.xorout as u64,
157
    check: CRC_32_AIXM.check as u64,
158
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_814141AB_FORWARD),
159
};
160
161
// width=32 poly=0xf4acfb13 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0x1697d06a residue=0x904cddbf name="CRC-32/AUTOSAR"
162
pub const CRC32_AUTOSAR: CrcParams = CrcParams {
163
    algorithm: CrcAlgorithm::Crc32Autosar,
164
    name: NAME_CRC32_AUTOSAR,
165
    width: 32,
166
    poly: CRC_32_AUTOSAR.poly as u64,
167
    init: CRC_32_AUTOSAR.init as u64,
168
    init_algorithm: CRC_32_AUTOSAR.init as u64,
169
    refin: CRC_32_AUTOSAR.refin,   // true
170
    refout: CRC_32_AUTOSAR.refout, // true
171
    xorout: CRC_32_AUTOSAR.xorout as u64,
172
    check: CRC_32_AUTOSAR.check as u64,
173
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_F4ACFB13_REFLECTED),
174
};
175
176
// width=32 poly=0xa833982b init=0xffffffff refin=true refout=true xorout=0xffffffff check=0x87315576 residue=0x45270551 name="CRC-32/BASE91-D"
177
pub const CRC32_BASE91_D: CrcParams = CrcParams {
178
    algorithm: CrcAlgorithm::Crc32Base91D,
179
    name: NAME_CRC32_BASE91_D,
180
    width: 32,
181
    poly: CRC_32_BASE91_D.poly as u64,
182
    init: CRC_32_BASE91_D.init as u64,
183
    init_algorithm: CRC_32_BASE91_D.init as u64,
184
    refin: CRC_32_BASE91_D.refin,   // true
185
    refout: CRC_32_BASE91_D.refout, // true
186
    xorout: CRC_32_BASE91_D.xorout as u64,
187
    check: CRC_32_BASE91_D.check as u64,
188
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_A833982B_REFLECTED),
189
};
190
191
// width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0xffffffff check=0xfc891918 residue=0xc704dd7b name="CRC-32/BZIP2"
192
pub const CRC32_BZIP2: CrcParams = CrcParams {
193
    algorithm: CrcAlgorithm::Crc32Bzip2,
194
    name: NAME_CRC32_BZIP2,
195
    width: 32,
196
    poly: CRC_32_BZIP2.poly as u64,
197
    init: CRC_32_BZIP2.init as u64,
198
    init_algorithm: CRC_32_BZIP2.init as u64,
199
    refin: CRC_32_BZIP2.refin,   // false
200
    refout: CRC_32_BZIP2.refout, // false
201
    xorout: CRC_32_BZIP2.xorout as u64,
202
    check: CRC_32_BZIP2.check as u64,
203
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_04C11DB7_FORWARD),
204
};
205
206
// width=32 poly=0x8001801b init=0x00000000 refin=true refout=true xorout=0x00000000 check=0x6ec2edc4 residue=0x00000000 name="CRC-32/CD-ROM-EDC"
207
pub const CRC32_CD_ROM_EDC: CrcParams = CrcParams {
208
    algorithm: CrcAlgorithm::Crc32CdRomEdc,
209
    name: NAME_CRC32_CD_ROM_EDC,
210
    width: 32,
211
    poly: CRC_32_CD_ROM_EDC.poly as u64,
212
    init: CRC_32_CD_ROM_EDC.init as u64,
213
    init_algorithm: CRC_32_CD_ROM_EDC.init as u64,
214
    refin: CRC_32_CD_ROM_EDC.refin,   // true
215
    refout: CRC_32_CD_ROM_EDC.refout, // true
216
    xorout: CRC_32_CD_ROM_EDC.xorout as u64,
217
    check: CRC_32_CD_ROM_EDC.check as u64,
218
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_8001801B_REFLECTED),
219
};
220
221
// width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680 residue=0xc704dd7b name="CRC-32/CKSUM"
222
pub const CRC32_CKSUM: CrcParams = CrcParams {
223
    algorithm: CrcAlgorithm::Crc32Cksum,
224
    name: NAME_CRC32_CKSUM,
225
    width: 32,
226
    poly: CRC_32_CKSUM.poly as u64,
227
    init: CRC_32_CKSUM.init as u64,
228
    init_algorithm: CRC_32_CKSUM.init as u64,
229
    refin: CRC_32_CKSUM.refin,   // false
230
    refout: CRC_32_CKSUM.refout, // false
231
    xorout: CRC_32_CKSUM.xorout as u64,
232
    check: CRC_32_CKSUM.check as u64,
233
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_04C11DB7_FORWARD),
234
};
235
236
// width=32 poly=0x1edc6f41 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xe3069283 residue=0xb798b438 name="CRC-32/ISCSI"
237
pub const CRC32_ISCSI: CrcParams = CrcParams {
238
    algorithm: CrcAlgorithm::Crc32Iscsi,
239
    name: NAME_CRC32_ISCSI,
240
    width: 32,
241
    poly: CRC_32_ISCSI.poly as u64,
242
    init: CRC_32_ISCSI.init as u64,
243
    init_algorithm: CRC_32_ISCSI.init as u64,
244
    refin: CRC_32_ISCSI.refin,   // true
245
    refout: CRC_32_ISCSI.refout, // true
246
    xorout: CRC_32_ISCSI.xorout as u64,
247
    check: CRC_32_ISCSI.check as u64,
248
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_1EDC6F41_REFLECTED),
249
};
250
251
// width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 residue=0xdebb20e3 name="CRC-32/ISO-HDLC"
252
pub const CRC32_ISO_HDLC: CrcParams = CrcParams {
253
    algorithm: CrcAlgorithm::Crc32IsoHdlc,
254
    name: NAME_CRC32_ISO_HDLC,
255
    width: 32,
256
    poly: CRC_32_ISO_HDLC.poly as u64,
257
    init: CRC_32_ISO_HDLC.init as u64,
258
    init_algorithm: CRC_32_ISO_HDLC.init as u64,
259
    refin: CRC_32_ISO_HDLC.refin,   // true
260
    refout: CRC_32_ISO_HDLC.refout, // true
261
    xorout: CRC_32_ISO_HDLC.xorout as u64,
262
    check: CRC_32_ISO_HDLC.check as u64,
263
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_04C11DB7_REFLECTED),
264
};
265
266
// width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0x00000000 check=0x340bc6d9 residue=0x00000000 name="CRC-32/JAMCRC"
267
pub const CRC32_JAMCRC: CrcParams = CrcParams {
268
    algorithm: CrcAlgorithm::Crc32Jamcrc,
269
    name: NAME_CRC32_JAMCRC,
270
    width: 32,
271
    poly: CRC_32_JAMCRC.poly as u64,
272
    init: CRC_32_JAMCRC.init as u64,
273
    init_algorithm: CRC_32_JAMCRC.init as u64,
274
    refin: CRC_32_JAMCRC.refin,   // true
275
    refout: CRC_32_JAMCRC.refout, // true
276
    xorout: CRC_32_JAMCRC.xorout as u64,
277
    check: CRC_32_JAMCRC.check as u64,
278
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_04C11DB7_REFLECTED),
279
};
280
281
// width=32 poly=0x741b8cd7 init=0xffffffff refin=true refout=true xorout=0x00000000 check=0xd2c22f51 residue=0x00000000 name="CRC-32/MEF"
282
pub const CRC32_MEF: CrcParams = CrcParams {
283
    algorithm: CrcAlgorithm::Crc32Mef,
284
    name: NAME_CRC32_MEF,
285
    width: 32,
286
    poly: CRC_32_MEF.poly as u64,
287
    init: CRC_32_MEF.init as u64,
288
    init_algorithm: CRC_32_MEF.init as u64,
289
    refin: CRC_32_MEF.refin,   // true
290
    refout: CRC_32_MEF.refout, // true
291
    xorout: CRC_32_MEF.xorout as u64,
292
    check: CRC_32_MEF.check as u64,
293
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_741B8CD7_REFLECTED),
294
};
295
296
// width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0x00000000 check=0x0376e6e7 residue=0x00000000 name="CRC-32/MPEG-2"
297
pub const CRC32_MPEG_2: CrcParams = CrcParams {
298
    algorithm: CrcAlgorithm::Crc32Mpeg2,
299
    name: NAME_CRC32_MPEG_2,
300
    width: 32,
301
    poly: CRC_32_MPEG_2.poly as u64,
302
    init: CRC_32_MPEG_2.init as u64,
303
    init_algorithm: CRC_32_MPEG_2.init as u64,
304
    refin: CRC_32_MPEG_2.refin,   // false
305
    refout: CRC_32_MPEG_2.refout, // false
306
    xorout: CRC_32_MPEG_2.xorout as u64,
307
    check: CRC_32_MPEG_2.check as u64,
308
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_04C11DB7_FORWARD),
309
};
310
311
// width=32 poly=0x000000af init=0x00000000 refin=false refout=false xorout=0x00000000 check=0xbd0be338 residue=0x00000000 name="CRC-32/XFER"
312
pub const CRC32_XFER: CrcParams = CrcParams {
313
    algorithm: CrcAlgorithm::Crc32Xfer,
314
    name: NAME_CRC32_XFER,
315
    width: 32,
316
    poly: CRC_32_XFER.poly as u64,
317
    init: CRC_32_XFER.init as u64,
318
    init_algorithm: CRC_32_XFER.init as u64,
319
    refin: CRC_32_XFER.refin,   // false
320
    refout: CRC_32_XFER.refout, // false
321
    xorout: CRC_32_XFER.xorout as u64,
322
    check: CRC_32_XFER.check as u64,
323
    keys: crate::CrcKeysStorage::from_keys_fold_256(KEYS_000000AF_FORWARD),
324
};
325
326
// CRC-32/AIXM
327
pub const KEYS_814141AB_FORWARD: [u64; 23] = [
328
    0x0000000000000000,
329
    0x9be9878f00000000,
330
    0x85b2a6e400000000,
331
    0x2aa81be300000000,
332
    0xa488a24c00000000,
333
    0x9be9878f00000000,
334
    0xb1efc5f600000000,
335
    0x00000001feff7f62,
336
    0x00000001814141ab,
337
    0x143b9cd200000000,
338
    0x9853011900000000,
339
    0x7836e63a00000000,
340
    0xaa29818100000000,
341
    0x3bd96ca700000000,
342
    0x60205cd400000000,
343
    0x74f21e8b00000000,
344
    0x3540871b00000000,
345
    0x0442099000000000,
346
    0x361f380200000000,
347
    0x6757ee2f00000000,
348
    0xffc42e7700000000,
349
    0xd12a88300000000,
350
    0x93a03b8800000000,
351
];
352
353
// CRC-32/AUTOSAR
354
pub const KEYS_F4ACFB13_REFLECTED: [u64; 23] = [
355
    0x0000000000000000,
356
    0x000000016130902a,
357
    0x0000000050428a9c,
358
    0x000000010b1e9a08,
359
    0x00000000d77bb854,
360
    0x000000016130902a,
361
    0x00000001b0d566c0,
362
    0x000000013cfdbf23,
363
    0x0000000191be6a5f,
364
    0x00000000b105f098,
365
    0x00000001b260c18a,
366
    0x00000001b0d68118,
367
    0x00000000c6f0b5d2,
368
    0x00000000ce9a9f48,
369
    0x00000000fc24cbf6,
370
    0x0000000018c71228,
371
    0x000000014b462960,
372
    0x00000001848ecbce,
373
    0x0000000049cb6c68,
374
    0x00000000c9d55d76,
375
    0x0000000022919656,
376
    0x00000001e97b6a9e,
377
    0x00000000000cbd7c,
378
];
379
380
// CRC-32/BASE91-D
381
pub const KEYS_A833982B_REFLECTED: [u64; 23] = [
382
    0x0000000000000000,
383
    0x00000001e065d896,
384
    0x00000001aca6d990,
385
    0x000000007ec6845e,
386
    0x000000009aa0f3be,
387
    0x00000001e065d896,
388
    0x00000000cf690ff2,
389
    0x000000009167fd37,
390
    0x00000001a833982b,
391
    0x00000001f0023e48,
392
    0x0000000054bacd0c,
393
    0x00000001677129ba,
394
    0x00000000ac52eee8,
395
    0x0000000068be1470,
396
    0x000000017208fc52,
397
    0x00000001c2e169fc,
398
    0x0000000122f9bd98,
399
    0x0000000192d6d10c,
400
    0x00000001942367fa,
401
    0x00000000c2044564,
402
    0x00000001a07ba234,
403
    0x000000010ffc58e6,
404
    0x000000015920d7a6,
405
];
406
407
// CRC-32/CD-ROM-EDC
408
pub const KEYS_8001801B_REFLECTED: [u64; 23] = [
409
    0x0000000000000000,
410
    0x00000001d5934102,
411
    0x000000006c90c100,
412
    0x00000001fbea69a0,
413
    0x000000006500d000,
414
    0x00000001d5934102,
415
    0x00000001f1030002,
416
    0x000000017000ffff,
417
    0x00000001b0030003,
418
    0x0000000178be62fe,
419
    0x00000001353195ce,
420
    0x0000000085a25e78,
421
    0x00000000a23c9cc0,
422
    0x000000005ead8550,
423
    0x00000001eab75dd2,
424
    0x000000012e7928a2,
425
    0x00000001f8931102,
426
    0x0000000086acf0c0,
427
    0x00000001517f91c2,
428
    0x00000001f75a6182,
429
    0x00000000bd01c000,
430
    0x00000001bcb30820,
431
    0x000000010d925102,
432
];
433
434
// CRC-32/MEF
435
pub const KEYS_741B8CD7_REFLECTED: [u64; 23] = [
436
    0x0000000000000000,
437
    0x000000014b0602f8,
438
    0x000000007b4bc878,
439
    0x0000000023b08408,
440
    0x00000001e9bbe8a4,
441
    0x000000014b0602f8,
442
    0x0000000018c5564c,
443
    0x0000000017d232cd,
444
    0x00000001d663b05d,
445
    0x00000001f5dbe222,
446
    0x00000001290fe3ca,
447
    0x00000000048d6a82,
448
    0x0000000063b45844,
449
    0x00000001a9b7f536,
450
    0x0000000190afdbca,
451
    0x00000000be6d8f38,
452
    0x00000001c06a9816,
453
    0x00000001b5a46922,
454
    0x0000000097259f1a,
455
    0x00000000adfa5198,
456
    0x000000009c899030,
457
    0x00000001adf2908e,
458
    0x00000001f91b48f0,
459
];
460
461
// CRC-32/XFER
462
pub const KEYS_000000AF_FORWARD: [u64; 23] = [
463
    0x0000000000000000,
464
    0x00295f2300000000,
465
    0xfafa517900000000,
466
    0x5cd86bb500000000,
467
    0xaf6f37a300000000,
468
    0x00295f2300000000,
469
    0x0000445500000000,
470
    0x00000001000000af,
471
    0x00000001000000af,
472
    0x9bd57b5d00000000,
473
    0xb7a4d76400000000,
474
    0x1ae0004200000000,
475
    0xe7720be600000000,
476
    0x9c7fc8fe00000000,
477
    0x3885faf800000000,
478
    0xb477ad7100000000,
479
    0x0ac2ae3d00000000,
480
    0x5eae9dbe00000000,
481
    0x784a483800000000,
482
    0x7d21bf2000000000,
483
    0xfaebd3d300000000,
484
    0x25ed382b00000000,
485
    0x6d2b811a00000000,
486
];
487
488
// CRC-32/ISO-HDLC (aka 'crc32'), CRC-32/JAMCRC
489
const KEYS_04C11DB7_REFLECTED: [u64; 23] = [
490
    0x0000000000000000, // unused placeholder to match 1-based indexing
491
    0x00000000ccaa009e, // (2^(32* 3) mod P(x))' << 1
492
    0x00000001751997d0, // (2^(32* 5) mod P(x))' << 1
493
    0x000000014a7fe880, // (2^(32*31) mod P(x))' << 1
494
    0x00000001e88ef372, // (2^(32*33) mod P(x))' << 1
495
    0x00000000ccaa009e, // (2^(32* 3) mod P(x))' << 1
496
    0x0000000163cd6124, // (2^(32* 2) mod P(x))' << 1
497
    0x00000001f7011641, // (floor(2^64/P(x)))'
498
    0x00000001db710641, // (P(x))'
499
    0x00000001d7cfc6ac, // (2^(32*27) mod P(x))' << 1
500
    0x00000001ea89367e, // (2^(32*29) mod P(x))' << 1
501
    0x000000018cb44e58, // (2^(32*23) mod P(x))' << 1
502
    0x00000000df068dc2, // (2^(32*25) mod P(x))' << 1
503
    0x00000000ae0b5394, // (2^(32*19) mod P(x))' << 1
504
    0x00000001c7569e54, // (2^(32*21) mod P(x))' << 1
505
    0x00000001c6e41596, // (2^(32*15) mod P(x))' << 1
506
    0x0000000154442bd4, // (2^(32*17) mod P(x))' << 1
507
    0x0000000174359406, // (2^(32*11) mod P(x))' << 1
508
    0x000000003db1ecdc, // (2^(32*13) mod P(x))' << 1
509
    0x000000015a546366, // (2^(32* 7) mod P(x))' << 1
510
    0x00000000f1da05aa, // (2^(32* 9) mod P(x))' << 1
511
    0x00000001322d1430,
512
    0x000000011542778a,
513
];
514
515
// CRC-32/ISCSI (aka 'crc32c')
516
const KEYS_1EDC6F41_REFLECTED: [u64; 23] = [
517
    0x0000000000000000, // unused placeholder to match 1-based indexing
518
    0x000000014cd00bd6, // (2^(32* 3) mod P(x))' << 1
519
    0x00000000f20c0dfe, // (2^(32* 5) mod P(x))' << 1
520
    0x000000000d3b6092, // (2^(32*31) mod P(x))' << 1
521
    0x000000006992cea2, // (2^(32*33) mod P(x))' << 1
522
    0x000000014cd00bd6, // (2^(32* 3) mod P(x))' << 1
523
    0x00000000dd45aab8, // (2^(32* 2) mod P(x))' << 1
524
    0x00000000dea713f1, // (floor(2^64/P(x)))'
525
    0x0000000105ec76f1, // (P(x))'
526
    0x000000014237f5e6, // (2^(32*27) mod P(x))' << 1
527
    0x000000002ad91c30, // (2^(32*29) mod P(x))' << 1
528
    0x0000000102f9b8a2, // (2^(32*23) mod P(x))' << 1
529
    0x00000001c1733996, // (2^(32*25) mod P(x))' << 1
530
    0x0000000039d3b296, // (2^(32*19) mod P(x))' << 1
531
    0x00000000083a6eec, // (2^(32*21) mod P(x))' << 1
532
    0x000000009e4addf8, // (2^(32*15) mod P(x))' << 1
533
    0x00000000740eef02, // (2^(32*17) mod P(x))' << 1
534
    0x00000001d82c63da, // (2^(32*11) mod P(x))' << 1
535
    0x000000001c291d04, // (2^(32*13) mod P(x))' << 1
536
    0x00000000ba4fc28e, // (2^(32* 7) mod P(x))' << 1
537
    0x00000001384aa63a, // (2^(32* 9) mod P(x))' << 1
538
    0x00000000b9e02b86,
539
    0x00000000dcb17aa4,
540
];
541
542
// CRC-32/BZIP2, CRC-32/CKSUM, CRC-32/MPEG-2
543
const KEYS_04C11DB7_FORWARD: [u64; 23] = [
544
    0x0000000000000000, // unused placeholder to match 1-based indexing
545
    0xf200aa6600000000, // 2^(32* 3) mod P(x) << 32
546
    0x17d3315d00000000, // 2^(32* 5) mod P(x) << 32
547
    0x022ffca500000000, // 2^(32*31) mod P(x) << 32
548
    0x9d9ee22f00000000, // 2^(32*33) mod P(x) << 32
549
    0xf200aa6600000000, // 2^(32* 3) mod P(x) << 32
550
    0x490d678d00000000, // 2^(32* 2) mod P(x) << 32
551
    0x0000000104d101df, // floor(2^64/P(x))
552
    0x0000000104c11db7, // P(x)
553
    0x6ac7e7d700000000, // 2^(32*27) mod P(x) << 32
554
    0xfcd922af00000000, // 2^(32*29) mod P(x) << 32
555
    0x34e45a6300000000, // 2^(32*23) mod P(x) << 32
556
    0x8762c1f600000000, // 2^(32*25) mod P(x) << 32
557
    0x5395a0ea00000000, // 2^(32*19) mod P(x) << 32
558
    0x54f2d5c700000000, // 2^(32*21) mod P(x) << 32
559
    0xd3504ec700000000, // 2^(32*15) mod P(x) << 32
560
    0x57a8445500000000, // 2^(32*17) mod P(x) << 32
561
    0xc053585d00000000, // 2^(32*11) mod P(x) << 32
562
    0x766f1b7800000000, // 2^(32*13) mod P(x) << 32
563
    0xcd8c54b500000000, // 2^(32* 7) mod P(x) << 32
564
    0xab40b71e00000000, // 2^(32* 9) mod P(x) << 32
565
    0x1851689900000000,
566
    0xa3dc855100000000,
567
];
568
569
pub(crate) const SIMD_CONSTANTS: [[u64; 2]; 4] = [
570
    [0x08090a0b0c0d0e0f, 0x0001020304050607], // smask
571
    [0x8080808080808080, 0x8080808080808080], // mask1
572
    [0xffffffffffffffff, 0x00000000ffffffff], // mask2 forward
573
    [0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF], // mask2 reverse
574
];
575
576
pub(crate) const PSHUFB_SHF_TABLE_REVERSE: [[u64; 2]; 2] = [
577
    [0x0706050403020100, 0x0f0e0d0c0b0a0908],
578
    [0x8786858483828180, 0x8f8e8d8c8b8a8988],
579
];
580
581
pub(crate) const PSHUFB_SHF_TABLE_FORWARD: [[u64; 2]; 2] = [
582
    [0x8786858483828100, 0x8f8e8d8c8b8a8988],
583
    [0x0706050403020100, 0x0f0e0d0c0b0a0908],
584
];