2 * Produce a "generalized CRC" table. Assumes a platform with
3 * /dev/urandom -- otherwise reimplement get_random_byte().
14 static uint8_t get_random_byte(void)
21 fd
= open("/dev/urandom", O_RDONLY
);
25 rv
= read(fd
, &buf
, 1);
26 if (rv
< 1 && errno
!= EAGAIN
)
33 static void random_permute(uint8_t *buf
)
38 for (i
= 0; i
< 256; i
++)
42 for (i
= 255; i
> 0; i
--) {
46 j
= get_random_byte() & m
;
54 static void xcrc_table(uint64_t *buf
)
59 memset(buf
, 0, 8*256); /* Make static checkers happy */
61 for (i
= 0; i
< 8; i
++) {
63 for (j
= 0; j
< 256; j
++)
64 buf
[j
] = (buf
[j
] << 8) | perm
[j
];
75 for (i
= 0; i
< 256; i
++) {
76 printf("%016"PRIx64
"\n", buf
[i
]);